Changeset 356
- Timestamp:
- 12/18/06 00:35:09
- Files:
-
- trunk/arenas.py (modified) (2 diffs)
- trunk/doc/modeling.html (modified) (1 diff)
- trunk/logic.py (modified) (1 diff)
- trunk/storage/storepypgsql.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/arenas.py
r355 r356 469 469 470 470 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 """ 472 490 if expr and not isinstance(expr, logic.Expression): 473 491 expr = logic.Expression(expr) … … 504 522 if added_fields: 505 523 # Remove the added identifier columns from the row. 506 row = row[: len(row) -added_fields]524 row = row[:-added_fields] 507 525 yield row 508 526 trunk/doc/modeling.html
r355 r356 253 253 at once with <tt class='def'>Arena.register_all(globals())</tt>. It will 254 254 grab 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> 255 mapping you pass to <tt>register_all</tt>) and register them. It then 256 returns a list of the classes it found.</p> 256 257 257 258 <p>The register and register_all methods also register any Associations trunk/logic.py
r355 r356 238 238 func: a function, with one positional arg and optional keyword args, 239 239 which must return bool. If func is None, it is initialized to 240 lambda x: True240 "lambda x: True". 241 241 kwtypes: a dictionary of {keyword: type} pairs. 242 242 earlybind: if True (the default), the given function will be 243 243 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. 244 247 """ 245 248 if func is None: 246 func = lambda x: True 247 248 if earlybind: 249 self._load_func(func) 249 self.func = lambda x: True 250 250 else: 251 self.func = func 251 if earlybind: 252 self._load_func(func) 253 else: 254 self.func = func 252 255 253 256 if kwtypes is None: trunk/storage/storepypgsql.py
r355 r356 47 47 48 48 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) because52 # that introduces null bytes into the SQL, which is a no-no.53 49 value = pickle.dumps(value, 2) 54 50 value = self.coerce_str_to_any(value, skip_encoding=False)
