Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 26

Show
Ignore:
Timestamp:
11/10/04 08:18:45
Author:
fumanchu
Message:

1. Use error trapping instead of asserts.
2. Bug in engines--can't .copy() a list, use [:]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/__init__.py

    r25 r26  
    11import ConfigParser 
    22import datetime 
     3 
    34 
    45from dejavu.containers import * 
  • trunk/analysis.py

    r25 r26  
    110110     
    111111    def results(self): 
    112         # Force all groups to functions. The reason we do it here instead 
    113         # of __init__ is so consumers can still read self.groups as strings 
     112        # Force all groups to functions. We do it here instead of __init__ 
     113        # so consumers can still read self.groups as strings 
    114114        # if that's what they supplied. 
    115115        groups = [_force_function(group) for group in self.groups] 
  • trunk/codewalk.py

    r25 r26  
    938938class KeywordInspector(Rewriter): 
    939939    """Produce a list of all keyword arguments expected.""" 
     940     
    940941    def __init__(self, obj): 
     942        """KeywordInspector(obj). List keyword arguments expected.""" 
    941943        Rewriter.__init__(self, obj) 
    942         assert self.co_flags & 0x0008 
    943         assert len(self.co_varnames) > 1 
     944        if not (self.co_flags & 0x0008): 
     945            raise ValueError("'%s' does not possess **kwargs." % obj) 
     946        if len(self.co_varnames) <= 1: 
     947            raise ValueError("'%s' does not possess more than 1 varname." % obj) 
    944948        self._kwargs = [] 
    945949        self.flag = None 
    946950     
    947951    def kwargs(self): 
     952        """kwargs() -> List of keyword arguments expected.""" 
    948953        self.walk() 
    949954        return self._kwargs 
  • trunk/containers.py

    r25 r26  
    374374    def row_number(self, **facet): 
    375375        k, v = facet.popitem() 
    376         return self.facets[k].index(v) 
     376        f = self.facets[k] 
     377        try: 
     378            return f.index(v) 
     379        except ValueError: 
     380            raise ValueError("'%s' is not a known %s" % (v, k)) 
    377381     
    378382    def row(self, **facet): 
  • trunk/engines.py

    r25 r26  
    8686        self.acquire() 
    8787        try: 
    88             return self.Members.copy() 
     88            return self.Members[:] 
    8989        finally: 
    9090            self.release() 
     
    119119    def __copy__(self): 
    120120        newUnit = dejavu.Unit.__copy__(self) 
    121         newUnit.Members = self.Members.copy() 
     121        newUnit.Members = self.Members[:] 
    122122        return newUnit 
    123123     
     
    417417        B.acquire() 
    418418        try: 
    419             B.Members = A.Members.copy() 
     419            B.Members = A.Members[:] 
    420420        finally: 
    421421            A.release() 
  • trunk/logic.py

    r25 r26  
    246246    def __and__(self, other): 
    247247        """Logical-and this Expression with another.""" 
    248         assert isinstance(other, Expression) 
     248        if not isinstance(other, Expression): 
     249            raise TypeError("'%s' is not an Expression" % other) 
    249250        ag = Aggregator(self.func) 
    250251        ag.and_combine(other.func) 
     
    255256    def __or__(self, other): 
    256257        """Logical-or this Expression with another.""" 
    257         assert isinstance(other, Expression) 
     258        if not isinstance(other, Expression): 
     259            raise TypeError("'%s' is not an Expression" % other) 
    258260        ag = Aggregator(self.func) 
    259261        ag.or_combine(other.func) 
  • trunk/readme.py

    r25 r26  
    1 """ 
     1"""Dejavu is an Object-Relational Mapper. 
     2 
     3Persisted objects are called "Units", and are served into 
     4Sandboxes within an Arena. Each Unit instance has a class, 
     5which maintains its schema via Unit Properties. 
     6 
     7"Dejavu", to quote Flying Circus episode 16, means "that strange feeling 
     8we sometimes get that we've lived through something before." What better 
     9name for an object server? Our terminology reflects this cognitive bent: 
     10sandboxes "memorize", "recall" and "forget" Units. 
     11 
     12Most Unit lifecycles follow the same pattern: 
     13    aUnit = sandbox.unit(cls, ID=ID) 
     14    val = aUnit.propertyName 
     15    aUnit.propertyName = newValue 
     16    del aUnit # or otherwise release the reference, e.g. close the scope. 
     17 
     18When creating new Units, a similar pattern would be: 
     19    newUnit = unit_class() 
     20    newUnit.propertyName = newValue 
     21    sandbox.memorize(newUnit) 
     22    del newUnit # or otherwise release the reference. 
     23 
     24Using recall(), you get an iterator: 
     25    for unit in sandbox.recall(cls, expr): 
     26        do_something_with(unit) 
     27 
     28You destroy a Unit via Unit.forget(). 
     29 
     30Applications only need to call Unit.repress() when they wish to stop 
     31caching the object, returning it to storage. This is very rare, and 
     32should really only be performed within dejavu code. 
     33 
     34 
     35LICENSE 
     36------- 
    237This work, including the source code, documentation 
    338and related data, is placed into the public domain. 
     
    1146RESULTING FROM THE USE, MODIFICATION, OR 
    1247REDISTRIBUTION OF THIS SOFTWARE. 
    13  
    14  
    15 Dejavu is an Object-Relational Mapper. Objects are called "Units", 
    16 and are served into Sandboxes within an Arena. Each Unit instance 
    17 has a class, which maintains its schema via Unit Properties. 
    18  
    19 "Dejavu", to quote Flying Circus episode 16, means "that strange feeling 
    20 we sometimes get that we've lived through something before." What better 
    21 name for an object server? Our terminology reflects this cognitive bent: 
    22 sandboxes "memorize", "recall" and "forget" Units. 
    23  
    24 Most Unit lifecycles follow the same pattern: 
    25     aUnit = sandbox.unit(cls, ID=ID) 
    26     val = aUnit.propertyName 
    27     aUnit.propertyName = newValue 
    28     del aUnit # or otherwise release the reference, e.g. close the scope. 
    29  
    30 When creating new Units, a similar pattern would be: 
    31     newUnit = unit_class() 
    32     newUnit.propertyName = newValue 
    33     sandbox.memorize(newUnit) 
    34     del newUnit # or otherwise release the reference. 
    35  
    36 Using recall(), you get an iterator: 
    37     for unit in sandbox.recall(cls, expr): 
    38         do_something_with(unit) 
    39  
    40 You destroy a Unit via Unit.forget(). 
    41  
    42 Applications only need to call Unit.repress() when they wish to stop 
    43 caching the object, returning it to storage. This is very rare, and 
    44 should really only be performed within dejavu code. 
    4548""" 
    4649 
     
    7174    and ([djvMissionTrip].[Field] = 'BC')) 
    7275    and ([u'C'] Like '%djvMissionTrip].[Plan%')" 
    73 5. Investigate making UnitCollection._IDs a full property (a list). This 
    74     would make pickling/unpickling easier. 
    75 6. More SM's. 
     765. More SM's. 
    7677    SQLite 
    7778    PostgreSQL 
     
    106107        them directly. 
    107108    8. Added __getstate__ and __setstate__ to Unit and subclasses. 
     109    9. Made UnitCollection._IDs a full property ("Members"). This 
     110        makes persistence (especially pickling/unpickling) easier. 
    108111 
    1091121.2.4 (10/4/04): 
     
    2262291.0.1 (7/16/04): 
    227230    1. Added the COPY rule to engines.py. 
     231 
     232Prior to July 2004, Dejavu was integrated with a Python application 
     233framework, which is now called "Cation". Development on the 
     234previously-integrated project began in September 2003. 
    228235""" 
  • trunk/storage/storeado.py

    r25 r26  
    753753         
    754754        # TODO: concat multiple pairs. 
    755         assert len(pairs) == 1 
     755        if len(pairs) != 1: 
     756            raise ValueError("Multiselect does not yet work on multiple pairs.") 
    756757        for cls, expr in pairs: 
    757758            if expr is None: