Implemented blueprint https://blueprints.launchpad.net/appy/+spec/shared-xml-marshall-and-unmarshaller
This commit is contained in:
parent
bdb220716c
commit
2d82dc4e0b
5 changed files with 491 additions and 190 deletions
|
@ -2,9 +2,30 @@
|
|||
import appy
|
||||
import os.path
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
appyPath = os.path.realpath(os.path.dirname(appy.__file__))
|
||||
mimeTypes = {'odt': 'application/vnd.oasis.opendocument.text',
|
||||
'doc': 'application/msword',
|
||||
'rtf': 'text/rtf',
|
||||
'pdf': 'application/pdf'}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
class UnmarshalledObject:
|
||||
'''Used for producing objects from a marshalled Python object (in some files
|
||||
like a CSV file or an XML file).'''
|
||||
def __repr__(self):
|
||||
res = u'<PythonObject '
|
||||
for attrName, attrValue in self.__dict__.iteritems():
|
||||
v = attrValue
|
||||
if hasattr(v, '__repr__'):
|
||||
v = v.__repr__()
|
||||
try:
|
||||
res += u'%s = %s ' % (attrName, v)
|
||||
except UnicodeDecodeError:
|
||||
res += u'%s = <encoding problem> ' % attrName
|
||||
res = res.strip() + '>'
|
||||
return res.encode('utf-8')
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
class Dummy: pass
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue