source: products/SimpleBlog/branches/plone-2.0.5-Blogging-APIs/__init__.py @ 3665

Last change on this file since 3665 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 2.7 KB
Line 
1from Globals import package_home
2from Products.Archetypes.public import process_types, listTypes
3from Products.CMFCore import utils
4from Products.CMFCore.DirectoryView import registerDirectory
5import os, os.path
6
7from config import SKINS_DIR, GLOBALS, PROJECTNAME
8from config import ADD_BLOGENTRY_PERMISSION,ADD_SIMPLEBLOG_PERMISSION
9
10from Globals import InitializeClass
11
12import xmlrpcMonkeyPatch
13
14registerDirectory(SKINS_DIR, GLOBALS)
15
16def initialize(context):
17
18    ## Allow module utils
19    from AccessControl import ModuleSecurityInfo, allow_module
20    ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('addTrackBack')
21
22    #allow_module('Products.SimpleBlog.Extensions.utils')
23
24
25    ##Import Types here to register them
26    import BlogEntry
27    import Blog
28    import BlogFolder
29    import TrackBack   
30   
31    content_types, constructors, ftis = process_types(
32        listTypes(PROJECTNAME),
33        PROJECTNAME)
34   
35   
36    blogIndex = getTypeIndex(content_types, 'Blog')
37    entryIndex=getTypeIndex(content_types, 'BlogEntry')
38    folderIndex = getTypeIndex(content_types, 'BlogFolder')   
39    trackbackIndex = getTypeIndex(content_types, 'TrackBack')   
40
41    blog_contstructor = []
42    blog_contstructor.append(constructors[blogIndex])
43    entry_contstructor = []
44    entry_contstructor.append(constructors[entryIndex])
45    entry_contstructor.append(constructors[folderIndex])
46    entry_contstructor.append(constructors[trackbackIndex])
47
48    blog_type = []
49    blog_type.append(content_types[blogIndex])
50    entry_type = []
51    entry_type.append(content_types[entryIndex])
52    entry_type.append(content_types[folderIndex])
53    entry_type.append(content_types[trackbackIndex])
54   
55   
56    utils.ContentInit(
57        PROJECTNAME + ' Content',
58        content_types      = tuple(blog_type),
59        permission         = ADD_SIMPLEBLOG_PERMISSION,
60        extra_constructors = tuple(blog_contstructor),
61        fti                = ftis,
62        ).initialize(context)
63   
64    utils.ContentInit(
65        PROJECTNAME + ' Content',
66        content_types      = tuple(entry_type),
67        permission         = ADD_BLOGENTRY_PERMISSION,
68        extra_constructors = tuple(entry_contstructor),
69        fti                = ftis,
70        ).initialize(context)
71   
72       
73    from SimpleBlogTool import SimpleBlogManager
74    utils.ToolInit(
75        'SimpleBlog manager', 
76        tools=(SimpleBlogTool.SimpleBlogManager,), 
77        product_name='SimpleBlog', 
78        icon='tool.gif', ).initialize(context)
79   
80def getTypeIndex(content_types, meta_type):
81    for i in range(len(content_types)):
82        if content_types[i].meta_type==meta_type:
83            return i
84           
85   
86   
87   
88   
89   
Note: See TracBrowser for help on using the repository browser.