Ignore:
Timestamp:
Apr 12, 2006 3:24:08 PM (18 years ago)
Author:
mylan
Message:

plone 2.1 version with blogging APIs support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py

    • Property svn:eol-style deleted
    r28 r319  
    33from Products.CMFCore import utils 
    44from Products.CMFCore.DirectoryView import registerDirectory 
    5 import os, os.path, sys, content 
    6  
    7 from Products.CMFCore.utils import ContentInit 
    8 from Products.CMFCore.utils import ToolInit 
     5import os, os.path 
    96 
    107from config import SKINS_DIR, GLOBALS, PROJECTNAME 
     8from config import ADD_BLOGENTRY_PERMISSION,ADD_SIMPLEBLOG_PERMISSION 
    119 
    1210from Globals import InitializeClass 
    1311 
     12import xmlrpcMonkeyPatch 
     13 
    1414registerDirectory(SKINS_DIR, GLOBALS) 
    15  
    16 from Products.SimpleBlog.Permissions import wireAddPermissions 
    17  
    18 # Module aliases - we don't always get it right on the first try, but and we 
    19 # can't move modules around because things are stored in the ZODB with the 
    20 # full module path. However, we can create aliases for backwards compatability. 
    21  
    22 sys.modules['Products.SimpleBlog.Blog'] = content.blog 
    23 sys.modules['Products.SimpleBlog.BlogEntry'] = content.blogentry 
    24 sys.modules['Products.SimpleBlog.BlogFolder'] = content.blogfolder 
    25 sys.modules['Products.SimpleBlog.TrackBack'] = content.trackback 
    2615 
    2716def initialize(context): 
     
    3221    ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('encodeURLData') 
    3322 
    34     from content import BlogEntry 
    35     from content import Blog 
    36     from content import BlogFolder 
    37     from content import TrackBack 
     23    #allow_module('Products.SimpleBlog.Extensions.utils') 
    3824 
    3925 
    40     listOfTypes = listTypes(PROJECTNAME) 
     26    ##Import Types here to register them 
     27    import BlogEntry 
     28    import Blog 
     29    import BlogFolder 
     30    import TrackBack     
     31     
     32    content_types, constructors, ftis = process_types( 
     33        listTypes(PROJECTNAME), 
     34        PROJECTNAME) 
     35     
     36     
     37    blogIndex = getTypeIndex(content_types, 'Blog') 
     38    entryIndex=getTypeIndex(content_types, 'BlogEntry') 
     39    folderIndex = getTypeIndex(content_types, 'BlogFolder')     
     40    trackbackIndex = getTypeIndex(content_types, 'TrackBack')     
    4141 
    42     content_types, constructors, ftis = process_types( 
    43         listOfTypes, 
    44         PROJECTNAME) 
     42    blog_contstructor = [] 
     43    blog_contstructor.append(constructors[blogIndex]) 
     44    entry_contstructor = [] 
     45    entry_contstructor.append(constructors[entryIndex]) 
     46    entry_contstructor.append(constructors[folderIndex]) 
     47    entry_contstructor.append(constructors[trackbackIndex]) 
    4548 
    46     from Products.SimpleBlog.Permissions import permissions 
     49    blog_type = [] 
     50    blog_type.append(content_types[blogIndex]) 
     51    entry_type = [] 
     52    entry_type.append(content_types[entryIndex]) 
     53    entry_type.append(content_types[folderIndex]) 
     54    entry_type.append(content_types[trackbackIndex]) 
    4755     
    48     allTypes = zip(content_types, constructors) 
    49     wireAddPermissions() 
    50     for atype, constructor in allTypes: 
    51         kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) 
    52         ContentInit( 
    53             kind, 
    54             content_types      = (atype,), 
    55             permission         = permissions[atype.portal_type], 
    56             extra_constructors = (constructor,), 
    57             fti                = ftis, 
    58             ).initialize(context) 
    59  
     56     
     57    utils.ContentInit( 
     58        PROJECTNAME + ' Content', 
     59        content_types      = tuple(blog_type), 
     60        permission         = ADD_SIMPLEBLOG_PERMISSION, 
     61        extra_constructors = tuple(blog_contstructor), 
     62        fti                = ftis, 
     63        ).initialize(context) 
     64     
     65    utils.ContentInit( 
     66        PROJECTNAME + ' Content', 
     67        content_types      = tuple(entry_type), 
     68        permission         = ADD_BLOGENTRY_PERMISSION, 
     69        extra_constructors = tuple(entry_contstructor), 
     70        fti                = ftis, 
     71        ).initialize(context) 
     72     
    6073         
    6174    from SimpleBlogTool import SimpleBlogManager 
     
    6679        icon='tool.gif', ).initialize(context) 
    6780     
    68  
     81def getTypeIndex(content_types, meta_type): 
     82    for i in range(len(content_types)): 
     83        if content_types[i].meta_type==meta_type: 
     84            return i 
     85             
    6986     
     87     
     88     
     89     
     90     
Note: See TracChangeset for help on using the changeset viewer.