Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

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

Changeset 356

Show
Ignore:
Timestamp:
12/18/06 00:35:09
Author:
fumanchu
Message:

Mostly doc tweaks.

Files:

Legend:

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

    r355 r356  
    469469     
    470470    def view(self, cls, attrs, expr=None, **kwargs): 
    471         """Iterator of all Property tuples.""" 
     471        """Yield tuples of attrs for the given cls which match the expr. 
     472         
     473        cls: The Unit subclass for which to yield property tuples. 
     474        attrs: a sequence of strings; each should be the name of 
     475            a UnitProperty on the given cls. 
     476        expr: a lambda or logic.Expression. If provided, data will only 
     477            be yielded for units of the given cls which match the expr. 
     478        **kwargs: additional expr filters in name=value format. 
     479         
     480        Each yielded value will be a list of values, in the same order as 
     481        the attrs arg. This facilitates unpacking in iterative consumer 
     482        code like: 
     483         
     484        for id, name in sandbox.view(Invoice, ['ID', 'Name'], f): 
     485            print id, ": ", name 
     486         
     487        This is generally much faster than recall, and should be preferred 
     488        for performance-sensitive code. 
     489        """ 
    472490        if expr and not isinstance(expr, logic.Expression): 
    473491            expr = logic.Expression(expr) 
     
    504522                if added_fields: 
    505523                    # Remove the added identifier columns from the row. 
    506                     row = row[:len(row) - added_fields] 
     524                    row = row[:-added_fields] 
    507525                yield row 
    508526     
  • trunk/doc/modeling.html

    r355 r356  
    253253at once with <tt class='def'>Arena.register_all(globals())</tt>. It will 
    254254grab any Unit subclasses out of your module's globals() (or any other 
    255 mapping you pass to <tt>register_all</tt>) and register them.</p> 
     255mapping you pass to <tt>register_all</tt>) and register them. It then 
     256returns a list of the classes it found.</p> 
    256257 
    257258<p>The register and register_all methods also register any Associations 
  • trunk/logic.py

    r355 r356  
    238238        func: a function, with one positional arg and optional keyword args, 
    239239            which must return bool. If func is None, it is initialized to 
    240             lambda x: True 
     240            "lambda x: True". 
    241241        kwtypes: a dictionary of {keyword: type} pairs. 
    242242        earlybind: if True (the default), the given function will be 
    243243            rewritten, binding as many constants as possible into co_consts. 
     244            The only reason to ever set it to False is for performance, 
     245            and you must be *certain* there are no global or cell refs 
     246            in your function. 
    244247        """ 
    245248        if func is None: 
    246             func = lambda x: True 
    247          
    248         if earlybind: 
    249             self._load_func(func) 
     249            self.func = lambda x: True 
    250250        else: 
    251             self.func = func 
     251            if earlybind: 
     252                self._load_func(func) 
     253            else: 
     254                self.func = func 
    252255         
    253256        if kwtypes is None: 
  • trunk/storage/storepypgsql.py

    r355 r356  
    4747     
    4848    def do_pickle(self, value): 
    49         # dumps with protocol 0 uses the 'raw-unicode-escape' encoding, 
    50         # and we take pains not to re-encode it with self.encoding. 
    51         # We can't use protocol 1 or 2 (which would use UTF-8) because 
    52         # that introduces null bytes into the SQL, which is a no-no. 
    5349        value = pickle.dumps(value, 2) 
    5450        value = self.coerce_str_to_any(value, skip_encoding=False)