Changeset 10610 for main


Ignore:
Timestamp:
10 Sep 2013, 15:06:04 (11 years ago)
Author:
uli
Message:

Read shared header and footer only once. Both are short enough to keep them in memory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/server.py

    r10607 r10610  
    2222template_dir = os.path.join(os.path.dirname(__file__), 'templates')
    2323
     24#: A piece of HTML that can be used in HTML headers.
     25SHARED_HEADER = open(os.path.join(template_dir, 'part_header.tpl'), 'r').read()
     26
     27#: A piece of HTML that can be used in HTML footers.
     28SHARED_FOOTER = open(os.path.join(template_dir, 'part_footer.tpl'), 'r').read()
     29
     30#: Seed random.
    2431RANDOM = random.SystemRandom(os.urandom(1024))
    2532
     
    188195    if os.path.isfile(path):
    189196        html = open(path, 'r').read()
    190         html = html.replace(
    191             'PART_HEADER',
    192             open(os.path.join(template_dir, 'part_header.tpl'), 'r').read())
    193         html = html.replace(
    194             'PART_FOOTER',
    195             open(os.path.join(template_dir, 'part_footer.tpl'), 'r').read())
     197        html = html.replace('PART_HEADER', SHARED_HEADER)
     198        html = html.replace('PART_FOOTER', SHARED_FOOTER)
    196199        return html
    197200    return None
Note: See TracChangeset for help on using the changeset viewer.