def getNode(name): node = helpers.getNode(name) if node is None: return NoResource() return NodeResource(node)
def getChildWithDefault(self, firstSegment, request): if firstSegment: fp = self.buildFilePath(request) if fp is not None: del request.postpath[:] return static.File(fp.path) # Init for everything except static files session = request.getSession() request.avatar = session.avatar if config.get("reloadMessages"): translate.loadMessages() request.translateTerm = translate.getTranslator(session.language) handler = self.dispatch.get(firstSegment) if handler is not None: return handler(request) node = helpers.getNode(firstSegment) if node is not None: if not access.allowed(request.avatar, node): return AccessDenied() return NodeResource(node) return NoResource()
def getChildWithDefault(self, firstSegment, request): if firstSegment: fp = self.buildFilePath(request) if fp is not None: del request.postpath[:] return static.File(fp.path) # Init for everything except static files session = request.getSession() request.avatar = session.avatar getCurrentUser = config.get('getCurrentUser') if getCurrentUser and request.avatar: request.current_user = getCurrentUser(request.avatar.id) getRequestStore = config.get('getRequestStore') if getRequestStore is not None: request.store = getRequestStore(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() request.translateTerm = translate.getTranslator(session.language) segment = firstSegment if self.caseInsensitiveUrl: segment = firstSegment.lower() handler = self.dispatch.get(segment) if handler is not None: return handler(request) node = helpers.getNode(firstSegment) if node is not None: return NodeResource(node) return NoResource()
def getChildWithDefault(self, firstSegment, request): if firstSegment: fp = self.buildFilePath(request) if fp is not None: del request.postpath[:] return static.File(fp.path) # Init for everything except static files session = request.getSession() request.avatar = session.avatar getRequestStore = config.get('getRequestStore') if getRequestStore is not None: request.store = getRequestStore(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() request.translateTerm = translate.getTranslator(session.language) segment = firstSegment if self.caseInsensitiveUrl: segment = firstSegment.lower() handler = self.dispatch.get(segment) if handler is not None: return handler(request) node = helpers.getNode(firstSegment) if node is not None: if not access.allowed(request.avatar, node): return AccessDenied() return NodeResource(node) return NoResource()
from warp.common import access as a from warp.helpers import getNode config = { 'domain': 'localhost', 'port': 8080, 'db': "sqlite:warp.sqlite", 'trace': False, 'default': 'home', "defaultRoles": ("anon",), "roles": { "anon": a.Role({ getNode("home"): (a.Allow(),), }), "admin": a.Role({}, default=(a.Allow(),)), }, }
def render_list_name(self, request): return link( self.obj.name, getNode("people"), "view", [self.obj.id])
from warp.common import access as a from warp.helpers import getNode config = { 'domain': 'localhost', 'port': 8080, 'db': "sqlite:warp.sqlite", # For posgres/mysql 'schema': { # Whether to check schema on startup 'check': False # By default migrations are read from "migrations" dir under # the project's root. Customize it with this key # 'migrations_dir': a twisted.python.filepath.FilePath }, # Whether to trace SQL queries using storm tracer 'trace': False, 'default': 'home', "defaultRoles": ("anon", ), "roles": { "anon": a.Role({ getNode("home"): (a.Allow(), ), }), "admin": a.Role({}, default=(a.Allow(), )), }, }
def linkAsParent(request): return link("Widgets", getNode("widgets"), "index")
def parentCrumb(self, request): return getNode("widgets")
def render_list_name(self, request): return link(self.name(request), getNode("widgets"), "view", [self.obj.id])