Re: [Zope] Python scripts

2012-07-06 Thread Laurence Rowe
On 6 July 2012 16:36, Richard Harley  wrote:
> That works great, thanks. So there is no way to do this across, say, a
> folder with hundreds of scripts in without duplicating the code in each
> individually?

For one Plone hotfix we took the approach of blacklisting certain
scripts by monkey-patching Bindings._bindAndExec (Bindings is a
superclass of PythonScript):

from Shared.DC.Scripts.Bindings import Bindings
from zExceptions import Forbidden

DO_NOT_PUBLISH = [
'script_id',
...
]

def _patched_bindAndExec(self, args, kw, caller_namespace):
'''Prepares the bound information and calls _exec(), possibly
with a namespace.
'''
template_id = hasattr(self, 'getId') and self.getId() or ''
request = getattr(self, 'REQUEST', None)
if (template_id and request and template_id in DO_NOT_PUBLISH and
request.get('PUBLISHED') is self):
raise Forbidden('Script may not be published.')
return self._original_bindAndExec(args, kw, caller_namespace)

Bindings._original_bindAndExec = Bindings._bindAndExec
Bindings._bindAndExec = _patched_bindAndExec

You could create an unpublishable subclass of PythonScript using a
similar technique. Ideally PythonScripts would opt in to being
publishable based on some metadata option.

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


Re: [Zope] Python scripts

2012-07-06 Thread Richard Harley
That works great, thanks. So there is no way to do this across, say, a 
folder with hundreds of scripts in without duplicating the code in each 
individually?



On 06/07/12 13:30, Laurence Rowe wrote:

On 6 July 2012 14:09, Richard Harley  wrote:

On Zope 2.10 is there a simple/universal way to only allow python scripts to
be called by DTML methods or other python scripts and not directly TTW?

You can check that the script is not the published object with:

 if container.REQUEST['PUBLISHED'] is script:
 raise 'Forbidden'

For newer versions of Zope raise an exception object:

 from zExceptions import Forbidden
 if container.REQUEST['PUBLISHED'] is script:
 raise Forbidden('Script may not be published.')

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


Re: [Zope] Python scripts

2012-07-06 Thread Laurence Rowe
On 6 July 2012 14:09, Richard Harley  wrote:
> On Zope 2.10 is there a simple/universal way to only allow python scripts to
> be called by DTML methods or other python scripts and not directly TTW?

You can check that the script is not the published object with:

if container.REQUEST['PUBLISHED'] is script:
raise 'Forbidden'

For newer versions of Zope raise an exception object:

from zExceptions import Forbidden
if container.REQUEST['PUBLISHED'] is script:
raise Forbidden('Script may not be published.')

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


[Zope] Python scripts

2012-07-06 Thread Richard Harley

Hi

On Zope 2.10 is there a simple/universal way to only allow python 
scripts to be called by DTML methods or other python scripts and not 
directly TTW?

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


Re: [Zope] Python Scripts and HTML Forms

2006-08-18 Thread Muk Yan
Hi Jonathan,Thanks a lot, it works today, but it was acting up a bit yesterday.  I really appreciate it, maybe I just needed to completely get rid of the browser cache.Peace and thanks again,Muk
On 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote:







If you have a line like
 

 
in your html file then if you try the following in 
your script file
 
print REQUEST['first_name']  
return printed
 
you should see "default value" printed 
out
 
you can try:
 
print REQUEST
 
to see the entire contents of REQUEST (very 
informative)
 
Note: if you do not have a default value in your 
 statement and you do not enter anything in the input field when 
the form is displayed, then when the form is submitted REQUEST will not contain 
an entry for the corresponding form field (an entry is made in REQUEST only when 
data is entered in the form field)
 
 
Jonathan
 
 

  - Original Message - 
  
From: 
  Muk Yan 
  To: 
Jonathan 
  Cc: 
zope@zope.org 
  Sent: Thursday, August 17, 2006 4:40 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey All,Sorry about that, what I meant is that I get a 
  KeyError. It says that the first_name in REQUEST['first_name'] is not found, 
  when I try to set the variable in line in the script where fname = 
  REQUEST['first_name'].Thanks in 
  advance.Cheers,Muk
  On 8/17/06, Jonathan < 
  [EMAIL PROTECTED]> wrote:
  


What does "it doesn't seem to work" mean?  
Error messages/traceback? What does your form & script contain?  
More info on the problem is definitely required!

 
 
 
Jonathan



- 
Original Message - 

From: 
Muk Yan 

To: 
Jonathan ; 
zope@zope.org 
    Sent: 
    Thursday, August 17, 2006 4:20 PM
Subject: 
Re: [Zope] Python Scripts and HTML Forms
Hey Jonathan, All,Thanks I tried your solution, but 
it doesn't seem to work.  Can anybody shed some more light on this 
situation, since what Jonathan provides is exactly what I want to do, but 
it's not working.Am I forgetting to put parameteres or some other 
newbie mistake like that?Thanks in advance and thanks again 
Jonathan.-Muk
On 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote: 


  
  
  Form variables are stored in REQUEST. In a 
  python script you gain access to REQUEST by:
   
  REQUEST = 
  container.REQUEST
  you can then access the form variables 
  by:
   
  fname = REQUEST['first_name']
   
   
  you can check for the presence of a form 
  variable by
   
  if 
  REQUEST.has_key('first_name'):
   
  or
   
  if REQUEST.get('first_name', 
  None):
   
   
  hth
   
  Jonathan
   
  
  
  - 
  Original Message - 
  
From: 
  Muk Yan 
      To: 
  zope@zope.org 
  Sent: 
  Thursday, August 17, 2006 2:57 PM
  Subject: 
  [Zope] Python Scripts and HTML Forms
  Dear Trusted Zope Zealots,This subject was a bit 
  too broad to do a google search on, because I've tried and the lack of 
  relevancy was astounding.I've probably been committing a cardinal 
  sin in DTML, but I couldn't figure any other work around. I have 
  an HTML form in a DTML Document say:Name: I want to use 
  "first_name" in a python script, but what I've been doing is setting it in 
  the process_this_form, which is a DTML method:DTML Method, 
  process_this_form:and in the Python Script, 
  this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there 
  anyway to directly access "first_name" from the form in the python script 
  without having to have to call the  and then 
  REQUEST.SESSION.get('firstName') in the python script.  Sort of a 
  sophomoric question, but any help would be appreciated.  Thanks in 
  advance.-Muk
  
  
  

  ___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 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] Python Scripts and HTML Forms

2006-08-17 Thread Gabriel Genellina

At Thursday 17/8/2006 17:40, Muk Yan wrote:

Sorry about that, what I meant is that I get a KeyError. It says 
that the first_name in REQUEST['first_name'] is not found, when I 
try to set the variable in line in the script where fname = 
REQUEST['first_name'].


Read the previous responses, you had an error in your html form, have 
you fixed it?




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


___
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] Python Scripts and HTML Forms

2006-08-17 Thread Jonathan



If you have a line like
 

 
in your html file then if you try the following in 
your script file
 
print REQUEST['first_name']  
return printed
 
you should see "default value" printed 
out
 
you can try:
 
print REQUEST
 
to see the entire contents of REQUEST (very 
informative)
 
Note: if you do not have a default value in your 
 statement and you do not enter anything in the input field when 
the form is displayed, then when the form is submitted REQUEST will not contain 
an entry for the corresponding form field (an entry is made in REQUEST only when 
data is entered in the form field)
 
 
Jonathan
 
 

  - Original Message - 
  From: 
  Muk Yan 
  To: Jonathan 
  Cc: zope@zope.org 
  Sent: Thursday, August 17, 2006 4:40 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey All,Sorry about that, what I meant is that I get a 
  KeyError. It says that the first_name in REQUEST['first_name'] is not found, 
  when I try to set the variable in line in the script where fname = 
  REQUEST['first_name'].Thanks in 
  advance.Cheers,Muk
  On 8/17/06, Jonathan < 
  [EMAIL PROTECTED]> wrote:
  


What does "it doesn't seem to work" mean?  
Error messages/traceback? What does your form & script contain?  
More info on the problem is definitely required!

 
 
 
Jonathan



- 
Original Message - 
From: 
Muk Yan 

To: 
Jonathan ; zope@zope.org 
Sent: 
    Thursday, August 17, 2006 4:20 PM
Subject: 
Re: [Zope] Python Scripts and HTML Forms
Hey Jonathan, All,Thanks I tried your solution, but 
it doesn't seem to work.  Can anybody shed some more light on this 
situation, since what Jonathan provides is exactly what I want to do, but 
it's not working.Am I forgetting to put parameteres or some other 
newbie mistake like that?Thanks in advance and thanks again 
Jonathan.-Muk
On 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote: 


  
  
  Form variables are stored in REQUEST. In a 
  python script you gain access to REQUEST by:
   
  REQUEST = 
  container.REQUEST
  you can then access the form variables 
  by:
   
  fname = REQUEST['first_name']
   
   
  you can check for the presence of a form 
  variable by
   
  if 
  REQUEST.has_key('first_name'):
   
  or
   
  if REQUEST.get('first_name', 
  None):
   
   
  hth
   
  Jonathan
   
  
  
  - 
  Original Message - 
  From: 
  Muk Yan 
      To: 
  zope@zope.org 
  Sent: 
  Thursday, August 17, 2006 2:57 PM
  Subject: 
  [Zope] Python Scripts and HTML Forms
  Dear Trusted Zope Zealots,This subject was a bit 
  too broad to do a google search on, because I've tried and the lack of 
  relevancy was astounding.I've probably been committing a cardinal 
  sin in DTML, but I couldn't figure any other work around. I have 
  an HTML form in a DTML Document say:Name: I want to use 
  "first_name" in a python script, but what I've been doing is setting it in 
  the process_this_form, which is a DTML method:DTML Method, 
  process_this_form:and in the Python Script, 
  this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there 
  anyway to directly access "first_name" from the form in the python script 
  without having to have to call the  and then 
  REQUEST.SESSION.get('firstName') in the python script.  Sort of a 
  sophomoric question, but any help would be appreciated.  Thanks in 
  advance.-Muk
  
  
  

  ___Zope 
  maillist  -  Zope@zope.orghttp://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 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] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Hey All,Sorry about that, what I meant is that I get a KeyError. It says that the first_name in REQUEST['first_name'] is not found, when I try to set the variable in line in the script where 
fname = REQUEST['first_name'].Thanks in advance.Cheers,MukOn 8/17/06, Jonathan <
[EMAIL PROTECTED]> wrote:






What does "it doesn't seem to work" mean?  
Error messages/traceback? What does your form & script contain?  More 
info on the problem is definitely required!
 
 
 
Jonathan

  - Original Message - 
  
From: 
  Muk Yan 
  To: 
Jonathan ; zope@zope.org 
  Sent: Thursday, August 17, 2006 4:20 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey Jonathan, All,Thanks I tried your solution, but it 
  doesn't seem to work.  Can anybody shed some more light on this 
  situation, since what Jonathan provides is exactly what I want to do, but it's 
  not working.Am I forgetting to put parameteres or some other newbie 
  mistake like that?Thanks in advance and thanks again 
  Jonathan.-Muk
  On 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote:

  


Form variables are stored in REQUEST. In a 
python script you gain access to REQUEST by:
 
REQUEST = 
container.REQUEST
you can then access the form variables 
by:
 
fname = REQUEST['first_name']
 
 
you can check for the presence of a form 
variable by
 
if 
REQUEST.has_key('first_name'):
 
or
 
if REQUEST.get('first_name', 
None):
 
 
hth
 
Jonathan
 


- 
Original Message - 

From: 
Muk Yan 
To: 
    zope@zope.org 
Sent: 
Thursday, August 17, 2006 2:57 PM
Subject: 
[Zope] Python Scripts and HTML Forms
Dear Trusted Zope Zealots,This subject was a bit too 
broad to do a google search on, because I've tried and the lack of relevancy 
was astounding.I've probably been committing a cardinal sin in DTML, 
but I couldn't figure any other work around. I have an HTML form in 
a DTML Document say:Name: I want to use 
"first_name" in a python script, but what I've been doing is setting it in 
the process_this_form, which is a DTML method:DTML Method, 
process_this_form:and 
in the Python Script, this_is_a_python_scriptI use 
REQUEST.SESSION.get('firstName')What my question is, is there anyway 
to directly access "first_name" from the form in the python script without 
having to have to call the  and then REQUEST.SESSION.get('firstName') in the python 
script.  Sort of a sophomoric question, but any help would be 
appreciated.  Thanks in advance.-Muk




___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 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] Python Scripts and HTML Forms

2006-08-17 Thread Jonathan



What does "it doesn't seem to work" mean?  
Error messages/traceback? What does your form & script contain?  More 
info on the problem is definitely required!
 
 
 
Jonathan

  - Original Message - 
  From: 
  Muk Yan 
  To: Jonathan ; zope@zope.org 
  Sent: Thursday, August 17, 2006 4:20 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey Jonathan, All,Thanks I tried your solution, but it 
  doesn't seem to work.  Can anybody shed some more light on this 
  situation, since what Jonathan provides is exactly what I want to do, but it's 
  not working.Am I forgetting to put parameteres or some other newbie 
  mistake like that?Thanks in advance and thanks again 
  Jonathan.-Muk
  On 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote:
  


Form variables are stored in REQUEST. In a 
python script you gain access to REQUEST by:
 
REQUEST = 
container.REQUEST
you can then access the form variables 
by:
 
fname = REQUEST['first_name']
 
 
you can check for the presence of a form 
variable by
 
if 
REQUEST.has_key('first_name'):
 
or
 
if REQUEST.get('first_name', 
None):
 
 
hth
 
Jonathan
 


- 
Original Message - 
From: 
Muk Yan 
To: 
zope@zope.org 
    Sent: 
Thursday, August 17, 2006 2:57 PM
Subject: 
[Zope] Python Scripts and HTML Forms
Dear Trusted Zope Zealots,This subject was a bit too 
broad to do a google search on, because I've tried and the lack of relevancy 
was astounding.I've probably been committing a cardinal sin in DTML, 
but I couldn't figure any other work around. I have an HTML form in 
a DTML Document say:Name: I want to use 
"first_name" in a python script, but what I've been doing is setting it in 
the process_this_form, which is a DTML method:DTML Method, 
process_this_form:and 
in the Python Script, this_is_a_python_scriptI use 
REQUEST.SESSION.get('firstName')What my question is, is there anyway 
to directly access "first_name" from the form in the python script without 
having to have to call the  and then REQUEST.SESSION.get('firstName') in the python 
script.  Sort of a sophomoric question, but any help would be 
appreciated.  Thanks in advance.-Muk




___Zope 
maillist  -  Zope@zope.orghttp://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 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] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Hey Jonathan, All,

Thanks I tried your solution, but it doesn't seem to work.  Can anybody
shed some more light on this situation, since what Jonathan provides is
exactly what I want to do, but it's not working.

Am I forgetting to put parameteres or some other newbie mistake like that?

Thanks in advance and thanks again Jonathan.

-MukOn 8/17/06, Jonathan <[EMAIL PROTECTED]> wrote:







Form variables are stored in REQUEST. In a python 
script you gain access to REQUEST by:
 
REQUEST = container.REQUEST
you can then access the form variables 
by:
 
fname = REQUEST['first_name']
 
 
you can check for the presence of a form variable 
by
 
if 
REQUEST.has_key('first_name'):
 
or
 
if REQUEST.get('first_name', 
None):
 
 
hth
 
Jonathan
 

  - Original Message - 
  
From: 
  Muk Yan 
  To: 
zope@zope.org 
  Sent: Thursday, August 17, 2006 2:57 
  PM
  Subject: [Zope] Python Scripts and HTML 
  Forms
  Dear Trusted Zope Zealots,This subject was a bit too 
  broad to do a google search on, because I've tried and the lack of relevancy 
  was astounding.I've probably been committing a cardinal sin in DTML, 
  but I couldn't figure any other work around. I have an HTML form in a 
  DTML Document say:Name: I want to use "first_name" 
  in a python script, but what I've been doing is setting it in the 
  process_this_form, which is a DTML method:DTML Method, 
  process_this_form:and in 
  the Python Script, this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there anyway 
  to directly access "first_name" from the form in the python script without 
  having to have to call the  and then REQUEST.SESSION.get('firstName') in the python 
  script.  Sort of a sophomoric question, but any help would be 
  appreciated.  Thanks in advance.-Muk
  
  

  ___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 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] Python Scripts and HTML Forms

2006-08-17 Thread Jonathan



Form variables are stored in REQUEST. In a python 
script you gain access to REQUEST by:
 
REQUEST = container.REQUEST
you can then access the form variables 
by:
 
fname = REQUEST['first_name']
 
 
you can check for the presence of a form variable 
by
 
if 
REQUEST.has_key('first_name'):
 
or
 
if REQUEST.get('first_name', 
None):
 
 
hth
 
Jonathan
 

  - Original Message - 
  From: 
  Muk Yan 
  To: zope@zope.org 
  Sent: Thursday, August 17, 2006 2:57 
  PM
  Subject: [Zope] Python Scripts and HTML 
  Forms
  Dear Trusted Zope Zealots,This subject was a bit too 
  broad to do a google search on, because I've tried and the lack of relevancy 
  was astounding.I've probably been committing a cardinal sin in DTML, 
  but I couldn't figure any other work around. I have an HTML form in a 
  DTML Document say:Name: I want to use "first_name" 
  in a python script, but what I've been doing is setting it in the 
  process_this_form, which is a DTML method:DTML Method, 
  process_this_form:and in 
  the Python Script, this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there anyway 
  to directly access "first_name" from the form in the python script without 
  having to have to call the  and then REQUEST.SESSION.get('firstName') in the python 
  script.  Sort of a sophomoric question, but any help would be 
  appreciated.  Thanks in advance.-Muk
  
  

  ___Zope maillist  
  -  
  Zope@zope.orghttp://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 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] Python Scripts and HTML Forms

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 2:02 pm, Jens Vagelpohl wrote:

> request.get(MY_VARIABLE)  ???

The one major problem with that is that it ties you to getting information 
from the request.  Better to write a script with explicit parameters and 
call it with those parameters.  Then, you can pull values from a database, 
another Zope object, or anything else.  Also makes testing *much* easier 
(since you can use the "Test" tab to experiment with it).
-- 
Kirk Strauser
The Day Companies
___
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] Python Scripts and HTML Forms

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 1:57 pm, Muk Yan wrote:

> Name:

Make that:

   

> DTML Method, process_this_form:
> 
> 
>
> and in the Python Script, this_is_a_python_script
> I use REQUEST.SESSION.get('firstName')

Make that:

  
-- 
Kirk Strauser
The Day Companies
___
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] Python Scripts and HTML Forms

2006-08-17 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 17 Aug 2006, at 14:57, Muk Yan wrote:
What my question is, is there anyway to directly access  
"first_name" from the form in the python script without having to  
have to call the first_name)> and then REQUEST.SESSION.get('firstName') in the  
python script.  Sort of a sophomoric question, but any help would  
be appreciated.  Thanks in advance.


request.get(MY_VARIABLE)  ???

jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFE5L1nRAx5nvEhZLIRAndPAKCBH00iBFg9n8b9xkAUSAFQzE2v4ACfZEgv
p7G0/4MUGqY8PX3qlThev/U=
=8RqC
-END 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 )


[Zope] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Dear Trusted Zope Zealots,This subject was a bit too broad to do a google search on, because I've tried and the lack of relevancy was astounding.I've probably been committing a cardinal sin in DTML, but I couldn't figure any other work around.
I have an HTML form in a DTML Document say:Name:
I want to use "first_name" in a python script, but what I've been doing is setting it in the process_this_form, which is a DTML method:DTML Method, process_this_form:and in the Python Script, this_is_a_python_scriptI use REQUEST.SESSION.get('firstName')What my question is, is there anyway to directly access "first_name" from the form in the python script without having to have to call the  and then REQUEST.SESSION.get('firstName') in the python script.  Sort of a sophomoric question, but any help would be appreciated.  Thanks in advance.-Muk
___
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] Python Scripts

2005-07-12 Thread Chris Withers

Dieter Maurer wrote:


I saw this today.

I expect DOS type line endings.

Your browser (or maybe the ":text" converter in ZPublisher) will remove
them. Therefore, they disappear when you "store" again.


Indeed, but should ZPT Python Scripts really be so sensitive to line 
endings?


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 )


Re: [Zope] Python Scripts

2005-06-17 Thread Dieter Maurer
Dennis Allison wrote at 2005-6-16 09:06 -0700:
>We have been seeing a number of instances where python scripts fail due to 
>an apparent "syntax error" but the syntax is correct and simply storing 
>the method restores it to functionality.   Anyone else seeing this?

I saw this today.

I expect DOS type line endings.

Your browser (or maybe the ":text" converter in ZPublisher) will remove
them. Therefore, they disappear when you "store" again.

-- 
Dieter
___
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] Python Scripts

2005-06-16 Thread Greg Fischer
Yeah, I do see that every once in a while.  I have a very simple
script, that looks perfect, but will always return "syntax error".  I
copied the text, pasted into a text editor and checked all the indents
and tabs, then recreated the script.  Problem went away.

What was interesting is that I didnt change the code.  And even
thought the indents were the same, re-adding them might have solved
it.  Dont know for sure, but I dont see this enough to cause me
problems.

Greg

On 6/16/05, J Cameron Cooper <[EMAIL PROTECTED]> wrote:
> > We have been seeing a number of instances where python scripts fail
> > due to an apparent "syntax error" but the syntax is correct and simply
> > storing the method restores it to functionality.   Anyone else seeing
> > this?
> 
> How do you mean "fail"?
> 
> Often times, if you have an error, save, test, and then use the back
> button, you'll see the old syntax error, even though the contents are
> the new (and correct) version.
> 
> If you just revisit the script (click on the id in the breadcrumbs) the
> message will go away.
> 
> --jcc
> --
> "Building Websites with Plone"
> http://plonebook.packtpub.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 )
> 


-- 
Greg Fischer
1st Byte Solutions
http://www.1stbyte.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] Python Scripts

2005-06-16 Thread J Cameron Cooper
We have been seeing a number of instances where python scripts fail 
due to an apparent "syntax error" but the syntax is correct and simply 
storing the method restores it to functionality.   Anyone else seeing 
this?


How do you mean "fail"?

Often times, if you have an error, save, test, and then use the back
button, you'll see the old syntax error, even though the contents are
the new (and correct) version.

If you just revisit the script (click on the id in the breadcrumbs) the
message will go away.

   --jcc
--
"Building Websites with Plone"
http://plonebook.packtpub.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 )


[Zope] Python Scripts

2005-06-16 Thread Dennis Allison
We have been seeing a number of instances where python scripts fail due to 
an apparent "syntax error" but the syntax is correct and simply storing 
the method restores it to functionality.   Anyone else seeing this?

-- 
Dennis Allison * Computer Systems Laboratory * Gates 227
   * Stanford University *  Stanford CA  94305
   * (650) 723-9213 * (650) 723-0033 fax
   * [EMAIL PROTECTED]
   * [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 )


[Zope] Python Scripts vs PythonMethods

2001-01-29 Thread David K. Trudgett

On Mon, Jan 29, 2001 at 11:50:17AM -0600, Fred Yankowski wrote:

> over those methods manually to Python Scripts.  Rats.  I'm just glad I
> didn't have too much invested into PythonMethods.
>
Admittedly, I haven't been following this very closely, but wasn't Python Scripts 
going to simply be a new name for PythonMethods?

Yours Confused

David Trudgett


___
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] Python Scripts in 2.2.x

2001-01-09 Thread Mayers, Philip J

Oops, ignore that - copied the wrong error from the window (from an earlier
attempt). The *real* error was that I was running zpasswd as root with a
umask of 077, which of course meant the webserver and Zope couldn't read the
resulting file.

So, the LoginManager product appears to work, but the problem now is when I
try to add a LoginManager to a folder, I get a NameError for 'path', with a
traceback:

Traceback (innermost last):
  File /usr/local/Zope23/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /usr/local/Zope23/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /usr/local/Zope23/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
  File /usr/local/Zope23/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /usr/local/Zope23/lib/python/ZPublisher/mapply.py, line 160, in
mapply
(Object: addLoginManager)
  File /usr/local/Zope23/lib/python/ZPublisher/Publish.py, line 112, in
call_object
(Object: addLoginManager)
  File /usr/local/Zope23/lib/python/App/special_dtml.py, line 120, in
__call__
(Object: addLoginManager)
(Info:
/usr/local/Zope23/lib/python/Products/LoginManager/addLoginManager.dtml)
  File /usr/local/Zope23/lib/python/DocumentTemplate/DT_String.py, line 528,
in __call__
(Object: addLoginManager)
  File /usr/local/Zope23/lib/python/DocumentTemplate/DT_In.py, line 633, in
renderwob
(Object: UserSourcesMetaTypes(this()))
  File /usr/local/Zope23/lib/python/DocumentTemplate/DT_Util.py, line 331,
in eval
(Object: UserSourcesMetaTypes(this()))
(Info: UserSourcesMetaTypes)
  File /usr/local/Zope23/lib/python/ZPublisher/HTTPRequest.py, line 772, in
__getitem__
NameError: (see above)


Regards,
Phil

+--+
| Phil Mayers, Network Support |
| Centre for Computing Services|
| Imperial College |
+--+  

-Original Message-
From: Mayers, Philip J 
Sent: 09 January 2001 10:01
To: 'Bill Anderson'
Subject: RE: [Zope] Python Scripts in 2.2.x


No, I'm afraid not:

Traceback (innermost last):
  File "/usr/local/Zope23/lib/python/OFS/Application.py", line 405, in
import_products
product=__import__(pname, global_dict, global_dict, silly)
  File "/usr/local/Zope23/lib/python/Products/LoginManager/__init__.py",
line 1, in ?
import LoginManager, LoginMethods, UserSources
  File "/usr/local/Zope23/lib/python/Products/LoginManager/LoginManager.py",
line 8, in ?
from Products.ZPatterns.Specialists import Specialist
  File "/usr/local/Zope23/lib/python/Products/ZPatterns/__init__.py", line
1, in ?
import Rack, Specialists, Customizers, AttributeProviders,
SheetProviders
  File "/usr/local/Zope23/lib/python/Products/ZPatterns/Rack.py", line 9, in
?
from DataSkins import DataSkin
  File "/usr/local/Zope23/lib/python/Products/ZPatterns/DataSkins.py", line
1, in ?
from DynPersist import DynPersist
ImportError: No module named DynPersist

Regards,
Phil

+--+
| Phil Mayers, Network Support |
| Centre for Computing Services|
| Imperial College |
+--+  

-Original Message-
From: Bill Anderson [mailto:[EMAIL PROTECTED]]
Sent: 09 January 2001 04:42
To: Mayers, Philip J
Subject: Re: [Zope] Python Scripts in 2.2.x


Mayers, Philip J wrote:

> I need to use LoginManager, which doesn't seem to work with 2.3, 

It does after a minor modification...
http://www.egroups.com/message/zope/47172

Bill Anderson


___
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] Python Scripts in 2.2.x

2001-01-08 Thread Ron Bickers

I'm running PythonScripts with 2.2.4 and, with one exception, they seem to
be working just fine.  The exception is that DTML namespace binding does not
work under 2.2.  You can, however, pass the namespace explicitly to get the
same effect.  Here is what you need to do to get it working.  Note that
PythonScripts under 2.2 is not supported by DC, so if this blows up, you're
out of luck.

1) Install PythonScripts from CVS (Zope2/lib/python/Products/PythonScripts)
just like any other Python Product.

2) Add these lines to lib/python/AccessControl/__init__.py in your Zope
installation:

from SecurityInfo import ClassSecurityInfo, ModuleSecurityInfo
from SecurityInfo import ACCESS_PRIVATE
from SecurityInfo import ACCESS_PUBLIC
from SecurityInfo import ACCESS_NONE
from SecurityInfo import secureModule

3) Add the CVS version of AccessControl/SecurityInfo.py to the AccessControl
directory.

4) Add the CVS version of OFS/Cache.py to the OFS directory.

5) Restart Zope

Other than the exception above, I haven't found anything to not function as
expected.
___

Ron Bickers
Logic Etc, Inc.
[EMAIL PROTECTED]


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> Mayers, Philip J
> Sent: Monday, January 08, 2001 10:40 AM
> To: '[EMAIL PROTECTED]'
> Subject: [Zope] Python Scripts in 2.2.x
>
>
> I need to use LoginManager, which doesn't seem to work with 2.3,
> and I need
> to use Python Scripts, which are not available (?) for 2.2.x - any ideas?
>


___
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] Python Scripts in 2.2.x

2001-01-08 Thread Mayers, Philip J

I need to use LoginManager, which doesn't seem to work with 2.3, and I need
to use Python Scripts, which are not available (?) for 2.2.x - any ideas?

Regards,
Phil

+--+
| Phil Mayers, Network Support |
| Centre for Computing Services|
| Imperial College |
+--+  

___
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] Python Scripts update

2001-01-04 Thread Evan Simpson

Python Scripts have gone through a fair number of changes and bugfixes
recently.  They should now work properly as methods of ZClasses.  When you
download the source of a Python Script, the title, parameter list, and
bindings are added to the source in the form of specially formatted
comments.  If source with these comments is uploaded or pasted into a Python
Script, it will properly set the properties mentioned in the comment block.
The default bindings have been changed to be more sensible.

If you want to give Python Scripts a try, you can go to
http://ps.4-am.com:9000/ , pick a password, and you'll get your own private
area in a trunk CVS checkout of Zope in which to play.

I promised examples when I first announced this site, and haven't gotten
around to writing any.  If you have created a script or set of objects on
the demo site that you would like to share as an example, please mail me the
URL.

Cheers,

Evan @ digicool & 4-am



___
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] python scripts to import data into ZODB...

2000-12-28 Thread Jonathan B. York

Howdy,

I want to import some data into the ZODB and I found this How-To,
http://www.zope.org/Members/michel/HowTos/ZODB-How-To, but there are
errors in the example code and I haven't been able to get it to work
right.


Can anyone point to any other information or example code that does
something like this?


jonathan


___
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] Python Scripts and Versioning

2000-12-13 Thread Chris Withers

Michel Pelletier wrote:
> 
> See, people used to post helpful little things like this in DTML.  What a
> nightmare.  Python Scripts rock!  We're gonna be seein' alot more of them
> fly by on the list once people get over the initial shock that they can do
> 90% of what they've been doing in Python.

Yay! :-)

Now all Zope needs is a concurrent versioning system with an 'archive to
CVS' option for folders and there won't be a need for python products
;-)

cheers,

Chris

___
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 )