[Zope-CMF] Creation of a new product to cmf

Kent Polk kent@goathill.org
13 Jun 2001 16:30:48 GMT


On 13 Jun 2001 04:35:00 -0500, Gitte Wange wrote:
> Hello,
> 
> For the past month I have been creating a new product that runs inside a CMF 
> Site.
> But this product isn't so great - yet :-)
> I has been created from a lot of dtml docs and methods and .. well it's not a 
> product in the matter that a real portal product would be.
> 
> So I am working on rewriting it.
> I follow the basics of the PortalPoll product guide but ...
> 
> I was wondering if the following is possible:
> I want to "attach" a MySQL connection to the product that you select when you 
> install the product. And insted of giving my ZClass a property sheet I want 
> to use the "properties" from the database.
> 
> Is this at all posible and if so - how ?

Yes. It is possible, though you have several potential chicken-or-egg
problems regarding your SQL connections and methods that have to
be dealt with before you attempt to instantiate a SQL-based Item
and deal with its properties.

Are for the properties, if you make sure you have an SQL connection
or SQL methods which are available, you can simply call those
methods to deal with the properties. You could also use ZPatterns
for this, but it is likely overkill.

A couple of ways to deal with selecting a connection are:

1) create a folder with a pre-determined id. Place the sql methods
and their dtml counterparts in there and call the folder property
methods directly from your item's internal methods. A bit brittle,
such as if the id of your SQL folder changes.

2) Use something like a folderish proxy. You can instantiate a
proxy, fill it with SQL/dtml methods. When you instantiate an item
(proxy client), the client can find the proxy by meta_type or such
and directly call the proxy's methods. This way, if the proxy id
is changed, the clients can likely still locate it, or you can
provide a selector to locate other proxies, but you start running
into chcken-or-egg problems with more than one proxy of the same
meta-type.

I wrote a Table proxy/client to test some of this stuff for some
products that I am working on. It works pretty good, but I have to
wrap dtml calls to the proxy in a dtml-with because I can't figure
out how to properly determine the namespace for dtml otherwise. If
I could figure that out, this would work quite cleanly. Note that
I mainly wrote the Table product as a proof of principle and it's
not terribly useful except for ideas.

One other advantage of the proxy is that it makes retrieving data
via SQL for the different Items much easier. You can map properties
and acquired object names to SQL queries and easily build your new
documents. My CMF Table product uses skins to query and view the
table data that corresponds to the item (also can create tables
and add table data from a csv file, etc).

Right now, I just use properties stored in the ZDB for my items
and don't store properties in the SQLdb, but it wouldn't be terribly
hard to add this. Mainly setting up a generic column db table which
maps property keys to items with the item id as the table key or
such, so the properties don't have to be defined in the db table.