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
From: Chris Withers <chrisw@nipltd.com>
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
Evan Simpson wrote:
From: Chris Withers <chrisw@nipltd.com>
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
From: Chris Withers <chrisw@nipltd.com>
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
Evan Simpson wrote:
From: Chris Withers <chrisw@nipltd.com>
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
From: Chris Withers <chrisw@nipltd.com>
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
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
participants (2)
-
Chris Withers -
Evan Simpson