source: products/quintagroup.ploneformgen.readonlystringfield/trunk/quintagroup/ploneformgen/readonlystringfield/widget.py @ 322

Last change on this file since 322 was 322, checked in by piv, 18 years ago

initial import

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1from zope.component import getMultiAdapter
2
3from AccessControl import ClassSecurityInfo
4
5from Products.CMFCore.permissions import View
6
7from Products.Archetypes.Widget import StringWidget
8from Products.Archetypes.Registry import registerWidget
9
10
11class ReadonlyStringWidget(StringWidget):
12    _properties = StringWidget._properties.copy()
13    _properties.update({
14        'macro' : "readonlystring",
15        })
16
17    security = ClassSecurityInfo()
18   
19    security.declareProtected(View, 'readonly')
20    def readonly(self, context, request):
21        portal_state = getMultiAdapter((context, request), name="plone_portal_state")
22        if portal_state.anonymous():
23            return None
24        else:
25            return '1'
26
27registerWidget(ReadonlyStringWidget,
28               title='ReadonlyString',
29               description=('Renders a HTML readonly text input box which '
30                            'accepts a single line of text'),
31               used_for=('Products.Archetypes.Field.StringField',)
32               )
Note: See TracBrowser for help on using the repository browser.