On Mon, 2004-06-28 at 12:50, Jeff Bone wrote: > > Just one more opinion here, but I'm with Bob on this one. Sure, many > > of the uses I envision are "declarative" in the sense that they just > > associate metadata with the function. But many other uses I envision > > would alter the function's behavior. > > I'm really curious what these uses might be. Here's one of my use case. In the Mailman3 implementation of the BerkeleyDB backend storage, I need to set up Berkeley transactions around various calls. It's programmatically possible to set up an explicit transaction to group several operations together, but it's also possible to wrap a single operation in a single transaction. Also, the Berkeley transactions must be wrapped in try/excepts so that if any Python level exception occurs, the transaction can be properly aborted. There's enough complexity in the implementation, and similarity in the use, that I wanted to encapsulate all that in a 'txnprop' decorator. I currently use the 'call-after-def' wrapper idiom that's possible in Python 2.3 today, but I want to use decorators for this, especially because I sometimes want to combine the txnprop wrapper with other decorators. Here's a pointer to some of the code: http://cvs.sourceforge.net/viewcvs.py/mailman/mailman3/src/mailman/berkeleydb/bdblist.py?rev=3.2&view=auto The txnprop() descriptor guarantees that self.txn is bound to a transaction inside the method call. -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20040628/80ff73a9/attachment.bin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4