Changeset 790
- Timestamp:
- 02/19/07 11:54:59
- Files:
-
- SimpleBlog/trunk/BloggerAPI.py (modified) (8 diffs)
- SimpleBlog/trunk/MetaWeblogAPI.py (modified) (16 diffs)
- SimpleBlog/trunk/MovableTypeAPI.py (modified) (7 diffs)
- SimpleBlog/trunk/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
SimpleBlog/trunk/BloggerAPI.py
r789 r790 56 56 if RPCAuth: 57 57 self.setupRPCAuth(RPCAuth) 58 58 59 59 security.declarePublic('setupRPCAuth') 60 60 def setupRPCAuth(self, RPCAuth): … … 68 68 unique ID of the new post. On error, it will return some error 69 69 message.""" 70 71 70 self.plone_log('blogger/newPost') 72 71 … … 81 80 82 81 #headers, body = parseHeadersBody(content) 83 84 82 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 94 83 blog.invokeFactory('BlogEntry', id = id, title = title, body = body) 95 84 entry = getattr(blog, id) … … 99 88 state = sbtool.getPublishedState() 100 89 entry.setEffectiveDate(DateTime.DateTime()) 101 90 102 91 # todo xxxxxxxxxx 103 92 wf_tool.doActionFor(entry,'publish', None) … … 114 103 115 104 sbtool = getToolByName(self, 'simpleblog_tool') 116 117 105 entry = sbtool.getByUID(postid) 118 119 106 entry.setBody(content, mimetype='text/html') 120 107 121 108 if publish: 122 109 wf_tool = getToolByName(self, 'portal_workflow') 123 110 entry.setEffectiveDate(DateTime.DateTime()) 124 111 wf_tool.doActionFor(entry, 'publish', None) 125 112 126 113 return True 127 114 … … 132 119 133 120 sbtool = getToolByName(self, 'simpleblog_tool') 134 135 121 entry = sbtool.getByUID(postid) 136 137 122 entry.aq_inner.aq_parent.manage_delObjects(entry.getId()) 138 123 139 124 return True 140 125 141 126 security.declarePublic('getRecentPosts') 142 127 def getRecentPosts(self, appkey, blogid, username, password, num): … … 162 147 return posts[:int(num)] 163 148 return posts 164 149 165 150 security.declarePublic('getUsersBlogs') 166 151 def getUsersBlogs(self, appkey, username, password): … … 216 201 self.plone_log('blogger/setTemplate') 217 202 pass 218 SimpleBlog/trunk/MetaWeblogAPI.py
r789 r790 56 56 if RPCAuth: 57 57 self.setupRPCAuth(RPCAuth) 58 58 59 59 security.declarePublic('setupRPCAuth') 60 60 def setupRPCAuth(self, RPCAuth): … … 64 64 def newPost(self, blogid, username, password, struct, publish): 65 65 """Some Stuff""" 66 67 66 self.plone_log('metaWeblog/newPost') 68 print 'metaWeblog/newPost' 69 70 sbtool = getToolByName(self, 'simpleblog_tool') 71 67 68 sbtool = getToolByName(self, 'simpleblog_tool') 72 69 blog = sbtool.getByUID(blogid) 73 70 … … 76 73 description = struct.get('mt_excerpt', '') 77 74 allow_comments = struct.get('mt_allow_comments', 1) 78 79 75 id = sbtool.idFromTitle(title) 80 76 … … 92 88 state = sbtool.getPublishedState() 93 89 entry.setEffectiveDate(DateTime.DateTime()) 94 95 90 # todo xxxxxxxxxx 96 91 wf_tool.doActionFor(entry, 'publish', None) … … 102 97 """Some stuff""" 103 98 self.plone_log('metaWeblog/editPost') 104 print 'metaWeblog/editPost' 105 sbtool = getToolByName(self, 'simpleblog_tool') 106 99 sbtool = getToolByName(self, 'simpleblog_tool') 107 100 entry = sbtool.getByUID(postid) 108 109 101 body = struct.get('description', struct.get('Description')) 110 102 title = struct.get('title', struct.get('Title')) 111 103 description = struct.get('mt_excerpt', '') 112 104 allow_comments = struct.get('mt_allow_comments', 1) 113 105 114 106 entry.setBody(body, mimetype='text/html') 115 107 entry.setTitle(title) 116 108 entry.setDescription(description) 117 109 disc_tool = getToolByName(self, 'portal_discussion') 118 110 119 111 #if allow_comments: 120 112 #disc_tool.overrideDiscussionFor(entry, 1) … … 129 121 130 122 entry.reindexObject() 131 123 132 124 return True 133 125 134 126 security.declarePublic('getPost') 135 127 def getPost(self, postid, username, password): 136 128 "Return a post I suppose" 137 129 self.plone_log('metaWeblog/getPost') 138 print 'metaWeblog/getPost' 139 sbtool = getToolByName(self, 'simpleblog_tool') 140 130 sbtool = getToolByName(self, 'simpleblog_tool') 131 141 132 post = sbtool.getByUID(postid) 142 133 disc_tool = getToolByName(self, 'portal_discussion') … … 152 143 res['mt_text_more']=post.getBody() 153 144 res['mt_allow_comments']=disc_tool.isDiscussionAllowedFor(post) 154 145 155 146 return res 156 147 else: … … 158 149 159 150 return res 160 151 161 152 security.declarePublic('getCategories') 162 153 def getCategories(self, blogid, username, password): 163 154 "Returns a struct containing description, htmlUrl and rssUrl" 164 155 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 170 159 cats = blog.listCategories() 171 172 160 categories = [] 173 161 for cat in cats: … … 177 165 'rssUrl' : blog.absolute_url() + ',/SimpleBlogCatSearch?category=' + cat 178 166 }) 179 180 self.plone_log('metaWeblog/getCategories: returning ', categories) 167 181 168 return categories 182 169 … … 185 172 "Returns true on success, fault on failure" 186 173 self.plone_log('metaWeblog/deletePost') 187 print 'metaWeblog/deletePost' 188 sbtool = getToolByName(self, 'simpleblog_tool') 189 174 sbtool = getToolByName(self, 'simpleblog_tool') 175 190 176 entry = sbtool.getByUID(postid) 191 192 177 entry.aq_inner.aq_parent.manage_delObjects(entry.getId()) 193 178 … … 199 184 The three basic elements are title, link and description. 200 185 For blogging tools that don't support titles and links, the description element holds what the Blogger API refers to as 'content'.""" 201 202 186 self.plone_log('metaWeblog/getRecentPosts') 203 print 'metaWeblog/getRecentPosts'204 187 sbtool = getToolByName(self, 'simpleblog_tool') 205 188 blog = sbtool.getByUID(blogid) … … 207 190 brains = blog.getFolderContents(contentFilter={'portal_type': 'BlogEntry'},) 208 191 # todo: what if entries are in subfolders? 209 210 192 posts = [] 211 193 for b in brains: … … 220 202 if num is not None: 221 203 return posts[:int(num)] 204 222 205 return posts 223 206 224 207 security.declarePublic('getUsersBlogs') 225 208 def getUsersBlogs(self, username, password): 226 209 """ Return all the blogs the user has access and write permission to """ 227 228 210 self.plone_log('metaWeblog/getUsersBlogs') 229 print 'metaWeblog/getUsersBlogs'230 211 catalog = getToolByName(self, 'portal_catalog') 231 212 results = catalog(meta_type='Blog') … … 248 229 userid, firstname, lastname, nickname, email, and url.""" 249 230 self.plone_log('metaWeblog/getUserInfo') 250 print 'metaWeblog/getUserInfo'251 231 252 232 membership=getToolByName(self, 'portal_membership') … … 258 238 for key,value in info.items(): 259 239 info[key] = getattr(member,key,None) or value 240 260 241 return info 261 242 … … 264 245 def newMediaObject(self, blogid, username, password, struct): 265 246 """Create media object and return it's URL or exception""" 266 267 247 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 273 251 media_name = struct.get('name', None) 274 252 mime_type = struct.get('type', None) SimpleBlog/trunk/MovableTypeAPI.py
r789 r790 35 35 def setupRPCAuth(self, RPCAuth): 36 36 RPCAuth.addAuthProvider(authTwoMethods, genericBloggerAuthTwo) 37 37 38 38 security.declarePublic('publishPost') 39 39 def publishPost(self, postid, username, password): 40 40 """ Publish a post """ 41 41 self.plone_log('mt/publishPost') 42 print 'mt/publishPost'43 44 42 sbtool = getToolByName(self, 'simpleblog_tool') 45 43 post = sbtool.getByUID(postid) 46 44 47 45 if post: 48 46 # do publishing … … 52 50 wf_tool.doActionFor(post, 'publish') # todo 53 51 return XMLRPCTRUE 52 54 53 raise AttributeError, "Entry %s does not exists" % postid 55 54 … … 58 57 """Get a list of posts titles by a user. 59 58 The number of posts is unlimited.""" 60 61 59 self.plone_log('mt/getRecentPostTitles') 62 print 'mt/getRecentPostTitles'63 60 sbtool = getToolByName(self, 'simpleblog_tool') 64 61 blog = sbtool.getByUID(blogid) … … 66 63 brains = blog.getFolderContents(contentFilter={'portal_type': 'BlogEntry'},) 67 64 # todo: what if entries are in subfolders? 68 69 65 posts = [] 70 66 for b in brains: … … 79 75 if numberOfPosts is not None: 80 76 return posts[:int(numberOfPosts)] 77 81 78 return posts 82 79 83 80 security.declarePublic('getCategoryList') 84 81 def getCategoryList(self, blogid, username, password): 85 82 """ Get a list of available categories """ 86 87 83 self.plone_log('mt/getCategoryList') 88 print 'mt/getCategoryList'89 84 sbtool = getToolByName(self, 'simpleblog_tool') 90 91 85 blog = sbtool.getByUID(blogid) 92 93 86 cats = blog.listCategories() 94 95 87 categories = [] 96 88 for cat in cats: … … 98 90 {'isPrimary':XMLRPCFALSE, 'categoryId': cat, 'categoryName' : cat}) 99 91 100 return categories 101 92 return categories 93 102 94 security.declarePublic('getPostCategories') 103 95 def getPostCategories(self, postid, username, password): 104 96 """ Return an existing posting categories in the RSS format. """ 105 106 97 self.plone_log('mt/getPostCategories') 107 print 'mt/getPostCategories'108 98 sbtool = getToolByName(self, 'simpleblog_tool') 109 99 post = sbtool.getByUID(postid) … … 120 110 def setPostCategories(self, postid, username, password, categories): 121 111 """ Return an existing posting categories in the RSS format. """ 122 123 112 self.plone_log('mt/setPostCategories') 124 print 'mt/setPostCategories'125 113 sbtool = getToolByName(self, 'simpleblog_tool') 126 114 post = sbtool.getByUID(postid) SimpleBlog/trunk/version.txt
r789 r790 1 qg2.5. 21 qg2.5.3
