class ProxyListExtension orm MapperExtension def before_insert self ma

1
2
3
4
5
6
7
8
9
class ProxyListExtension(orm.MapperExtension):
def before_insert(self, mapper, connection, instance):
instance.hash = sha.new(instance.url).hexdigest()
orm.mapper(Proxy, proxy_table)
orm.mapper(ProxyList, proxylist_table, properties={
'proxies': orm.relation(Proxy, secondary=list_proxy, backref='lists'),
}, extension=ProxyListExtension())