Re: [Zope] Reading lines from a Zope File object

2005-07-12 Thread Chris Withers

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

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Reading lines from a Zope File object

2005-06-23 Thread John Poltorak

What function is used to read lines from a Zope File object using Python? 
Is there any example of this anywhere?

Doing a search for 'python read zope object' is just too generic to find 
any python code to do this.


-- 
John



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Reading lines from a Zope File object

2005-06-23 Thread J Cameron Cooper

John Poltorak wrote:
What function is used to read lines from a Zope File object using Python? 
Is there any example of this anywhere?


Doing a search for 'python read zope object' is just too generic to find 
any python code to do this.


You can get the main contents of a File with the 'data' attribute. It 
returns a string.


You can ask a string 'splitlines' among other methods:

http://python.org/doc/lib/string-methods.html

You may also be interested in 'split'.

--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Reading lines from a Zope File object

2005-06-23 Thread J Cameron Cooper

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
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )