comparison MoinMoin/wsgiapp.py @ 6080:236f7a9370c4

context always has context.request, no need to pass a request param
author 'Karl O. Pinc' <kop@meme.com>
date Tue, 16 Sep 2014 09:22:19 -0500
parents 35473fe0967d
children
comparison
equal deleted inserted replaced
6079:dca00e9c5bcd 6080:236f7a9370c4
132 # 1. jump to page where user left off 132 # 1. jump to page where user left off
133 if not pagename and context.user.remember_last_visit and action_name == 'show': 133 if not pagename and context.user.remember_last_visit and action_name == 'show':
134 response = redirect_last_visited(context) 134 response = redirect_last_visited(context)
135 # 2. handle action 135 # 2. handle action
136 else: 136 else:
137 response = handle_action(request, context, pagename, action_name) 137 response = handle_action(context, pagename, action_name)
138 if isinstance(response, Context): 138 if isinstance(response, Context):
139 response = response.request 139 response = response.request
140 return response 140 return response
141 141
142 def handle_action(request, context, pagename, action_name='show'): 142 def handle_action(context, pagename, action_name='show'):
143 """ Actual dispatcher function for non-XMLRPC actions. 143 """ Actual dispatcher function for non-XMLRPC actions.
144 144
145 Also sets up the Page object for this request, normalizes and 145 Also sets up the Page object for this request, normalizes and
146 redirects to canonical pagenames and checks for non-allowed 146 redirects to canonical pagenames and checks for non-allowed
147 actions. 147 actions.
172 elif action_name[0].isupper() and not action_name in \ 172 elif action_name[0].isupper() and not action_name in \
173 get_available_actions(cfg, context.page, context.user): 173 get_available_actions(cfg, context.page, context.user):
174 msg = _("You are not allowed to do %(action_name)s on this page.") % { 174 msg = _("You are not allowed to do %(action_name)s on this page.") % {
175 'action_name': wikiutil.escape(action_name), } 175 'action_name': wikiutil.escape(action_name), }
176 if context.user.valid: 176 if context.user.valid:
177 log_attempt(action_name + '/action unavailable', False, request, context.user.name, pagename=pagename) 177 log_attempt(action_name + '/action unavailable', False,
178 context.request, context.user.name, pagename=pagename)
178 else: 179 else:
179 log_attempt(action_name + '/action unavailable', False, request, pagename=pagename) 180 log_attempt(action_name + '/action unavailable', False, context.request, pagename=pagename)
180 # Suggest non valid user to login 181 # Suggest non valid user to login
181 msg += " " + _("Login and try again.") 182 msg += " " + _("Login and try again.")
182 183
183 if msg: 184 if msg:
184 context.theme.add_msg(msg, "error") 185 context.theme.add_msg(msg, "error")
189 handler = action.getHandler(context, action_name) 190 handler = action.getHandler(context, action_name)
190 if handler is None: 191 if handler is None:
191 msg = _("You are not allowed to do %(action_name)s on this page.") % { 192 msg = _("You are not allowed to do %(action_name)s on this page.") % {
192 'action_name': wikiutil.escape(action_name), } 193 'action_name': wikiutil.escape(action_name), }
193 if context.user.valid: 194 if context.user.valid:
194 log_attempt(action_name + '/no handler', False, request, context.user.name, pagename=pagename) 195 log_attempt(action_name + '/no handler', False, context.request, context.user.name, pagename=pagename)
195 else: 196 else:
196 log_attempt(action_name + '/no handler', False, request, pagename=pagename) 197 log_attempt(action_name + '/no handler', False, context.request, pagename=pagename)
197 # Suggest non valid user to login 198 # Suggest non valid user to login
198 msg += " " + _("Login and try again.") 199 msg += " " + _("Login and try again.")
199 context.theme.add_msg(msg, "error") 200 context.theme.add_msg(msg, "error")
200 context.page.send_page() 201 context.page.send_page()
201 else: 202 else: