mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-03 06:19:59 -04:00
fixes, but still unsure of things
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
Events
|
||||
------
|
||||
|
||||
.. automodule:: sqlalchemy.event
|
||||
:members:
|
||||
|
||||
|
||||
@@ -146,6 +146,9 @@ class Listeners(_ExecEvent):
|
||||
return bool(self.listeners or self.parent_listeners)
|
||||
|
||||
def append(self, obj, target):
|
||||
# this will be needed, but not
|
||||
# sure why we don't seem to need it yet
|
||||
# if obj not in self.listeners:
|
||||
self.listeners.append(obj)
|
||||
|
||||
class dispatcher(object):
|
||||
|
||||
@@ -104,9 +104,6 @@ class QueryableAttribute(interfaces.PropComparator):
|
||||
self.comparator = comparator
|
||||
self.parententity = parententity
|
||||
|
||||
# TODO: this can potentially be moved to AttributeImpl,
|
||||
# have Sphinx document the "events" class directly, implement an
|
||||
# accept_with() that checks for QueryableAttribute
|
||||
class events(event.Events):
|
||||
"""Events for ORM attributes.
|
||||
|
||||
@@ -123,6 +120,12 @@ class QueryableAttribute(interfaces.PropComparator):
|
||||
|
||||
active_history = False
|
||||
|
||||
# TODO: what to do about subclasses !!
|
||||
# a shared approach will be needed. listeners can be placed
|
||||
# before subclasses are created. new attrs on subclasses
|
||||
# can pull them from the superclass attr. listeners
|
||||
# should be auto-propagated to existing subclasses.
|
||||
|
||||
@classmethod
|
||||
def listen(cls, fn, identifier, target, active_history=False):
|
||||
if active_history:
|
||||
@@ -347,7 +350,10 @@ class AttributeImpl(object):
|
||||
else:
|
||||
self.is_equal = compare_function
|
||||
|
||||
attr = getattr(class_, key)
|
||||
# TODO: pass in the manager here
|
||||
# instead of doing a lookup
|
||||
attr = manager_of_class(class_)[key]
|
||||
|
||||
for ext in util.to_list(extension or []):
|
||||
ext._adapt_listener(attr, ext)
|
||||
|
||||
@@ -356,7 +362,6 @@ class AttributeImpl(object):
|
||||
|
||||
self.expire_missing = expire_missing
|
||||
|
||||
|
||||
def hasparent(self, state, optimistic=False):
|
||||
"""Return the boolean value of a `hasparent` flag attached to
|
||||
the given state.
|
||||
@@ -1011,6 +1016,14 @@ class ClassManager(dict):
|
||||
def mapper(self):
|
||||
raise exc.UnmappedClassError(self.class_)
|
||||
|
||||
def _attr_has_impl(self, key):
|
||||
"""Return True if the given attribute is fully initialized.
|
||||
|
||||
i.e. has an impl.
|
||||
"""
|
||||
|
||||
return key in self and self[key].impl is not None
|
||||
|
||||
def _configure_create_arguments(self,
|
||||
_source=None,
|
||||
deferred_scalar_loader=None):
|
||||
@@ -1504,6 +1517,7 @@ def register_attribute_impl(class_, key,
|
||||
manager[key].impl = impl
|
||||
|
||||
manager.post_configure_attribute(key)
|
||||
|
||||
|
||||
def register_descriptor(class_, key, proxy_property=None, comparator=None,
|
||||
parententity=None, property_=None, doc=None):
|
||||
|
||||
@@ -482,7 +482,7 @@ class MapperProperty(object):
|
||||
|
||||
_compile_started = False
|
||||
_compile_finished = False
|
||||
|
||||
|
||||
def init(self):
|
||||
"""Called after all mappers are created to assemble
|
||||
relationships between mappers and perform other post-mapper-creation
|
||||
@@ -647,7 +647,7 @@ class StrategizedProperty(MapperProperty):
|
||||
``StrategizedOption`` objects via the Query.options() method.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def _get_context_strategy(self, context, path):
|
||||
cls = context.attributes.get(('loaderstrategy',
|
||||
_reduce_path(path)), None)
|
||||
@@ -683,9 +683,10 @@ class StrategizedProperty(MapperProperty):
|
||||
self.strategy = self.__init_strategy(self.strategy_class)
|
||||
|
||||
def post_instrument_class(self, mapper):
|
||||
if self.is_primary():
|
||||
if self.is_primary() and \
|
||||
not mapper.class_manager._attr_has_impl(self.key):
|
||||
self.strategy.init_class_attribute(mapper)
|
||||
|
||||
|
||||
def build_path(entity, key, prev=None):
|
||||
if prev:
|
||||
return prev + (entity, key)
|
||||
|
||||
@@ -907,7 +907,10 @@ class OrderedSet(set):
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._list)
|
||||
|
||||
|
||||
def __add__(self, other):
|
||||
return self.union(other)
|
||||
|
||||
def __repr__(self):
|
||||
return '%s(%r)' % (self.__class__.__name__, self._list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user