On Thu, 28 Jun 2001 22:42:13 +0200 (CEST)
Dieter Maurer <[EMAIL PROTECTED]> wrote:

> 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.

    True, but you already found a possible answer:

> Your example seems to suggests, that you would like
> the tag to be omitted, when the expression
> raise a NameError.
> But, in fact, it is not clear whether this is anticipated
> by "optional" or a serious problem (maybe deep in the
> expression) that should be reported.

    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?

Yves-Eric Martin

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

Reply via email to