~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/directory_ui.py

  • Committer: Michael Hudson
  • Date: 2009-02-26 02:06:31 UTC
  • Revision ID: michael.hudson@canonical.com-20090226020631-qzyi4o6hbtph9brg
stupidize CSS until IE6 gets it more or less right

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import datetime
20
20
import logging
21
 
import stat
 
21
import os
22
22
 
23
 
from bzrlib import branch, errors
 
23
from bzrlib import branch
24
24
 
25
25
from loggerhead import util
26
26
from loggerhead.controllers import TemplatedBranchView
48
48
 
49
49
    template_path = 'loggerhead.templates.directory'
50
50
 
51
 
    def __init__(self, static_url_base, transport, name):
 
51
    def __init__(self, static_url_base, path, name):
52
52
 
53
53
        class _branch(object):
54
54
            context_url = 1
57
57
            def static_url(path):
58
58
                return self._static_url_base + path
59
59
        self._branch = _branch
60
 
        self._history_callable = lambda: None
 
60
        self._history_callable = lambda:None
 
61
        self._path = path
61
62
        self._name = name
62
63
        self._static_url_base = static_url_base
63
 
        self.transport = transport
64
64
        self.log = logging.getLogger('')
65
65
 
66
66
    def get_values(self, path, kwargs, response):
67
 
        listing = [d for d in self.transport.list_dir('.')
68
 
                   if not d.startswith('.')]
 
67
        listing = [d for d in os.listdir(self._path)
 
68
                   if not d.startswith('.')
 
69
                   and os.path.isdir(os.path.join(self._path, d))]
69
70
        listing.sort(key=lambda x: x.lower())
70
71
        dirs = []
71
72
        parity = 0
72
73
        for d in listing:
 
74
            p = os.path.join(self._path, d)
73
75
            try:
74
 
                b = branch.Branch.open_from_transport(self.transport.clone(d))
75
 
                if b.get_config().get_user_option('http_serve') == 'False':
76
 
                    continue
 
76
                b = branch.Branch.open(p)
77
77
            except:
78
 
                try:
79
 
                    if not stat.S_ISDIR(self.transport.stat(d).st_mode):
80
 
                        continue
81
 
                except errors.NoSuchFile:
82
 
                    continue
83
78
                b = None
84
79
            dirs.append(DirEntry(d, parity, b))
85
80
            parity = 1 - parity