def defaultView(self, request): context = self.context try: name = getDefaultViewName(context, request) return context, [name,] except ComponentLookupError: return context, None
def browserDefault(self, request): """See zope.container.traversal.ContainerTraverser. -> context, (view_uri,) """ default_name = self.default_name if default_name is None: default_name = getDefaultViewName(self, request) return self, (default_name,)
def browserDefault(self, request): ob = self.context if list(providedBy(ob)): view_name = getDefaultViewName(ob, request) return ob, (("@@%s" % view_name), ) return ob, ()
def authorized(self, result): obj = result.object() defaultview = getDefaultViewName(obj, self.request) try: view = queryMultiAdapter((ProxyFactory(obj), self.request), name=defaultview) return True except Unauthorized: print False
def defaultView(self, request): context = self.context try: name = getDefaultViewName(context, request) return context, [ name, ] except ComponentLookupError: return context, None
def browserDefault(self, request): # if we have a RESTful request, we will handle # GET, POST and HEAD differently (PUT and DELETE are handled already # but not on the BrowserRequest layer but the HTTPRequest layer) if interfaces.IRESTLayer.providedBy(request): rest_view = component.getMultiAdapter( (self.context, self.request), name=request.method) return rest_view, () view_name = getDefaultViewName(self.context, request) view_uri = "@@%s" % view_name return self.context, (view_uri,)
def browserDefault(self, request): ob = self.context view_name = getDefaultViewName(ob, request) view = self.publishTraverse(request, view_name) if hasattr(view, 'browserDefault'): view, path = view.browserDefault(request) if len(path) == 1: view = view.publishTraverse(request, path[0]) path = () else: path = () return view, path
def is_view_template(self): # We only do something special for IWeblogEntry objects. #if not IWeblogEntry.providedBy(self.context): # return super(QuillsContextState, self).is_view_template() url = self.current_base_url() url_parts = url.split('/') if url_parts[-1] == self.context.getId(): # The last part of the URL is the same as the id of the object, so # we assume that there is no extra view specified, and thus that we # must be on the default view of the object. return True elif url_parts[-1] == getDefaultViewName(self.context, self.request): # The last part of the URL is the same as the default view name, so # we assume that we are using the default view. return True return False
def publishTraverse(self, request, name): """Interpret any remaining names on the traversal stack as keywords of this topic container. Only exception is an appended view name at the end of the traversal stack, or if a sub-class aborts the process This operation will empty the traversal stack! While the view have an instance of ``klass`` as context, it will have the topic container as acquistion parent! The ``klass`` instance will be initialized with the keywords taken from the traversal stack. """ self.request = request # collect keywords keywords = [] while self.hasMoreNames(): keywords.append(name) name = self.nextName() # Determine view view_name = None context = None if name.startswith('@@'): # A view has explicitly been requested, so make that the # view_name (stripping off the leading @@ which causes view # lookups to fail otherwise). view_name = name[2:] else: # last name is another keyword keywords.append(name) if len(keywords) == 0: # No keywords given, just a view specified. Create a view for the # topic container. context = self.context else: context = self.wrapUp(keywords).__of__(self.context) view_name = view_name or getDefaultViewName(context, request) view = getMultiAdapter((context, request), name=view_name) return view.__of__(self.context)
def browserDefault(self, request): view_name = getDefaultViewName(self.context, request) view_uri = "@@%s" % view_name return self.context, (view_uri, )
def browserDefault(self, request): ob = self.context view_name = getDefaultViewName(ob, request) return ob, (view_name, )
def browserDefault(self, request): return self.context, (getDefaultViewName(self.context, request),)
def getDefaultViewForObject(self, obj, view_name): obj = obj.__of__(self.context) view_name = view_name or getDefaultViewName(obj, self.request, self.context) view = getMultiAdapter((obj, self.request), name=view_name) return view.__of__(self.context)
def authorized(self, result): obj = result.object() defaultview = getDefaultViewName(obj, self.request) view = queryMultiAdapter((ProxyFactory(obj), self.request), name=defaultview) return canAccess(view, "__call__")