[gen] When duplicating a file via appy.fields.file::FileInfo.replicateFile, the source file can be binary data in a str instead of an opened file handler.
This commit is contained in:
parent
ae69509354
commit
a671094167
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
import time, os.path, mimetypes, shutil
|
import time, os.path, mimetypes, shutil
|
||||||
|
from cStringIO import StringIO
|
||||||
from appy import Object
|
from appy import Object
|
||||||
from appy.fields import Field
|
from appy.fields import Field
|
||||||
from appy.px import Px
|
from appy.px import Px
|
||||||
|
@ -123,8 +124,10 @@ class FileInfo:
|
||||||
|
|
||||||
def replicateFile(self, src, dest):
|
def replicateFile(self, src, dest):
|
||||||
'''p_src and p_dest are open file handlers. This method copies content
|
'''p_src and p_dest are open file handlers. This method copies content
|
||||||
of p_src to p_dest and returns the file size.'''
|
of p_src to p_dest and returns the file size. Note that p_src can
|
||||||
|
also be binary data in a string.'''
|
||||||
size = 0
|
size = 0
|
||||||
|
if isinstance(src, str): src = StringIO(src)
|
||||||
while True:
|
while True:
|
||||||
chunk = src.read(self.BYTES)
|
chunk = src.read(self.BYTES)
|
||||||
if not chunk: break
|
if not chunk: break
|
||||||
|
|
|
@ -1203,6 +1203,7 @@ class ToolMixin(BaseMixin):
|
||||||
user = tool.user
|
user = tool.user
|
||||||
else:
|
else:
|
||||||
user = tool.search1('User', noSecurity=True, login=login)
|
user = tool.search1('User', noSecurity=True, login=login)
|
||||||
|
if not user: return login
|
||||||
return user.getTitle(normalized=normalized)
|
return user.getTitle(normalized=normalized)
|
||||||
|
|
||||||
def tempFile(self):
|
def tempFile(self):
|
||||||
|
|
|
@ -249,6 +249,7 @@ class XmlParser(ContentHandler, ErrorHandler):
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
self._xml = xml
|
||||||
self.parser.setContentHandler(self)
|
self.parser.setContentHandler(self)
|
||||||
self.parser.setErrorHandler(self)
|
self.parser.setErrorHandler(self)
|
||||||
self.parser.setFeature(feature_external_ges, False)
|
self.parser.setFeature(feature_external_ges, False)
|
||||||
|
|
Loading…
Reference in a new issue