Пример #1
0
Файл: web.py Проект: cerha/pytis
 def _handle_subpath(self, req, record):
     if req.unresolved_path[0] == 'attachments':
         storage = self._attachment_storage(record)
         if storage:
             resource = storage.find_resource_by_uri(req.uri())
             if resource and resource.src_file():
                 return wiking.serve_file(req, resource.src_file())
         raise wiking.NotFound()
     return super(Menu, self)._handle_subpath(req, record)
Пример #2
0
 def _handle_subpath(self, req, record):
     if req.unresolved_path[0] == 'attachments':
         storage = self._attachment_storage(record)
         if storage:
             resource = storage.find_resource_by_uri(req.uri())
             if resource and resource.src_file():
                 return wiking.serve_file(req, resource.src_file())
         raise wiking.NotFound()
     return super(Menu, self)._handle_subpath(req, record)
Пример #3
0
 def _handle_resource(self, req, filename):
     subdir = filename.split('/', 1)[0]
     if subdir in ('images', 'css', 'scripts', 'media', 'flash'):
         # This is just a temporary hack to allow backward compatibility
         # with resource URIs using type specific subdirectories.
         # Wiking no longer generates such URIs and applications should
         # avoid them too as this hack will be removed in future.
         filename = filename[len(subdir) + 1:]
     else:
         subdir = None
     resource = self._provider.resource(filename)
     if resource and resource.src_file() and (subdir is None or resource.SUBDIR == subdir):
         return wiking.serve_file(req, resource.src_file(),
                                  allow_redirect=not filename.endswith('.css'))
     else:
         raise NotFound()
Пример #4
0
 def _handle_resource(self, req, filename):
     subdir = filename.split('/', 1)[0]
     if subdir in ('images', 'css', 'scripts', 'media', 'flash'):
         # This is just a temporary hack to allow backward compatibility
         # with resource URIs using type specific subdirectories.
         # Wiking no longer generates such URIs and applications should
         # avoid them too as this hack will be removed in future.
         filename = filename[len(subdir) + 1:]
     else:
         subdir = None
     resource = self._provider.resource(filename)
     if resource and resource.src_file() and (subdir is None
                                              or resource.SUBDIR == subdir):
         return wiking.serve_file(
             req,
             resource.src_file(),
             allow_redirect=not filename.endswith('.css'))
     else:
         raise NotFound()
Пример #5
0
 def _handle(self, req):
     directory = os.environ.get('PYTIS_CMS_ATTACHMENTS_STORAGE')
     if not directory or not req.unresolved_path:
         raise wiking.Forbidden
     assert not (directory.startswith('http://')
                 or directory.startswith('https://'))
     identifier = req.unresolved_path[0]
     del req.unresolved_path[0]
     storage = pp.FileAttachmentStorage(
         os.path.join(directory, identifier),
         self._base_uri(req) + '/' + identifier)
     action = req.param('action')
     if action is None:
         if req.unresolved_path:
             resource = storage.find_resource_by_uri(req.uri())
             if resource:
                 return wiking.serve_file(req, resource.src_file())
             else:
                 raise wiking.NotFound
         else:
             data = req.param('data')
             if data:
                 if req.param('authorized_readonly') != False:
                     raise wiking.AuthorizationError()
                 return self._insert(req, storage, data.filename(),
                                     data.file())
             else:
                 return self._list(req, storage)
     else:
         filename = req.unresolved_path[0]
         del req.unresolved_path[0]
         if req.unresolved_path:
             raise wiking.BadRequest()
         if action == 'retrieve':
             return self._retrieve(req, storage, filename)
         elif action == 'info':
             return self._info(req, storage, filename)
         elif action == 'update':
             if req.param('authorized_readonly') != False:
                 raise wiking.AuthorizationError()
             return self._update(req, storage, filename)
         else:
             raise wiking.BadRequest()
Пример #6
0
 def _handle(self, req):
     directory = os.environ.get('PYTIS_CMS_ATTACHMENTS_STORAGE')
     if not directory or not req.unresolved_path:
         raise wiking.Forbidden
     assert not (directory.startswith('http://') or directory.startswith('https://'))
     identifier = req.unresolved_path[0]
     del req.unresolved_path[0]
     storage = pp.FileAttachmentStorage(os.path.join(directory, identifier),
                                        self._base_uri(req)+'/'+identifier)
     action = req.param('action')
     if action is None:
         if req.unresolved_path:
             resource = storage.find_resource_by_uri(req.uri())
             if resource:
                 return wiking.serve_file(req, resource.src_file())
             else:
                 raise wiking.NotFound
         else:
             data = req.param('data')
             if data:
                 if req.param('authorized_readonly') != False:
                     raise wiking.AuthorizationError()
                 return self._insert(req, storage, data.filename(), data.file())
             else:
                 return self._list(req, storage)
     else:
         filename = req.unresolved_path[0]
         del req.unresolved_path[0]
         if req.unresolved_path:
             raise wiking.BadRequest()
         if action == 'retrieve':
             return self._retrieve(req, storage, filename)
         elif action == 'info':
             return self._info(req, storage, filename)
         elif action == 'update':
             if req.param('authorized_readonly') != False:
                 raise wiking.AuthorizationError()
             return self._update(req, storage, filename)
         else:
             raise wiking.BadRequest()
Пример #7
0
 def _handle(self, req):
     filename = wiking.cfg.site_icon
     if filename:
         return wiking.serve_file(req, filename, 'image/vnd.microsoft.icon')
     else:
         raise NotFound()
Пример #8
0
 def _handle(self, req):
     filename = wiking.cfg.site_icon
     if filename:
         return wiking.serve_file(req, filename, 'image/vnd.microsoft.icon')
     else:
         raise NotFound()