Logo Search packages:      
Sourcecode: zope-coreblog version File versions

def zope-coreblog-1.0::COREBlog::COREBlog::manage_addEntry (   self,
  author,
  body,
  extend,
  excerpt,
  main_category,
  moderated,
  sub_category = [],
  title = "",
  subtitle = "",
  entry_date = "",
  format = 0,
  allow_comment = 0,
  receive_trackback = 0,
  trackback_url = "",
  sendnow = 0,
  REQUEST = None,
  sendping = 1,
  kw 
)

Add a Entry object

Definition at line 411 of file COREBlog.py.

                                          :
        """Add a Entry object"""

        #validaters
        v_h = self.removeHTML
        v_b = self.validateEntryBody
        v_c = self.validateCommentBody

        if REQUEST and (REQUEST.form.has_key('preview') or not title):
            if not entry_date:
                entry_date = str(DateTime())
            cats = []
            try:
                cats.append(self.getCategory(main_category)[0])
                for ct in sub_category:
                    cats.append(self.getCategory(int(ct))[0])
            except:
                pass

            if not title:
                kw['worning_message'] = "Title is required."

            kw['date_created'] = lambda x=entry_date : DateTime(x)
            kw['year_created'] = lambda x=entry_date: DateTime(x).year()
            kw['day_created'] = lambda x=entry_date: DateTime(x).day()
            kw['month_created'] = lambda x=entry_date: DateTime(x).month()
            kw['entry_category_list'] = lambda x=cats: x
            kw['tbpingurl'] = lambda : "not defined on pewview"
            kw['entry_title'] = lambda x=v_h(title) : x
          kw['title'] = v_h(title)
            kw['subtitle'] = v_h(subtitle)
            kw['count_comment'] = lambda : 0
            kw['count_trackback'] = lambda : 0
          if format in html_formats:
            kw['rendered_body'] = v_b(body)
            kw['body'] = v_b(body)
          else:
            kw['rendared_body'] = body
            kw['body'] = body
            #Set control values
            kw['noheader'] = 1
            kw['nocomment'] = 1
            kw['nocommentform'] = 1

            #Returns addEntryForm
            return self.manage_addEntryForm(self,REQUEST,**kw)

        new_id = self.getNewEntryID()
        #remove category duplications
        cats_s = [main_category] + sub_category
        cats = []
        for id in cats_s:
            if not self.categories.has_key(int(id)):
                raise ValueError,"Category of ID(%s) does not exist." % (str(id))
            cats.append(int(id))
        cats = make_unique(cats)

        if not excerpt:
            prebody = html2text(v_h(get_rendered_body(body,format)))
            excerpt = get_string_part(prebody,excerpt_length,self.get_charcode())
            if len(excerpt) < len(prebody):
                excerpt = excerpt + "..."

        tburls = split_in_newline(trackback_url)

        crsec = time()
        if entry_date:
            crsec = int(DateTime(entry_date).millis()/1000)

      cooked_body = body
      if format in html_formats:
          cooked_body = v_b(body)
        obj = Entry(new_id, \
                        v_h(author),cooked_body,v_b(extend),v_c(excerpt), \
                        moderated,title,subtitle,cats, \
                        format,allow_comment,receive_trackback, \
                        tburls,crsec)
        obj.__of__(self)
        self.setEntry(new_id,obj)
        self.entry_list.insert(new_id)

        #add category count
        if moderated:
            self.addCategoryCount(cats[0],1)

        self._p_changed = 1

        #Catalogging...
        obj.index(self)

        call_addentry_hook(self,new_id,v_h(author),cooked_body,v_b(extend),v_c(excerpt), \
                        moderated,title,subtitle,cats, \
                        format,allow_comment,receive_trackback)

        pingservers_prop = self.getProperty("ping_servers")
        pingservers = []
        if pingservers_prop:
            for srv in pingservers_prop:
                if srv:
                    pingservers.append(srv)

        if moderated:
            if REQUEST:
                if sendnow and obj.count_sending_trackback() > 0:
                    return REQUEST.RESPONSE.redirect('./' + str(new_id) + "/manage_sendPINGTrackback")
                elif pingservers and len(pingservers) > 0:
                    return REQUEST.RESPONSE.redirect('./' + str(new_id) + "/manage_sendPINGTrackback")
                else:
                    return REQUEST.RESPONSE.redirect('manage_entryForm')
            elif sendping:
                #Entry might add via mail....
                obj.aq_parent = self
                obj.sendPING()
        else:
            if REQUEST:
                return REQUEST.RESPONSE.redirect('manage_entryForm')

        return new_id


    security.declareProtected(ManageCOREBlog, 'manage_deleteEntries')
    def manage_deleteEntries(self,ids,REQUEST=None):


Generated by  Doxygen 1.6.0   Back to index