[gen] Added attribute 'xml' on every field allowing to customize the XML marshalling process. [gen] Added new layout 'xml', now different from the 'view' layout, allowing to define which fields are to be dumped in the XML version of some object. [gen] Security fix in ToolMixin::getUser. [gen] Bugfix in Mixin::getUrl. [shared] dav.py: method 'get' can now accept parameters. [shared] xml_parser: changes to the XmlMarshaller (due to XML-related changes).
This commit is contained in:
parent
f055ec1754
commit
c53654a1a1
19 changed files with 119 additions and 80 deletions
|
@ -141,7 +141,7 @@ class Field:
|
|||
layouts, move, indexed, searchable, specificReadPermission,
|
||||
specificWritePermission, width, height, maxChars, colspan,
|
||||
master, masterValue, focus, historized, mapping, label,
|
||||
sdefault, scolspan, swidth, sheight, persist):
|
||||
sdefault, scolspan, swidth, sheight, persist, xml):
|
||||
# The validator restricts which values may be defined. It can be an
|
||||
# interval (1,None), a list of string values ['choice1', 'choice2'],
|
||||
# a regular expression, a custom function, a Selection instance, etc.
|
||||
|
@ -250,6 +250,13 @@ class Field:
|
|||
# For some fields it is not wanted (ie, fields used only as masters to
|
||||
# update slave's selectable values).
|
||||
self.persist = persist
|
||||
# Standard marshallers are provided for converting values of this field
|
||||
# into XML. If you want to customize the marshalling process, you can
|
||||
# define a method in "xml" that will accept a field value and will
|
||||
# return a possibly different value. Be careful: do not return a chunk
|
||||
# of XML here! Simply return an alternate value, that will be
|
||||
# XML-marshalled.
|
||||
self.xml = xml
|
||||
|
||||
def init(self, name, klass, appName):
|
||||
'''When the application server starts, this secondary constructor is
|
||||
|
@ -351,7 +358,7 @@ class Field:
|
|||
for r in res:
|
||||
if r == layoutType: return True
|
||||
return
|
||||
elif res in ('view', 'edit', 'result', 'buttons'):
|
||||
elif res in ('view', 'edit', 'result', 'buttons', 'xml'):
|
||||
return res == layoutType
|
||||
# For showing a field on layout "buttons", the "buttons" layout must
|
||||
# explicitly be returned by the show method.
|
||||
|
@ -570,6 +577,12 @@ class Field:
|
|||
method in string.py).'''
|
||||
return self.getFormattedValue(obj, value, showChanges)
|
||||
|
||||
def getXmlValue(self, obj, value):
|
||||
'''This method allows a developer to customize the value that will be
|
||||
marshalled into XML. It makes use of attribute "xml".'''
|
||||
if not self.xml: return value
|
||||
return self.xml(obj, value)
|
||||
|
||||
def getIndexType(self):
|
||||
'''Returns the name of the technical, Zope-level index type for this
|
||||
field.'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue