[Zope3-checkins] SVN: Zope3/trunk/ Fix bug in
PropertySheetDefinitionPermissionEditView. Use "Permission
Ids" vocabulary for to render the DropDownWidget and use a
hook over the permission id for to render the SELECT'ed
permission. Are there other permission drop down widgets in
use somewhere?
Roger Ineichen
roger at projekt01.ch
Sat May 29 08:39:08 EDT 2004
Log message for revision 25124:
Fix bug in PropertySheetDefinitionPermissionEditView. Use "Permission Ids" vocabulary for to render the DropDownWidget and use a hook over the permission id for to render the SELECT'ed permission. Are there other permission drop down widgets in use somewhere?
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2004-05-29 12:21:19 UTC (rev 25123)
+++ Zope3/trunk/doc/CHANGES.txt 2004-05-29 12:39:08 UTC (rev 25124)
@@ -18,6 +18,9 @@
- Fixed so that a UnicodeDecodeError isn't produced when Internet
Explorer requests a page containing non-ISO-8859-1 characters.
+ - Fixed the TextWidget and TextAreaWidget, added convertion
+ from string to unicode in the method _toFieldValue.
+
Restructuring
- The event system was completely reimplemented:
@@ -65,7 +68,7 @@
Jim Fulton, Marius Gedminas, Fred Drake, Philipp von Weitershausen,
Stephan Richter, Dmitry Vasiliev, Scott Pascoe, Bjorn Tillenius,
- Eckart Hertzler
+ Eckart Hertzler, Roger Ineichen
Note: If you are not listed and contributed, please add yourself. This
note will be deleted before the release.
Modified: Zope3/trunk/doc/CREDITS.txt
===================================================================
--- Zope3/trunk/doc/CREDITS.txt 2004-05-29 12:21:19 UTC (rev 25123)
+++ Zope3/trunk/doc/CREDITS.txt 2004-05-29 12:39:08 UTC (rev 25124)
@@ -555,6 +555,8 @@
Made improvements to and helped create documentation for the on-line
help system.
+
+ Bug fixes on widget and views.
- Benjamin Saller
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py 2004-05-29 12:21:19 UTC (rev 25123)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py 2004-05-29 12:39:08 UTC (rev 25124)
@@ -17,6 +17,7 @@
"""
__metaclass__ = type
+from zope.app import zapi
from zope.proxy import removeAllProxies
from zope.app.publisher.browser import BrowserView
from zope.app.container.browser.adding import Adding
@@ -26,6 +27,7 @@
from zope.app.workflow.stateful.definition import State, Transition
from zope.schema import getFields, Choice
+from zope.app.security.interfaces import IPermission
from zope.security.checker import CheckerPublic
from zope.security.proxy import trustedRemoveSecurityProxy
from zope.app.form.utility import setUpWidget
@@ -70,31 +72,39 @@
schema = self.context.relevantDataSchema
if schema is not None:
for name, field in getFields(schema).items():
- # Try to get current settings
+
if self.context.schemaPermissions.has_key(name):
get_perm, set_perm = self.context.schemaPermissions[name]
+ try:
+ get_perm_id = get_perm.id
+ except:
+ get_perm_id = None
+ try:
+ set_perm_id = set_perm.id
+ except:
+ set_perm_id = None
else:
- get_perm, set_perm = None, None
+ get_perm_id, set_perm_id = None, None
# Create the Accessor Permission Widget for this field
permField = Choice(
__name__=name+'_get_perm',
title=u"Accessor Permission",
- vocabulary="Permissions",
+ vocabulary="Permission Ids",
default=CheckerPublic,
required=False)
setUpWidget(self, name + '_get_perm', permField, IInputWidget,
- value=get_perm)
+ value=get_perm_id)
# Create the Mutator Permission Widget for this field
permField = Choice(
__name__=name+'_set_perm',
title=u"Mutator Permission",
default=CheckerPublic,
- vocabulary="Permissions",
+ vocabulary="Permission Ids",
required=False)
setUpWidget(self, name+'_set_perm', permField, IInputWidget,
- value=set_perm)
+ value=set_perm_id)
def update(self):
status = ''
@@ -106,11 +116,27 @@
schema = self.context.relevantDataSchema
perms = trustedRemoveSecurityProxy(self.context.schemaPermissions)
for name, field in getFields(schema).items():
- getPerm = getattr(
- self, name+'_get_perm_widget').getInputValue()
- setPerm = getattr(
- self, name+'_set_perm_widget').getInputValue()
- perms[name] = (getPerm, setPerm)
+
+ getPermWidget = getattr(self, name+'_get_perm_widget')
+ setPermWidget = getattr(self, name+'_set_perm_widget')
+
+ # get the selected permission id from the from request
+ get_perm_id = getPermWidget.getInputValue()
+ set_perm_id = setPermWidget.getInputValue()
+
+ # get the right permission from the given id
+ get_perm = zapi.getUtility(IPermission, get_perm_id)
+ set_perm = zapi.getUtility(IPermission, set_perm_id)
+
+ # set the permission back to the instance
+ perms[name] = (get_perm, set_perm)
+
+ # update widget ohterwise we see the old value
+ getPermWidget.setRenderedValue(get_perm_id)
+ setPermWidget.setRenderedValue(set_perm_id)
+
+
+
status = 'Fields permissions mapping updated.'
return status
More information about the Zope3-Checkins
mailing list