[Zope] Implementing class factory via ZClass or External Method

Sean Winstead seanw@surehand.com
Sun, 18 May 2003 08:02:24 -0400


Hi,

In our Zope installation, I have implemented support for PayPal IPN via a
Python Script.
Now I am trying to reorganize the code so that we can support multiple
payment
processors.

I want to implement one PaymentHandler class per payment processor and have
a factory
class that provides an instance of PaymentHandler depending upon the
parameters
submitted with the payment processor's request to Zope.

However, I am having trouble determining how to implement this in Zope. I'm
not sure
if I should use a Zope Product/ZClass or if I should implement this via an
external
method.

Regarding the former, is it true that an "instance" variable always refers
to a
variable tied to the particular instance of that product within a Zope
folder?
Can an instance variable be specific to the request that is being processed?
For example, can the code parse a "customer ID" variable out of the request
sent to
Zope and retain that customer ID only for the duration of the request?

Regarding the external method approach, I reorganized our code into an
external
method that instantiates a factory class. The factory class then creates an
instance of the class appropriate to the request being processed. The
external
method called by Zope and the factory class are contained in the same
module.
The processor-specific class is contained in a separate module that is
imported
by the external method module containing the factory class.

When the factory attempts to instantiate the processor-specific class, the
following error is returned:

NameError.  global name 'payPalIPNHandler' is not defined.

I have verified that class payPalIPNHandler does exist and that the
case-sensitivity
of the letters in the name are correct.

Any advice or shedding of light will be appreciated.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.481 / Virus Database: 277 - Release Date: 5/13/2003