~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/directory_ui.py

  • Committer: Michael Hudson
  • Date: 2008-08-04 21:22:16 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: michael.hudson@canonical.com-20080804212216-ipcz6x168fxie6b3
fix for non-branch case, small cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
 
23
23
from bzrlib import branch
24
 
from bzrlib import errors
25
24
 
26
25
from loggerhead.controllers import TemplatedBranchView
27
26
 
30
29
        self.dirname = dirname
31
30
        self.parity = parity
32
31
        self.branch = branch
33
 
        self.last_change =  datetime.datetime.fromtimestamp(
 
32
        if branch is not None:
 
33
            self.last_change =  datetime.datetime.fromtimestamp(
34
34
                branch.repository.get_revision(branch.last_revision()).timestamp)
35
35
 
36
36
class DirectoryUI(TemplatedBranchView):
40
40
    template_path = 'loggerhead.templates.directory'
41
41
 
42
42
    def __init__(self, static_url_base, path, name):
43
 
        class branch(object):
44
 
            @staticmethod
45
 
            def static_url(path):
46
 
                return self._static_url_base + path
 
43
        class _branch(object):
47
44
            context_url = 1
48
 
        self._branch = branch
 
45
        self._branch = _branch
49
46
        self._history = None
50
47
        self._path = path
51
48
        self._name = name
59
56
        listing.sort(key=lambda x: x.lower())
60
57
        dirs = []
61
58
        parity = 0
 
59
        def static_url(path):
 
60
            return self._static_url_base + path
62
61
        for d in listing:
63
62
            p = os.path.join(self._path, d)
64
63
            try:
70
69
        return {
71
70
            'dirs': dirs,
72
71
            'name': self._name,
 
72
            'static_url': static_url,
73
73
            }