Changeset 319

Show
Ignore:
Timestamp:
04/12/06 10:24:08
Author:
mylan
Message:

plone 2.1 version with blogging APIs support.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/Blog.py

    r318 r319  
    66import Permissions 
    77from Products.CMFCore.utils import getToolByName 
     8 
     9import MetaWeblogAPI 
     10import BloggerAPI 
     11import MovableTypeAPI 
     12 
    813 
    914schema = BaseFolderSchema +  Schema(( 
     
    123128    global_allow=1 
    124129    schema=schema 
     130 
     131    blogger = None 
     132    metaWeblog = None 
    125133     
    126134    content_icon='simpleblog_icon.gif' 
     
    141149          'visible':0}) 
    142150 
     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 
    143167    def manage_afterAdd(self, item, container): 
    144168        BaseFolder.manage_afterAdd(self, item, container) 
     
    171195        return val 
    172196 
     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 
    173208registerType(Blog) 
    174209 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/Install.py

    r318 r319  
    66 
    77from Products.SimpleBlog.config import * 
     8 
     9from Products.SimpleBlog import MetaWeblogAPI 
     10from Products.SimpleBlog import BloggerAPI 
     11from Products.SimpleBlog import MovableTypeAPI 
    812 
    913portlets=['here/portlet_simpleblog/macros/portletBlogFull_local',  
     
    8084    add_workflow(self, 'trackback_workflow', 'trackback_workflow (TrackBack Workflow)', ('TrackBack',), out) 
    8185    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     
    83104    print >> out, "Successfully installed %s." % PROJECTNAME 
    84105    return out.getvalue() 
     
    96117        wf_tool.setChainForPortalTypes(types, wf_id) 
    97118    out.write('Added workflow "%s"\n'%wf_id) 
     119 
     120def 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." 
    98126 
    99127 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/Extensions/utils.py

    r318 r319  
    2929            pass 
    3030 
     31 
     32from Products.SimpleBlog import MetaWeblogAPI 
     33from Products.SimpleBlog import BloggerAPI 
     34from Products.SimpleBlog import MovableTypeAPI 
     35 
     36def 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  
    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/plone-2.1-Blogging-APIs/__init__.py

    r318 r319  
    1010from Globals import InitializeClass 
    1111 
     12import xmlrpcMonkeyPatch 
    1213 
    1314registerDirectory(SKINS_DIR, GLOBALS) 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/version.txt

    r318 r319  
    1 1.4.0qg 
     11.5qg