Domains are used by listbox in report and domain mode, in these mode, a tree is display on the left of the listbox to let the user perform a selection. You can either define domains using categories or base domains objects.

The use of base domain objects is based on domain generator, this permits the dynamic generation of domain and thus any possible combination.

How to define a base domain

Just go to portal_domains and add a base domain object, give it an explicit id and specify a python script into the field Domain Generator.

What does the domain generator script do

This script is called for each level in the tree that will be displayed to the user, it must return a list of domains for a given depth.

The domain generator script takes two arguments, the depth into the tree and the parent object. Based on this parameter it must generate a list of temporary domains.

Here is an example:

   1 ##parameters=depth, parent, **kw
   2 from Products.ERP5Type.Document import newTempDomain
   3 domain_list=[]
   4 if depth == 1:
   5   domain = parent.generateTempDomain(id="new_id")
   6   domain.edit(title="Title", membership_criterion_base_category=('a_category',),\
   7                              membership_criterion_category=('a_category/value',),\
   8                              domain_generator_method_id=script.id)
   9   domain_list.append(domain)
  10 else:
  11   ...
  12 return domain_list

Note that you always have to register the domain_generator_method_id attribute on new temporary domain in order to make them work

How to use these domain into listbox

Just add the base domain id into the Domain Tree or Report Tree field

More info on domain and domain selection can be find here

HowToUseDomainGenerator (last edited 2008-01-03 13:48:04 by localhost)