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 | import xmlrpcMonkeyPatch |
---|
13 | |
---|
14 | registerDirectory(SKINS_DIR, GLOBALS) |
---|
15 | |
---|
16 | def initialize(context): |
---|
17 | |
---|
18 | ## Allow module utils |
---|
19 | from AccessControl import ModuleSecurityInfo, allow_module |
---|
20 | ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('addTrackBack') |
---|
21 | ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('encodeURLData') |
---|
22 | |
---|
23 | #allow_module('Products.SimpleBlog.Extensions.utils') |
---|
24 | |
---|
25 | |
---|
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') |
---|
41 | |
---|
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]) |
---|
48 | |
---|
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]) |
---|
55 | |
---|
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 | |
---|
73 | |
---|
74 | from SimpleBlogTool import SimpleBlogManager |
---|
75 | utils.ToolInit( |
---|
76 | 'SimpleBlog manager', |
---|
77 | tools=(SimpleBlogTool.SimpleBlogManager,), |
---|
78 | product_name='SimpleBlog', |
---|
79 | icon='tool.gif', ).initialize(context) |
---|
80 | |
---|
81 | def 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 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|