Changeset 272

Show
Ignore:
Timestamp:
02/17/06 07:25:11
Author:
mylan
Message:

for plone 2.0.5 with API: BloggerAPI, MetaWeblogAPI, MovableTypeAPI

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SimpleBlog/branches/plone2.0.5(API)/Blog.py

    r268 r272  
    66import Permissions 
    77from Products.CMFCore.utils import getToolByName 
     8 
     9import MetaWeblogAPI 
     10import BloggerAPI 
     11import MovableTypeAPI 
     12 
    813 
    914schema = BaseFolderSchema +  Schema(( 
     
    9398                                    description_msgid="help_adminEmail", 
    9499                                    i18n_domain="SimpleBlog", 
    95                                                    condition="python:0", 
     100                                    condition="python:0", 
    96101                                    description="Enter administrator's email for receaving notification about blog's activity"), 
    97102               ) 
     
    122127    global_allow=1 
    123128    schema=schema 
     129 
     130    blogger = None 
     131    metaWeblog = None 
    124132     
    125133    content_icon='simpleblog_icon.gif' 
     
    140148          'visible':0}) 
    141149 
     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 
    142166    def manage_afterAdd(self, item, container): 
    143167        BaseFolder.manage_afterAdd(self, item, container) 
     
    170194        return val 
    171195 
     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 
    172207registerType(Blog) 
    173208 
  • SimpleBlog/branches/plone2.0.5(API)/Extensions/Install.py

    r268 r272  
    77from Products.SimpleBlog.config import * 
    88 
     9from Products.SimpleBlog import MetaWeblogAPI 
     10from Products.SimpleBlog import BloggerAPI 
     11from Products.SimpleBlog import MovableTypeAPI 
     12 
    913portlets=['here/portlet_simpleblog/macros/portletBlogFull_local',  
    1014          'here/portlet_simpleblog/macros/portletBlogFull_global', 
    1115          'here/portlet_simpleblog/macros/portletBlogRecent_local', 
    1216          'here/portlet_simpleblog/macros/portletBlogRecent_global'] 
    13  
    1417 
    1518 
     
    7780    add_workflow(self, 'trackback_workflow', 'trackback_workflow (TrackBack Workflow)', ('TrackBack',), out) 
    7881    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     
    80100    print >> out, "Successfully installed %s." % PROJECTNAME 
    81101    return out.getvalue() 
     
    93113        wf_tool.setChainForPortalTypes(types, wf_id) 
    94114    out.write('Added workflow "%s"\n'%wf_id) 
     115 
     116def 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." 
    95122 
    96123 
     
    151178                        new.append(l) 
    152179                o.column_two_portlets=new 
    153          
    154              
  • SimpleBlog/branches/plone2.0.5(API)/SimpleBlogTool.py

    r268 r272  
    66from Products.CMFCore import CMFCorePermissions 
    77import zLOG,os 
    8  
     8from Products.CMFCore.utils import getToolByName 
     9import re 
    910import calendar 
    1011calendar.setfirstweekday(6) #start day  Mon(0)-Sun(6) 
     
    3233        self.manage_addProperty('showIcons', 1,'boolean') 
    3334 
     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         
    3457 
    3558    def _getState(self): 
  • SimpleBlog/branches/plone2.0.5(API)/__init__.py

    r268 r272  
    1010from Globals import InitializeClass 
    1111 
     12import xmlrpcMonkeyPatch 
    1213 
    1314registerDirectory(SKINS_DIR, GLOBALS)