Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 1772:eee2a0f99aea maint-0.6
oops
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 28 Aug 2003 05:20:40 +0000 |
| parents | d81d215167fd |
| children | ae5ed85b111a |
comparison
equal
deleted
inserted
replaced
| 1770:d97e8f4989b6 | 1772:eee2a0f99aea |
|---|---|
| 1 import sys, cgi, urllib, os, re, os.path, time, errno | 1 import sys, cgi, urllib, os, re, os.path, time, errno, mimetypes |
| 2 | 2 |
| 3 from roundup import hyperdb, date, rcsv | 3 from roundup import hyperdb, date, rcsv |
| 4 from roundup.i18n import _ | 4 from roundup.i18n import _ |
| 5 | 5 |
| 6 try: | 6 try: |
| 114 # compiled template is up to date | 114 # compiled template is up to date |
| 115 return self.templates[src] | 115 return self.templates[src] |
| 116 | 116 |
| 117 # compile the template | 117 # compile the template |
| 118 self.templates[src] = pt = RoundupPageTemplate() | 118 self.templates[src] = pt = RoundupPageTemplate() |
| 119 pt.write(open(src).read()) | 119 # use pt_edit so we can pass the content_type guess too |
| 120 content_type = mimetypes.guess_type(filename)[0] or 'text/html' | |
| 121 pt.pt_edit(open(src).read(), content_type) | |
| 120 pt.id = filename | 122 pt.id = filename |
| 121 pt.mtime = time.time() | 123 pt.mtime = time.time() |
| 122 return pt | 124 return pt |
| 123 | 125 |
| 124 def __getitem__(self, name): | 126 def __getitem__(self, name): |
