# HG changeset patch # User paulb # Date 1196984317 0 # Node ID a9b44a61e215981e9a8face9d1d697e327317916 # Parent 1bb1edb3e4723a4b5ff79d58aef398b9d54776d3 [project @ 2007-12-06 23:38:37 by paulb] Added an optional attribute name, for use when retaining the store object, to StoreSelector objects. diff -r 1bb1edb3e472 -r a9b44a61e215 WebStack/Resources/Selectors.py --- a/WebStack/Resources/Selectors.py Sat Dec 01 00:33:36 2007 +0000 +++ b/WebStack/Resources/Selectors.py Thu Dec 06 23:38:37 2007 +0000 @@ -107,16 +107,18 @@ a DB-API connection object or any object providing a 'rollback' method. """ - def __init__(self, resource, store): + def __init__(self, resource, store, attribute_name="store"): """ Initialise the selector with a 'resource' (to which all requests shall be forwarded), providing a 'store' which shall be maintained as an - attribute. + attribute. The optional 'attribute_name' can be used to define the name + of the attribute employed - it is set to "store" by default. """ self.resource = resource self.store = store + self.attribute_name = attribute_name def respond(self, trans): @@ -130,7 +132,7 @@ unfinished, uncommitted transactions. """ - trans.get_attributes()["store"] = self.store + trans.get_attributes()[self.attribute_name] = self.store try: self.resource.respond(trans) finally: