[IronPython] Frames in IronPython
Jeff Hardy
jdhardy at gmail.com
Wed Dec 31 06:00:35 CET 2008
I don't know what the feature list is going to be for 2.1, but I'd
like to see frame objects near the top. Almost every piece of Python
code I've tried uses them in some way. Often it's for debugging
purposes (and can be worked around), but not always. Trac has this
lovely piece of code:
@staticmethod
def implements(*interfaces):
"""Can be used in the class definiton of `Component` subclasses to
declare the extension points that are extended.
"""
import sys
frame = sys._getframe(1)
locals_ = frame.f_locals
# Some sanity checks
assert locals_ is not frame.f_globals and '__module__' in locals_, \
'implements() can only be used in a class definition'
locals_.setdefault('_implements', []).extend(interfaces)
This is the core of Trac's plugin system, and is used in nearly every
class. I can't see anyway to work around this kind of code without
touching every class in Trac. SCons has similar code as well, to
handle its SConscript files.
The following issues deal with this:
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=12876
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=15399
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=15400
I realize that this is a major feature, but I hope that it can get in
sooner rather than later.
- Jeff
More information about the Ironpython-users
mailing list