[Zope3-dev] mini howto and discussion: Zope 2 and Zope 3

Gary Poster gary at zope.com
Thu Apr 1 08:32:30 EST 2004


(this is not an april fool's :-)

tav wrote (hey tav) me an email asking about the Zope 2/Zope 3 
integration stuff we have.  I'm swamped, especially this week, but I 
(and ZC) have wanted to get this out, so here's a big chunk of info. 
It's a start, at least.

I'll give an overview of what you need to do to get started, what we
haven't released yet, and why IMO you shouldn't mess with this except as
a curiosity yet.

1) what you need to get started

get zope3 (we're on a march-5-2004 tag because we haven't caught up with
the most recent big changes yet, but the head will probably work for
what I'm describing now), Zope2 (we're using 2.7.0 final
or--temporarily--the 2.7 beta 3, depending on other stuff), and the
Interface package (HEAD; this is Packages3/Interface in the zope
repository) .

Using your favorite method--site-packages, python path, whatever--make
sure that the new Interface package will be found before the one
in Zope 2.  We typically put the Interface package in our Zope's 
Python's site-packages...I forget why.  Then we make the PYTHONPATH load 
  Zope 2 (and, importantly Zope 2's ZODB...or another Zope 2-compatible 
ZODB is fine), and *then* Zope 3 (so we're masking Zope 3's ZODB 
package.  This works on Windows too, btw--Zope 2's "Zope" package does 
not mask Zope 3's "zope" package even though Windows is not 
case-sensitive because Python compensates for this OS error ;-)

You'll need a custom site.zcml so that, for instance, you don't have two
publishers duking it out.  I've attached the important guts of ours so
you can see what we're doing with it.  (by the way, I think this is an
interesting validation of Jim's general goal for zcml and Zope 3
configuration--we're only getting what we need, mostly :-).

Finally, you need something in Zope 2 that fires the Zope 3 zcml stuff.
We just have a product that all Zope 3-based things have to import.
In the __init__.py of the base product, we call out to a utility 
function that does, essentially, this::

   from zope.configuration.xmlconfig import XMLConfig
   site_zcml = "..." # location of your site.zcml.  We actually
   # put this in an environment variable and snarf it up here.
   XMLConfig(site_zcml)()

Now you're getting started. :-)

2) what we haven't released yet

we have other software that runs with this basic configuration, making
widgets work, making it possible to add Zope 3-generated content through
the CMF, and so on.  When I or someone else who knows this stuff has a
chance to breathe, maybe we'll start figuring out what we can release.
Right now we're paddling too hard on our customer engagements.

This includes a portal_add tool that is a Zope 3 IAdding and a Zope 2
tool; about the most basic Zope 2 -> Zope 3 request adapter that works;
a very simple Zope 3 view object that lives in the skins tool and is
sugar for allowing rendered Zope 3 content to be inserted into Zope 2
templates as structure; a whole buncha buncha widgets and a few usages
of the cool widget framework Fred checked in to the Zope 3 core way back
when; a Zope 2/CMF-friendly zcml type directive that includes info for
both CMF types and Zope 3 forms; a new and improved variant of the Zope
3 form machinery (really want to propose this to Zope 3 if I ever get 
the time); a CMF typeinfo object that uses the zcml-based info; and 
various other helpers and glue for the task.  For instance, Zope 3 
widgets expect the publisher to spit up unicode.  Zope 2 doesn't do 
that.  We currently have the quick fix of declaring new widgets for Text 
fields that convert string input to unicode output.  There probably is a 
better solution, but we didn't need it for now.

Some of this might be proprietary; most or all of it is simply 
unreleased (and, if released, would only be supported for our paying 
customers, for now...read on :-).

3) why IMO you shouldn't mess with this right now

This isn't going to be supported externally until Zope 2.8/2.9.
Instead, it is an evolutionary step helping us understand what Zope
2/Zope 3 integration will become, and letting us use the technology
fruitfully in the meanwhile.

Jim has a mission to get Zope 3 technology working with Zope 2.  That's
part of what the Zope HEAD (to be Zope 2.8) is about--letting Zope 3 and
Zope 2 use the same ZODB and thus coexist more easily and profitably.
This will change our usage of Zope 3.  Then Jim has plans to
release a Zope 2 (2.9) that *officially* has support for some of the
Zope 3 features.

This may or may not build off of what we have so far here; either way, I
am confident that the new version of this will be superior to what we
have right now.  We'll have Jim's guidance and our experience with the
current usage.  Then we'll all have the shared community/ZC effort
combining Zope 3 and Zope 2 that we are all hoping for.  We'll
internally support migration from our current work, but not externally.

If you have the appetite for this sort of migration also, then jump on
in, but be aware of what you're in for. :-)

So that's it.  Feel free to ask questions.  I probably won't have the 
time to answer much more till next week though.

Gary

-------------- next part --------------
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>

<!-- set up what we minimally need for our particular Zope 3 use -->

<include package="zope.configuration" file="meta.zcml" />
<include package="zope.app.publisher.browser" file="meta.zcml" />
<include package="zope.app.browser.form" file="meta.zcml" />
<include package="zope.app.component" file="meta.zcml" />
<include package="zope.app.event" file="meta.zcml" />
<include package="zope.app.schema" file="meta.zcml" />
<include package="zope.app.i18n" file="meta.zcml" />
<include package="zope.app.component" />
<include package="zope.app.browser.form" />
<include package="zope.app.browser.exception" />
<include package="zope.app.i18n" />
<include package="zope.app.event" />

<adapter for="*"
  factory="zope.app.traversing.adapters.Traverser"
  provides="zope.app.interfaces.traversing.ITraverser"
  />

<adapter for="*"
  factory="zope.app.traversing.adapters.DefaultTraversable"
  provides="zope.app.interfaces.traversing.ITraversable" />

</zopeConfigure>




More information about the Zope3-dev mailing list