You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Graham Dumpleton (JIRA)" <ji...@apache.org> on 2007/05/11 07:33:15 UTC
[jira] Created: (MODPYTHON-220) In PSP pages, 'import' doesn't map
through to apache.import_module().
In PSP pages, 'import' doesn't map through to apache.import_module().
---------------------------------------------------------------------
Key: MODPYTHON-220
URL: https://issues.apache.org/jira/browse/MODPYTHON-220
Project: mod_python
Issue Type: Improvement
Components: psp
Affects Versions: 3.3.1
Reporter: Graham Dumpleton
When Python code appears in SSI files, a trick is performed such that the Python code in the SSI files is seen as having been originally imported using the new module importer. This means that if 'import' is used with the Python code, it will map through to apache.import_module() and first use that mechanism to try and import code modules. This trick is not performed for PSP pages however.
What needs to be done for PSP pages is the equivalent of the SSI trick:
class _InstanceInfo:
def __init__(self, label, file, cache):
self.label = label
self.file = file
self.cache = cache
self.children = {}
filter.req.ssi_globals["__file__"] = filter.req.filename
filter.req.ssi_globals["__mp_info__"] = _InstanceInfo(
None, filter.req.filename, None)
filter.req.ssi_globals["__mp_path__"] = []
What this is doing is setting up in the environment of the SSI code object the magic variables that 'import' hook looks for to allow it to map to apache.import_module().
If same done in PSP pages then 'import' will map to apache.import_module() for PSP pages also as first step.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MODPYTHON-220) In PSP pages, 'import' doesn't
map through to apache.import_module().
Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MODPYTHON-220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506331 ]
Graham Dumpleton commented on MODPYTHON-220:
--------------------------------------------
Workaround is that instead of using:
import module
use:
from mod_python import apache
module = apache.import_module("module")
> In PSP pages, 'import' doesn't map through to apache.import_module().
> ---------------------------------------------------------------------
>
> Key: MODPYTHON-220
> URL: https://issues.apache.org/jira/browse/MODPYTHON-220
> Project: mod_python
> Issue Type: Improvement
> Components: psp
> Affects Versions: 3.3.1
> Reporter: Graham Dumpleton
>
> When Python code appears in SSI files, a trick is performed such that the Python code in the SSI files is seen as having been originally imported using the new module importer. This means that if 'import' is used with the Python code, it will map through to apache.import_module() and first use that mechanism to try and import code modules. This trick is not performed for PSP pages however.
> What needs to be done for PSP pages is the equivalent of the SSI trick:
> class _InstanceInfo:
> def __init__(self, label, file, cache):
> self.label = label
> self.file = file
> self.cache = cache
> self.children = {}
> filter.req.ssi_globals["__file__"] = filter.req.filename
> filter.req.ssi_globals["__mp_info__"] = _InstanceInfo(
> None, filter.req.filename, None)
> filter.req.ssi_globals["__mp_path__"] = []
> What this is doing is setting up in the environment of the SSI code object the magic variables that 'import' hook looks for to allow it to map to apache.import_module().
> If same done in PSP pages then 'import' will map to apache.import_module() for PSP pages also as first step.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MODPYTHON-220) In PSP pages, 'import' doesn't map
through to apache.import_module().
Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MODPYTHON-220?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Graham Dumpleton updated MODPYTHON-220:
---------------------------------------
Attachment: MP220-20070622-1-grahamd.diff
Attached patch MP220-20070622-1-grahamd.diff which fixes this problem.
> In PSP pages, 'import' doesn't map through to apache.import_module().
> ---------------------------------------------------------------------
>
> Key: MODPYTHON-220
> URL: https://issues.apache.org/jira/browse/MODPYTHON-220
> Project: mod_python
> Issue Type: Improvement
> Components: psp
> Affects Versions: 3.3.1
> Reporter: Graham Dumpleton
> Attachments: MP220-20070622-1-grahamd.diff
>
>
> When Python code appears in SSI files, a trick is performed such that the Python code in the SSI files is seen as having been originally imported using the new module importer. This means that if 'import' is used with the Python code, it will map through to apache.import_module() and first use that mechanism to try and import code modules. This trick is not performed for PSP pages however.
> What needs to be done for PSP pages is the equivalent of the SSI trick:
> class _InstanceInfo:
> def __init__(self, label, file, cache):
> self.label = label
> self.file = file
> self.cache = cache
> self.children = {}
> filter.req.ssi_globals["__file__"] = filter.req.filename
> filter.req.ssi_globals["__mp_info__"] = _InstanceInfo(
> None, filter.req.filename, None)
> filter.req.ssi_globals["__mp_path__"] = []
> What this is doing is setting up in the environment of the SSI code object the magic variables that 'import' hook looks for to allow it to map to apache.import_module().
> If same done in PSP pages then 'import' will map to apache.import_module() for PSP pages also as first step.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.