[Zope] How to read a file object

2005-06-01 Thread John Poltorak


How do I go about reading a Zope file object in Python?

I'd appreciate it if anyone could point me to a repository of small code 
snippets which illustrate some simple techniques usable in Python scripts 
running under Zope.


-- 
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] How to read a file object

2005-06-01 Thread Andreas Jung



--On 1. Juni 2005 10:01:22 +0100 John Poltorak [EMAIL PROTECTED] wrote:




How do I go about reading a Zope file object in Python?


Define what reading a Zope File object means? You mean you want the
body of an upload file?

-aj


pgpmNUJZSSkaB.pgp
Description: PGP signature
___
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] How to read a file object

2005-06-01 Thread John Poltorak
On Wed, Jun 01, 2005 at 12:46:44PM +0200, Andreas Jung wrote:
 
 
 --On 1. Juni 2005 10:01:22 +0100 John Poltorak [EMAIL PROTECTED] wrote:
 
 
 
  How do I go about reading a Zope file object in Python?
 
 Define what reading a Zope File object means? You mean you want the
 body of an upload file?
 
 -aj


I mean the thing that is created when I click on 'File' from the drop down 
menu of ZMI.


I'm trying to learn some Python basics and hoping to use Zope as front end 
for writing and running a few snippets of code which may help me get a 
better understanding of how Zope and Python interact.


-- 
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] How to read a file object

2005-06-01 Thread Andreas Jung



--On 1. Juni 2005 12:03:39 +0100 John Poltorak [EMAIL PROTECTED] wrote:


On Wed, Jun 01, 2005 at 12:46:44PM +0200, Andreas Jung wrote:



--On 1. Juni 2005 10:01:22 +0100 John Poltorak [EMAIL PROTECTED] wrote:



 How do I go about reading a Zope file object in Python?

Define what reading a Zope File object means? You mean you want the
body of an upload file?

-aj



I mean the thing that is created when I click on 'File' from the drop
down  menu of ZMI.




When you upload a file through HTTP upload then you can access the body
as context.REQUEST['yourfile'].read(). Means the uploaded file is 
temporarily stored as file like object...I am pretty sure this is explained 
in the Zope Book *wink*.


-aj



pgpxsL4rjI46I.pgp
Description: PGP signature
___
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] How to read a file object

2005-06-01 Thread Vital Lobachevsky

John Poltorak wrote:

On Wed, Jun 01, 2005 at 12:46:44PM +0200, Andreas Jung wrote:



--On 1. Juni 2005 10:01:22 +0100 John Poltorak [EMAIL PROTECTED] wrote:




How do I go about reading a Zope file object in Python?


Define what reading a Zope File object means? You mean you want the
body of an upload file?

-aj




I mean the thing that is created when I click on 'File' from the drop down 
menu of ZMI.


Suppose your file 'myFile' and your script 'myScript' in the same 
folder. You can get file data in your script using 'data' property:


fileData = container.myFile.data
...
___
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] How to read a file object

2005-06-01 Thread Andreas Jung



--On 1. Juni 2005 15:02:16 +0300 Vital Lobachevsky [EMAIL PROTECTED] wrote:


Suppose your file 'myFile' and your script 'myScript' in the same folder.
You can get file data in your script using 'data' property:

fileData = container.myFile.data


You should *not* do that. You are using an implementation detail that is
unlikely thought to be used for public use. You should use 
str(container.myFile) instead.


-aj


pgpOFXqUlzKEq.pgp
Description: PGP signature
___
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] How to read a file object

2005-06-01 Thread Tino Wildenhain
Am Mittwoch, den 01.06.2005, 15:02 +0300 schrieb Vital Lobachevsky:
 John Poltorak wrote:
  On Wed, Jun 01, 2005 at 12:46:44PM +0200, Andreas Jung wrote:
  
 
 --On 1. Juni 2005 10:01:22 +0100 John Poltorak [EMAIL PROTECTED] wrote:
 
 
 
 How do I go about reading a Zope file object in Python?
 
 Define what reading a Zope File object means? You mean you want the
 body of an upload file?
 
 -aj
  
  
  
  I mean the thing that is created when I click on 'File' from the drop down 
  menu of ZMI.
 
 Suppose your file 'myFile' and your script 'myScript' in the same 
 folder. You can get file data in your script using 'data' property:
 
 fileData = container.myFile.data
 ...

beside the fact its a not really public attribute, it isnt
even garantied to be s simple string. Most of the time
its a Pdata object chain.

And yes, file/image really lack file semantics.
-- 
Tino Wildenhain [EMAIL PROTECTED]

___
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] How to read a file object

2005-06-01 Thread Paul Winkler
On Wed, Jun 01, 2005 at 10:01:22AM +0100, John Poltorak wrote:
 I'd appreciate it if anyone could point me to a repository of small code 
 snippets which illustrate some simple techniques usable in Python scripts 
 running under Zope.

http://zopelabs.com/
Note there is a Python(Script) category with over 100 recipes:
http://zopelabs.com/cookbook/byCategory?category=Python%28Script%29

-- 

Paul Winkler
http://www.slinkp.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] How to read a file object

2005-06-01 Thread Lennart Regebro
On 6/1/05, John Poltorak [EMAIL PROTECTED] wrote:
 I'm trying to learn some Python basics and hoping to use Zope as front end
 for writing and running a few snippets of code

In that case you should use Zope3. Zope2 is highly-unpythonic, and
using it pretty much requires you to learn Zope first, and Python
later. Zope2 should be used if you want to build a site with a content
management tool like CPS or Plone or Silva, or if you otherwise have
some software you wnat to use that runs on Zope2.

But if you want to learn python, or create stuff from scratch, Zope3
is generally a much better option.

 which may help me get a better understanding of how Zope and Python interact.

When it comes to Zope2: Trust me, you don't want to know. :)

-- 
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
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 )