diff --git a/product/ERP5/Document/Domain.py b/product/ERP5/Document/Domain.py index 3ef7ed1e34863de090324752ac5d3dae23ed374a..5e9a22071dd3c64009339d66914ff4a351d9128d 100755 --- a/product/ERP5/Document/Domain.py +++ b/product/ERP5/Document/Domain.py @@ -63,6 +63,14 @@ class Domain(Predicate, MetaNode, MetaResource): - definition of selection (to map to matrix) - ability for use to "save" favourite report (user reports) - library of favourite reports (global reports) + + Domain and Domain Generators are now unified. Any domain may act + as a domain generator or as a simple predicate. + + A Domain Generator uses a method (SQL, Python) to select objects + which are then wrapped as Virtual Domains. This can be used for + example to provide the list the 10 best selling shops to + a report tree. """ meta_type = 'ERP5 Domain' portal_type = 'Domain' @@ -84,3 +92,38 @@ class Domain(Predicate, MetaNode, MetaResource): since it is never present in the category list """ return '/'.join(self.portal_url.getRelativeContentPath(self)[1:]) + + # Generator API - DRAFT + + # We must overload objectValues and friends + def DRAFT_objectValues(self): + # We must return objects which are inside the domain + # + objects which are generated by the domain generator + return super.objectValues() + self.getDomainGeneratorList() + pass + + # How to define a generated subdomain + def getDomainGeneratorList(self, depth=0): + # We call a script which builds for us a list DomainGenerator instances + # We need a way to know how deep we are in the domain generation + # to prevent infinite recursion + pass + +# Hand made temp object (rather than ERP5Type generated) because we need +# it now +class DomainGenerator(TempDomain): + """ + This class defines a predicate as well as all necessary + information to generate subdomains. + + Instances are stored in RAM as temp objects + + Generator API - DRAFT + """ + + # We must overload objectValues and friends + def objectValues(self): + # We must return objects which are generated by the domain generator + return self.getDomainGeneratorList(depth = self.depth + 1) + +