[ZPatterns] Using ZPatterns not TTW

R. David Murray bitz@bitdance.com
Sun, 3 Jun 2001 18:46:56 -0400 (EDT)


I want to use ZPatterns in an app, but having used them TTW in my
last app, I really would like to avoid that and manage to have
an honest to goodness file system based Product to do my work in,
while still getting the advantage of the ZPatterns storage abstraction.
I find it *much* more convient to work that way than through the
web.  So I'm trying to instantiate ZPatterns stuff from a python
Product, and it's not going very well <wry grin>.

I tried modling my code on what Steve S. has in EMarket, but while
I get a Specialist, it seems to be subtly broken at the moment and
I can't figure out why.  Maybe my problem is with how Zope works
and not with how ZPatterns works, but at the moment it doesn't look
that way.  And I can't figure out why my code is giving different
results than Steve gets...although I am running it on 2.3.2 and
only instantiated EMarket under pre-2.3.2 zope.

My manage_add code is trying to instantiate an ObjectManager, and
to create an instance of a Specialist subclass inside that
Object Manager.  Here is what I think ought to do the trick:

def manage_addCRMSystem(self, id, title='', REQUEST=None):
        "Web callable"
        id = str(id)
        CRMSys = CRMSystem(id)
        CRMSys.title = title
        self._setObject(id,CRMSys)
        CustSp = Customers("Customers")
        CRMSys._setObject("Customers",CustSp)
        if REQUEST is None: return
        self.REQUEST.RESPONSE.redirect("%s/%s/manage" %\
                 (self.absolute_url(),id))

Everything gets created, but if I click on the 'Racks' or 'PataPlugins'
tabs inside the created Specialist, I end up with URLs that do *not*
have the ObjectManager in them.  The RacksGroup and ProviderGroup
seem to think that the Specialist is sitting in the root of the Zope
tree instead of inside the ObjectManager instance.

Am I doing something obvious wrong?  I tried various patterns of acquistion
wrapping, but nothing changed the behavior.

--RDM