[Zope3-dev] Stylistic question about using adapters
Jim Washington
jwashin at vt.edu
Fri Jan 21 10:15:29 EST 2005
Florent Guillaume wrote:
> [reposting here as it seems nobody reads zope3-users]
>
> I'm wondering if using adapters is the best way to do the following:
>
> I have a MailBox class that holds central information, and it contains
> instances of MailFolder that themselve contain MailMessage. From the
> code of a MailMessage, I need to get some config parameters from the
> mailbox. So somewhere I have a function that goes up the containment
> hierarchy to find an IMailBox (I'd rather not make it a method of
> MailMessage because it's really got to do with the containment hierarchy
> and not the behavior of the message itself).
>
> Is it best to leave this function standalone and call it directly, or is
> it better somehow to make it into an adapter from IMailMessage to
> IMailBox ? I'm not really "adapting" here, I'm returning a completely
> different object, so I have philosophical problems...
>
> What do you think is best ?
>
> Thanks,
> Florent
>
How about an interface, e.g., IMailMessageContained,
which would have a method
getMailBoxParams()
then adapt IMailMessage to IMailMessageContained
The adapter would then do all the necessary zapi.getParent(), etc., stuff.
I'm new to this, too, but since it's philosophy, I can't be entirely wrong.
-Jim Washington
More information about the Zope3-dev
mailing list