Permalink
Browse files

Make getting app users a bit saner, allow configuring Mako error page…

…s, pass kwargs through to access callbacks
  • Loading branch information...
1 parent cbe2de1 commit 7b6ad3aee0b0cb64d2b51c693677dc3212a86f90 @brendonh committed Apr 27, 2012
Showing with 15 additions and 14 deletions.
  1. +1 −1 warp/common/access.py
  2. +0 −12 warp/common/avatar.py
  3. +1 −1 warp/helpers.py
  4. +13 −0 warp/webserver/resource.py
View
@@ -116,7 +116,7 @@ def __init__(self, callback):
self.callback = callback
def allows(self, other, **kwargs):
- return self.callback(other)
+ return self.callback(other, **kwargs)
View
@@ -32,18 +32,6 @@ def _getRoles(self):
roles = property(_getRoles)
- _user = None
- def _getAppUser(self):
- if self._user is None:
- getUser = runtime.config.get('getAppUser')
- if getUser is None:
- raise NotImplementedError("No getAppUser callback configured")
-
- self._user = getUser(self)
- return self._user
- user = property(_getAppUser)
-
-
def __repr__(self):
return "<Avatar '%s'>" % self.email.encode("utf-8")
View
@@ -51,7 +51,7 @@ def renderTemplateObj(request, template, **kw):
def getTemplate(templatePath):
return Template(filename=templatePath,
lookup=templateLookup,
- format_exceptions=True,
+ format_exceptions=config.get('makoErrorPages', True),
output_encoding="utf-8")
def renderTemplate(request, templatePath, **kw):
View
@@ -1,4 +1,5 @@
import os.path
+import warnings
from zope.interface import implements
@@ -62,6 +63,18 @@ def getChildWithDefault(self, firstSegment, request):
else:
request.store = avatar_store
+ if request.avatar is not None:
+ getUser = config.get('getRequestUser')
+ if getUser is not None:
+ request.avatar.user = getUser(request)
+ else:
+ # Backward compatibility
+ getUser = config.get('getAppUser')
+ if getUser is not None:
+ warnings.warn("getAppUser is deprecated, use getRequestUser instead",
+ DeprecationWarning)
+ request.avatar.user = getUser(request.avatar)
+
if config.get('reloadMessages'):
translate.loadMessages()

0 comments on commit 7b6ad3a

Please sign in to comment.