Yves-Eric Martin writes:
> > I expect that "dtml-sqltest" does not support the "expr"
> > attribute due to its "optional".
> > It is not easy to define the semantics of "optional" for
> > arbitrary expressions.
> To overcome that problem, I think it would make sense to treat the
> "optional" like this: when the expression raises a NameError, if the
> variable name that caused the error is an expected argument of the
> ZSQLMethod, then this argument was not provided, so do not render the
> sqltest tag. Otherwise, we have a real error. In a pythonish algorithm,
> that would look like this:
> renderedExpr = eval(expr)
> except NameError, varName:
> if varName in ZSQLMethodArguments:
> # "optional" behavior for missing variable
> # We have a real error
> raise NameError, varName
> # render sqltest tag
> Do you think that makes sense?
If I were a purist, I would answer: no.
The name error could come from a nested call that incidentally
uses the same name for a variable as a request argument.
If I were a Zope maintainer, I would answer: no.
The feature is rarely used and if it is, there is
a way to do it with existing DTML means:
As you demonstrated:
does work, although it is not really nice -- but not too bad, either.
If I would need this feature extensively, I would privately
enhance Zope as necessary. I learned yesterday, how to
use "cvs import/checkout/update" to keep such private enhancements
across Zope upgrades.
But your point was: The feature is used in the Zope book,
thus, apparently, it was useful. The question:
"why not implement the feature rather than change the book".
Maybe, DC says something about this....
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -