Work started: (MODPYTHON-193) Add req.hlist.location to
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Work started: (MODPYTHON-193) Add req.hlist.location to




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Work started: (MODPYTHON-193) Add req.hlist.location to  
Graham Dumpleton (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-17-06 06:12 AM

[ http://issues.apache.org/jira/brows...ON-193?page=all ]

Work on MODPYTHON-193 started by Graham Dumpleton.

> Add req.hlist.location to mirror req.hlist.directory.
> -----------------------------------------------------
>
>                 Key: MODPYTHON-193
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-193
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>            Reporter: Graham Dumpleton
>         Assigned To: Graham Dumpleton
>             Fix For: 3.3
>
>
> In mod_python 3.3 a new function is available when the new module importer
 is
> used called apache.get_handler_root(). The purpose of the function is to r
eturn
> the directory specified by the Directory directive in which the current
> Python*Handler was defined within. In the case of DirectoryMatch being use
d or
> Directory with ~ match, the value returned will always have any wildcards 
or
> regular expressions expanded and will show the true physical directory mat
ched
> by Apache for the request.
> This function is effectively a wrapper around the value of req.hlist.direc
tory,
> but is actually a bit more complicated than that. The reason there is a bi
t
> more to it than that, is that the function is actually callable while modu
les
> are being imported, ie., outside of the context of the actual request hand
ler.
> It is able to be called in this way, as the new importer sets up a per thr
ead
> cache where it stashes the information for access for the life of the requ
est.
> Further complications arise where req.add_handler() is used and no handler
 path
> is supplied as last argument to this function. In that case req.hlist.dire
ctory
> is None, but the handler path associated with the context in which
> req.add_handler() was called can be determined by tracking back through
> req.hlist.parent until the directory attribute is specified. To avoid a us
er
> doing this, the value that apache.get_handler_root() returns has already h
ad
> that done where necessary.
> The reason for making the handler root available when modules are being
> imported, as it then makes it a lot easier for web applications to use the
> directory that Python*Handler directive was defined for as an anchor point
 for
> the application code, with access to further module imports or config file
s
> being made in respect of this directive dynamically rather than have to ha
rd
> code paths in the Apache configuration using PythonOption. In using this
> though, one does have to be careful that modules aren't shared between two
> handler roots by using PythonInterpreter to separate two distinct web
> applications when necessary.
> This is all well and good if the Directory/DirectoryMatch directives are u
sed,
> but useless if the Location/LocationMatch directives are used. Where these
 are
> currently used, apache.get_handler_root() and req.hlist.directory yield '/
'. I
> think originally I had the code returning an empty string, but when suppor
t for
> expansion of wildcards was added and path normalisation done, the '/' was
> getting returned instead.
> For starters, instead of '/' the None value should be the result where
> Location/LocationMatch directives are used. Second, there should really be
 an
> equivalent to req.hlist.location which yields the leading part or the URL 
which
> corresponds to the directory stored in req.hlist.directory. In effect this
 is
> yielding an absolute base URL and would mean that it would no longer be
> necessary to perform calculations like described in:
>   http://www.modpython.org/pipermail/...rch/020501.html
> for calculating handler base URLs where Directory/DirectoryMatch is used,
> something that most people seem to get wrong from what I have seen.
> An important thing about that code is that it only works for when
> Directory/DirectoryMatch is used. There is actually no way (at least that 
I
> know of), for actually determining what the expanded path corresponding to
 a
> Location/LocationMatch directive is. This is a major grumbling point for
> packages like Trac, MoinMoin, Django and TurboGears, as it means that they
 have
> to require the user to manually duplicate the path to the directive in a
> PythonOption or using some other configuration mechanism so that the packa
ge
> knows where its root URL is.
> Thus, if req.hlist.location can be supplied, this would solve this problem
. In
> respect of apache.get_handler_root(), am not sure there really should be a
n
> equivalent within the apache module as knowing the location at the time of
> import sounds a bit dubious to me even if it might be useful if a package
> performs configuration at time of import. It would be much more sensible f
or a
> package to use the req.hlist.location value at the time of each request. O
ne
> option is to add a req.base_uri attribute or req.get_base_uri() method to 
the
> request object. This would take into consideration the need to recurse bac
k
> through parent handler contexts where req.add_handler() is used, like with
> req.hlist.directory.
> In summary:
> 1. Change code so req.hlist.directory is None where Location/LocationMatch
> directive is used.
> 2. Add req.hlist.location which gives the base URL, ie., leading path of U
RL,
> which equates to the directory specified by req.hlist.directory where the
> directory has come from the Apache configuration.
> 3. Look at adding a new method or attribute to request object which provid
es
> the base URL with value being inherited from parent handler contexts where
> appropriate. Would need to select an appropriate name for this.
> I think this is important enough to sneak it into mod_python 3.3, then we 
can
> silence those other packages who grumble that it can't be determined. :-)






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:23 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register