Re: [Zope] Reading lines from a Zope File object
Andy McKay wrote:
J Cameron Cooper wrote:
You can get the main contents of a File with the 'data' attribute. It returns a string.
I think it actually returns an object (for large file support), if you want the data as a string you need to string it.
So for small files:
datastr = str(context.fileObject.data)
Should work.
Yes, forgot that caveat. For large files, 'data' can return a "Pdata", a list of strings. For small files, it returns a string. Always doing 'str' is a good idea. --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com/ Enfold Systems, LLC http://www.enfoldsystems.com
J Cameron Cooper wrote:
Yes, forgot that caveat. For large files, 'data' can return a "Pdata", a list of strings. For small files, it returns a string. Always doing 'str' is a good idea.
Well, there's a reason for PData ;-) str'ing a large file will use lots of memory... str'ing lots of large files in one transaction will topple your machine! Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (2)
-
Chris Withers -
J Cameron Cooper