Commit 3360be10 authored by Jean-Paul Smets's avatar Jean-Paul Smets

DRAFT API of domain generator


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5734 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c56c8944
...@@ -63,6 +63,14 @@ class Domain(Predicate, MetaNode, MetaResource): ...@@ -63,6 +63,14 @@ class Domain(Predicate, MetaNode, MetaResource):
- definition of selection (to map to matrix) - definition of selection (to map to matrix)
- ability for use to "save" favourite report (user reports) - ability for use to "save" favourite report (user reports)
- library of favourite reports (global 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' meta_type = 'ERP5 Domain'
portal_type = 'Domain' portal_type = 'Domain'
...@@ -84,3 +92,38 @@ class Domain(Predicate, MetaNode, MetaResource): ...@@ -84,3 +92,38 @@ class Domain(Predicate, MetaNode, MetaResource):
since it is never present in the category list since it is never present in the category list
""" """
return '/'.join(self.portal_url.getRelativeContentPath(self)[1:]) 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment