1 | from zope.interface import alsoProvides, noLongerProvides |
---|
2 | |
---|
3 | from quills.app.utilities import recurseToInterface |
---|
4 | from quills.core.interfaces import IWeblogEnhanced |
---|
5 | from quills.core.interfaces.enabled import IPossibleWeblogEntry |
---|
6 | |
---|
7 | from Products.CMFCore.utils import getToolByName |
---|
8 | |
---|
9 | from quintagroup.quills.extras.browser.interfaces import IWeblogCategory |
---|
10 | from zope.component import getSiteManager |
---|
11 | |
---|
12 | def set_layout(sc_info): |
---|
13 | #portal = sc_info.getPortal() |
---|
14 | obj = sc_info.object |
---|
15 | weblog = recurseToInterface(obj, IWeblogEnhanced) |
---|
16 | if weblog: |
---|
17 | updateBlogPost(obj) |
---|
18 | |
---|
19 | def updateBlogPost(obj): |
---|
20 | # set default layout |
---|
21 | obj.setLayout('weblogentry_view') |
---|
22 | # add providing of IPossibleWeblogEntry interface |
---|
23 | if not IPossibleWeblogEntry.providedBy(obj): |
---|
24 | alsoProvides(obj, IPossibleWeblogEntry) |
---|
25 | # allow discussion for object |
---|
26 | dt = getToolByName(obj,'portal_discussion') |
---|
27 | dt.overrideDiscussionFor(obj, 1) |
---|
28 | |
---|
29 | def processBlog(self, path, blogentry_types=["Document",]): |
---|
30 | catalog = getToolByName(self,'portal_catalog') |
---|
31 | brains = catalog(path=path, portal_type=blogentry_types) |
---|
32 | for b in brains: |
---|
33 | obj = b.getObject() |
---|
34 | updateBlogPost(obj) |
---|
35 | print b.getURL(), 'updated' |
---|
36 | #raise Exception("some error") |
---|
37 | |
---|
38 | |
---|
39 | def processBlogSubFolders(self): |
---|
40 | # update blog sub-folders |
---|
41 | res = [] |
---|
42 | brains = self.portal_catalog(path='/'.join(self.getPhysicalPath()), |
---|
43 | portal_type=['Large Plone Folder','Folder']) |
---|
44 | context_path = '/'.join(self.getPhysicalPath()) |
---|
45 | brains = filter(lambda b:not b.getPath()==context_path, brains) |
---|
46 | for bf in brains: |
---|
47 | item_res = [bf.getPath(),0,0] |
---|
48 | ob = bf.getObject() |
---|
49 | if ob.hasProperty('layout'): |
---|
50 | ob.manage_delProperties(['layout',]) |
---|
51 | ob.manage_addProperty('layout','weblogfolder_view','string') |
---|
52 | if IWeblogEnhanced.providedBy(ob): |
---|
53 | noLongerProvides(ob,IWeblogEnhanced) |
---|
54 | item_res[1] = 1 |
---|
55 | if not IWeblogCategory.providedBy(ob): |
---|
56 | alsoProvides(ob,IWeblogCategory) |
---|
57 | item_res[2] = 1 |
---|
58 | res.append(item_res) |
---|
59 | return res |
---|