[mod_python] Using a psp parser from outside mod_python

dharana dharana at dharana.net
Thu Jun 23 13:48:40 EDT 2005


Hmmm,

-----
from mod_python import _psp
_psp.parsestring(python_code)
-----

works without any problems as it has no needs to be in apache env. Shouldn't we 
split psp.py into the apache-specific stuff (PSP class) and general purpose 
stuff for better modularity? I find myself using _psp.parsestring instead of 
psp.parsestring a lot more. And I think the _psp functions shouldn't be directly 
called (correct me please if I'm wrong).


Jim Gallacher wrote:
> dharana wrote:
> 
>> Hello list,
>>
>> If I try to:
>>
>>     from mod_python.psp import PSP
>>
>> from a cmdline python script I get "ImportError: No module named 
>> _apache". I'm dynamically generating psp templates (mixes of xhtml and 
>> <% %> tags) that need to be parsed into full xhtml from a non-apache 
>> env. Is there any possibility of using PSP this way?
>>
> 
> A quick look at psp.py indicates that the _apache module (which is only 
> available within the apache) is used for acquiring a global lock on the 
> dbm file used for caching psp pages.
> 
> It should be easy to adapt psp.py to implement your own locking scheme, 
> or eliminate locking altogether if you are generating your pages in a 
> single process.
> 
> And I'm sure you've already figured out that you'll need to simulate the 
> request object.
> 
> Regards
> Jim
> 
> 
> 
> 

-- 
dharana



More information about the Mod_python mailing list