(moving back onto list, hopefully my head/wall contact will save others braincells ;-) Jim Fulton wrote:
On an (almost) related matter, are there any docs (other than the code ;-) for how __call__ is handles WRT to <dtml-var something>? I had a look at DTMLMethod.py and PythonMethod.py and ended up very confused...
Currently, DTML looks at something that it is going to render and tries to decide if it's callable. If it is, it checks to see if it has a true isDocTemp attribute. If an object is callable and has a true isDocTemp, then it is called with None and the DTML namespace. Otherwise, if an object is callable, it is just called.
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
We are going to provide an alternate interface, so that if an object has a special method, then this will be called instead.
okay... which proposal/project is this in?
I think the 'client', rather than 'self' is what I'm after, but how can I get it inside my product's __call__ method?
Hmmm... I don't suppose there's a nice definition of what the 'client' is, what's likely to be in the namespace stack and what self is likely to be in these circumstances lying around anywhere, is there? ;-)
You can't really. You should be able to infer it from the acquisition context. For example, 'client' should be aq_parent.
def __call__(self): """ """ print self.aq_parent.id This is called by a <dtml-var myObject> in standard_html_header which is also called with a dtml-var in, lets say, the DTML documnet: myDocument. The above code prints the id of this product instance's container. I was expecting it to print the id of myDocument. Is this me misunderstanding what the 'client' is, or is something else going on? In either case, what do I need to go to get hold of what would be PARENTS[0-1], if you see what I mean?
Note that subtemplates are not invoked on the objects they are found in, but in the namespace they are called in. This is a bit weird and not really intensional. :(
I think I'm probably going to be relying on this, and I _think_ it makes sense to me. I presume subtemplate calls are things like doing <dtml-var myObject>? In which case it seems sensible to keep playing in the namespace and just popping myObject on top as an instanceDict. I'm note quite sure how you think this area should work adn what difference it would make, could you elaborate? :-S
PS: In python product terms, whats' the difference between implementing __call__, __str__ or render?
render?
Yeah, that's what I thought, but a coupla people have mentioned it. Maybe they're thinking of DTML tags?
__call__ implements the () operator (in C++ terms). It is the method you implement to make your object callable.
__str__ is the method you implement to control how your object is converted to a human readable string.
So what's the difference in terms of doing <dtml-var myobject> and http://site.com/myobject, if there is any? cheers, Chris PS: What I'm actually looking for out of all of this is the getPhysicalPath() of the final object that was traversed through the URL. e.g: If the URL was http://www.nipltd.com/folder/somethingelse/myobject, I'm looking for something like: [<Application Instance at 0x000000> (Zope) , <Folder Instance at 0x000000> (folder) , <DTMLDocument Instance at 0x000000> (myobject)] If there's an easier way to get this from within the __call__ method of a python product, someone PLEASE tell me! ;-)
Chris Withers wrote:
(moving back onto list, hopefully my head/wall contact will save others braincells ;-)
Jim Fulton wrote:
On an (almost) related matter, are there any docs (other than the code ;-) for how __call__ is handles WRT to <dtml-var something>? I had a look at DTMLMethod.py and PythonMethod.py and ended up very confused...
Currently, DTML looks at something that it is going to render and tries to decide if it's callable. If it is, it checks to see if it has a true isDocTemp attribute. If an object is callable and has a true isDocTemp, then it is called with None and the DTML namespace. Otherwise, if an object is callable, it is just called.
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
def __call__(self, ignored, md): ...
We are going to provide an alternate interface, so that if an object has a special method, then this will be called instead.
okay... which proposal/project is this in?
I don't remember. Evan?
I think the 'client', rather than 'self' is what I'm after, but how can I get it inside my product's __call__ method?
Hmmm... I don't suppose there's a nice definition of what the 'client' is, what's likely to be in the namespace stack and what self is likely to be in these circumstances lying around anywhere, is there? ;-)
client is just a namespace, defined by it's attributes. It's not really in the namespace. Neither is self.
You can't really. You should be able to infer it from the acquisition context. For example, 'client' should be aq_parent.
def __call__(self): """ """ print self.aq_parent.id
This is called by a <dtml-var myObject> in standard_html_header which is also called with a dtml-var in, lets say, the DTML documnet: myDocument.
The above code prints the id of this product instance's container.
That's what I expect. 'client', in DocumentTemplate is usually the object the template was invoked on.
I was expecting it to print the id of myDocument. Is this me misunderstanding what the 'client' is,
Yes.
or is something else going on?
In either case, what do I need to go to get hold of what would be PARENTS[0-1], if you see what I mean?
I don't see what you mean.
Note that subtemplates are not invoked on the objects they are found in, but in the namespace they are called in. This is a bit weird and not really intensional. :(
I think I'm probably going to be relying on this, and I _think_ it makes sense to me. I presume subtemplate calls are things like doing <dtml-var myObject>?
That's fine.
In which case it seems sensible to keep playing in the namespace and just popping myObject on top as an instanceDict. I'm note quite sure how you think this area should work adn what difference it would make, could you elaborate? :-S
First, I have no intention of changing anything in a backward incompatible way. For that matter, I don't have much interest in changing DTML at this point, given: http://dev.zope.org/Wikis/DevSite/Projects/XHTMLTemplate I think that if you say: <dtml-var expr="foo.bar"> that foo's namespace should take precedence over the DTML namespace, but, in fact, foo's namespace is ignored. I think that this should at least happen optionally. Otherwise, how could you think of bar as a method?
PS: In python product terms, whats' the difference between implementing __call__, __str__ or render?
render?
Yeah, that's what I thought, but a coupla people have mentioned it. Maybe they're thinking of DTML tags?
Well, a number of people have suggested that there should be a separate render (ie call as subtemlpate) interface. Maybe that's what what you meant. Evan, help me out here. :)
__call__ implements the () operator (in C++ terms). It is the method you implement to make your object callable.
__str__ is the method you implement to control how your object is converted to a human readable string.
So what's the difference in terms of doing <dtml-var myobject> and http://site.com/myobject, if there is any?
The difference is clearer if you have http://site.com/foo/bar vs <dtml-var expr="foo.bar"> in http://site.com/zoo/splat. In the former case, foo's namespace is at the top of the stack and, in the second case, it's not on the stack.
PS: What I'm actually looking for out of all of this is the getPhysicalPath() of the final object that was traversed through the URL. e.g: If the URL was http://www.nipltd.com/folder/somethingelse/myobject, I'm looking for something like: [<Application Instance at 0x000000> (Zope) , <Folder Instance at 0x000000> (folder) , <DTMLDocument Instance at 0x000000> (myobject)]
getPhysicalPath returns a list of strings, not objects.
If there's an easier way to get this from within the __call__ method of a python product, someone PLEASE tell me! ;-)
aq_chain(x, 1)[-1:] should give this to you, I believe, or be very close. :) Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
def __call__(self, ignored, md): ...
Right, now if I call other DTML methods from my __call__ method, can I just call them with: self.nav_header(self, ignored, md)? In any case, what is self in __call__(self, ...) and what should it be in nav_header(self, ...)?
expecting it to print the id of myDocument. Is this me misunderstanding what the 'client' is,
Yes.
Fair enough... I think what I meant was whatever the object that <dtml-var "this()"> would return if that occurend in the standard_html_header method.
In either case, what do I need to go to get hold of what would be PARENTS[0-1], if you see what I mean?
I don't see what you mean.
http://a.site/folder/object/myobject myobject contains <dtml-var standard_html_header> standard_html_header contains <dtml-var mynavigator> __call__ is a method of the Navigator product, of which mynavigator is an instance. Anyway, in that __call__, self.REQUEST.PARENTS = [zope-app,folder,object] (roughly) By PARENTS[0-1], I meant the myobject object, itself. Hurm, I'm finding this hard to explain clearly, let me know if I'm getting closer :-S
I think that if you say:
<dtml-var expr="foo.bar">
that foo's namespace should take precedence over the DTML namespace,
Okay, I see what you mean now :-)
render?
Well, a number of people have suggested that there should be a separate render (ie call as subtemlpate) interface. Maybe that's what what you meant.
Nope... DT_Var.py line 258: def render(self, md): ...is what I think the people who mentioned it to me were talking about.
<dtml-var expr="foo.bar"> in http://site.com/zoo/splat.
In the former case, foo's namespace is at the top of the stack and, in the second case, it's not on the stack.
Okay, that clears it up :-)
PS: What I'm actually looking for out of all of this is the getPhysicalPath() of the final object that was traversed through the URL. e.g: If the URL was http://www.nipltd.com/folder/somethingelse/myobject, I'm looking for something like: [<Application Instance at 0x000000> (Zope) , <Folder Instance at 0x000000> (folder) , <DTMLDocument Instance at 0x000000> (myobject)]
getPhysicalPath returns a list of strings, not objects.
d'Oh!
If there's an easier way to get this from within the __call__ method of a python product, someone PLEASE tell me! ;-)
aq_chain(x, 1)[-1:] should give this to you, I believe, or be very close. :)
Won't that just return x? (hmm... does aq_chain return [child,...,parent] or [parent,...,child]?) I think the hard part fo the problem I'm trying to solve is finding out what x is from within the __call__ method. Any help muchly appreciated, sorry this is takign such a long time to sort out in my head... ;-) cheers, Chris
Chris Withers wrote:
Jim Fulton wrote:
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
def __call__(self, ignored, md): ...
Right, now if I call other DTML methods from my __call__ method, can I just call them with:
self.nav_header(self, ignored, md)?
No: self.nav_header(None, md)
In any case, what is self in __call__(self, ...) and what should it be in nav_header(self, ...)?
Python method signatures always begin with an argument that is the instance to which they are bound. (snip)
In either case, what do I need to go to get hold of what would be PARENTS[0-1], if you see what I mean?
I don't see what you mean.
http://a.site/folder/object/myobject
myobject contains <dtml-var standard_html_header> standard_html_header contains <dtml-var mynavigator>
Is myobject a DTMLMethod? Some kind of container? I don't see how it can contain a var tag if it's not DTML. If it is DTML, I don't see where mynavigator fits in.
__call__ is a method of the Navigator product, of which mynavigator is an instance.
Anyway, in that __call__, self.REQUEST.PARENTS = [zope-app,folder,object] (roughly)
By PARENTS[0-1], I meant the myobject object, itself.
Uh OK.
Hurm, I'm finding this hard to explain clearly, let me know if I'm getting closer :-S
OK, you've snipped the orignal question, so I'm off the hook. :) (I don't really know if you want me to comment on anything else here.)
I think that if you say:
<dtml-var expr="foo.bar">
that foo's namespace should take precedence over the DTML namespace,
Okay, I see what you mean now :-)
render?
Well, a number of people have suggested that there should be a separate render (ie call as subtemlpate) interface. Maybe that's what what you meant.
Nope... DT_Var.py line 258: def render(self, md): ...is what I think the people who mentioned it to me were talking about.
Ok, well that's that's part of the DTML tag interface, which I assume you aren't interested in. (snip)
If there's an easier way to get this from within the __call__ method of a python product, someone PLEASE tell me! ;-)
aq_chain(x, 1)[-1:] should give this to you, I believe, or be very close. :)
Won't that just return x? (hmm... does aq_chain return [child,...,parent] or [parent,...,child]?)
[child ... parent]
I think the hard part fo the problem I'm trying to solve is finding out what x is from within the __call__ method.
Any help muchly appreciated, sorry this is takign such a long time to sort out in my head... ;-)
The Zope debugger is your friend. It's a good way to find out some details like this. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
http://a.site/folder/object/myobject
myobject contains <dtml-var standard_html_header> standard_html_header contains <dtml-var mynavigator>
Is myobject a DTMLMethod? Some kind of container?
Sorry... a good example for myobject would be a DTML Document.
I don't see how it can contain a var tag if it's not DTML. If it is DTML, I don't see where mynavigator fits in.
It is DTML, containing the line <dtml-var standard_html_header> standard_html_header is a DTML Method containing <dtml-var mynavigator> mynavigator is an object of meta_type 'Navigator' and it's the __call__ method of the Navigator product that I'm having trouble writing :-S
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
def __call__(self, ignored, md): ...
This, of coruse, begs the question as to what 'ignored' is, but I probably don't want to know ;-)
No: self.nav_header(None, md)
ok..
In any case, what is self in __call__(self, ...) and what should it be in nav_header(self, ...)?
Python method signatures always begin with an argument that is the instance to which they are bound.
Okay, so in the __call__ case, self will be the mynavigator object? Anyway, the isDocTemp thing seems to be getting somewhere. md is a TemplateDict, and that's a stack of InstanceDict's, right? Now, from what I've seen from playing, the object I've been looking for all along is the one whose InstanceDict is on the top of the md stack. So, two questions: 1. How can I get the top most InstanceDict out of md? is _pop the only way? If so, I would guess I do: x = md._pop(1) md._push(x) to get the InstanceDict without disturting the namespace stack? 2. How would I turn the InstanceDict, x, back into an object? From reading pDocumentTemplate.py, I would guess: obj = x.self Is that right? well, thanks for all the help, I _think_ the end is in sight now ;-) cheers, Chris PS: Once I've got that object, can I still use aq_chain(obj,1) to get the list of obj and its containing parents? (In essence, the PARENTS'y type thing I've been looking for all along ;-)
Jim Fulton wrote: <snip __call__ stuff> Okay, this is almost the same, but apparently not the same. I have a Python Product Class, with a method, a_method, that gets called from some of the Python Product's management screens (encapsulation is good ;-) This method needs several parameters from the namespace, so when it's called I was hoping I wouldn't have to do something nasty and clunky like: <dtml-var "a_method(param1,param2,param3)"> Given my recently acquired __call__ Zen, I thought 'No problem...' and tried to define the method as follows: isDocTemplate = 1 def a_method(self, ignored=None, md=None): ...with the hope I'd just be able to do <dtml-var a_method> and pluck the stuff from md. No dice. md and ignored turn up as None from all the <dtml-var a_method> calls. :-( What am I doing wrong? How can I get access to the namespace in a method of a class like this? cheers, Chris
On Fri, 13 Oct 2000 11:48:39 +0100, Chris Withers <chrisw@nipltd.com> wrote:
I have a Python Product Class, with a method, a_method, that gets called from some of the Python Product's management screens (encapsulation is good ;-)
This method needs several parameters from the namespace, so when it's called I was hoping I wouldn't have to do something nasty and clunky like:
<dtml-var "a_method(param1,param2,param3)">
Given my recently acquired __call__ Zen, I thought 'No problem...' and tried to define the method as follows:
isDocTemplate = 1
def a_method(self, ignored=None, md=None):
...with the hope I'd just be able to do <dtml-var a_method> and pluck the stuff from md.
No dice.
md and ignored turn up as None from all the <dtml-var a_method> calls. :-(
What am I doing wrong? How can I get access to the namespace in a method of a class like this?
You need to have the isDocTemplate=1 as an attribute of the method object itself, not the class that contains the method. You also need some extra voodoo if you want to call the method directly from ZPublisher (by including the method name in a url). Here a link to a wrapper that does it all.... <http://www.zope.org/Members/htrd/howto/FunctionTemplate> you would use.... def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method) Toby Dickenson tdickenson@geminidataloggers.com
Toby Dickenson wrote:
<http://www.zope.org/Members/htrd/howto/FunctionTemplate>
you would use....
def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method)
That looks like it'll do the trick... I wonder if there's any way you can role it up into a Product so that I don't need to have FunctionTemplate.py in each folder of a product that needs to use it? cheers, Chris
Chris Withers wrote:
Toby Dickenson wrote:
<http://www.zope.org/Members/htrd/howto/FunctionTemplate>
you would use....
def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method)
That looks like it'll do the trick... I wonder if there's any way you can role it up into a Product so that I don't need to have FunctionTemplate.py in each folder of a product that needs to use it?
Is it *really* the case that you often want to method to be called directly via the Web *and* and from DTML? This doesn't seem right to me. In any case, if you *just* want to get your function to be called from DTML (and your class is an extension class), you can give it the isDocTemp attribute like so: class MyClass(.... include some extension class ...): some_methodisDocTemp=1 def some_method(self, ignored, md): .... Methods in extension classes can have (read-only) attributes by defining an attribute whose name is the concatenation of the method name and the attribute name. Note that the method is also callable from the web as usual. If you want it to be called the same way as a template, you'd need to use: class MyClass(.... include some extension class ...): some_methodisDocTemp=1 def some_method(trueself, self, REQUEST, RESPONSE=None): .... In this example, 'trueself' is bound by Python and is the traditional python self. The 'self' argument gets bound by the publisher to the object the method was invoked on. Note that if you get called from the web, RESPONSE will not be none. This is a handy way to decide if you are called from the web or as a sub-template. Of course, someone could pass a non-None RESPONSE argument directly. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
In any case, if you *just* want to get your function to be called from DTML (and your class is an extension class), you can give it the isDocTemp attribute like so:
class MyClass(.... include some extension class ...):
some_methodisDocTemp=1 def some_method(self, ignored, md):
great :-) that did the trick, thanks... I can't help but feel this woudl all be so much simpler if it was documented somewhere for idiots like me :-S cheers, Chris
Chris Withers wrote:
Jim Fulton wrote:
In any case, if you *just* want to get your function to be called from DTML (and your class is an extension class), you can give it the isDocTemp attribute like so:
class MyClass(.... include some extension class ...):
some_methodisDocTemp=1 def some_method(self, ignored, md):
great :-) that did the trick, thanks...
I can't help but feel this woudl all be so much simpler if it was documented somewhere for idiots like me :-S
Well, it *is* documented somewhere. (In the ExtensionClass documentation), but not somewhere where you were likely to find it. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
Chris Withers wrote:
Toby Dickenson wrote:
<http://www.zope.org/Members/htrd/howto/FunctionTemplate>
you would use....
def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method)
That looks like it'll do the trick... I wonder if there's any way you can role it up into a Product so that I don't need to have FunctionTemplate.py in each folder of a product that needs to use it?
Is it *really* the case that you often want to method to be called directly via the Web *and* and from DTML? This doesn't seem right to me.
As I understand it, that's not the issue. Chris wants to receive the DTML namespace implicitly.
In any case, if you *just* want to get your function to be called from DTML (and your class is an extension class), you can give it the isDocTemp attribute like so:
class MyClass(.... include some extension class ...):
some_methodisDocTemp=1 def some_method(trueself, self, REQUEST, RESPONSE=None): ....
That's a good idea, I wish I'd thought of it. :-) However, the new calling convention (__render_with_namespace__, or something like that) might break "isDocTemp" code.
Note that if you get called from the web, RESPONSE will not be none. This is a handy way to decide if you are called from the web or as a sub-template. Of course, someone could pass a non-None RESPONSE argument directly.
This convention is helpful but not at all documented, so products (ZWiki is a good example) often break this convention. Shane
Shane Hathaway wrote:
Jim Fulton wrote:
Chris Withers wrote:
Toby Dickenson wrote:
<http://www.zope.org/Members/htrd/howto/FunctionTemplate>
you would use....
def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method)
That looks like it'll do the trick... I wonder if there's any way you can role it up into a Product so that I don't need to have FunctionTemplate.py in each folder of a product that needs to use it?
Is it *really* the case that you often want to method to be called directly via the Web *and* and from DTML? This doesn't seem right to me.
As I understand it, that's not the issue. Chris wants to receive the DTML namespace implicitly.
In any case, if you *just* want to get your function to be called from DTML (and your class is an extension class), you can give it the isDocTemp attribute like so:
class MyClass(.... include some extension class ...):
some_methodisDocTemp=1 def some_method(trueself, self, REQUEST, RESPONSE=None): ....
That's a good idea, I wish I'd thought of it. :-)
However, the new calling convention (__render_with_namespace__, or something like that) might break "isDocTemp" code.
I thought of that, but I don't think so. There are obviously enough people using the isDocTemp thing that we'll probably need to keep supporting it. The use of a separate render method won't be convenient for iplementing simple methods. Not that that is necessarily that critical.
Note that if you get called from the web, RESPONSE will not be none. This is a handy way to decide if you are called from the web or as a sub-template. Of course, someone could pass a non-None RESPONSE argument directly.
This convention is helpful but not at all documented, so products (ZWiki is a good example) often break this convention.
Which convention? The passing of arguments with names meaningful to the publisher is certainly well documented. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
Shane Hathaway wrote:
Jim Fulton wrote:
Note that if you get called from the web, RESPONSE will not be none. This is a handy way to decide if you are called from the web or as a sub-template. Of course, someone could pass a non-None RESPONSE argument directly.
This convention is helpful but not at all documented, so products (ZWiki is a good example) often break this convention.
Which convention? The passing of arguments with names meaningful to the publisher is certainly well documented.
No, I was referring to the convention of RESPONSE being passed only if ZPublisher is calling the method. It is not documented and often broken. Shane
Shane Hathaway wrote:
Jim Fulton wrote:
Shane Hathaway wrote:
Jim Fulton wrote:
Note that if you get called from the web, RESPONSE will not be none. This is a handy way to decide if you are called from the web or as a sub-template. Of course, someone could pass a non-None RESPONSE argument directly.
This convention is helpful but not at all documented, so products (ZWiki is a good example) often break this convention.
Which convention? The passing of arguments with names meaningful to the publisher is certainly well documented.
No, I was referring to the convention of RESPONSE being passed only if ZPublisher is calling the method. It is not documented and often broken.
The fact that ZPublisher will pass it is documented. Whether or not something else calls it is up to the something else. The method designer specified an interface that includes RESPONSE. If it requires RESPONSE, by not specifying a default, then it requires the clients to oass it. If the clients don't, then they are not satisfying the interface. Are you saying that objects that require that RESPONSE is passed are broken because they don't sufficiently advertise the fact? Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Jim Fulton wrote:
The fact that ZPublisher will pass it is documented. Whether or not something else calls it is up to the something else. The method designer specified an interface that includes RESPONSE. If it requires RESPONSE, by not specifying a default, then it requires the clients to oass it. If the clients don't, then they are not satisfying the interface. Are you saying that objects that require that RESPONSE is passed are broken because they don't sufficiently advertise the fact?
I'm saying that there are some methods which expect the RESPONSE to be passed only when called by ZPublisher. They expect RESPONSE to be "None" when called as a subtemplate or otherwise. The only problem is that this convention is not enforced. But we've strayed... :-) Shane
Toby Dickenson wrote:
<http://www.zope.org/Members/htrd/howto/FunctionTemplate>
you would use....
def a_method(self,md): do_stuff_with(md['param1'],md['param2']) a_method = FunctionTemplate(a_method)
Okay, spoke too soon... when I do the above and then call the method with: <dtml-var a_method> I get: Error type: exceptions.AttributeError Error value: __len__ Traceback (innermost last): File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 222, in publish_module File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 187, in publish File E:\Zope\2271B4~1.2\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: testdefiner) File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 171, in publish File E:\Zope\2271B4~1.2\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: index_html) File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: index_html) File E:\Zope\2271B4~1.2\lib\python\App\special_dtml.py, line 120, in __call__ (Object: index_html) (Info: E:\Zope\2.2.2\lib\python\Products\A_product\Form.dtml) File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLLocator.py, line 103, in __call__ (Object: index_html) File E:\Zope\2271B4~1.2\lib\python\DocumentTemplate\DT_String.py, line 528, in __call__ (Object: index_html) File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 288, in debug_render_blocks File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 286, in debug_render_blocks File E:\Zope\2271B4~1.2\lib\python\DocumentTemplate\DT_In.py, line 691, in renderwob (Object: _.range(1,11)) File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 288, in debug_render_blocks File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 286, in debug_render_blocks File E:\Zope\2271B4~1.2\lib\python\DocumentTemplate\DT_Let.py, line 147, in render (Object: row=sequence-item) File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 242, in debug_render_blocks File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 221, in debugException File E:\Zope\2.2.1\lib\python\Products\ZDebug\DTMLDebug.py, line 239, in debug_render_blocks File E:\Zope\2.2.2\lib\python\Products\A_product\FunctionTemplate.py, line 38, in __call__ AttributeError: (see above) What's going on? cheers, Chris
From: "Jim Fulton" <jim@digicool.com>
We are going to provide an alternate interface, so that if an object has a special method, then this will be called instead.
okay... which proposal/project is this in?
I don't remember. Evan?
PythonMethods, essentially, unless you'd really like me to make this a separate project. It's *such* a small change, tho. Cheers, Evan @ digicool & 4-am
Evan Simpson wrote:
PythonMethods, essentially, unless you'd really like me to make this a separate project. It's *such* a small change, tho.
No, not at all, just where I can find some docs for this specific bit would be more than sufficient :-) cheers, Chris
From: Chris Withers <fresh@bay-c.co.uk>
Evan Simpson wrote:
PythonMethods, essentially, unless you'd really like me to make this a separate project. It's *such* a small change, tho.
No, not at all, just where I can find some docs for this specific bit would be more than sufficient :-)
http://dev.zope.org/Wikis/DevSite/Projects/PythonMethods/NamespaceObjectInte... ...has the details, such as they are. Cheers, Evan @ digicool & 4-am
On Tue, 26 Sep 2000 16:11:50 +0100, Chris Withers <chrisw@nipltd.com> wrote:
So, if I give my product a class attribute of isDocTemp=1, what signature should I give my product's __call__ method so it picks up the DTML namespace?
Interestingly, Ive just put a HowTo that does this <http://www.zope.org/Members/htrd/howto/FunctionTemplate> This is a wrapper that that lets an old dtml file be replaced with a python function, without having to update all the old dtml files that call it. In other words, Internalized External Methods ;-) Why? Because Ive only just realized how error-prone non-trivial dtml can be. (and how ugly error-free dtml is) hth, Toby Dickenson tdickenson@geminidataloggers.com
participants (6)
-
Chris Withers -
Chris Withers -
Evan Simpson -
Jim Fulton -
Shane Hathaway -
Toby Dickenson