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

Automatic construction of handler class.



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.3.x, 3.2.10
    • Fix Version/s: None
    • Component/s: core
    • Labels:


      When defining a mod_python handler, it is possible to supply a dotted path for the actual handler function to be used. Ie:

      PythonHandler module::instance.function

      when determing the handler to execute, it will use the dotted path to traverse any object hierarchy. Thus the above will execute "function()" of the object instance called "instance" in the module called "module".

      If instead one provides:

      PythonHandler module::class.function

      where 'class' is the name of a class type, then referencing 'function' within that type will result in an instance of the class automatically being created just for the current request, with "function()' then being called on that transient instance of the class.

      For an instance of the class to be created in this way, one must access a member function of the class type. If an instance of the class is callable in its own right, ie., has a _call_() method, it is not however possible to say:

      PythonHandler module::class

      To get that to work, you instead have to use:

      PythonHandler module::class._call_

      First change should be that if a class is callable through having a _call() method, then it should not be necessary to reference the __call_() method explicitly, instead, referencing the class type itself should be enough. Ie., using

      PythonHandler module::class

      should work.

      Note that the code will have to be smart enough to handle both new and old style classes.

      The next issue with this automatic initialisation of a class type is that although the _call_() method needs to accept the 'req' argument, the constructor has to as well if it is being created automatically. The code should allow for the case where the class doesn't want to have to deal with the 'req' object as an argument to the constructor. Ie., it should be optional for the constructor, although always still required for the actual function of the class instance being called.




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


              • Created: