On 26.02.06 03:52:14, Allen Huang wrote:
>   I didn't realize that I mis type the code. The code what suppose to be ..
>    imageDataFile=StringIO(str(dataID.data))

If dataId is a string this won't work.

>  tfw = open(imageDataFile, "r")
>   so, what your saying is that I don't need to open the file that I wanted to 
> read into and extract the data? But how can that be?

You have to forget about files when you're working with ZODB, because
this Database doesn't have any file in it. Those are all objects and
when you do something like

myobj = getattr(self, 'name')

you'll get an object. This object might be an instance of the File class
and thus behave like a file, but it still is only an object. Your
StringIO constructor already get the content of this object, i.e. the
text that is stored in it, because you give it via myobj.data. 

The next thing is, if you already can access the text content via
myobj.data you don't need StringIO.

>   How would you write the external method if you were to read a text file 
> that you store in ZOPE database and extract the infromation line by line?

Suppose dataID contains the id of the object something like this:

obj = getattr(self, dataID)
for line in str(obj.data).split('\n'):

That's all.


You will gain money by an immoral action.
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to