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

def zope-coreblog-1.0::Entry::Entry::tbping (   self,
  REQUEST = None,
  RESPONSE = None 
)

Method for receiving Trackback PING

Definition at line 909 of file Entry.py.

00909                                                :
        """Method for receiving Trackback PING"""
      
        cb = self.blog()
        REQUEST.set('error_code',0)
        #char_code = cb.get_charcode()
        #resp = Entry.tb_ping_resp_tpl % (char_code,0,"")

        try:
            #__mode=rss
            if REQUEST and REQUEST.form.has_key('__mode') and REQUEST.form['__mode'] == 'rss':
                REQUEST.set('mode_rss',1)
            #check parameters
            elif not REQUEST or (REQUEST and not REQUEST.form.has_key('url')):
                raise RuntimeError,"Paramater 'url' required."
            else:
                #check method... accept only 'POST' method
                #if not REQUEST.has_key('REQUEST_METHOD') or \
                #                lower(REQUEST['REQUEST_METHOD']) != 'post':
                #    raise RuntimeError, "Trackback ping was calld with 'GET' method. Please call with 'POST' method."

                #check sending charcode
                fc = ""
                fromcode = ""
                if REQUEST.has_key("charcode"):
                    #get charcode from POST paramater
                    fc = REQUEST.form["charcode"]
                else:
                    #get charcode from Content-type header
                    ch = REQUEST.get_header('Content-type')
                    if ch:
                        ch = lower(ch)
                        fr = search("charset=([\S]*)",ch)
                        if fr and fr.groups():
                            fc = fr.groups()[0]
                if fc:
                    
                    fc = lower(sub("[_-]","",fc))
                    if cc_dic.has_key(fc):
                        fromcode = cc_dic[fc]

                char_code = cb.get_charcode()
                #parameters
                val = {}
                val['url'] = convert_charcode(REQUEST.form['url'],char_code,fromcode)
                val['title'] = val['url']
                val['excerpt'] = ""
                val['blog_name'] = ""

                for key in ['title','excerpt','blog_name']:
                    if REQUEST.form.has_key(key):
                        val[key] = convert_charcode(REQUEST.form[key],char_code,fromcode)
                #finnaly,add trackback to Entry!
                self.addTrackback(val['title'],val['excerpt'],val['url'],val['blog_name'])
        except ValueError,e:
            REQUEST.set('error_code',1)
            REQUEST.set('message',"Requested url('%s') does not exist" % (str(e.args[0])))
            #resp = Entry.self.tb_ping_resp_tpl % (char_code,1,Entry.tb_ping_message_tpl % ()))
        except RuntimeError,e:
            REQUEST.set('error_code',1)
            REQUEST.set('message',e.args[0])
            #resp = Entry.tb_ping_resp_tpl % (char_code,1,Entry.tb_ping_message_tpl % (e.args[0]))
        except:
            REQUEST.set('error_code',1)
            #resp = Entry.tb_ping_resp_tpl % (char_code,1,Entry.tb_ping_message_tpl % ("Some Error Occured"))

        return self.tbresult(self,REQUEST)

    #


Generated by  Doxygen 1.6.0   Back to index