[Zope] PIL/Zope Problem

2000-10-27 Thread Marcello Lupo

Hi to all,
i read all the documentation and made all things to let interact PIL and
Zope and i cannot find the way to make it work.
If i try to import PIL from pyton interpreter it works perfectly with:

***
Python 1.5.2 (#1, Jul 17 1999, 22:10:16)  [GCC egcs-2.91.66
19990314/Linux (egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 import PIL
 data=PIL.Image.open("/home/httpd/listanozze/docs/images/prove/ccc.jpg","r")
 print data.format
JPEG
 print data.info
{'adobe_transform': 1, 'progression': 1, 'adobe': 100, 'jfif': 258}
 print data.size
(450, 309)
  
**

as you can see it works.
But when i try to access PIL.Image.open from an external method in Zope
i get:

***


 Error Type: AttributeError
 Error Value: Image



 Troubleshooting Suggestions

  The URL may be incorrect. 
  The parameters passed to this resource may be
incorrect. 
  A resource that this resource relies on may be
encountering an error. 

 For more detailed information about the error, please refer
to the HTML source for this page. 

 If the error persists please contact the site maintainer.
Thank you for your patience. 


Traceback (innermost last):
  File /home/httpd/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py, line
214, in publish_module
  File /home/httpd/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py, line
179, in publish
  File /home/httpd/Zope-2.1.6-src/lib/python/Zope/__init__.py, line 202,
in zpublisher_exception_hook
(Object: ElementWithAttributes)
  File /home/httpd/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py, line
165, in publish
  File /home/httpd/Zope-2.1.6-src/lib/python/ZPublisher/mapply.py, line
160, in mapply
(Object: pippo)
  File /home/httpd/Zope-2.1.6-src/lib/python/ZPublisher/Publish.py, line
102, in call_object
(Object: pippo)
  File /home/httpd/Zope-2.1.6-src/lib/python/OFS/DTMLMethod.py, line
150, in __call__
(Object: pippo)
  File
/home/httpd/Zope-2.1.6-src/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
(Object: pippo)
  File
/home/httpd/Zope-2.1.6-src/lib/python/DocumentTemplate/DT_Util.py, line
335, in eval
(Object: resize_image(foto))
(Info: foto)
  File string, line 0, in ?
  File
/home/httpd/Zope-2.1.6-src/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 255, in __call__
(Object: resize_image)
(Info: ((ZPublisher.HTTPRequest.FileUpload instance at 8565c90,),
{}, None))
  File /home/httpd/Zope-2.1.6-src/Extensions/image_op.py, line 7, in
resize_image
(Object: ElementWithAttributes)
AttributeError: (see above)

*

My external Method say:

import PIL

def resize_image(self, foto):

if foto:
data=PIL.Image.open(foto)
data=data.resize((128, 128))
return data.size
else:
return "Nothing" 

***


Can anyone help me??
Thanks
Bye,
MArcello

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] TEXT FILE Operation

2000-09-12 Thread Marcello Lupo

Hi to all,
anyone know how to let Zope interact with text files on the system on it
is running.
Like making changes to files, search and replare some text or insert or
delete text and save the file again?
I'm pretty new and i don't know if it is possible for Zope.
Thank You in advice.
Marcello

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] TEXT FILE Operation

2000-09-12 Thread Marcello Lupo

Thank you,
infact this is the problem, right now i'm not able to program in python
but only on using zope.
I used the FSSession product before and i think that should be a Similar
product to make changes on files.
thank you for the help.

Marcello


Rik Hoekstra wrote:
 
  anyone know how to let Zope interact with text files on the system on it
  is running.
 
 I take it you mean files external to the ZODB database
 
  Like making changes to files, search and replare some text or insert or
  delete text and save the file again?
  I'm pretty new and i don't know if it is possible for Zope.
 
 You can just about anything you want using external methods (written in
 Python) or Python Products, including reading, writing, deleting and
 changing and using regular expressions. Be aware of security issues,
 though, as you'll effectively be opening up part of your filesystem to
 access through the web
 
 Rik

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Re: FSSession newbie problem

2000-06-12 Thread Marcello Lupo

Hi,
well the system run now but as i told before if i put a dtml-call
FSSession in all my pages, FSSession open one session for page
everytime i load it. So the cart result everytime containing only the
last item and the files created contain the values.
If i put dtml-call FSSession only in the first document of the e-comm
section it works well, but the file created do not contain the values,
seems to remain in MEMORY.

Should I make some kind of call to FSSession UID in the pages to let the
FSSession to recover the right session and not to open a new one?
Becouse the problem seems to be in fact that the FSSession is not able
to recover the correct ID of the file (from cookie).

I made some try and if i use the site passing via Roxen web server
through the PCGI the cookie is all another becouse the browser has a
cookie that was set from another application on the same server so the
browser seems to pass only that cookie and not the SessionUID cookie.
I tried to clean all my cookies and it worked fine if a go directly to
my pages not passing from the pages that generate the other cookie.

If i pass directly from the Zope port to access the resource it is ok...

Have some ideas to let the browser pass the cookie in a right way? 
I think we can work on the PATH but i don't know how.
Thanks for help.
Bye

Hung Jung Lu wrote:
 
 From: Pavlos Christoforou [EMAIL PROTECTED]
 On Fri, 9 Jun 2000, Marcello Lupo wrote:
   1) Is necessary to call FSSession in every document of the site Yes it
 is neccessary beacuse HTTP is stateless. It will only start a new
 session if FSSession cannot find a valid UID either through a cookie or a
 FORM or as part of te URL
 
 Pavlos: this is the part that is confusing to newbies. FSSession can be made
 in such a way that this initial call can be avoided. HappySession works that
 way: no need for explicit initialization. Matter of fact, in the very first
 call to the HappySession (any dictionary method), it does the initialization
 itself behind the scene. FSSession can do the same thing.
 
 It's a minor detail, but anything to make a newbie's life easier is worth
 it. :)
 
 regards,
 
 Hung Jung
 
 
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] Re: FSSession newbie problem

2000-06-09 Thread Marcello Lupo

Well... the statements are not in the same file but in two different
files. 
This are the statements, the dtml-call FSSession is in the
standard_html_header.


Method list_products:

dtml-var standard_html_header
dtml-unless "FSSession.has_key('carrello')"
dtml-call "FSSession.set('carrello',{})"
/dtml-unless

form action="aggiungi_prodotto" name="carrello" method="get"
target="Carrello"
input type="hidden" name="ID" value="dtml-if
"FSSession.has_key('ID')"dtml-call
"FSSession['ID']+1"dtml-else1/dtml-if"
input type="hidden" name="codice_famiglia" value="dtml-var cod_prod"
input type="hidden" name="codice_prodotto" value="dtml-var
cod_ident"
input type="hidden" name="nome_prodotto" value="dtml-var
nome_prod_it"
input type="hidden" name="prezzo" value="dtml-var prez_lire"
input type="hidden" name="quantita_prodotto" value="1"
input type="image" name="acquista" value="acquista"
src="/ecom/images/freccia2.jpg" border="0"
/form
dtml-var standard-html-footer

Method aggiungi_prodotto:

dtml-var standard_html_header
dtml-var "REQUEST.form"br  # CHECK It prints out fine the form
dictionary!!

dtml-in "REQUEST.form.items()"
dtml-var sequence-item
/dtml-in # CHECK It prints out fine the form
variable!!


dtml-call "FSSession['carrello'].update(REQUEST.form)"
br
dtml-var ID
dtml-var codice_famiglia
dtml-var codice_prodotto
dtml-var nome_prodotto
dtml-var prezzo
dtml-var quantita_prodotto    Them works fine!!

br
dtml-var "FSSession('carrello')"br   It prints out "None"
dtml-var standard_html_footer


The FSSession is in the same folder of my two methods, may be this a
problem?
I tried out the code in a single page and it works fine if you limit to
create the variable 'carrello' in the FSSession. I checked the session
file and it contains :
--cut here
(dp1
S'carrello'
p2
(ds.
 cut here--
The problem is when i try to update the variable 'carrello' with
something. 

I tryed the code you gave to me and it works so i think that the problem
is that i initialize the variable in a method and update it in another
one.
Probably the second method point to a different session file than the
first.

Well thank you for help, for now i will make all in one method and of
you have some ideas to solve it it will be appreciated.

Bye.
Marcello

Hung Jung Lu wrote:
 
 --- In [EMAIL PROTECTED], Marcello Lupo [EMAIL PROTECTED] wrote:
 and macically i obtain the same error.
 this is the code i used:
 dtml-call FSSession
 dtml-unless "FSSession.has_key('cart')"
 dtml-call "FSSession.set('cart',{})"
 /dtml-unless
 
 dtml-call "FSSession['carrello'].update(REQUEST.form)"
 
 I have tried your code with 'cart' everywhere, and it worked just fine. Can
 you print out the form variables?  Are all the statements inside the same
 DTML file? It really works fine. Also, make sure that FSSession is in a
 parent folder of your DTML method. (Root folder is usually a good idea.) Is
 your machine cookie-enabled?
 
 
 dtml-var standard_html_header
 dtml-call FSSession
 dtml-unless "FSSession.has_key('cart')"
   dtml-call "FSSession.set('cart',{})"
 /dtml-unless
 dtml-call "FSSession['cart'].update(REQUEST.form)"
 dtml-var "FSSession['cart']"
 dtml-var standard_html_footer
 
 
 If you still have problems, you can try SQLSession or HappySession. For
 beginners I would recommend HappySession so you don't need to worry about
 the details of FSSession or SQLSession.
 
 Download HappySession from
 http://www.zope.org/Members/hungjunglu/Products/HappySession
 
 Add an HappySession instance in your Zope hierarchy. Then try:
 
 
 dtml-var standard_html_header
 dtml-unless "SESSION.has_key('cart')"
   dtml-call "SESSION.set('cart',{})"
 /dtml-unless
 dtml-call "SESSION['cart'].update(REQUEST.form)"
 dtml-var "SESSION['cart']"
 dtml-var standard_html_footer
 
 
 regards,
 
 Hung Jung
 
 
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] FSSession newbie problem

2000-06-08 Thread Marcello Lupo



Pavlos Christoforou wrote:
 
 Hi Marcello
 
 On Wed, 7 Jun 2000, Marcello Lupo wrote:
 
  and macically i obtain the same error.
  this is the code i used:
  dtml-call FSSession
  dtml-unless "FSSession.has_key('cart')"
  dtml-call "FSSession.set('cart',{})"
  /dtml-unless
 
  dtml-call "FSSession['carrello'].update(REQUEST.form)"
 
 
 Shouldn't the above be:
 
 dtml-call "FSSession['cart'].update(REQUEST.form)"
 
 Pavlos
Sorry ... Yes I use "carrello" in italian stay for cart and to send the
e-mail i have changed it in cart and in that  point i forgotten to
change carrello in cart for the e-mail. In few words i use everywhere
"carrello".
Sorry form the mistake but the problem is not there :-)
Thanks,
Marcello

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] FSSession newbie problem

2000-06-07 Thread Marcello Lupo

Hello,
i'm trying to use the FSSession to have a little shopping cart for
e-commerce.

I can initialize the dictionary named "cart" and it is created in the
datafile.
When i try to update it with the data from my form i get the error:

Zope Error

 Zope has encountered an error while publishing this
resource. 

 Error Type: AttributeError
 Error Value: 'None' object has no attribute 'update'


For curiosity i tried the example bundled in README.txt of the FSSEssion
and macically i obtain the same error.
this is the code i used:
dtml-call FSSession
dtml-unless "FSSession.has_key('cart')"
dtml-call "FSSession.set('cart',{})"
/dtml-unless
dtml-comment
#
dtml-var "REQUEST.form"br
dtml-in "REQUEST.form.items()"
dtml-var sequence-item
/dtml-in
This is only to check that the form passes the values correctly

/dtml-comment
dtml-call "FSSession['carrello'].update(REQUEST.form)"

Can anyone help me?
Thanks
ATIS

___
Zope maillist  -  [EMAIL PROTECTED]
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 )