[Zope] evaluating attribute values

John Eikenberry John Eikenberry <jae@kavi.com>
Thu, 4 Mar 1999 15:12:12 -0800 (PST)


On Thu, 4 Mar 1999, Robin Dunn wrote:

> Sorry, your ideas don't work either.
> 
> This time I get a NameError for mhost in the following code in
> SendMailtag.py.  mhost is never being created.
> 
> 
>         if self.mailhost:
>             mhost=md[self.mailhost]
>         elif self.smtphost:
>             mhost=MailBase()
>             mhost._init(localHost=gethostname(), smtpHost=self.smtphost,
>                         smtpPort=self.port)
> 
>         mhost.send(self.section(md.this, md), self.mailto, self.mailfrom,
>                    self.subject)

I think we're trying to assign a string where a mailhost object is needed.
I'm not sure how to get around this, without an external method. Though
with an external method, it'd be pretty simple:

(warning: untested)

def get_mailhost(self,property_name):
	""" gets the mailhost """

	mailhost_id = getattr(self,property_name)
	return getattr(self,mailhost_id)
	
Or something like this... [shrug]

---

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