Пример #1
0
    def setUp(self):
        self.root = self.layer.get_application()
        self.layer.login('author')

        factory = self.root.manage_addProduct['SilvaFind']
        factory.manage_addSilvaFind('search', 'Search your Site')
        factory = self.root.manage_addProduct['Silva']
        factory.manage_addFolder('folder', 'Folder')
        factory = self.root.folder.manage_addProduct['Silva']
        factory.manage_addMockupVersionedContent('info', 'Information')

        self.documents = Batch(
            self.root.service_catalog(meta_type=['Mockup VersionedContent'],
                                      path='/root/folder'))
        self.empty = Batch([])
Пример #2
0
    def update(self, topic=None, text=None, anonymous=False):
        super(ForumView, self).update()

        topic = str(topic or '', 'UTF-8').strip()
        text = str(text or '', 'UTF-8').strip()

        for name, action in self.ACTIONS:
            if name in self.request.form:
                action(self, topic, text, anonymous)
                break

        self.topics = Batch(self.context.topics(),
                            count=self.context.topic_batch_size,
                            name='topics',
                            request=self.request)

        # We don't want batch links to include form data.
        navigation = getMultiAdapter((self.context, self.topics, self.request),
                                     IBatching)
        navigation.keep_query_string = False
        self.navigation = navigation()
Пример #3
0
    def update(self, title=None, text=None, anonymous=False):
        super(TopicView, self).update()
        title = str(title or '', 'UTF-8').strip()
        text = str(text or '', 'UTF-8').strip()

        for name, action in self.ACTIONS:
            if name in self.request.form:
                action(self, title, text, anonymous)
                break

        self.comments = Batch(self.context.comments(),
                              count=self.context.comment_batch_size,
                              name='comments',
                              request=self.request)

        # We don't want batch links to include form data.
        navigation = getMultiAdapter(
            (self.context, self.comments, self.request), IBatching)
        navigation.keep_query_string = False
        self.navigation = navigation()
        self.action_url = navigation.batch_last['url'] + '#forum-bottom'
 def to_html(self, content, request, **parameters):
     """ render HTML for SQL source
     """
     values = self._get_data(parameters)
     names = values.names()
     batch_size = self._default_batch_size
     if parameters.get('sqlbatchsize'):
         batch_size = int(parameters.get('sqlbatchsize'))
     data = Batch(
         values.dictionaries(),
         factory=self._decode_dict_helper,
         count=batch_size,
         name=self.getId(),
         request=request)
     model = content
     if IVersion.providedBy(content):
         model = content.get_content()
     layout = self._getOb(self._layout_id)
     batch = getMultiAdapter((model, data, request), IBatching)()
     return layout(
         table=data, batch=batch, names=names, parameters=parameters)
 def to_html(self, content, request, **parameters):
     """ render HTML for CSV source
     """
     rows = self._data[:]
     param = {}
     param.update(parameters)
     if not param.get('csvtableclass'):
         param['csvtableclass'] = 'default'
     batch_size = self._default_batch_size
     batch = ''
     if param.get('csvbatchsize'):
         batch_size = int(param.get('csvbatchsize'))
     model = content
     if IVersion.providedBy(content):
         model = content.get_content()
     if rows:
         headings = rows[0]
         rows = Batch(rows[1:],
                      count=batch_size,
                      name=self.getId(),
                      request=request)
         param['headings'] = headings
         batch = getMultiAdapter((model, rows, request), IBatching)()
     return self.layout(table=rows, batch=batch, parameters=param)