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 2006/02/09 04:05:57 UTC

[jira] Created: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Improvements associated with req.handler for type checker phase.
----------------------------------------------------------------

         Key: MODPYTHON-125
         URL: http://issues.apache.org/jira/browse/MODPYTHON-125
     Project: mod_python
        Type: Improvement
  Components: core  
    Versions: 3.3    
    Reporter: Graham Dumpleton


One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.

In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.

To illustrate how it might be used, imagine an Apache configuration for a directory of:

  PythonTypeHandler select_handler
  PythonHandler deliver_content

Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.

Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:

  def typehandler(req):
    if os.path.splitext(req.filename)[1] == ".py":
      req.handler = "mod_python"
      return apache.OK
    return apache.DECLINED

You might even say exactly which handler should be called as well.

  def typehandler(req):
    if os.path.splitext(req.filename)[1] == ".py":
      req.handler = "mod_python"
      req.add_handler("PythonHandler","mod_python.publisher")
      return apache.OK
    return apache.DECLINED

Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.

Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/MODPYTHON-125?page=comments#action_12367176 ] 

Graham Dumpleton commented on MODPYTHON-125:
--------------------------------------------

Note that although changes have been commited to make req.handler writable. Nothing has been done about making req.content_encoding and req.content_languages writable. Nor has anything been done about the fact that req.content_languages isn't documented. Seperate issue should possibly be created for these changes.

> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>          Key: MODPYTHON-125
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-125
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton

>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Work started: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-125?page=all ]
     
Work on MODPYTHON-125 started by Graham Dumpleton

> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>          Key: MODPYTHON-125
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-125
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton
>     Assignee: Graham Dumpleton
>      Fix For: 3.3

>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-125?page=all ]
     
Graham Dumpleton resolved MODPYTHON-125:
----------------------------------------

    Resolution: Fixed

> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>          Key: MODPYTHON-125
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-125
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton
>     Assignee: Graham Dumpleton
>      Fix For: 3.3

>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-125?page=all ]

Graham Dumpleton updated MODPYTHON-125:
---------------------------------------

    Fix Version: 3.3
      Assign To: Graham Dumpleton

> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>          Key: MODPYTHON-125
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-125
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton
>     Assignee: Graham Dumpleton
>      Fix For: 3.3

>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/MODPYTHON-125?page=comments#action_12365686 ] 

Graham Dumpleton commented on MODPYTHON-125:
--------------------------------------------

Forgot to mention that req.content_languages is not documented in mod_python HTML documentation for request object.

> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>          Key: MODPYTHON-125
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-125
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton

>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (MODPYTHON-125) Improvements associated with req.handler for type checker phase.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MODPYTHON-125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Graham Dumpleton closed MODPYTHON-125.
--------------------------------------


> Improvements associated with req.handler for type checker phase.
> ----------------------------------------------------------------
>
>                 Key: MODPYTHON-125
>                 URL: https://issues.apache.org/jira/browse/MODPYTHON-125
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.3
>            Reporter: Graham Dumpleton
>         Assigned To: Graham Dumpleton
>             Fix For: 3.3
>
>
> One purpose of the type checker phase in Apache, as able to be hooked using the PythonTypeHandler directive, is to use it to make decisions as to which actual handler should be used to deliver up the content for a request. It is also intended to be used to set up attributes such as req.content_type, req.content_encoding and req.content_languages. An example of an Apache module which supplies a function for this phase is mod_mime. That module uses lookups based on content type as derived from request URL extension type, to specify which handler should be used to generate the content. Another is mod_negotiation, which performs other sorts of determinations based on the request extension.
> In mod_python, there are a few missing bits which would allow you to use mod_python to do the same sorts of things. These are that req.handler, req.content_encoding and req.content_languages are not writable. Of these the most important is probably req.handler.
> To illustrate how it might be used, imagine an Apache configuration for a directory of:
>   PythonTypeHandler select_handler
>   PythonHandler deliver_content
> Although the PythonHandler directive is specified here, it is never actually called. This is because the configuration doesn't specify either "SetHandler" or "AddHandler" directives. When the SetHandler directive is used, normally the Apache core would see it and trigger mod_python for the content handler phase. If AddHandler is instead used, it is mod_mime that would trigger mod_python be used if the extension matches that in the request URL.
> Instead of using either of these directives, what should instead be able to be done is that a handler associated with PythonTypeHandler could say that mod_python should be triggered for the content phase. This might be done something like:
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       return apache.OK
>     return apache.DECLINED
> You might even say exactly which handler should be called as well.
>   def typehandler(req):
>     if os.path.splitext(req.filename)[1] == ".py":
>       req.handler = "mod_python"
>       req.add_handler("PythonHandler","mod_python.publisher")
>       return apache.OK
>     return apache.DECLINED
> Unfortunately, this doesn't work because req.handler isn't writable. With req.handler writable it does work and the handler associated with PythonHandler, or as specified using req.add_handler() will be executed for the content phase.
> Now the main intent of this JIRA issue is to make req.handler writable, but at the same time it is to highlight that for completeness, that req.content_encoding and req.content_languages should also probably be made writable as they are values which for example are modifed by mod_mime in this phase of processing. Note that req.content_type is already writable, which is another attribute which mod_mime modifies in this phase.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.