Changeset 319 in products for SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py
- Timestamp:
- Apr 12, 2006 3:24:08 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py
- Property svn:eol-style deleted
r28 r319 3 3 from Products.CMFCore import utils 4 4 from Products.CMFCore.DirectoryView import registerDirectory 5 import os, os.path, sys, content 6 7 from Products.CMFCore.utils import ContentInit 8 from Products.CMFCore.utils import ToolInit 5 import os, os.path 9 6 10 7 from config import SKINS_DIR, GLOBALS, PROJECTNAME 8 from config import ADD_BLOGENTRY_PERMISSION,ADD_SIMPLEBLOG_PERMISSION 11 9 12 10 from Globals import InitializeClass 13 11 12 import xmlrpcMonkeyPatch 13 14 14 registerDirectory(SKINS_DIR, GLOBALS) 15 16 from Products.SimpleBlog.Permissions import wireAddPermissions17 18 # Module aliases - we don't always get it right on the first try, but and we19 # can't move modules around because things are stored in the ZODB with the20 # full module path. However, we can create aliases for backwards compatability.21 22 sys.modules['Products.SimpleBlog.Blog'] = content.blog23 sys.modules['Products.SimpleBlog.BlogEntry'] = content.blogentry24 sys.modules['Products.SimpleBlog.BlogFolder'] = content.blogfolder25 sys.modules['Products.SimpleBlog.TrackBack'] = content.trackback26 15 27 16 def initialize(context): … … 32 21 ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('encodeURLData') 33 22 34 from content import BlogEntry 35 from content import Blog 36 from content import BlogFolder 37 from content import TrackBack 23 #allow_module('Products.SimpleBlog.Extensions.utils') 38 24 39 25 40 listOfTypes = listTypes(PROJECTNAME) 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 41 42 content_types, constructors, ftis = process_types( 43 listOfTypes, 44 PROJECTNAME) 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]) 45 48 46 from Products.SimpleBlog.Permissions import permissions 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]) 47 55 48 allTypes = zip(content_types, constructors) 49 wireAddPermissions() 50 for atype, constructor in allTypes: 51 kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) 52 ContentInit( 53 kind, 54 content_types = (atype,), 55 permission = permissions[atype.portal_type], 56 extra_constructors = (constructor,), 57 fti = ftis, 58 ).initialize(context) 59 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 60 73 61 74 from SimpleBlogTool import SimpleBlogManager … … 66 79 icon='tool.gif', ).initialize(context) 67 80 68 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 69 86 87 88 89 90
Note: See TracChangeset
for help on using the changeset viewer.