[Zope3-dev] Package organization quandry
Jim Fulton
jim@zope.com
Wed, 15 May 2002 16:09:56 -0400
Guido van Rossum wrote:
>
> > There's a tradeoff between moving things out of App to encourage
> > their use outside of the Zope application server and keeping the
> > dependencies between things outside of App to a minimum.
>
> One possible strategy is to avoid hard-coded dependencies and instead
> pass the necessary objects or classes in at construction time. I
> think TAL already uses this approach: there's a default execution
> engine that's pretty simple and uses nothing except core Python; to
> get the ZPT engine you instantiate and pass it explicitly. Maybe this
> idea can be extended?
This apporach doesn't work that well if there are a lot of clients of
the constructor. For example, users of PageTemplateFiles should be able
to:
index = PageTemplateFile('index.zpt')
If people effectively always have to:
index = PageTemplateFile('index.zpt', engine=ZopeEngine)
Then I think the extra argument is just a dead chicken
(meaningless sacrifice;). I'd as soon provide a constructor that
automated this. I could put this constructor in a separate package
in App. This is basically the option I'm considering.
The specialization involves more than just engine selection though.
For example, I have a class that specialized page templates to be
view methods, requiring changes in a number of methods and adding a
__get__.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org