...zdb in this case.

I need to make a "global recompile" function available, since zdb requires the co_filename attribute of the script's func_code object to be set to something meaningful, rather than the useless "Script (Python)" it usually gets set to.

Once zdb is installed, any scripts editted will have this set, but I wanted to provide a utility method in a similar vein to python scripts' recompile function that could be globally accesed, however since zdb registers no classes, I ended up having to do some fairly horrific stuff, the following code is from zdb's __init__.py:

# recompilation utlitity
def initialize(context):
# This horrificness is required because Zope doesn't understand the concept
    # of a Product that doesn't register any classes :-(
    fd=getattr(pack, '__FactoryDispatcher__', None)
    if fd is None:
        class __FactoryDispatcher__(FactoryDispatcher):
            "Factory Dispatcher for a Specific Product"

        fd = pack.__FactoryDispatcher__ = __FactoryDispatcher__

    if not hasattr(pack, '_m'): pack._m=fd.__dict__
    pack._m['debug_compile'] = debug_compile
    pack._m['debug_compile__roles__'] = ('Manager',)

Now, this breaks in 2.8, so what SHOULD I be doing to make a method globally available in a way that works in both 2.7 and 2.8?



Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to