[Zope] Acquisition and/or Traversal [correction]

D2 borelan@wanadoo.fr
Thu, 30 Jan 2003 18:41:17 -0400


Thanks for the links, i had read the DevGuide when i began with Zope,=20
but found it esoteric at that time.
My knowledge evolving, it's easier to read

What i understood,
Containment: the objects' house and the path to the object from the root
context: the road used to reach the object.
A property will be searched first in the object's containment, then in=20
its parents ones, to the root. If the containment-search failed, the=20
search will be made in the context.
The context may be searched by using basic acquisition or by calling=20
methods on wrappers (aq_inner, aq_chain, aq_parent, _of_, etc. .

My example company will be a mix of containment and context design.

Company/
	Headquarters/
	Subsidiary 1/
		   |
		to n /(HQ and Sub will be called departments)
	Products/
		- Items
		    Property 'related_to' (the HQ or a Sub)
		    Property 'belongs_to' (the id of HQ or the Sub which
  				           sells the product)
	Proposals/
		- Items
		    Property 'related_to' (the HQ or a Sub)
		    Property 'belongs_to' (the id of HQ or the Sub
  				           editing the proposal)

	- addMethod
	- listMethod

When i want to add a product or a Proposal i use :
Company/<Department_id>/<Products_or_Proposals/addMethod : the object=20
will inherit of the department properties but will be stored in=20
<Products_or_Proposals> that will be the context.
Departements will be one of the aq_parent of the object.

When i want to list all Products or Proposals i use
Company/Products_or_Proposals/listMethod

for a specific Subsidiary i use
Company/<department_id>/Products_or_Proposals/listMethod
as i need to have the sub's specific Products + the HQ's Products, i=20
test the 'related_to' and 'belongs_to' properties.

Not too stupid ?

Andre

Dylan Reinhardt a =E9crit:
> One quick correction...
>=20
> At 06:51 AM 1/29/2003, D2 wrote:
>=20
>> in context._setObject() context *is* containment ?
>=20
>=20
> I didn't read this question correctly before and gave an unhelpful=20
> answer.  The context object contains, among other things, a reference t=
o=20
> your current container object.
>=20
> Using container-related methods on context (the object) has the effect=20
> of applying them to a specific container object... which container=20
> object that is will be determined by context (as in the environment, no=
t=20
> the context object).
>=20
> Using container methods on the context object allows you to generalize=20
> your code, but it's the same thing as if you hard-coded a folder name=20
> and applied the same methods to it: any objects you create using this=20
> technique will have a containment relationship with a specific=20
> container.  Which container that is can be determined by context if you=
=20
> wish.
>=20
> Sorry if that's pretty jargon-dense... it's a trickier question than I=20
> realized at first.
>=20
> Dylan
>=20
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>=20