~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/zptsupport.py

  • Committer: Tom Haddon
  • Date: 2008-11-24 20:26:26 UTC
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: tom.haddon@canonical.com-20081124202626-x0sva3e7zxlqtckw
Allow the script to run as root or another user, but start the loggerhead process as the correct user

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import logging
19
19
import os
20
20
import pkg_resources
21
 
import re
22
21
import StringIO
23
22
 
24
23
from simpletal import simpleTAL, simpleTALES
34
33
    tinstance = _zpt_cache.get(tfile)
35
34
    stat = os.stat(tfile)
36
35
    if tinstance is None or tinstance.stat != stat:
37
 
        text = open(tfile).read()
38
 
        text = re.sub(r'\s*\n\s*', '\n', text)
39
 
        text = re.sub(r'[ \t]+', ' ', text)
40
36
        tinstance = _zpt_cache[tfile] = TemplateWrapper(
41
 
            simpleTAL.compileXMLTemplate(text), tfile, stat)
 
37
            simpleTAL.compileXMLTemplate(open(tfile)), tfile, stat)
42
38
    return tinstance
43
39
 
44
40