Mercurial > hg > SimpleWiki
comparison simplewiki/handlers.py @ 2:2464e2051b78
[mq]: index
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 07 Sep 2010 21:00:46 -0700 |
parents | 4c83f7715993 |
children | 56ab6b90cd1a |
comparison
equal
deleted
inserted
replaced
1:4c83f7715993 | 2:2464e2051b78 |
---|---|
82 | 82 |
83 def __call__(self): | 83 def __call__(self): |
84 return getattr(self, self.request.method.title())() | 84 return getattr(self, self.request.method.title())() |
85 | 85 |
86 def Get(self): | 86 def Get(self): |
87 # needs to have self.template set | |
88 template = self.app.loader.load(self.template) | 87 template = self.app.loader.load(self.template) |
89 return Response(content_type='text/html', | 88 return Response(content_type='text/html', |
90 body=template.generate(**self.data).render('html')) | 89 body=template.generate(**self.data).render('html')) |
91 | 90 |
91 | |
92 class Index(Handler): | |
93 | |
94 template = 'index.html' | |
95 | |
96 def __init__(self, app, request): | |
97 Handler.__init__(self, app, request) | |
98 self.directory = os.path.join(app.directory, *request.environ['path']) | |
99 if not os.path.isdir(self.directory): | |
100 raise HandlerMatchException | |
101 path = request.environ['path'] | |
102 files = [] | |
103 files = os.listdir(self.directory) | |
104 self.data = { 'request': request, | |
105 'link': self.link, | |
106 'directory': '/' + '/'.join(path), | |
107 'files': files } | |
108 | |
109 def __call__(self): | |
110 return getattr(self, self.request.method.title())() | |
111 | |
112 def Get(self): | |
113 if not self.request.path_info.endswith('/'): | |
114 self.redirect(self.request.path_info + '/') | |
115 template = self.app.loader.load(self.template) | |
116 return Response(content_type='text/html', | |
117 body=template.generate(**self.data).render('html')) | |
118 |