~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/__init__.py

  • Committer: Matt Nordhoff
  • Date: 2009-05-04 20:29:13 UTC
  • Revision ID: mnordhoff@mattnordhoff.com-20090504202913-tmlkyrrlwojyzgha
Fix typo in NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 
20
 
import re
21
20
import time
22
21
 
23
22
from paste.request import path_info_pop, parse_querystring
34
33
        self.buf = []
35
34
        self.buflen = 0
36
35
        self.writefunc = writefunc
37
 
        self.bytes_saved = 0
38
36
        self.buf_limit = buf_limit
39
37
 
40
38
    def flush(self):
41
 
        chunk = ''.join(self.buf)
42
 
        chunk = re.sub(r'\s*\n\s*', '\n', chunk)
43
 
        chunk = re.sub(r'[ \t]+', ' ', chunk)
44
 
        self.bytes_saved += self.buflen - len(chunk)
45
 
        self.writefunc(chunk)
 
39
        self.writefunc(''.join(self.buf))
46
40
        self.buf = []
47
41
        self.buflen = 0
48
42
 
109
103
        template.expand_into(w, **vals)
110
104
        w.flush()
111
105
        self.log.info(
112
 
            'Rendering %s: %r secs, %s bytes, %s (%2.1f%%) bytes saved' % (
113
 
                self.__class__.__name__,
114
 
                time.time() - z,
115
 
                w.bytes,
116
 
                w.bytes_saved,
117
 
                100.0*w.bytes_saved/w.bytes))
 
106
            'Rendering %s: %r secs, %s bytes' % (
 
107
                self.__class__.__name__, time.time() - z, w.bytes))
118
108
        return []
119
109
 
120
110
    def get_revid(self):
121
111
        h = self._history
122
112
        if h is None:
123
113
            return None
124
 
        if len(self.args) > 0:
 
114
        if len(self.args) > 0 and self.args != ['']:
125
115
            return h.fix_revid(self.args[0])
126
116
        else:
127
117
            return h.last_revid