[Zope] Problem working around string.split issue

Casey Duncan casey_duncan@yahoo.com
Mon, 31 Dec 2001 13:53:25 -0800 (PST)


The problem is likely due to the fact that myFile.data
is not a string for large files, so you can't split
it. It is actually a PData object which segments the
data into chunks for better memory handling.

If you use the str() function on the file though, that
should give you what you want:

theData = str(myFile)

hth,
-Casey

--- complaw@hal-pc.org wrote:
> I have a python script that works just fine in Zope
> for SMALL input files
> (between 1-100 cases).  However, Zope returns an
> error when the input file gets
> large (100+ cases, depending on the situation).  In
> the error message, Zope
> points to a line where I take the input file and
> split it to create a list of
> lines.  Note, the same script (with split) works
> just fine when I run the script
> in regular python (i.e., outside of Zope).
> 
> To get around this, I would normally just read the
> file one line at a time,
> however, we don't have access to the sys module in
> Zope.  I have loaded the
> input file into a File Object in Zope, and can
> access it via...
> 
> theData = context.myFile.data
> 
> The problem that I have is that when you do a split
> on theData, Zope returns the
> split error (IF myFile is large enough).
> 
> The question I have is, how can I read small chunks
> of content from the File
> Object?  This is akin to reading a text file one
> line at a time.  
> 
> Any hints?
> 
> Ron
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
> 
> http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com