On Thursday 11 October 2001 07:29 am, you wrote:
I've been asked too many times now by developers what is wrong when they call ZSQL Methods without passing parameters because their parameters are in the namespace. This seems to make sense to all new Zopers (and some older ones like myself) because all other DTML lookups are in the entire namespace.
You can do this now by passing the namespace as an argument to the ZSQL method: <dtml-call expr="ZSQLMethod(_)"> Which works because ZSQL methods expect their first positionak argument to be a mapping object. If it is omitted, it uses REQUEST. Granted this is not the prettiest, but DTML isn't known for it asthetics 8^)
Anyway, I propose that ZSQLMethods change and do variable lookups in the entire namespace, not just the REQUEST object. It seems to be a simple enough change (at least it looks it) and I can submit the patches, but the harder thing is to get people to agree that it is a change for the better.
Yes this would be a simple change. And it would break nearly every existing Zope application that uses ZSQL methods. Think of how many people use "id" as a field name in their tables...
The only argument that I have heard against it is that variables will be found mysteriously through the stack and that this is harder to understand. However, that just makes it inconsistent with all other DTML and therefore mysterious in its own way.
Actually this behavior has a parallel. ZCatalogs work the same way. By default they only check the REQUEST object for search arguments. That's not to say I like it. It makes necessary one of the most lothesome DTML statements: <dtml-call expr="REQUEST.set('foo',bar)">
Consistency is much better for learning and for remembering, and DTML in ZSQL should work the same as DTML in DTML Methods, etc. Please consider this and abuse me as appropriate ;)
Regards, Tim
I agree with you in principle, but I think that calling stuff from DTML will never be made intuitive. I do think much of the time (although certainly not all) ZSQL arguments are coming from REQUEST. So, assuming this is patched, it would necessitate things like: <dtml-with name="REQUEST"><dtml-call name="ZSQLMethod"></dtml-with> or <dtml-call expr="ZSQLMethod(REQUEST)"> for the majority of cases to make sure things come from REQUEST. This I think just trades one work-around for another... Actually I think calling DTML from DTML sucks rocks <dtml-call expr="DTMLMethod(_.None,_)"> anyone? /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/