[Zope] The XML-dtml notation "&dtml-variable;"
Andrew
andrew@apl-software.com
4 Nov 1999 19:05:36 -0000
Christopher Petrilli <petrilli@digicool.com> said:
> On 11/4/99 10:57 AM, Andrew at andrew@eventera.com wrote:
>
> >
> > How is this different from the following?
> >
> > <dtml-var foo null="default-value">
>
> Null is different than missing :-) Missing is the existence of the variable
> at all, Null is that it's "empty".
Oooohhhhhh! That is a GREAT idea. Here is a patch.
Drew
*** DT_Var.py Thu Nov 04 14:00:22 1999
--- DT_Var.py.save Thu Nov 04 13:34:48 1999
***************
*** 212,218 ****
capitalize=1, spacify=1, null='', fmt='s',
size=0, etc='...', thousands_commas=1,
html_quote=1, url_quote=1, sql_quote=1,
! newline_to_br=1, default='')
self.args=args
self.modifiers=tuple(
--- 212,218 ----
capitalize=1, spacify=1, null='', fmt='s',
size=0, etc='...', thousands_commas=1,
html_quote=1, url_quote=1, sql_quote=1,
! newline_to_br=1)
self.args=args
self.modifiers=tuple(
***************
*** 234,253 ****
def render(self, md):
name=self.__name__
val=self.expr
! args=self.args
! have_arg=args.has_key
!
! if val is None:
! try:
! val = md[name]
! except KeyError:
! if have_arg('default'):
! return args['default']
! else:
! raise KeyError
else:
val=val.eval(md)
!
__traceback_info__=name, val, args
--- 234,246 ----
def render(self, md):
name=self.__name__
val=self.expr
! if val is None:
! val = md[name]
else:
val=val.eval(md)
!
! args=self.args
! have_arg=args.has_key
__traceback_info__=name, val, args