source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/newsextender.py @ 2404

Last change on this file since 2404 was 2402, checked in by mylan, 14 years ago

#131: Added NewsExtender? SchemaExtender? adapter

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1from zope.component import adapts
2from zope.interface import implements
3from archetypes.schemaextender.field import ExtensionField
4from archetypes.schemaextender.interfaces import ISchemaExtender
5
6from Products.Archetypes.public import SelectionWidget
7from Products.Archetypes.public import MultiSelectionWidget
8from Products.Archetypes.public import LinesField
9from Products.Archetypes.public import StringField
10from Products.Archetypes.public import DisplayList
11
12class ExtendableStringField(ExtensionField, StringField):
13    """An extendable string field."""
14
15class ExtendableLinesField(ExtensionField, LinesField):
16    """An extendable string field."""
17
18access_lst = ("", "Subscription", "Registration")
19genres_lst = ("", "PressRelease","Satire","Blog","OpEd","Opinion","UserGenerated")
20
21class NewsExtender(object):
22    implements(ISchemaExtender)
23
24    fields = [
25        ExtendableStringField("gsm_access",
26            accessor="gsm_access",
27            vocabulary=DisplayList(zip(access_lst, access_lst)),
28            schemata="GoogleSitemap",
29            widget = SelectionWidget(
30                label="Access",
31                description="Specifies whether an article is available to all " \
32                    "readers (in case of the emtpy field, or only to those " \
33                    "with a free or paid membership to your site.",
34                format="radio"),
35        ),
36        ExtendableStringField("gsm_genres",
37            accessor="gsm_genres",
38            vocabulary=DisplayList(zip(genres_lst, genres_lst)),
39            schemata="GoogleSitemap",
40            widget = MultiSelectionWidget(
41                label="Genres",
42                description="Select one or more properties for an article, " \
43                    "namely, whether it is a press release, a blog post, an " \
44                    "opinion, an op-ed piece, user-generated content, or satire.",
45                format="checkbox"),
46        ),
47    ]
48
49    def __init__(self, context):
50        self.context = context
51
52    def getFields(self):
53        return self.fields
Note: See TracBrowser for help on using the repository browser.