smpthost or dtml tag problems
Dear All, I do not know what I am doing wrong here. when I executed the below codes it gives the error below for both true and false conditions, but when i change the line 1 to <dtml-if "email "> it stop giving the error but allow user sending without entering email address. <dtml-if "email and '@' in email"> <dtml-sendmail smtphost="mail.domain.com"> To: <advert@domain.com> From: <<dtml-var email>> cc: <kamal@dv.net> Subject: Advert Placement Name: <dtml-var fullnames> Company Name: <dtml-var company> </dtml-sendmail> <dtml-else> <P>Please complete all of the required fields.<br> The following fields are missing:</P> <dtml-comment> Display the emtpy fields. Repeat the <dtml-if "requiredfieldname ==''">....</dtml-if> for each field you want to display. </dtml-comment> <dtml-if "email == ''"> E-mail address</p> </dtml-if> </dtml-if> An error was encountered while publishing this resource. TypeError Sorry, a site error occurred. Traceback (innermost last): * Module ZPublisher.Publish, line 150, in publish_module * Module ZPublisher.Publish, line 114, in publish * Module Zope.App.startup, line 182, in zpublisher_exception_hook * Module ZPublisher.Publish, line 98, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module OFS.DTMLMethod, line 126, in __call__ * Module DocumentTemplate.DT_String, line 474, in __call__ * Module OFS.DTMLMethod, line 119, in __call__ * Module DocumentTemplate.DT_String, line 474, in __call__ * Module OFS.DTMLMethod, line 119, in __call__ * Module DocumentTemplate.DT_String, line 474, in __call__ * Module DocumentTemplate.DT_Util, line 201, in eval * __traceback_info__: email * Module <string>, line 2, in f * Module OFS.ObjectManager, line 645, in __getitem__ * Module OFS.ObjectManager, line 237, in _getOb TypeError: unsliceable object (Also, an error occurred while attempting to render the standard error message.
Hamzat Kamal wrote:
<dtml-if "email and '@' in email">
try: <dtml-if "email and ('@' in email)">
<dtml-if "email == ''"> E-mail address</p> </dtml-if>
Yuk, this doesn't match your test above... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Hamzat Kamal wrote:
<dtml-if "email and '@' in email">
try:
<dtml-if "email and ('@' in email)">
<dtml-if "email == ''"> E-mail address</p> </dtml-if>
Yuk, this doesn't match your test above...
I can't remember the original question, but if it was something like: "I want to check that the user has entered an email address (via a form) and that the email address contains the '@' character" then this should work: <dtml-if "REQUEST.has_key('email') and ('@' in REQUEST.get('email', ''))"> Email OK <dtml-else> Email Not Good </dtml-if> Jonathan
participants (3)
-
Chris Withers -
Hamzat Kamal -
Jonathan Hobbs