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

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

Field "exportFields" is redundant and was removed from schema.

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