Changeset 272
- Timestamp:
- 02/17/06 07:25:11
- Files:
-
- SimpleBlog/branches/plone2.0.5(API) (copied) (copied from SimpleBlog/tags/1.3.5qg)
- SimpleBlog/branches/plone2.0.5(API)/Blog.py (modified) (5 diffs)
- SimpleBlog/branches/plone2.0.5(API)/Extensions/Install.py (modified) (4 diffs)
- SimpleBlog/branches/plone2.0.5(API)/SimpleBlogTool.py (modified) (2 diffs)
- SimpleBlog/branches/plone2.0.5(API)/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
SimpleBlog/branches/plone2.0.5(API)/Blog.py
r268 r272 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(( … … 93 98 description_msgid="help_adminEmail", 94 99 i18n_domain="SimpleBlog", 95 condition="python:0",100 condition="python:0", 96 101 description="Enter administrator's email for receaving notification about blog's activity"), 97 102 ) … … 122 127 global_allow=1 123 128 schema=schema 129 130 blogger = None 131 metaWeblog = None 124 132 125 133 content_icon='simpleblog_icon.gif' … … 140 148 'visible':0}) 141 149 150 def initializeArchetype(self, **kwargs): 151 BaseFolder.initializeArchetype(self, **kwargs) 152 RPCAuth = self.simpleblog_tool.findRPCAuth(self) 153 154 # Setup the MetaWeblog API 155 self.metaWeblog = MetaWeblogAPI.MetaWeblogAPI().__of__(self) 156 self.metaWeblog.setupRPCAuth(RPCAuth) 157 158 # Setup the Blogger API 159 self.blogger = BloggerAPI.BloggerAPI().__of__(self) 160 self.blogger.setupRPCAuth(RPCAuth) 161 162 # Setup the MovableTypeAPI API 163 self.mt = MovableTypeAPI.MovableTypeAPI().__of__(self) 164 self.mt.setupRPCAuth(RPCAuth) 165 142 166 def manage_afterAdd(self, item, container): 143 167 BaseFolder.manage_afterAdd(self, item, container) … … 170 194 return val 171 195 196 def listCategories(self): 197 cats=self.getCategories() 198 199 # add the global categories 200 for c in self.simpleblog_tool.getGlobalCategories(): 201 if not c in cats: 202 cats.append(c) 203 cats = list(cats) 204 cats.sort() 205 return tuple(cats) 206 172 207 registerType(Blog) 173 208 SimpleBlog/branches/plone2.0.5(API)/Extensions/Install.py
r268 r272 7 7 from Products.SimpleBlog.config import * 8 8 9 from Products.SimpleBlog import MetaWeblogAPI 10 from Products.SimpleBlog import BloggerAPI 11 from Products.SimpleBlog import MovableTypeAPI 12 9 13 portlets=['here/portlet_simpleblog/macros/portletBlogFull_local', 10 14 'here/portlet_simpleblog/macros/portletBlogFull_global', 11 15 'here/portlet_simpleblog/macros/portletBlogRecent_local', 12 16 'here/portlet_simpleblog/macros/portletBlogRecent_global'] 13 14 17 15 18 … … 77 80 add_workflow(self, 'trackback_workflow', 'trackback_workflow (TrackBack Workflow)', ('TrackBack',), out) 78 81 wf_tool.setChainForPortalTypes( ('TrackBack'), 'trackback_workflow') 79 82 83 # Create an RPCAuth if there is not one already 84 installRPCAuth(self) 85 RPCAuth = self.simpleblog_tool.findRPCAuth(self) 86 87 # add the blogger object to the portal's root 88 # Setup the MetaWeblog API 89 portal.metaWeblog = MetaWeblogAPI.MetaWeblogAPI().__of__(self) 90 portal.metaWeblog.setupRPCAuth(RPCAuth) 91 92 # Setup the Blogger API 93 portal.blogger = BloggerAPI.BloggerAPI().__of__(self) 94 portal.blogger.setupRPCAuth(RPCAuth) 95 96 # Setup the MovableTypeAPI API 97 portal.mt = MovableTypeAPI.MovableTypeAPI().__of__(self) 98 portal.mt.setupRPCAuth(RPCAuth) 99 80 100 print >> out, "Successfully installed %s." % PROJECTNAME 81 101 return out.getvalue() … … 93 113 wf_tool.setChainForPortalTypes(types, wf_id) 94 114 out.write('Added workflow "%s"\n'%wf_id) 115 116 def installRPCAuth(self): 117 if not hasattr(self, 'RPCAuth'): 118 try: 119 self.manage_addProduct['RPCAuth'].manage_addRPCAuth('RPCAuth') 120 except: 121 raise "An RPCAuth instance could not be created. Please make sure RPCAuth is installed correctly." 95 122 96 123 … … 151 178 new.append(l) 152 179 o.column_two_portlets=new 153 154 SimpleBlog/branches/plone2.0.5(API)/SimpleBlogTool.py
r268 r272 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/plone2.0.5(API)/__init__.py
r268 r272 10 10 from Globals import InitializeClass 11 11 12 import xmlrpcMonkeyPatch 12 13 13 14 registerDirectory(SKINS_DIR, GLOBALS)
