[Zope-CVS] CVS: Packages/pypes/pypes - interfaces.py:1.27
casey at zope.com
Thu Jun 17 00:44:55 EDT 2004
Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv11872
Add __name__ attr to ICanonicalExtent
Touch up IQuery and factory interfaces
Implement __name__ for extents
=== Packages/pypes/pypes/interfaces.py 1.26 => 1.27 ===
--- Packages/pypes/pypes/interfaces.py:1.26 Thu Jun 10 00:44:24 2004
+++ Packages/pypes/pypes/interfaces.py Thu Jun 17 00:44:53 2004
@@ -327,6 +327,11 @@
key = Attribute('key',
"""Key for this extent in the extent service""")
+ __name__ = Attribute('__name__',
+ """String name of this extent. This allows the extent to be used
+ as a named input to queries.
# """Return the direct sub-extents of the extent, if any, which are
# disjoint canonical sets which are subsets of the extent.
@@ -485,25 +490,28 @@
- def __call__(inputs=None, criteria=None, order=None, limit=None):
+ def __call__(inputs, criteria=None, order=None, limit=None):
"""Create and return an IQuery object. Argument values override
defaults provided by the query class (if any).Query classes that
supply defaults for all the necessary arguments can be constructed
with no arguments.
- inputs -- A tuple(!) of self-named inputs (with __name__ attrs) or a
- mapping of 'name':'input' pairs. Inputs are sets of objects,
- typically extents or identity sets.
+ inputs -- A single named set (via its __name__), an iterable of named
+ sets, or a mapping of name:set pairs. Input sets are objects
+ implementing the Python set protocol (i.e., ISet objects). The input
+ names are used to refer to members of the inputs in the criteria and
+ order expressions of the query.
criteria -- An IExpression object used as the criteria for selecting
objects from the inputs.
order -- An IOrderExpression object or a sequence of them that
determines the order of the result output.
- limit -- An integer value specifying the maximum number of results
- the query returns.
+ limit -- An integer value 1 or greater specifying the maximum number of
+ results the query returns. limit may not be provided without also
+ specifying order.
Missing mandatory or inappropriate argument values should fail early
and raise an appropriate PypesQueryError.
@@ -546,17 +554,20 @@
"""Execute the query and return the results as an IQueryResult.
- inputs_names -- The names of inputs to 'select' for output. If not
- specified, then all inputs are returned in the results. If a name
+ inputs_names -- The names of inputs to 'select' for output. If none are
+ specified, then all inputs are returned in the results. Note that
+ the order of the output names is arbitrary if the inputs were defined
+ using an unordered mapping, such as a dictionary. If a name
not cooresponding to an input is specifed, raise PypesQueryError.
If one input is selected, then the result items are simply the objects
matched by the query. If multiple inputs are selected, then the result
items are tuples containing the matching joined objects cooresponding
- to the named inputs.
+ to the named inputs.
select may return duplicate results if one or more inputs is not
- selected for output.
+ selected for output. If all inputs are selected then the results
+ generated will be unique.
@@ -570,7 +581,9 @@
"""Execute the query and return an ISet object containing the
- objects from input_name that were selected by the criteria.
+ objects from input_name that were selected by the criteria. This
+ may return the input itself if the criteria selected all of its
=== Packages/pypes/pypes/extent.py 1.10 => 1.11 ===
--- Packages/pypes/pypes/extent.py:1.10 Tue Apr 27 23:24:32 2004
+++ Packages/pypes/pypes/extent.py Thu Jun 17 00:44:54 2004
@@ -29,7 +29,7 @@
from pypes.identity import IdentitySet, listenForIdEvents
from pypes.interfaces import IExtentService, IExtentMap
from pypes.interfaces import IExtent, ICanonicalExtent, IDerivedExtent
-from pypes.exceptions import SetLookupError
+from pypes.exceptions import SetLookupError, PypesError
from pypes.util import classKey, classFromKey
@@ -57,6 +57,13 @@
if key is not None:
self.key = key
+ self.__name__ = key.__name__
+ except AttributeError:
+ if isinstance(key, str):
+ self.__name__ = key
+ raise PypesError('key does not provide extent name')
self._qualifiers = qualifiers
self._instances = instances
More information about the Zope-CVS