Hi all, I'm having trouble getting DTML to format None values the way I want them. I have a database table with a bunch of string columns which may be NULL. They range in size from 2 characters to 256. I want to be able to edit them in a HTML form. The way I've been constructing this form is something like: <INPUT TYPE="TEXT" NAME="title" VALUE="<!--#var COURSE-->" MAXLENGTH=256 SIZE=20> <INPUT TYPE="TEXT" NAME="language" VALUE="<!--#var LANGUAGE null=""-->" MAXLENGTH=2 SIZE=2> and so on... The null="" argument to var doesn't get used unless I supply a fmt= argument _and_ that format string fails to format the value. The problem is that the representation I want is fmt="%s", and that formats a None value quite nicely. I can just hear Jim Fulton saying "this problem disappears using Missing.Value" but I don't want to have to integrate Missing.Value into the rest of the codebase we have. At the moment, I've patched the DT_Var.py render() method so it detects the null= argument regardless of the fmt= argument: *** DT_Var.py.old Fri Feb 26 11:19:49 1999 --- DT_Var.py Fri Feb 26 11:19:53 1999 *************** *** 269,274 **** --- 269,276 ---- val = special_formats[fmt](val, name, md) elif fmt=='': val='' else: val = fmt % val + elif have_arg('null') and val is None: + val = args['null'] # finally, pump it through the actual string format... fmt=self.fmt YMMV, Richard
[richard posts a patch to add handling of #var null tag, in the absence of a fmt tag] Talk about timing - I had hit exactly the same problem today, and was smacking my head against a wall. Can this minor patch please go into the next release? It clears up a small area of confusion (particularly since the docs don't warn that null only works if you have a fmt tag) Anthony.
On Fri, Feb 26, 1999 at 04:18:12PM +1100, Anthony Baxter wrote:
Talk about timing - I had hit exactly the same problem today, and was smacking my head against a wall. Can this minor patch please go into the next release? It clears up a small area of confusion (particularly since the docs don't warn that null only works if you have a fmt tag)
Ah, so *this* is why my pages weren't coming out right. :-) I'll patch my local copy of Zope, but it would be good to roll this into the next release. It shouldn't break any existing pages. Cheers, Eric
<!--#var LANGUAGE null=""--> I posted about this same problem a couple of weeks ago and got no response. Now I know what is going on! I got around it with the inelligant solution of: <!--#if LANGUAGE--><!--#var LANGUAGE--><!--#/if LANGUAGE--> Does your patch mean that I don't need a fmt= atribute? Are you using 1.9 or 1.10? Does 1.10 do the same thing? Should you send this to the collector? From the documentation I expected it to work without the fmt= atribute, therefore, it could be considered a bug, right? Phil. ----------------------------------------------------------- Philip Aylesworth mailto:purple@mnsi.net
[Philip Aylesworth]
Does your patch mean that I don't need a fmt= atribute?
Yes.
Are you using 1.9 or 1.10? Does 1.10 do the same thing?
My patch was against 1.10
Should you send this to the collector? From the documentation I expected it to work without the fmt= atribute, therefore, it could be considered a bug, right?
Yep, I've submitted a report to the Collector. Richard
participants (4)
-
Anthony Baxter -
Eric Kidd -
Philip Aylesworth -
richard.jones@fulcrum.com.au