Merge lp://staging/~beuno/loggerhead/abstract_paths into lp://staging/loggerhead

Proposed by Martin Albisetti
Status: Merged
Merged at revision: 233
Proposed branch: lp://staging/~beuno/loggerhead/abstract_paths
Merge into: lp://staging/loggerhead
To merge this branch: bzr merge lp://staging/~beuno/loggerhead/abstract_paths
Reviewer Review Type Date Requested Status
Paul Hummer (community) Needs Fixing
Loggerhead Team Pending
Review via email: mp+1414@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) wrote :

The branch refactors a few cruft, and implements paths instead of file_ids to navigate through Loggerhead

Revision history for this message
Paul Hummer (rockstar) wrote :
Download full text (18.9 KiB)

=== modified file 'loggerhead/controllers/__init__.py'
--- loggerhead/controllers/__init__.py 2008-09-30 02:04:14 +0000
+++ loggerhead/controllers/__init__.py 2008-10-25 18:13:27 +0000
@@ -63,8 +63,8 @@ class TemplatedBranchView(object):
     def __call__(self, environ, start_response):
         z = time.time()
         h = self._history
- kw = dict(parse_querystring(environ))
- util.set_context(kw)
+ kwargs = dict(parse_querystring(environ))
+ util.set_context(kwargs)
         args = []
         while 1:
             arg = path_info_pop(environ)
@@ -72,6 +72,17 @@ class TemplatedBranchView(object):
                 break
             args.append(arg)

+ revid = None
+ if h is not None:
+ if len(args) > 0:
+ revid = h.fix_revid(args[0])
+ else:
+ revid = h.last_revid
+
+ path = None
+ if len(args) > 1:
+ path = '/'.join(args[1:])
+
         vals = {
             'static_url': self._branch.static_url,
             'branch': self._branch,
@@ -81,7 +92,7 @@ class TemplatedBranchView(object):
         }
         vals.update(templatefunctions)
         headers = {}
- vals.update(self.get_values(h, args, kw, headers))
+ vals.update(self.get_values(h, revid, path, kwargs, headers))

         self.log.info('Getting information for %s: %r secs' % (
             self.__class__.__name__, time.time() - z,))
@@ -93,6 +104,7 @@ class TemplatedBranchView(object):
         w = BufferingWriter(writer, 8192)
         template.expand_into(w, **vals)
         w.flush()
- self.log.info('Rendering %s: %r secs, %s bytes, %s (%2.1f%%) bytes saved' % (
- self.__class__.__name__, time.time() - z, w.bytes, w.bytes_saved, 100.0*w.bytes_saved/w.bytes))
+ self.log.info('Rendering %s: %r secs, %s bytes, %s (%2.1f%%) bytes saved' %
+ (self.__class__.__name__, time.time() - z, w.bytes, w.bytes_saved,
+ 100.0*w.bytes_saved/w.bytes))
         return []

=== modified file 'loggerhead/controllers/annotate_ui.py'
--- loggerhead/controllers/annotate_ui.py 2008-09-09 22:42:27 +0000
+++ loggerhead/controllers/annotate_ui.py 2008-10-25 18:13:27 +0000
@@ -36,19 +36,10 @@ class AnnotateUI (TemplatedBranchView):

     template_path = 'loggerhead.templates.annotate'

- def get_values(self, h, args, kw, headers):
- if len(args) > 0:
- revid = h.fix_revid(args[0])
- else:
- revid = h.last_revid
-
- path = None
- if len(args) > 1:
- path = '/'.join(args[1:])
- if not path.startswith('/'):
- path = '/' + path
+ def get_values(self, h, revid, path, kwargs, headers):

- file_id = kw.get('file_id', None)
+ revid = h.fix_revid(revid)
+ file_id = kwargs.get('file_id', None)
         if (file_id is None) and (path is None):
             raise HTTPBadRequest('No file_id or filename provided to annotate')

=== modified file 'loggerhead/controllers/atom_ui.py'
--- loggerhead/controllers/atom_ui.py 2008-07-22 00:40:03 +0000
+++ loggerhead/controllers/atom_ui.py 2008-10-25 18:13:27 +0000
@@ -24,7 +24,...

Revision history for this message
Paul Hummer (rockstar) wrote :
Download full text (20.3 KiB)

Branch is good. I'd vote tweak on a few small, stylistic changes: 80 line
character breaks, the var name h should be history, and a single tab.

> === modified file 'loggerhead/controllers/__init__.py'
> --- loggerhead/controllers/__init__.py 2008-09-30 02:04:14 +0000
> +++ loggerhead/controllers/__init__.py 2008-10-25 18:13:27 +0000
> @@ -63,8 +63,8 @@ class TemplatedBranchView(object):
> def __call__(self, environ, start_response):
> z = time.time()
> h = self._history
> - kw = dict(parse_querystring(environ))
> - util.set_context(kw)
> + kwargs = dict(parse_querystring(environ))
> + util.set_context(kwargs)
> args = []
> while 1:
> arg = path_info_pop(environ)
> @@ -72,6 +72,17 @@ class TemplatedBranchView(object):
> break
> args.append(arg)
>
> + revid = None
> + if h is not None:
> + if len(args) > 0:
> + revid = h.fix_revid(args[0])
> + else:
> + revid = h.last_revid
> +
> + path = None
> + if len(args) > 1:
> + path = '/'.join(args[1:])
> +
> vals = {
> 'static_url': self._branch.static_url,
> 'branch': self._branch,
> @@ -81,7 +92,7 @@ class TemplatedBranchView(object):
> }
> vals.update(templatefunctions)
> headers = {}
> - vals.update(self.get_values(h, args, kw, headers))
> + vals.update(self.get_values(h, revid, path, kwargs, headers))
>
> self.log.info('Getting information for %s: %r secs' % (
> self.__class__.__name__, time.time() - z,))
> @@ -93,6 +104,7 @@ class TemplatedBranchView(object):
> w = BufferingWriter(writer, 8192)
> template.expand_into(w, **vals)
> w.flush()
> - self.log.info('Rendering %s: %r secs, %s bytes, %s (%2.1f%%) bytes saved' % (
> - self.__class__.__name__, time.time() - z, w.bytes, w.bytes_saved, 100.0*w.bytes_saved/w.bytes))
> + self.log.info('Rendering %s: %r secs, %s bytes, %s (%2.1f%%) bytes saved' %
> + (self.__class__.__name__, time.time() - z, w.bytes, w.bytes_saved,
> + 100.0*w.bytes_saved/w.bytes))
> return []
>

Break at 80 characters please.

> === modified file 'loggerhead/controllers/annotate_ui.py'
> --- loggerhead/controllers/annotate_ui.py 2008-09-09 22:42:27 +0000
> +++ loggerhead/controllers/annotate_ui.py 2008-10-25 18:13:27 +0000
> @@ -36,19 +36,10 @@ class AnnotateUI (TemplatedBranchView):
>
> template_path = 'loggerhead.templates.annotate'
>
> - def get_values(self, h, args, kw, headers):
> - if len(args) > 0:
> - revid = h.fix_revid(args[0])
> - else:
> - revid = h.last_revid
> -
> - path = None
> - if len(args) > 1:
> - path = '/'.join(args[1:])
> - if not path.startswith('/'):
> - path = '/' + path
> + def get_values(self, h, revid, path, kwargs, headers):
>
> - file_id = kw.get('file_id', None)
> + revid = h.fix_revid(revid)
> + file_id = kwargs.get('file_id', None)
...

review: Needs Fixing
231. By Martin Albisetti

Updated NEWS

Revision history for this message
Martin Albisetti (beuno) wrote :

Fixed.
Thanks for the review, merging!

Revision history for this message
Martin Albisetti (beuno) wrote :

Merged!

232. By Martin Albisetti

80 char fixes

233. By Martin Albisetti

s/h/history/

Subscribers

People subscribed via source and target branches