[1] | 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 | |
---|
| 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 | |
---|
| 80 | def 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 | |
---|