2009-06-29 07:06:01 -05:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
import appy
|
|
|
|
import os.path
|
|
|
|
|
2009-08-17 10:06:17 -05:00
|
|
|
# ------------------------------------------------------------------------------
|
2009-06-29 07:06:01 -05:00
|
|
|
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'}
|
2009-08-17 10:06:17 -05:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
class UnmarshalledObject:
|
|
|
|
'''Used for producing objects from a marshalled Python object (in some files
|
|
|
|
like a CSV file or an XML file).'''
|
2009-11-11 13:22:13 -06:00
|
|
|
def __init__(self, **fields):
|
|
|
|
for k, v in fields.iteritems():
|
|
|
|
setattr(self, k, v)
|
2009-08-17 10:06:17 -05:00
|
|
|
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')
|
|
|
|
|
2009-08-28 08:14:26 -05:00
|
|
|
class UnmarshalledFile:
|
|
|
|
'''Used for producing file objects from a marshalled Python object.'''
|
|
|
|
def __init__(self):
|
|
|
|
self.name = '' # The name of the file on disk
|
|
|
|
self.mimeType = None # The MIME type of the file
|
|
|
|
self.content = '' # The binary content of the file of a file object
|
|
|
|
self.size = 0 # The length of the file in bytes.
|
|
|
|
|
2009-08-17 10:06:17 -05:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
class Dummy: pass
|
2009-06-29 07:06:01 -05:00
|
|
|
# ------------------------------------------------------------------------------
|