Here are the examples of the python api sqlalchemy.util.memoized_property taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
30 Examples
3
Example 1
@util.memoized_property
def heads(self):
"""All "head" revisions as strings.
This is normally a tuple of length one,
unless unmerged branches are present.
:return: a tuple of string revision numbers.
"""
self._revision_map
return self.heads
3
Example 2
Project: alembic Source File: revision.py
@util.memoized_property
def bases(self):
"""All "base" revisions as strings.
These are revisions that have a ``down_revision`` of None,
or empty tuple.
:return: a tuple of string revision numbers.
"""
self._revision_map
return self.bases
3
Example 3
Project: alembic Source File: revision.py
@util.memoized_property
def _real_heads(self):
"""All "real" head revisions as strings.
:return: a tuple of string revision numbers.
"""
self._revision_map
return self._real_heads
3
Example 4
Project: alembic Source File: revision.py
@util.memoized_property
def _real_bases(self):
"""All "real" base revisions as strings.
:return: a tuple of string revision numbers.
"""
self._revision_map
return self._real_bases
3
Example 5
@util.memoized_property
def should_autocommit(self):
autocommit = self.execution_options.get('autocommit',
not self.compiled and
self.statement and
expression.PARSE_AUTOCOMMIT
or False)
if autocommit is expression.PARSE_AUTOCOMMIT:
return self.should_autocommit_text(self.unicode_statement)
else:
return autocommit
3
Example 6
Project: CouchPotatoV1 Source File: default.py
@util.memoized_property
def _default_params(self):
if self.dialect.positional:
return self.dialect.execute_sequence_format()
else:
return {}
3
Example 7
Project: CouchPotatoV1 Source File: log.py
@util.memoized_property
def logging_name(self):
# limit the number of loggers by chopping off the hex(id).
# some novice users unfortunately create an unlimited number
# of Engines in their applications which would otherwise
# cause the app to run out of memory.
return "0x...%s" % hex(id(self))[-4:]
3
Example 8
Project: CouchPotatoV1 Source File: visitors.py
@util.memoized_property
def _visitor_dict(self):
visitors = {}
for name in dir(self):
if name.startswith('visit_'):
visitors[name[6:]] = getattr(self, name)
return visitors
3
Example 9
@util.memoized_property
def _isolation_lookup(self):
extensions = __import__('psycopg2.extensions').extensions
return {
'READ COMMITTED':extensions.ISOLATION_LEVEL_READ_COMMITTED,
'READ UNCOMMITTED':extensions.ISOLATION_LEVEL_READ_UNCOMMITTED,
'REPEATABLE READ':extensions.ISOLATION_LEVEL_REPEATABLE_READ,
'SERIALIZABLE':extensions.ISOLATION_LEVEL_SERIALIZABLE
}
3
Example 10
@util.memoized_property
def should_autocommit(self):
autocommit = self.execution_options.get('autocommit',
not self.compiled and
self.statement and
expression.PARSE_AUTOCOMMIT
or False)
if autocommit is expression.PARSE_AUTOCOMMIT:
return self.should_autocommit_text(self.unicode_statement)
else:
return autocommit
3
Example 11
@util.memoized_property
def target_class(self):
"""The intermediary class handled by this :class:`.AssociationProxy`.
Intercepted append/set/assignment events will result
in the generation of new instances of this class.
"""
return self._get_property().mapper.class_
3
Example 12
@util.memoized_property
def scalar(self):
"""Return ``True`` if this :class:`.AssociationProxy` proxies a scalar
relationship on the local side."""
scalar = not self._get_property().uselist
if scalar:
self._initialize_scalar_accessors()
return scalar
3
Example 13
Project: maraschino Source File: descriptor_props.py
@util.memoized_property
def _comparable_elements(self):
return [
getattr(self.parent.class_, prop.key)
for prop in self.props
]
3
Example 14
Project: maraschino Source File: instrumentation.py
@util.memoized_property
def _state_constructor(self):
self.dispatch.first_init(self, self.class_)
if self.mutable_attributes:
return state.MutableAttrInstanceState
else:
return state.InstanceState
0
Example 15
Project: alembic Source File: revision.py
@util.memoized_property
def _revision_map(self):
"""memoized attribute, initializes the revision map from the
initial collection.
"""
map_ = {}
heads = sqlautil.OrderedSet()
_real_heads = sqlautil.OrderedSet()
self.bases = ()
self._real_bases = ()
has_branch_labels = set()
has_depends_on = set()
for revision in self._generator():
if revision.revision in map_:
util.warn("Revision %s is present more than once" %
revision.revision)
map_[revision.revision] = revision
if revision.branch_labels:
has_branch_labels.add(revision)
if revision.dependencies:
has_depends_on.add(revision)
heads.add(revision.revision)
_real_heads.add(revision.revision)
if revision.is_base:
self.bases += (revision.revision, )
if revision._is_real_base:
self._real_bases += (revision.revision, )
# add the branch_labels to the map_. We'll need these
# to resolve the dependencies.
for revision in has_branch_labels:
self._map_branch_labels(revision, map_)
for revision in has_depends_on:
self._add_depends_on(revision, map_)
for rev in map_.values():
for downrev in rev._all_down_revisions:
if downrev not in map_:
util.warn("Revision %s referenced from %s is not present"
% (downrev, rev))
down_revision = map_[downrev]
down_revision.add_nextrev(rev)
if downrev in rev._versioned_down_revisions:
heads.discard(downrev)
_real_heads.discard(downrev)
map_[None] = map_[()] = None
self.heads = tuple(heads)
self._real_heads = tuple(_real_heads)
for revision in has_branch_labels:
self._add_branches(revision, map_, map_branch_labels=False)
return map_
0
Example 16
Project: sqlalchemy Source File: test_versioning.py
def test_update_multi_missing_broken_multi_rowcount(self):
@util.memoized_property
def rowcount(self):
if len(self.context.compiled_parameters) > 1:
return -1
else:
return self.context.rowcount
with patch.object(
config.db.dialect, "supports_sane_multi_rowcount", False):
with patch(
"sqlalchemy.engine.result.ResultProxy.rowcount",
rowcount):
Foo = self.classes.Foo
s1 = self._fixture()
f1s1 = Foo(value='f1 value')
s1.add(f1s1)
s1.commit()
f1s1.value = 'f2 value'
s1.flush()
eq_(f1s1.version_id, 2)
0
Example 17
@util.memoized_property
def static(self):
return CannedResults(self)
0
Example 18
Project: CouchPotatoV1 Source File: default.py
@util.memoized_property
def is_crud(self):
return self.isinsert or self.isupdate or self.isdelete
0
Example 19
Project: CouchPotatoV1 Source File: default.py
@util.memoized_property
def _is_explicit_returning(self):
return self.compiled and \
getattr(self.compiled.statement, '_returning', False)
0
Example 20
Project: CouchPotatoV1 Source File: default.py
@util.memoized_property
def _is_implicit_returning(self):
return self.compiled and \
bool(self.compiled.returning) and \
not self.compiled.statement._returning
0
Example 21
Project: CouchPotatoV1 Source File: state.py
@util.memoized_property
def committed_state(self):
return {}
0
Example 22
@util.memoized_property
def parents(self):
return {}
0
Example 23
@util.memoized_property
def pending(self):
return {}
0
Example 24
Project: CouchPotatoV1 Source File: state.py
@util.memoized_property
def callables(self):
return {}
0
Example 25
Project: CouchPotatoV1 Source File: state.py
@util.memoized_property
def mutable_dict(self):
return {}
0
Example 26
Project: maraschino Source File: default.py
@util.memoized_property
def _type_memos(self):
return weakref.WeakKeyDictionary()
0
Example 27
Project: maraschino Source File: associationproxy.py
@util.memoized_property
def _value_is_scalar(self):
return not self._get_property().\
mapper.get_property(self.value_attr).uselist
0
Example 28
Project: maraschino Source File: descriptor_props.py
@util.memoized_property
def _attribute_keys(self):
return [
prop.key for prop in self.props
]
0
Example 29
Project: maraschino Source File: descriptor_props.py
@util.memoized_property
def _proxied_property(self):
return getattr(self.parent.class_, self.name).property
0
Example 30
Project: maraschino Source File: instrumentation.py
@util.memoized_property
def mapper(self):
# raises unless self.mapper has been assigned
raise exc.UnmappedClassError(self.class_)