Re: [viewvc-dev] [PATCH] mod_python configuration

Alon Bar-Lev <[email protected]> Thu, 15 Sep 2011 20:11:11 +0300
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Message-ID <CAOazyz0x0wLLvYTM-L_Du_+MLBPwvx-318bxqeE8Y+XbMeRnHg__48201.9088617109$1316106680$gmane$org@mail.gmail.com>
On Thu, Sep 15, 2011 at 7:51 PM, C. Michael Pilato <[email protected]> wrote:
> On 09/15/2011 11:19 AM, Alon Bar-Lev wrote:
>>> That said, in reviewing your patch, it occurs to me that the code in
>>> viewvc.load_config() probably shouldn't use os.environ() to check for that
>>> variable, but (if a 'server' is provided') should use server.getenv()
>>> instead.  That way, the appropriate environment-checking function for the
>>> deployment type (mod_python, CGI, IIS, etc.) is used.
>>>
>>> Would you be willing to explore this idea a bit to see if it makes sense?
>>
>> Well,
>>
>> SetEnv does not work in mod_python, at least not in my setup.
>
> How do you know that SetEnv doesn't work for mod_python?  How are you
> testing that?

Apache
---
<Location /viewvc>
       DirectoryIndex viewvc.py
#       PythonOption org.viewvc.conf_file "/var/www/localhost/conf/viewvc.conf"
       SetEnv VIEWVC_CONF_PATHNAME "/var/www/localhost/conf/viewvc.conf"
</Location>
---

Viewvc
---
     pathname = (server.getenv("VIEWVC_CONF_PATHNAME")
                 or os.environ.get("VIEWVC_CONF_PATHNAME")
                 or os.environ.get("VIEWCVS_CONF_PATHNAME")
                 or os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                 "viewvc.conf"))
---

Well, I am more like C guy but it looks right and does not work.
I may miss something?
Does it work for you?

>
>> So we need something like:
>>
>>   if pathname is None:
>>     pathname = (server.get_options()["org.viewvc.conf_file"]              <----
>>                 or os.environ.get("VIEWVC_CONF_PATHNAME")
>>                 or os.environ.get("VIEWCVS_CONF_PATHNAME")
>>                 or os.path.join(os.path.dirname(os.path.dirname(__file__)),
>>                                 "viewvc.conf"))
>>
>> However

Correction, the server is your own viewvc object... so it actually need to be:

  pathname = (server.request.get_options()["org.viewvc.conf_file"]
                or os.environ.get("VIEWVC_CONF_PATHNAME")
                or os.environ.get("VIEWCVS_CONF_PATHNAME")
                or os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                "viewvc.conf"))


>>
>> 1. The python throws and exception if element within hash is not found
>> (I expect it to return None...) so I leave it for you...
>
> server.get_options().get("org.viewvc.conf_file") returns None of the key
> doesn't exist in the dictionary/hash.

Strange, I getting an exception.
---
 File "/usr/lib64/python2.7/site-packages/viewvc/viewvc.py", line
4411, in load_config
    pathname = (server.request.get_options()["org.viewvc.conf_file44"]

KeyError: 'org.viewvc.conf_file44'
---

Not python developer...

But I can add get_option in the ModPythonServer object that returns
None if not exists.

>
>> 2. Correct me if I am wrong but this does not overrides the default
>> within file, it does set if config is null, and it never is as the
>> viewvc-install sets CONF_PATHNAME to none null.
>> I expect environment / option to override the hard coded anyway, so
>> remove the "if pathname is None:" (and of course un-indent...).
>
> You are correct.  I read that wrongly.
>
>> 3. Environment(or options) should be documented in INSTALL.... A
>> complete <Directory sample would be nice! :)
>
> Fair enough.  :-)
>
> --
> C. Michael Pilato <[email protected]>
> CollabNet   <>   www.collab.net   <>   Distributed Development On Demand
>
>

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4251&dsMessageId=2839270

To unsubscribe from this discussion, e-mail: [[email protected]].