Changeset 319
- Timestamp:
- 04/12/06 10:24:08
- Files:
-
- SimpleBlog/branches/plone-2.1-Blogging-APIs/Blog.py (modified) (4 diffs)
- SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/Install.py (modified) (3 diffs)
- SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/utils.py (modified) (1 diff)
- SimpleBlog/branches/plone-2.1-Blogging-APIs/SimpleBlogTool.py (modified) (2 diffs)
- SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py (modified) (1 diff)
- SimpleBlog/branches/plone-2.1-Blogging-APIs/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
SimpleBlog/branches/plone-2.1-Blogging-APIs/Blog.py
r318 r319 6 6 import Permissions 7 7 from Products.CMFCore.utils import getToolByName 8 9 import MetaWeblogAPI 10 import BloggerAPI 11 import MovableTypeAPI 12 8 13 9 14 schema = BaseFolderSchema + Schema(( … … 123 128 global_allow=1 124 129 schema=schema 130 131 blogger = None 132 metaWeblog = None 125 133 126 134 content_icon='simpleblog_icon.gif' … … 141 149 'visible':0}) 142 150 151 def initializeArchetype(self, **kwargs): 152 BaseFolder.initializeArchetype(self, **kwargs) 153 RPCAuth = self.simpleblog_tool.findRPCAuth(self) 154 155 # Setup the MetaWeblog API 156 self.metaWeblog = MetaWeblogAPI.MetaWeblogAPI().__of__(self) 157 self.metaWeblog.setupRPCAuth(RPCAuth) 158 159 # Setup the Blogger API 160 self.blogger = BloggerAPI.BloggerAPI().__of__(self) 161 self.blogger.setupRPCAuth(RPCAuth) 162 163 # Setup the MovableTypeAPI API 164 self.mt = MovableTypeAPI.MovableTypeAPI().__of__(self) 165 self.mt.setupRPCAuth(RPCAuth) 166 143 167 def manage_afterAdd(self, item, container): 144 168 BaseFolder.manage_afterAdd(self, item, container) … … 171 195 return val 172 196 197 def listCategories(self): 198 cats=self.getCategories() 199 200 # add the global categories 201 for c in self.simpleblog_tool.getGlobalCategories(): 202 if not c in cats: 203 cats.append(c) 204 cats = list(cats) 205 cats.sort() 206 return tuple(cats) 207 173 208 registerType(Blog) 174 209 SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/Install.py
r318 r319 6 6 7 7 from Products.SimpleBlog.config import * 8 9 from Products.SimpleBlog import MetaWeblogAPI 10 from Products.SimpleBlog import BloggerAPI 11 from Products.SimpleBlog import MovableTypeAPI 8 12 9 13 portlets=['here/portlet_simpleblog/macros/portletBlogFull_local', … … 80 84 add_workflow(self, 'trackback_workflow', 'trackback_workflow (TrackBack Workflow)', ('TrackBack',), out) 81 85 wf_tool.setChainForPortalTypes( ('TrackBack'), 'trackback_workflow') 82 86 87 # Create an RPCAuth if there is not one already 88 installRPCAuth(self) 89 RPCAuth = self.simpleblog_tool.findRPCAuth(self) 90 91 # add the blogger object to the portal's root 92 # Setup the MetaWeblog API 93 portal.metaWeblog = MetaWeblogAPI.MetaWeblogAPI().__of__(self) 94 portal.metaWeblog.setupRPCAuth(RPCAuth) 95 96 # Setup the Blogger API 97 portal.blogger = BloggerAPI.BloggerAPI().__of__(self) 98 portal.blogger.setupRPCAuth(RPCAuth) 99 100 # Setup the MovableTypeAPI API 101 portal.mt = MovableTypeAPI.MovableTypeAPI().__of__(self) 102 portal.mt.setupRPCAuth(RPCAuth) 103 83 104 print >> out, "Successfully installed %s." % PROJECTNAME 84 105 return out.getvalue() … … 96 117 wf_tool.setChainForPortalTypes(types, wf_id) 97 118 out.write('Added workflow "%s"\n'%wf_id) 119 120 def installRPCAuth(self): 121 if not hasattr(self, 'RPCAuth'): 122 try: 123 self.manage_addProduct['RPCAuth'].manage_addRPCAuth('RPCAuth') 124 except: 125 raise "An RPCAuth instance could not be created. Please make sure RPCAuth is installed correctly." 98 126 99 127 SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/utils.py
r318 r319 29 29 pass 30 30 31 32 from Products.SimpleBlog import MetaWeblogAPI 33 from Products.SimpleBlog import BloggerAPI 34 from Products.SimpleBlog import MovableTypeAPI 35 36 def migrateToAPIs(self): 37 """ migrate existing SimpleBlog instance to support BloggingAPIs """ 38 RPCAuth = self.simpleblog_tool.findRPCAuth(self) 39 # Setup the MetaWeblog API 40 self.metaWeblog = MetaWeblogAPI.MetaWeblogAPI().__of__(self) 41 self.metaWeblog.setupRPCAuth(RPCAuth) 42 # Setup the Blogger API 43 self.blogger = BloggerAPI.BloggerAPI().__of__(self) 44 self.blogger.setupRPCAuth(RPCAuth) 45 # Setup the MovableTypeAPI API 46 self.mt = MovableTypeAPI.MovableTypeAPI().__of__(self) 47 self.mt.setupRPCAuth(RPCAuth) SimpleBlog/branches/plone-2.1-Blogging-APIs/SimpleBlogTool.py
r318 r319 6 6 from Products.CMFCore import CMFCorePermissions 7 7 import zLOG,os 8 8 from Products.CMFCore.utils import getToolByName 9 import re 9 10 import calendar 10 11 calendar.setfirstweekday(6) #start day Mon(0)-Sun(6) … … 32 33 self.manage_addProperty('showIcons', 1,'boolean') 33 34 35 security.declarePublic('getByUID') 36 def getByUID(self, uid): 37 "Shortcut method for the [Blogger,MetaWeblog]API code" 38 39 uid_catalog = getToolByName(self, 'uid_catalog') 40 lazy_cat = uid_catalog(UID=uid) 41 o = lazy_cat[0].getObject() 42 return o 43 44 security.declarePublic('findRPCAuth') 45 def findRPCAuth(self, parent): 46 while hasattr(parent,'aq_parent'): 47 RPCAuths = parent.objectValues('RPC Auth') 48 for RPCAuth in RPCAuths: 49 return RPCAuth 50 parent = parent.aq_parent 51 return None 52 53 security.declarePublic('idFromTitle') 54 def idFromTitle(self, title): 55 id = re.sub('[^A-Za-z0-9_]', '', re.sub(' ', '_', title)).lower() 56 return id 34 57 35 58 def _getState(self): SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py
r318 r319 10 10 from Globals import InitializeClass 11 11 12 import xmlrpcMonkeyPatch 12 13 13 14 registerDirectory(SKINS_DIR, GLOBALS) SimpleBlog/branches/plone-2.1-Blogging-APIs/version.txt
r318 r319 1 1. 4.0qg1 1.5qg
