Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-220

In PSP pages, 'import' doesn't map through to apache.import_module().

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • 3.3.1
    • 3.3.x
    • psp
    • None

    Description

      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.

      Attachments

        1. MP220-20070622-1-grahamd.diff
          0.9 kB
          Graham Phillip Dumpleton

        Activity

          People

            grahamd Graham Phillip Dumpleton
            grahamd Graham Phillip Dumpleton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: