|
From: Sinang, D. <D.S...@sp...> - 2006-04-28 16:23:43
|
Thanks for the detailed explanation Daniele.
I was supposed to ask a whole bunch of questions on how to
programmatically add properties, but the Zope Book answered them all.=20
My instance-creation code now looks like this :
wf =3D context.mywf
=20
instance_id =3D wf.addInstance( process_id=3D'mypr',
customer=3D'myCustomer-4', comments=3D'myComments', title=3D'myTitle',
activation=3D1)
wf.getInstance(instance_id).manage_addProperty('jobname', 'ABC12345',
'string')
This is coming out to be really cool !!! :)
-----Original Message-----
From: Daniele Tarini [mailto:d.t...@ic...]
Sent: Friday, April 28, 2006 4:44 PM
To: Sinang, Danny
Cc: ope...@li...
Subject: Re: [Openflow-dev] Adding columns
Correct.
Figure out what goes in the workitem and what goes in the instance
(ie:job), keeping in mind that workitems can (and do) aquire attributes
from their containing instances (jobs): if an instance has an attribute
"jobname", all its workitems will be able to access it.
My only concern is that adding attributes during the object __init__
will make all your workitems and instances have those additional
attributes, since the share the __init__ code. This is fine if you have
just one process, but in case you have multiple processes you probably
won't like sharing process A attributes with process B attributes on the
same instance.
Two approaches to tackle the issue are:
1) using properties to add values to your instances where needed. Using
properties has a few nice effects:
- you can add/change/remove properties from a PropertyManager object
(like the instance) during runtime, as you see fit
- a property is handled as a real attribute of the object
- properties, as attributes, are correctly cataloged by the catalog
- properties can be monitored through ZMI, accessing the 'Properties'
tab of the instance object.
An instance, inheriting from Folder, is already PropertyManager. If you
want a workitem to use properties as well (it never happened to me),
you'll have to make it PropertyManager in the code.
2) the cvs version of OpenFlow can create instances through factories.
Each process has its own factory creating its own instance object. This
way you can have process A create instances of kind A with their own
attributes and methods, while process B creates instances of kind B with
other attributes and methods. This is a bit advanced use of OpenFlow,
and requires a good knowledge of the Zope/OpenFlow python code base. But
it's very rewarding, flexible and efficient.
Cheers,
Daniele
Sinang, Danny wrote:
> Please disregard my previous question. What I really meant was ...
>=20
> How do I make each workitem / job remember additional info ?
>=20
> For example, aside from a title, id, comments, and actor, I also want
> to track the jobnumber and date due.
>=20
> From what I see in the instance.py , it looks like I only need to add
> parameters to the __init__ and addInstance methods, and add some lines
> like :
>=20
> self.jobname =3D jobname
> self.dateDue =3D dateDue
>=20
> Is this correct ?
>
> ----------------------------------------------------------------------
> --
> *From:* ope...@li...
> [mailto:ope...@li...] *On Behalf Of
> *Sinang, Danny
> *Sent:* Friday, April 28, 2006 10:49 AM
> *To:* ope...@li...
> *Subject:* [Openflow-dev] Adding columns
>
> Dear All,
>=20
> I'd like to add columns to my OpenFlow Catalog.
>=20
> Do I need to edit /ZOPE/Products/OpenFlow/openflow.py or can I just
> add them via the Metadata page on the ZMI ?
>=20
> - Danny
>=20
>=20
--
Ing. Daniele Tarini - Research & Development - Icube S.r.l.
Address: Via Ridolfi 15 - 56124 Pisa (PI), Italy
E-mail: d.t...@ic... Web: http://www.icube.it
Phone: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588
|