Beispiel #1
0
def addSection(self, id='', title='', body='', skip_splitting='',
                REQUEST=None):
    """ """

    errors = []
    if not title:
        errors.append('The title field must have a value')
    if not body:
        errors.append('The section must have a body')
    if errors:
        self.setSessionErrors(errors)
        if REQUEST is not None:
            self.setSession('title', title)
            self.setSession('body', body)
            self.REQUEST.RESPONSE.redirect(self.absolute_url() +
                                           '/section_add_html')
        return
    self.delSession('title')
    self.delSession('body')

    id = base_id = self.utSlugify(id or title)
    i = 0
    while self._getOb(id, None) is not None:
        i += 1
        id = '%s-%d' % (base_id, i)
    ob = Section(id, title)
    self._setObject(id, ob)
    ob = self._getOb(id)
    if skip_splitting:
        addParagraph(ob, body=body)
    else:
        ob.parseBody(body)
    if REQUEST is not None:
        self.REQUEST.RESPONSE.redirect(self.absolute_url())
Beispiel #2
0
 def parseBody(self):
     output = parse(self.body)
     for paragraph in output:
         addParagraph(self, body=paragraph)
Beispiel #3
0
 def parseBody(self):
     output = parse(self.body)
     for paragraph in output:
         addParagraph(self, body=paragraph)