Changeset 3382

Show
Ignore:
Timestamp:
07/24/07 17:11:00 (1 year ago)
Author:
mscott
Message:

Merge policy-57 branch's Schevo to the Schevo trunk.

r11118@sandiago (orig r3276): mscott | 2007-06-22 15:53:53 -0500
branch for #57
r11139@sandiago (orig r3297): mscott | 2007-06-28 15:06:23 -0500
merge from trunk:


r11138@sandiago (orig r3296): mscott | 2007-06-28 14:40:29 -0500
Update footers to remove non-current address, and leave just the city
in its place.




r11143@sandiago (orig r3301): mscott | 2007-06-29 09:12:36 -0500
Move schevo tests from Schevo/tests to Schevo/schevo/test -- this
makes them accessible by other packages without hackishness.



r11149@sandiago (orig r3307): mscott | 2007-07-05 16:42:51 -0500

r11148@sandiago (orig r3306): mscott | 2007-07-05 16:23:30 -0500
Change copyright from 2001-2006 to 2001-2007.




r11187@sandiago (orig r3308): mscott | 2007-07-05 16:50:45 -0500
Change copyright from 2001-2006 to 2001-2007



r11189@sandiago (orig r3310): mscott | 2007-07-05 17:09:19 -0500
Some tests in test_change didn't get split up into format 1 and format
2 tests like the rest did when the format 2 engine was introduced.



r11194@sandiago (orig r3315): mscott | 2007-07-05 17:37:10 -0500
Remove spurious variable names that were no-ops.



r11195@sandiago (orig r3316): mscott | 2007-07-05 17:42:26 -0500
Rename classes to disambiguate.



r11208@sandiago (orig r3329): mscott | 2007-07-06 18:38:08 -0500
Test for extent names rather than extents. This allows the test to be
used as a basis for a SchevoPolicy? test.



r11227@sandiago (orig r3348): mscott | 2007-07-09 22:28:10 -0500
Embed test transactions directly into the schema, rather than
the test class. Makes it more resuable for tests in SchevoPolicy?.



r11228@sandiago (orig r3349): mscott | 2007-07-09 22:49:36 -0500
Move transaction classes to schema in test_entity_extent.


Compare against base transaction class to test transaction method hiding
in test_label.


Wrap rdb.t methods in RestrictedTransaction instances.


Label RestrictedTransaction instances the same as their parent.




r11229@sandiago (orig r3350): mscott | 2007-07-09 23:16:33 -0500
Move more transactions away from being inline test code and into the
test schema.


Skip test_callable_wrapper in test_transaction tests in
SchevoPolicy?.


RestrictedDatabase now checks return type and converts lists or
tuples of entities into lists or tuples of RestrictedEntity
instances.


Support _undo for RestrictedTransaction instances.



r11232@sandiago (orig r3353): mscott | 2007-07-11 13:50:44 -0500
Schevo:


  • Extents now have id in their public API. Needed to streamline Placeholder and to support SchevoPolicy.


    SchevoPolicy?:

  • Store the rdb of an extent to support the db attribute of RestrictedExtent.

  • Store the rdb and rextent of an entity in RestrictedEntity to support introspection from e.g. Placeholder.


    r11236@sandiago (orig r3357): mscott | 2007-07-11 23:09:42 -0500
    Add a _transform method to entity fields, to allow filtering by packages
    such as SchevoPolicy?.


    r11239@sandiago (orig r3360): mscott | 2007-07-11 23:24:54 -0500
    Better compatibility with SchevoPolicy? tests.


    r11251@sandiago (orig r3372): mscott | 2007-07-23 22:19:02 -0500
    Allow schevo.field.Field.copy to cope with Field subclasses that use slots.

    In .sys.field_map() of a RestrictedEntity?, only transform fields that may_store_entities.


    r11255@sandiago (orig r3376): mscott | 2007-07-24 09:14:33 -0500
    Add _results method to schevo.query.Query to allow easy overriding of
    instances' call methods -- you cannot override a call method
    for an instance, it is very much attached to the class itself.

    Wrap results of queries so that RestrictedEntities? are returned.


    r11256@sandiago (orig r3377): mscott | 2007-07-24 09:51:06 -0500
    Fix a test in schevo.test.test_query (should be _results and not call).

    Add a cmp method to RestrictedEntity? so they can be properly sorted.


    r11257@sandiago (orig r3378): mscott | 2007-07-24 10:06:58 -0500
    Add .db to RestrictedEntity? .sys namespace

    Compare results of count(), not count methods themselves, when
    comparing transaction's .sys.count with its originating entity's
    .sys.count


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Schevo/schevo/database2.py

    r3306 r3382  
    12561256                e_id = extent_name_id[e_name] 
    12571257                EntityClass = E[e_name] 
    1258                 extent = Extent(self, e_name, EntityClass) 
     1258                extent = Extent(self, e_name, e_id, EntityClass) 
    12591259                extents[e_id] = extents[e_name] = extent 
    12601260                relaxed[e_name] = {} 
  • trunk/Schevo/schevo/extent.py

    r3306 r3382  
    1818    """An extent of entity instances.""" 
    1919 
    20     def __init__(self, db, name, EntityClass): 
     20    def __init__(self, db, name, id, EntityClass): 
    2121        # Decorate the EntityClass. 
    2222        EntityClass._db = db 
     
    2929        self.default_key = EntityClass._default_key 
    3030        self.field_spec = EntityClass._field_spec 
     31        self.id = id 
    3132        self.index_spec = EntityClass._index_spec 
    3233        self.initial = EntityClass._initial 
  • trunk/Schevo/schevo/field.py

    r3306 r3382  
    306306        FieldClass = self.__class__ 
    307307        new_field = FieldClass(None, None) 
    308         new_field.__dict__.update(self.__dict__) 
     308        try: 
     309            new_field.__dict__.update(self.__dict__) 
     310        except AttributeError: 
     311            for name in self.__slots__: 
     312                setattr(new_field, name, getattr(self, name)) 
    309313        return new_field 
    310314 
     
    11611165        return [(r(value), value) for value in values] 
    11621166 
     1167    def _transform(self, transform_entity): 
     1168        """Transforms, in place, the value of the field, using the 
     1169        return value of `transform_entity(entity)` for each entity 
     1170        that is in the field's value. 
     1171 
     1172        This is used by extension libraries such as SchevoPolicy. 
     1173        """ 
     1174        value = self._value 
     1175        if isinstance(value, EntityActual): 
     1176            self._value = transform_entity(value) 
     1177 
    11631178    def validate(self, value): 
    11641179        """Validate the value, raising an error on failure.""" 
     
    13231338    def reversible(self, value=None): 
    13241339        return None 
     1340 
     1341    def _transform(self, transform_entity): 
     1342        value = self._value 
     1343        if isinstance(value, list): 
     1344            self._value = [transform_entity(entity) for entity in value] 
    13251345 
    13261346    def _unassign(self, member): 
     
    14291449        return None 
    14301450 
     1451    def _transform(self, transform_entity): 
     1452        value = self._value 
     1453        if isinstance(value, (set, frozenset)): 
     1454            self._value = set(transform_entity(entity) for entity in value) 
     1455 
    14311456    def validate(self, value): 
    14321457        """Validate the value, raising an error on failure.""" 
     
    15231548    def reversible(self, value=None): 
    15241549        return None 
     1550 
     1551    def _transform(self, transform_entity): 
     1552        value = self._value 
     1553        if isinstance(value, (set, frozenset)): 
     1554            self._value = set( 
     1555                set(transform_entity(entity) for entity in inner_set) 
     1556                for inner_set in value 
     1557                ) 
    15251558 
    15261559    def validate(self, value): 
  • trunk/Schevo/schevo/placeholder.py

    r3306 r3382  
    1717    def __init__(self, entity): 
    1818        """Create a Placeholder instance based on `entity`.""" 
    19         self.extent_id = entity._db._extent_name_id[entity._extent.name] 
     19        self.extent_id = entity._extent.id 
    2020        self.oid = entity._oid 
    2121        self.entity = entity 
     
    8787            # would result in it being the wrong one. 
    8888            return self.entity 
    89         extent = db.extent(db._extent_id_name[self.extent_id]
     89        extent = db.extent(self.extent_id
    9090        oid = self.oid 
    9191        if oid in extent: 
  • trunk/Schevo/schevo/query.py

    r3306 r3382  
    3636 
    3737    def __call__(self): 
     38        """Shortcut to get to `_query_results` method.""" 
     39        return self._results() 
     40 
     41    def _results(self): 
    3842        """Return a `Results` instance based on the current state of 
    3943        this query.""" 
     
    5660        self._label = label 
    5761 
    58     def __call__(self): 
     62    def _results(self): 
    5963        return results(self._fn()) 
    6064 
     
    156160            field.assigned = True 
    157161 
    158     def __call__(self): 
     162    def _results(self): 
    159163        return results(self._on.find(**self._criteria)) 
    160164 
     
    195199        self._other_field_name = other_field_name 
    196200 
    197     def __call__(self): 
     201    def _results(self): 
    198202        return results(self._entity.sys.links( 
    199203            self._other_extent, self._other_field_name)) 
     
    293297        self.value = value 
    294298 
    295     def __call__(self): 
     299    def _results(self): 
    296300        on = self.on 
    297301        if isinstance(on, base.Query): 
     
    410414        self.queries = list(queries) 
    411415 
    412     def __call__(self): 
     416    def _results(self): 
    413417        assert log(1, 'called Intersection') 
    414418        resultset = None 
     
    498502        self.queries = list(queries) 
    499503 
    500     def __call__(self): 
     504    def _results(self): 
    501505        resultset = set() 
    502506        for query in self.queries: 
     
    519523        self.FieldClass = FieldClass 
    520524 
    521     def __call__(self): 
     525    def _results(self): 
    522526        field_name = self.field_name 
    523527        groups = {} 
     
    542546        self.FieldClass = FieldClass 
    543547 
    544     def __call__(self): 
     548    def _results(self): 
    545549        def generator(): 
    546550            field_name = self.field_name 
     
    574578        self.FieldClass = FieldClass 
    575579 
    576     def __call__(self): 
     580    def _results(self): 
    577581        def generator(): 
    578582            field_name = self.field_name