Improvements in the XML marshaller.

This commit is contained in:
Gaetan Delannay 2010-03-31 15:49:54 +02:00
parent 3f08cb989f
commit 9cff9df299
5 changed files with 85 additions and 45 deletions

View file

@ -340,16 +340,19 @@ class AbstractWrapper:
def export(self, at='string'):
'''Creates an "exportable", XML version of this object. If p_at is
"string", this method returns the XML version. Else, (a) if not p_at,
the XML will be exported on disk, in the OS temp folder, with an
ugly name; (b) else, it will be exported at path p_at.'''
"string", this method returns the XML version, without the XML
prologue. Else, (a) if not p_at, the XML will be exported on disk,
in the OS temp folder, with an ugly name; (b) else, it will be
exported at path p_at.'''
# Determine where to put the result
toDisk = (at != 'string')
if toDisk and not at:
at = getOsTempFolder() + '/' + self.o.UID() + '.xml'
# Create the XML version of the object
xml = XmlMarshaller(cdata=True, dumpUnicode=True).marshall(
self.o, objectType='appy')
marshaller = XmlMarshaller(cdata=True, dumpUnicode=True,
dumpXmlPrologue=toDisk,
rootTag=self.klass.__name__)
xml = marshaller.marshall(self.o, objectType='appy')
# Produce the desired result
if toDisk:
f = file(at, 'w')

View file

@ -229,4 +229,21 @@ class Keywords:
op = ' %s ' % self.operator
return op.join(self.keywords)+'*'
return ''
# ------------------------------------------------------------------------------
class FakeBrain:
'''This class behaves like a brain retrieved from a query to a ZCatalog. It
is used for representing a fake brain that was generated from a search in
a distant portal_catalog.'''
Creator = None
created = None
modified = None
review_state = None
def has_key(self, key): return hasattr(self, key)
def getPath(self): return self.path
def getURL(self, relative=0): return self.url
def _unrestrictedGetObject(self): return self
def pretty_title_or_id(self): return self.Title
def getObject(self, REQUEST=None): return self
def getRID(self): return self.url
# ------------------------------------------------------------------------------