source: products/qPloneGoogleSitemaps/branches/contenttype/content/sitemap.py @ 389

Last change on this file since 389 was 389, checked in by crchemist, 18 years ago

Fixup error in _initializeTopicTool.

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1"""Definition of the Sitemap content type
2"""
3
4from zope.interface import implements, directlyProvides
5
6from Products.Archetypes import atapi
7from Products.ATContentTypes.content import base
8from Products.ATContentTypes.content import schemata
9from Products.CMFCore.utils import getToolByName
10
11from Products.qPloneGoogleSitemaps import qPloneGoogleSitemapsMessageFactory as _
12from Products.qPloneGoogleSitemaps.interfaces import ISitemap
13from Products.qPloneGoogleSitemaps.config import PROJECTNAME
14
15SitemapSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
16
17    # -*- Your Archetypes field definitions here ... -*-
18    atapi.LinesField(
19        name='portalTypes',
20        storage = atapi.AnnotationStorage(),
21        required=False,
22        default=['Document',],
23        vocabulary="availablePortalTypes",
24        #schemata ='default',
25        widget=atapi.MultiSelectionWidget(
26            label=_(u"Define the types"),
27            description=_(u"Define the types to be included in sitemap."),
28        ),
29    ),
30    atapi.LinesField(
31        name='states',
32        storage = atapi.AnnotationStorage(),
33        required=False,
34        default=['published',],
35        vocabulary="getWorkflowStates",
36        #schemata ='default',
37        widget=atapi.MultiSelectionWidget(
38            label=_(u"Review status"),
39            description=_(u"You may include items in sitemap depend of their " \
40                          u"review state."),
41        ),
42    ),
43    atapi.LinesField(
44        name='blackout_list',
45        storage = atapi.AnnotationStorage(),
46        required=False,
47        #default='',
48        #schemata ='default',
49        widget=atapi.LinesWidget(
50            label=_(u"Blackout entries"),
51            description=_(u"The objects with the given ids will not be " \
52                          u"included in sitemap."),
53        ),
54    ),
55    atapi.LinesField(
56        name='reg_exp',
57        storage = atapi.AnnotationStorage(),
58        required=False,
59        #default='',
60        #schemata ='default',
61        widget=atapi.LinesWidget(
62            label=_(u"URL processing Regular Expressions"),
63            description=_(u"Provide regular expressions (in Perl syntax), " \
64                          u"one per line to be applied to URLs before " \
65                          u"including them into Sitemap. For instance, " \
66                          u"\"s/\/index_html//\" will remove /index_html " \
67                          u"from URLs representing default documents."),
68        ),
69    ),
70    atapi.LinesField(
71        name='urls',
72        storage = atapi.AnnotationStorage(),
73        required=False,
74        #default='',
75        #schemata ='default',
76        widget=atapi.LinesWidget(
77            label=_(u"Additional URLs"),
78            description=_(u"Define additional URLs that are not objects and " \
79                          u"that should be included in sitemap."),
80        ),
81    ),
82    atapi.StringField(
83        name='verificationFilename',
84        storage = atapi.AnnotationStorage(),
85        required=False,
86        #default='',
87        #schemata ='default',
88        widget=atapi.StringWidget(
89            label=_(u"Provide verification file name"),
90            description=_(u"Default verification file name for this sitemaps"),
91        ),
92    ),
93
94))
95
96# Set storage on fields copied from ATContentTypeSchema, making sure
97# they work well with the python bridge properties.
98
99SitemapSchema['title'].storage = atapi.AnnotationStorage()
100SitemapSchema['description'].storage = atapi.AnnotationStorage()
101
102schemata.finalizeATCTSchema(SitemapSchema, moveDiscussion=False)
103SitemapSchema['relatedItems'].schemata='metadata'
104SitemapSchema['relatedItems'].widget.visible = {'edit':'invisible', 'view':'invisible'}
105
106
107class Sitemap(base.ATCTContent):
108    """Search engine Sitemap content type"""
109    implements(ISitemap)
110
111    portal_type = "Sitemap"
112    schema = SitemapSchema
113
114    #title = atapi.ATFieldProperty('title')
115    #description = atapi.ATFieldProperty('description')
116    def availablePortalTypes(self):
117        pt = getToolByName(self, 'portal_types')
118        types = pt.listContentTypes()
119        return atapi.DisplayList(zip(types,types))
120
121    def getWorkflowStates(self):
122        pw = getToolByName(self,'portal_workflow')
123        states = list(set([v for k,v in pw.listWFStatesByTitle()]))
124        states.sort()
125        return atapi.DisplayList(zip(states, states))
126
127
128atapi.registerType(Sitemap, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.