[Zope-dev] python scripts and variables

2002-03-05 Thread Sebastian Sippl

Hi,

I ve got a little problem:

I am starting a python script within a python script.

how do i pass the variables from one to the other?

(i tried setting the request variables and getting the values by the
python script but it didnt work)

it looks like this:

Python-Script:

code of python script1

container.REQUEST.set('value', '123') -I tried this but my
script didnt get the value

container.py2  Second python script should get values by the
request variable

code of python script1


Sebastian


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] python scripts and variables

2002-03-05 Thread Jens Quade

Sebastian Sippl [EMAIL PROTECTED] writes:

 I am starting a python script within a python script.

like, context.script2(parameters,...)?

 how do i pass the variables from one to the other?

Use the parameter list.

 container.py2  Second python script should get values by the
 request variable
 

This way, the script isn't even called - to call a 
method in python you have to use () after it, optionally
filled with parameters.

But you should be able to pass parameters around using 
the request, too. Just call your method in the context.

jens




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] python scripts

2001-05-14 Thread Tom Deprez

Hi,

This weekend I did some work on python scripts and found some things which
suprised me, can someone enlighten me on this why these 'strange' things are
needed? :

1. When calling a method from a python script you've to do this :

(assume x is the value to pass  and name is a parameter of mymethod)

  context.mymethod(name=x)

   The following doesn't works :

 context.mymethod(x) (this gives an error)

   Why

2. Assume you've an sqlmethod which expects 2 parametes, but one is optional
:

eg
select *
from invoice
dtml-sqlgroup where required
   dtml-sqlgroup
dtml-sqltest customersid column=customers_id op=eq
type=int
dtml-and
 dtml-sqltest productsid column=products_id op=eq type=int
optional
   /dtml-sqlgroup
/dtml-sqlgroup

   So, you could run this sql with or without the productsid

  No, calling from python script doesn't works since it

  expects: context.mymethod(customerid=..., productsid=...)

  while context.mymethod(customerid=...) doesn't work..

Now, this implies that I've to write 2 sqlmethods (one with 2 parameters and
one with 1),
which is pretty stupid, since sqlmethods perfect allow to ignore a parameter
when not passed...


Can somebody tell me more on this? Why this is the case and perhaps a
solution for (2)

Thanks in advance,

Tom Deprez











___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Chris Withers

Hi,

Got a bug and an old unanswered question:

The Bug:

If I use an name other than 'context' to bind to context, I quite often (but not
always :-S) get a KeyError on that name.

The Question:

If I'm calling a Python Script from a Python Product (for example), how would I
pass a namespace to the script that would get bound as the namespace argument?

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Evan Simpson

From: Chris Withers [EMAIL PROTECTED]
 The Bug:

 If I use an name other than 'context' to bind to context, I quite often
(but not
 always :-S) get a KeyError on that name.

I'll check this out.  It's in the Collector, right?

 The Question:

 If I'm calling a Python Script from a Python Product (for example), how
would I
 pass a namespace to the script that would get bound as the namespace
argument?

Treat it as a keyword argument.  "Caller's namespace" is the only one of the
binding names that behaves this way, since the caller has complete control
over the contents of the namespace anyway.  For example:

myps(_=ns)

Cheers,

Evan @ digicool  4-am


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Chris Withers

Evan Simpson wrote:
 
 From: Chris Withers [EMAIL PROTECTED]
  The Bug:
 
  If I use an name other than 'context' to bind to context, I quite often
 (but not
  always :-S) get a KeyError on that name.
 
 I'll check this out.  It's in the Collector, right?

It is now ;-)

http://classic.zope.org:8080/Collector/1982/view

  The Question:
 
  If I'm calling a Python Script from a Python Product (for example), how
 would I
  pass a namespace to the script that would get bound as the namespace
 argument?
 
 Treat it as a keyword argument.  "Caller's namespace" is the only one of the
 binding names that behaves this way, since the caller has complete control
 over the contents of the namespace anyway.  For example:
 
 myps(_=ns)

Cool :-) And even though I pass it in as _, it'll get bound to whatever is
specified on the bindings tab, right?

Thanks for the quick reply,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Chris Withers

Evan Simpson wrote:
 
 From: Chris Withers [EMAIL PROTECTED]
  Cool :-) And even though I pass it in as _, it'll get bound to whatever is
  specified on the bindings tab, right?
 
 Nope.  If you called it "fred" on the bindings tab, pass it as "fred".

rats :-( How hard would it be to make it work like that though?

I wonder if that's not the root of the bug I reported?

I'm calling a python script with the context bound to, lets say, 'fred'. 
I call the python script like this:

result = self.aq_acquire(variable_containing_name_of_PS)(a_dictionary)

...where self is an instance of my python product, and a_dictionary, is, well, a
dictionary that's aimed at the specified parameter of the python script.

HTH,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Evan Simpson

From: Chris Withers [EMAIL PROTECTED]
 Cool :-) And even though I pass it in as _, it'll get bound to whatever is
 specified on the bindings tab, right?

Nope.  If you called it "fred" on the bindings tab, pass it as "fred".

Cheers,

Evan @ digicool  4-am


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Evan Simpson

From: Chris Withers [EMAIL PROTECTED]
 I'm calling a python script with the context bound to, lets say, 'fred'.
 I call the python script like this:

 result = self.aq_acquire(variable_containing_name_of_PS)(a_dictionary)

 ...where self is an instance of my python product, and a_dictionary, is,
well, a
 dictionary that's aimed at the specified parameter of the python script.

"aimed at"?  This will pass the dictionary as a single positional parameter.
It won't do anything with bound names or keyword parameters.

Cheers,

Evan @ digicool  4-am


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Python Scripts Bug Question

2001-02-20 Thread Chris Withers

Evan Simpson wrote:
 
 "aimed at"?  This will pass the dictionary as a single positional parameter.
 It won't do anything with bound names or keyword parameters.

Cool, that's what I meant... I just wondered if the way I was calling it might
have had something to do with cotnext not being bound to its correct name.

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Python Scripts

2001-02-13 Thread Chris Withers

Evan Simpson wrote:
 
 You shouldn't have to do anything special; You just call it.

How would I pass a DTML namespace that I might have lying around when I make the
call so that it gets bound to the appropriate Namespace variable in the script?

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] 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-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )