# Hybrid methods/attributes, based on similar functionality in SQLAlchemy: # http://docs.sqlalchemy.org/en/improve_toc/orm/extensions/hybrid.html class hybrid_method(object): def __init__(self, func, expr=None): self.func = func self.expr = expr or func def __get__(self, instance, instance_type): if instance is None: return self.expr.__get__(instance_type, instance_type.__class__) return self.func.__get__(instance, instance_type) def expression(self, expr): self.expr = expr return self class hybrid_property(object): def __init__(self, fget, fset=None, fdel=None, expr=None): self.fget = fget self.fset = fset self.fdel = fdel self.expr = expr or fget def __get__(self, instance, instance_type): if instance is None: return self.expr(instance_type) return self.fget(instance) def __set__(self, instance, value): if self.fset is None: raise AttributeError('Cannot set attribute.') self.fset(instance, value) def __delete__(self, instance): if self.fdel is None: raise AttributeError('Cannot delete attribute.') self.fdel(instance) def setter(self, fset): self.fset = fset return self def deleter(self, fdel): self.fdel = fdel return self def expression(self, expr): self.expr = expr return self
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
__init__.py | File | 0 B | 0644 |
|
_speedups.cpython-38-x86_64-linux-gnu.so | File | 239.53 KB | 0755 |
|
_sqlite_ext.cpython-38-x86_64-linux-gnu.so | File | 72.59 KB | 0755 |
|
_sqlite_udf.cpython-38-x86_64-linux-gnu.so | File | 88.42 KB | 0755 |
|
apsw_ext.py | File | 4.94 KB | 0644 |
|
berkeleydb.py | File | 4.04 KB | 0644 |
|
csv_loader.py | File | 75 B | 0644 |
|
csv_utils.py | File | 11.34 KB | 0644 |
|
dataset.py | File | 10.74 KB | 0644 |
|
db_url.py | File | 3.8 KB | 0644 |
|
djpeewee.py | File | 7.72 KB | 0644 |
|
fields.py | File | 11.53 KB | 0644 |
|
flask_utils.py | File | 5.53 KB | 0644 |
|
gfk.py | File | 5.89 KB | 0644 |
|
hybrid.py | File | 1.44 KB | 0644 |
|
kv.py | File | 4.69 KB | 0644 |
|
migrate.py | File | 23.49 KB | 0644 |
|
pool.py | File | 8.01 KB | 0644 |
|
postgres_ext.py | File | 13.13 KB | 0644 |
|
read_slave.py | File | 1.42 KB | 0644 |
|
reflection.py | File | 21.33 KB | 0644 |
|
shortcuts.py | File | 7.03 KB | 0644 |
|
signals.py | File | 2.2 KB | 0644 |
|
sqlcipher_ext.py | File | 4.12 KB | 0644 |
|
sqlite_ext.py | File | 34.94 KB | 0644 |
|
sqlite_udf.py | File | 13.26 KB | 0644 |
|
sqliteq.py | File | 8.34 KB | 0644 |
|
test_utils.py | File | 2.73 KB | 0644 |
|