Changeset 790

Show
Ignore:
Timestamp:
02/19/07 11:54:59
Author:
mylan
Message:

Clear blogging APIs modules, up version.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SimpleBlog/trunk/BloggerAPI.py

    r789 r790  
    5656        if RPCAuth: 
    5757            self.setupRPCAuth(RPCAuth) 
    58          
     58 
    5959    security.declarePublic('setupRPCAuth') 
    6060    def setupRPCAuth(self, RPCAuth): 
     
    6868        unique ID of the new post.  On error, it will return some error 
    6969        message.""" 
    70          
    7170        self.plone_log('blogger/newPost') 
    7271 
     
    8180 
    8281        #headers, body = parseHeadersBody(content) 
    83  
    8482        id = sbtool.idFromTitle(title) 
    85          
    86         self.plone_log("<blogger.newPost()>") 
    87         self.plone_log("blogid: ", blogid) 
    88         self.plone_log("content: ", content) 
    89         #self.plone_log("headers: ", headers) 
    90         #self.plone_log("body: ", body) 
    91         self.plone_log("publish: ", publish) 
    92         self.plone_log("</blogger.newPost()>") 
    93                  
    9483        blog.invokeFactory('BlogEntry', id = id, title = title, body = body) 
    9584        entry = getattr(blog, id) 
     
    9988            state = sbtool.getPublishedState() 
    10089            entry.setEffectiveDate(DateTime.DateTime()) 
    101              
     90 
    10291            # todo xxxxxxxxxx 
    10392            wf_tool.doActionFor(entry,'publish', None) 
     
    114103 
    115104        sbtool = getToolByName(self, 'simpleblog_tool') 
    116          
    117105        entry = sbtool.getByUID(postid) 
    118          
    119106        entry.setBody(content, mimetype='text/html') 
    120          
     107 
    121108        if publish: 
    122109            wf_tool = getToolByName(self, 'portal_workflow') 
    123110            entry.setEffectiveDate(DateTime.DateTime()) 
    124111            wf_tool.doActionFor(entry, 'publish', None) 
    125              
     112 
    126113        return True 
    127114 
     
    132119 
    133120        sbtool = getToolByName(self, 'simpleblog_tool') 
    134          
    135121        entry = sbtool.getByUID(postid) 
    136  
    137122        entry.aq_inner.aq_parent.manage_delObjects(entry.getId()) 
    138123 
    139124        return True 
    140          
     125 
    141126    security.declarePublic('getRecentPosts') 
    142127    def getRecentPosts(self, appkey, blogid, username, password, num): 
     
    162147            return posts[:int(num)] 
    163148        return posts 
    164      
     149 
    165150    security.declarePublic('getUsersBlogs') 
    166151    def getUsersBlogs(self, appkey, username, password): 
     
    216201        self.plone_log('blogger/setTemplate') 
    217202        pass 
    218  
  • SimpleBlog/trunk/MetaWeblogAPI.py

    r789 r790  
    5656        if RPCAuth: 
    5757            self.setupRPCAuth(RPCAuth) 
    58          
     58 
    5959    security.declarePublic('setupRPCAuth') 
    6060    def setupRPCAuth(self, RPCAuth): 
     
    6464    def newPost(self, blogid, username, password, struct, publish): 
    6565        """Some Stuff""" 
    66          
    6766        self.plone_log('metaWeblog/newPost') 
    68         print 'metaWeblog/newPost' 
    69          
    70         sbtool = getToolByName(self, 'simpleblog_tool') 
    71  
     67 
     68        sbtool = getToolByName(self, 'simpleblog_tool') 
    7269        blog = sbtool.getByUID(blogid) 
    7370 
     
    7673        description = struct.get('mt_excerpt', '') 
    7774        allow_comments = struct.get('mt_allow_comments', 1) 
    78          
    7975        id = sbtool.idFromTitle(title) 
    8076 
     
    9288            state = sbtool.getPublishedState() 
    9389            entry.setEffectiveDate(DateTime.DateTime()) 
    94              
    9590            # todo xxxxxxxxxx 
    9691            wf_tool.doActionFor(entry, 'publish', None) 
     
    10297        """Some stuff""" 
    10398        self.plone_log('metaWeblog/editPost') 
    104         print 'metaWeblog/editPost' 
    105         sbtool = getToolByName(self, 'simpleblog_tool') 
    106          
     99        sbtool = getToolByName(self, 'simpleblog_tool') 
    107100        entry = sbtool.getByUID(postid) 
    108  
    109101        body  = struct.get('description', struct.get('Description'))     
    110102        title = struct.get('title', struct.get('Title')) 
    111103        description = struct.get('mt_excerpt', '') 
    112104        allow_comments = struct.get('mt_allow_comments', 1) 
    113          
     105 
    114106        entry.setBody(body, mimetype='text/html') 
    115107        entry.setTitle(title) 
    116108        entry.setDescription(description) 
    117109        disc_tool = getToolByName(self, 'portal_discussion') 
    118          
     110 
    119111        #if allow_comments: 
    120112            #disc_tool.overrideDiscussionFor(entry, 1) 
     
    129121 
    130122        entry.reindexObject() 
    131                      
     123 
    132124        return True 
    133          
     125 
    134126    security.declarePublic('getPost') 
    135127    def getPost(self, postid, username, password): 
    136128        "Return a post I suppose" 
    137129        self.plone_log('metaWeblog/getPost') 
    138         print 'metaWeblog/getPost' 
    139         sbtool = getToolByName(self, 'simpleblog_tool') 
    140          
     130        sbtool = getToolByName(self, 'simpleblog_tool') 
     131 
    141132        post = sbtool.getByUID(postid) 
    142133        disc_tool = getToolByName(self, 'portal_discussion') 
     
    152143            res['mt_text_more']=post.getBody() 
    153144            res['mt_allow_comments']=disc_tool.isDiscussionAllowedFor(post) 
    154                  
     145 
    155146            return res 
    156147        else: 
     
    158149 
    159150        return res 
    160          
     151 
    161152    security.declarePublic('getCategories') 
    162153    def getCategories(self, blogid, username, password): 
    163154        "Returns a struct containing description, htmlUrl and rssUrl" 
    164155        self.plone_log('metaWeblog/getCategories') 
    165         print 'metaWeblog/getCategories' 
    166         sbtool = getToolByName(self, 'simpleblog_tool') 
    167          
    168         blog = sbtool.getByUID(blogid) 
    169          
     156        sbtool = getToolByName(self, 'simpleblog_tool') 
     157        blog = sbtool.getByUID(blogid) 
     158 
    170159        cats = blog.listCategories() 
    171          
    172160        categories = [] 
    173161        for cat in cats: 
     
    177165                'rssUrl' : blog.absolute_url() + ',/SimpleBlogCatSearch?category=' + cat 
    178166                }) 
    179                  
    180         self.plone_log('metaWeblog/getCategories: returning ', categories) 
     167 
    181168        return categories 
    182169 
     
    185172        "Returns true on success, fault on failure" 
    186173        self.plone_log('metaWeblog/deletePost') 
    187         print 'metaWeblog/deletePost' 
    188         sbtool = getToolByName(self, 'simpleblog_tool') 
    189          
     174        sbtool = getToolByName(self, 'simpleblog_tool') 
     175 
    190176        entry = sbtool.getByUID(postid) 
    191  
    192177        entry.aq_inner.aq_parent.manage_delObjects(entry.getId()) 
    193178 
     
    199184         The three basic elements are title, link and description.  
    200185         For blogging tools that don't support titles and links, the description element holds what the Blogger API refers to as 'content'.""" 
    201  
    202186        self.plone_log('metaWeblog/getRecentPosts') 
    203         print 'metaWeblog/getRecentPosts' 
    204187        sbtool = getToolByName(self, 'simpleblog_tool') 
    205188        blog = sbtool.getByUID(blogid) 
     
    207190        brains = blog.getFolderContents(contentFilter={'portal_type': 'BlogEntry'},) 
    208191        # todo: what if entries are in subfolders? 
    209          
    210192        posts = [] 
    211193        for b in brains: 
     
    220202        if num is not None: 
    221203            return posts[:int(num)] 
     204 
    222205        return posts 
    223      
     206 
    224207    security.declarePublic('getUsersBlogs') 
    225208    def getUsersBlogs(self, username, password): 
    226209        """ Return all the blogs the user has access and write permission to """ 
    227  
    228210        self.plone_log('metaWeblog/getUsersBlogs') 
    229         print 'metaWeblog/getUsersBlogs' 
    230211        catalog = getToolByName(self, 'portal_catalog') 
    231212        results = catalog(meta_type='Blog') 
     
    248229        userid, firstname, lastname, nickname, email, and url.""" 
    249230        self.plone_log('metaWeblog/getUserInfo') 
    250         print 'metaWeblog/getUserInfo' 
    251231 
    252232        membership=getToolByName(self, 'portal_membership') 
     
    258238            for key,value in info.items(): 
    259239                info[key] = getattr(member,key,None) or value 
     240 
    260241        return info 
    261242 
     
    264245    def newMediaObject(self, blogid, username, password, struct): 
    265246        """Create media object and return it's URL or exception""" 
    266          
    267247        self.plone_log('metaWeblog/newMediaObject') 
    268         print 'metaWeblog/newMediaObject' 
    269          
    270         sbtool = getToolByName(self, 'simpleblog_tool') 
    271         blog = sbtool.getByUID(blogid) 
    272          
     248        sbtool = getToolByName(self, 'simpleblog_tool') 
     249        blog = sbtool.getByUID(blogid) 
     250 
    273251        media_name = struct.get('name', None) 
    274252        mime_type = struct.get('type', None) 
  • SimpleBlog/trunk/MovableTypeAPI.py

    r789 r790  
    3535    def setupRPCAuth(self, RPCAuth): 
    3636        RPCAuth.addAuthProvider(authTwoMethods, genericBloggerAuthTwo) 
    37          
     37 
    3838    security.declarePublic('publishPost') 
    3939    def publishPost(self, postid, username, password): 
    4040        """ Publish a post """ 
    4141        self.plone_log('mt/publishPost') 
    42         print 'mt/publishPost' 
    43          
    4442        sbtool = getToolByName(self, 'simpleblog_tool') 
    4543        post = sbtool.getByUID(postid)         
    46          
     44 
    4745        if post: 
    4846            # do publishing 
     
    5250                wf_tool.doActionFor(post, 'publish')  # todo 
    5351            return XMLRPCTRUE 
     52 
    5453        raise AttributeError, "Entry %s does not exists" % postid 
    5554 
     
    5857        """Get a list of posts titles by a user. 
    5958        The number of posts is unlimited.""" 
    60  
    6159        self.plone_log('mt/getRecentPostTitles') 
    62         print 'mt/getRecentPostTitles' 
    6360        sbtool = getToolByName(self, 'simpleblog_tool') 
    6461        blog = sbtool.getByUID(blogid) 
     
    6663        brains = blog.getFolderContents(contentFilter={'portal_type': 'BlogEntry'},) 
    6764        # todo: what if entries are in subfolders? 
    68          
    6965        posts = [] 
    7066        for b in brains: 
     
    7975        if numberOfPosts is not None: 
    8076            return posts[:int(numberOfPosts)] 
     77 
    8178        return posts 
    82     
     79 
    8380    security.declarePublic('getCategoryList') 
    8481    def getCategoryList(self, blogid, username, password): 
    8582        """ Get a list of available categories """ 
    86  
    8783        self.plone_log('mt/getCategoryList') 
    88         print 'mt/getCategoryList' 
    8984        sbtool = getToolByName(self, 'simpleblog_tool') 
    90          
    9185        blog = sbtool.getByUID(blogid) 
    92          
    9386        cats = blog.listCategories() 
    94          
    9587        categories = [] 
    9688        for cat in cats: 
     
    9890                {'isPrimary':XMLRPCFALSE, 'categoryId': cat, 'categoryName' : cat}) 
    9991 
    100         return categories    
    101     
     92        return categories 
     93 
    10294    security.declarePublic('getPostCategories') 
    10395    def getPostCategories(self, postid, username, password): 
    10496        """ Return an existing posting categories in the RSS format. """ 
    105  
    10697        self.plone_log('mt/getPostCategories') 
    107         print 'mt/getPostCategories' 
    10898        sbtool = getToolByName(self, 'simpleblog_tool') 
    10999        post = sbtool.getByUID(postid) 
     
    120110    def setPostCategories(self, postid, username, password, categories): 
    121111        """ Return an existing posting categories in the RSS format. """ 
    122  
    123112        self.plone_log('mt/setPostCategories') 
    124         print 'mt/setPostCategories' 
    125113        sbtool = getToolByName(self, 'simpleblog_tool') 
    126114        post = sbtool.getByUID(postid) 
  • SimpleBlog/trunk/version.txt

    r789 r790  
    1 qg2.5.2 
     1qg2.5.3