1 | from Globals import package_home |
---|
2 | from Products.Archetypes.public import process_types, listTypes |
---|
3 | from Products.CMFCore import utils |
---|
4 | from Products.CMFCore.DirectoryView import registerDirectory |
---|
5 | import os, os.path |
---|
6 | |
---|
7 | from config import SKINS_DIR, GLOBALS, PROJECTNAME |
---|
8 | from config import ADD_BLOGENTRY_PERMISSION,ADD_SIMPLEBLOG_PERMISSION |
---|
9 | |
---|
10 | from Globals import InitializeClass |
---|
11 | |
---|
12 | |
---|
13 | registerDirectory(SKINS_DIR, GLOBALS) |
---|
14 | |
---|
15 | def 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 | |
---|
79 | def 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 | |
---|