Find the context of importer



I'm using Python in a scripting environment. The host application would
pass in some objects so that the script can act on it. But there are a
number of things I like to add to every script to make it a decent
environment, for example, setting up exception hook to show error
properly. I tried to factorize this into a module called script_util.
For example:

------------------------------------------------------------------------
script:

# host application would pass in objects like window, document, etc.

import script_util

.... do something with window, document, etc, ...

------------------------------------------------------------------------
script_util.py:

import sys

def myExceptionHandler(...):
importer.window.alert(message)

sys.excepthook = myExceptionHandler
sys.stdout = myOutputPipe
------------------------------------------------------------------------


However in order for script_util to work, it needs to have access to
the importer's context to get access to the host objects. Is there
anyway for it to find out? I guess I can do something like:

------------------------------------------------------------------------
import script_util
script_util.init(globals())
------------------------------------------------------------------------

But I like to make something brain dead easy with just the import
statement if possible.

Thank you,

wy

.



Relevant Pages

  • Re: internet proxy
    ... Is it possible to create separate shortcuts to IE - one with 'proxy server ... This script gets used when you enable the "Automatically ... connect to the host so no proxy would get used. ...
    (microsoft.public.windowsxp.general)
  • Re: How do I insert a cgi script into Publisher page?
    ... is not where I host my website. ... If your ISP supports cgi and has a form handling program then a form ... You must tell the server what e mail address you want the form results ... any where else you so desire or an auto redirect script with a delay. ...
    (microsoft.public.publisher.webdesign)
  • Re: SAFE MODE,fopen, and chmod
    ... The files going into the users/ folder are created by the "apache" user. ... I have a free php hosting account with an account name 'sample'. ... The host is "running in SAFE MODE", where, it seems that for fopen, mkdir and many other functions, a check is done for the UID of the script-running process to be the same as the UID of each resource concernedand only if the UIDs match, is the function allowed to work successfully. ... The same script has in the prior lines created the directory ...
    (comp.lang.php)
  • Re: Setting new date with offset in days
    ... run (or host) the script. ... WSH which can run both JScript and WScript. ... Isn't WScript the windows program ... It seems that JavaScript or JScript is best used in a web ...
    (comp.lang.javascript)
  • Re: Scripting hosts backwards on my system
    ... the //H switch sets the default host which will be used when a script is ... Copyright Microsoft Corporation 1996-2001. ... even though CScript was long ago ...
    (microsoft.public.scripting.vbscript)