~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to lib/sqlalchemy/orm/state.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2013-10-28 22:29:40 UTC
  • mfrom: (1.4.24)
  • Revision ID: package-import@ubuntu.com-20131028222940-wvyqffl4g617caun
Tags: 0.8.3-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
        dict_.pop(key, None)
306
306
        self.callables[key] = self
307
307
 
308
 
    def _set_callable(self, dict_, key, callable_):
309
 
        """Remove the given attribute and set the given callable
310
 
           as a loader."""
311
 
 
312
 
        old = dict_.pop(key, None)
313
 
        if old is not None and self.manager[key].impl.collection:
314
 
            self.manager[key].impl._invalidate_collection(old)
315
 
        self.callables[key] = callable_
 
308
    @classmethod
 
309
    def _row_processor(cls, manager, fn, key):
 
310
        impl = manager[key].impl
 
311
        if impl.collection:
 
312
            def _set_callable(state, dict_, row):
 
313
                old = dict_.pop(key, None)
 
314
                if old is not None:
 
315
                    impl._invalidate_collection(old)
 
316
                state.callables[key] = fn
 
317
        else:
 
318
            def _set_callable(state, dict_, row):
 
319
                state.callables[key] = fn
 
320
        return _set_callable
316
321
 
317
322
    def _expire(self, dict_, modified_set):
318
323
        self.expired = True
359
364
 
360
365
        self.manager.dispatch.expire(self, attribute_names)
361
366
 
362
 
    def __call__(self, passive):
 
367
    def __call__(self, state, passive):
363
368
        """__call__ allows the InstanceState to act as a deferred
364
369
        callable for loading expired attributes, which is also
365
370
        serializable (picklable).
522
527
    to a particular attribute on a particular mapped object.
523
528
 
524
529
    The :class:`.AttributeState` object is accessed
525
 
    via the :attr:`.InstanceState.attr` collection
 
530
    via the :attr:`.InstanceState.attrs` collection
526
531
    of a particular :class:`.InstanceState`::
527
532
 
528
533
        from sqlalchemy import inspect
529
534
 
530
535
        insp = inspect(some_mapped_object)
531
 
        attr_state = insp.attr.some_attribute
 
536
        attr_state = insp.attrs.some_attribute
532
537
 
533
538
    """
534
539