evaluating attribute values
How can I evaluate a #var equivallent for setting a tag attribute value? For example, Zope doesn't like this: <!--#sendmail smtphost=<!--#var smtpHost--> --> or this: <!--#sendmail smtphost=smtpHost--> (it tries to use smtpHost as the host name, instead of its value) Help! -- Robin Dunn robin@AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! Try http://AllDunn.com/laughworks/ for a good laugh.
On Thu, 4 Mar 1999, Robin Dunn wrote:
For example, Zope doesn't like this:
<!--#sendmail smtphost=<!--#var smtpHost--> -->
or this:
<!--#sendmail smtphost=smtpHost-->
(it tries to use smtpHost as the host name, instead of its value)
Try: <!--#sendmail "smtphost=smtpHost"--> or this: <!--#sendmail "smtphost=_['smtpHost']"--> --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
Ok, what's the trick to getting special characters to be converted to their escape codes (eg. " to "). This is particularly important for forms in which the user may enter these types of character. For instance, if I create a property on a folder that is a string, and if the string I enter has quotes around it... it doesn't show in the interface the next time I go to edit the properties. For example, in MCExam, the 2nd sample question has this as an answer "bar, spam". If I go to the folder's properties to change it, it doesn't show up. In the source it looks like: <input type="text" name="ans3:string" size="35" value=""bar, spam""> Obviously, if I then save changes, the value is gone altogether. Is there a way of automatically converting quotes and other special characters to their escape codes (like the sqlquote method)? Thanks, --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
it looks like:
<input type="text" name="ans3:string" size="35" value=""bar, spam"">
Obviously, if I then save changes, the value is gone altogether.
Is there a way of automatically converting quotes and other special characters to their escape codes (like the sqlquote method)?
Grovelling through the source I find something called html_quote in lib/python/DocumentTemplate/DT_Util.py, so I tried: <!--#var nastyvar html_quote--> Which seems to so the right thing in the generated source. I'm not sure how to get at the equivalent method call, though. Does that help? (p.s. there's url_quote, as well) -- Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> NSBRI Research Scientist/Programmer Computer and Information Technology Institute Rice University, 6100 S. Main St., Houston, TX 77005
On Thu, 4 Mar 1999, Ross J. Reedstrom wrote:
Grovelling through the source I find something called html_quote in lib/python/DocumentTemplate/DT_Util.py, so I tried:
<!--#var nastyvar html_quote-->
Which seems to so the right thing in the generated source. I'm not sure how to get at the equivalent method call, though.
Does that help?
Yes. This is just what I was looking for. This leads to a followup question/request for the group. 'manage_addProperty' calls various converters from ZPublisher.Converters to format the properties values. Shouldn't html_quote be used when formatting strings and text? This would be trivial to change. Would this cause some problem I don't realize? If not, I'd like to add this to the Collector for the next version. --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
At 00:24 05/03/99 , John Eikenberry wrote:
'manage_addProperty' calls various converters from ZPublisher.Converters to format the properties values. Shouldn't html_quote be used when formatting strings and text? This would be trivial to change. Would this cause some problem I don't realize? If not, I'd like to add this to the Collector for the next version.
Yes, because you sometimes (most of the time, really), want to have the raw input from the user. If you then use this raw input in HTML again, only *then* should you quote out any HTML. Besides, what if I want the data to be URL quoted? Or SQL quoted? -- M.J. Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
On Fri, 5 Mar 1999, Martijn Pieters wrote:
At 00:24 05/03/99 , John Eikenberry wrote:
'manage_addProperty' calls various converters from ZPublisher.Converters to format the properties values. Shouldn't html_quote be used when formatting strings and text? This would be trivial to change. Would this cause some problem I don't realize? If not, I'd like to add this to the Collector for the next version.
Yes, because you sometimes (most of the time, really), want to have the raw input from the user. If you then use this raw input in HTML again, only *then* should you quote out any HTML. Besides, what if I want the data to be URL quoted? Or SQL quoted?
Yeah, I already figured out that the problem was actually in the OFS/properties.dtml file (I moved over to the zope-dev list, as I realized this thread really belongs there). In properties.dtml the 'string' type is listed twice: <!--#if "type in ('string', 'int', 'long', 'float', 'date')"--> <input type="text" name="<!--#var id-->:<!--#var type-->" size="35" value="<!--#var "_[id]"-->"> <!--#elif "type=='string'"--> <input type="text" name="<!--#var id-->:string" size="35" value="<!--#var "_[id]" html_quote-->"> 'string' needs to be removed from that first list. I'll be submitting this to the Collector. --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
At 22:24 04/03/99 , Robin Dunn wrote:
How can I evaluate a #var equivallent for setting a tag attribute value?
For example, Zope doesn't like this:
<!--#sendmail smtphost=<!--#var smtpHost--> -->
or this:
<!--#sendmail smtphost=smtpHost-->
(it tries to use smtpHost as the host name, instead of its value)
Help!
Why not use a MailHost Object? On that object you can then set the appropriate SMTP Host, even from DTML code.. -- M.J. Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (4)
-
John Eikenberry -
Martijn Pieters -
reedstrmļ¼ wallace.ece.rice.edu -
Robin Dunn