Ejemplo n.º 1
0
 def apply(self, root, request):
     try:
         content = traverse(self.path, root, request)
     except zExceptions.BadRequest:
         return root
     request['URL'] = self.url
     request['ACTUAL_URL'] = self.server_url + urlparse.urlunparse(
         ('', '') + urlparse.urlparse(request['ACTUAL_URL'])[2:])
     request['SERVER_URL'] = str(self.server_url)
     request._script = list(self.server_script)
     request._resetURLS()
     if self.skin:
         # Apply hardcoded skin
         skin = queryUtility(IBrowserSkinType, name=self.skin)
         if skin is None:
             logger.error(
                 u"Missing skin '%s', please update your settings.",
                 self.skin)
         else:
             applySkinButKeepSome(request, skin)
             if self.skin_enforce:
                 request[SET_SKIN_ALLOWED_FLAG] = False
     else:
         # Fallback on the default Silva skin
         if ISilvaObject.providedBy(content):
             publication = content.get_publication()
             skin_lookup = ISkinLookup(publication, None)
             if skin_lookup is not None:
                 skin = skin_lookup.get_skin(request)
                 if skin is not None:
                     # We found a skin to apply
                     applySkinButKeepSome(request, skin)
     return content
Ejemplo n.º 2
0
 def _restore_public_skin(self, request, root):
     lookup = ISkinLookup(root.get_publication(), None)
     if lookup is not None:
         skin = lookup.get_skin(request)
         if skin is not None:
             # We found a skin to apply
             applySkinButKeepSome(request, skin)
     alsoProvides(request, INonCachedLayer)