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