Beispiel #1
0
 def __init__(self, root, url, rewrite):
     self.path = utils.path2tuple(rewrite.rewrite)
     self.url = to_url(url + rewrite.original)
     parts = urlparse.urlparse(self.url)
     self.server_url = urlparse.urlunparse(parts[:2] + ('',) * 4)
     self.server_script = split_path_info(parts[2])
     self.skin = rewrite.skin
     self.skin_enforce = rewrite.skin_enforce
     try:
         traverse(self.path, root)
     except zExceptions.BadRequest:
         raise ValueError(u"Invalid rewrite path %s" % rewrite.rewrite)
Beispiel #2
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
 def _load_service(self):
     return traverse(
         self.context.__silva__ + ('service_forest',), self.context)