예제 #1
0
 def _bag_list(self, tiddlers):
     if '/feedbag' in self.environ['selector.matches'][0]:
         representation_link = '%s/feedbag' % (self._server_prefix())
         bag = Bag('feedbag')
         bag.policy.manage = ["NONE"]
         bag.policy.delete = ["NONE"]
         bag.desc = 'Recent Public Stuff'
     else:
         name = self.environ['wsgiorg.routing_args'][1]['bag_name']
         name = urllib.unquote(name)
         name = name.decode('utf-8')
         representation_link = '%s/bags/%s/tiddlers' % (
                 self._server_prefix(), encode_name(name))
         bag = self.environ['tiddlyweb.store'].get(Bag(name))
     representations = self._tiddler_list_header(representation_link)
     user_object = get_user_object(self.environ)
     publicity = ''
     try:
         bag.policy.allows(user_object, 'manage')
         policy = bag.policy
         publicity = determine_publicity(user_object, policy)
     except (UserRequiredError, ForbiddenError):
         policy = None
     try:
         bag.policy.allows(user_object, 'delete')
         delete = True
     except (UserRequiredError, ForbiddenError):
         delete = False
     data = {'title': 'TiddlyHoster Bag %s' % bag.name, 'policy': policy,
             'publicity': publicity, 'delete': delete,
             'bag': bag, 'tiddlers': tiddlers, 'representations': representations}
     del self.environ['tiddlyweb.title']
     return send_template(self.environ, 'baglist.html', data)
예제 #2
0
    def list_tiddlers(self, bag):
        """
        If the URL is a list of bag tiddlers, we present a bag
        editing interface. Otherwise we use the parent serialization.
        """
        if (self.environ['wsgiorg.routing_args'][1].get('tiddler_name')):
            return HTMLSerialization.list_tiddlers(self, bag)

        try:
            name = self.environ['wsgiorg.routing_args'][1]['bag_name']
        except KeyError: # not a bag link
            return HTMLSerialization.list_tiddlers(self, bag)

        representation_link = '%s/bags/%s/tiddlers' % (
                self._server_prefix(), encode_name(bag.name))
        representations = self._tiddler_list_header(representation_link)
        user_object = get_user_object(self.environ)
        publicity = ''
        try:
            bag.policy.allows(user_object, 'manage')
            policy = bag.policy
            publicity = determine_publicity(user_object, policy)
        except (UserRequiredError, ForbiddenError):
            policy = None
        try:
            bag.policy.allows(user_object, 'delete')
            delete = True
        except (UserRequiredError, ForbiddenError):
            delete = False
        data = {'title': 'TiddlyHoster Bag %s' % bag.name, 'policy': policy,
                'publicity': publicity, 'delete': delete,
                'bag': bag, 'representations': representations}
        del self.environ['tiddlyweb.title']
        return send_template(self.environ, 'baglist.html', data)
예제 #3
0
 def _bag_list(self, tiddlers):
     if '/feedbag' in self.environ['selector.matches'][0]:
         representation_link = '%s/feedbag' % (self._server_prefix())
         bag = Bag('feedbag')
         bag.policy.manage = ["NONE"]
         bag.policy.delete = ["NONE"]
         bag.desc = 'Recent Public Stuff'
     else:
         name = self.environ['wsgiorg.routing_args'][1]['bag_name']
         name = urllib.unquote(name)
         name = name.decode('utf-8')
         representation_link = '%s/bags/%s/tiddlers' % (
             self._server_prefix(), encode_name(name))
         bag = self.environ['tiddlyweb.store'].get(Bag(name))
     representations = self._tiddler_list_header(representation_link)
     user_object = get_user_object(self.environ)
     publicity = ''
     try:
         bag.policy.allows(user_object, 'manage')
         policy = bag.policy
         publicity = determine_publicity(user_object, policy)
     except (UserRequiredError, ForbiddenError):
         policy = None
     try:
         bag.policy.allows(user_object, 'delete')
         delete = True
     except (UserRequiredError, ForbiddenError):
         delete = False
     data = {
         'title': 'TiddlyHoster Bag %s' % bag.name,
         'policy': policy,
         'publicity': publicity,
         'delete': delete,
         'bag': bag,
         'tiddlers': tiddlers,
         'representations': representations
     }
     del self.environ['tiddlyweb.title']
     return send_template(self.environ, 'baglist.html', data)