[Zope3-dev] Comments on Tutorial step1

Jim Fulton jim@zope.com
Mon, 11 Mar 2002 19:06:49 -0500


"R. David Murray" wrote:
> 
> In reading step 1 of the PythonProgrammersTutorial, the following
> questions occured to me.  Because I haven't quite gotten a working
> Z3 on FreeBSD yet, I haven't tried to actually run the step1
> code yet.  Perhaps some of my questions would be answered by
> experimentation, but perhaps someone will want to address the
> questions in the tutorial even if that's true <grin>.
> 
> o Is INSTANCE_HOME supported?

Not sure what you mean by this. The environment variable isn't used
any more. The notion of an INSTANCE_HOME is still useful. Note that
SOFTWARE_HOME is no longer interesting. All you should need is
a PYTHONPATH variable.

> o In the example of creating an instance of Contact, '.Contact' is
> used.  Given the previous discussion I would expect this to resolve
> to "Zope.Products.Contact", not "Zope.Contact.Contact".  Some
> additional verbiage to explain this would probably be a good idea.

The README.txt files are out of date. :(

The slides (in slides.sdd.gz) are authoratative.

.Contact. expands to ZopeProducts.Contact.Contact.Contact
 
> o "A different identifier could have been provided in the
> zmi:provideClass' directive.  Example of doing this? 

That was science fiction. We need support for doing this, 
probably via a factory_id attribute.

> Or are the
> other attributes of provideClass documented somewhere?
> 
> o What would it mean to provide a different identifier?  If I named
> it "MyContact", would I then use 'MyContact' (note, no dots) in
> createObject?

You might provide a different identifier if you expected to 
plug in alternate factory implementations. In this case, I'd
probably use the dotted name of the interface of the objects
I expected the factory to create.
 
> o If the provideClass causes a "factory component [to be] created
> and registered", and the first arg of createObject controls where
> the factory components are looked for, how does one control where
> the factory component gets created? 

There is no where. In Zope 3, instantiation and placing (adding)
are separate opperations.

> Are we just talking about
> the Module hierarchy here, and ob is Module?  (That doesn't seem
> likely).

No, ob is the location in the object system (e.g. a folder)
where the factory should be looked for. When you call createObject, 
createObject will look for the closest factory service to ob
and ask it for a factory with the given id.
 
> o If you just want the "first" factory to be used (whatever
> that means), can you specify None for ob?

Specifying None for ob would cause the *last*, factory to be used.
The first factory is the factory closest to you. Specifying None would
look for a globally defined factory.
 
> o The sample products.zcml entry has file="Contact.zcml".  Would
> the example be better if it were file="Contacts/Contacts.zcml"?
> I'm thinking that it is probably *not* desirable to have a .zcml
> file for every component in the top level Zope3 directory, but that
> these files would instead typically be in the module directory for
> the component.  This would be doubly true for Product components.
> If there's a reason for putting them all in the root, that should
> be discussed.

In the slides it:

<include package=".Contact" file="Contact.zcml" />

This causes the file to be looked for in the directory of the
ZopeProducts.Contact package.
 
> o Speaking of location, if this PythonProgrammersTutorial is intended
> as the beginning of the "end user developer" documentation (as
> opposed to developer-ofZope3 documentation), which is my impression
> of it's target audience, would it be better for the example component
> to be placed in the Products directory?

There is no Products directory in Zope3. :)

There is a ZopeProducts *package*. The Contacts package will be a sub-package
of that. My intention is that, eventually, there can be many ZopeProducts
directories in the Python path and that they will be knit together to form
one package.

 
> o The tutorial tells you to install the products.zcml file (or edit
> the existing one).  It does not tell you to create a Contact
> directory under Zope and put the Contact.py and __init__.py file
> there, but unless I missed something (I haven't been able to try
> it yet) that step is also necessary.

The slides tell you to make the Contacts package a sub-package of the
ZopeProducts package. :)

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