Child: [d5a6fa] (diff)

Download this file

dl_main.py    62 lines (46 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#-*- python -*-
import logging
# Non-stdlib imports
import pkg_resources
from tg import expose, validate, redirect, response, config
from pylons import g, c, request
from pymongo.bson import ObjectId
# Pyforge-specific imports
from pyforge.app import Application, ConfigOption, SitemapEntry, DefaultAdminController
from pyforge.lib import helpers as h
from pyforge.lib.security import require, has_artifact_access
from pyforge.model import ProjectRole
# Local imports
from forgedownloads import version
from pyforge.ext.sfx.lib.sfx_api import SFXProjectApi
log = logging.getLogger(__name__)
class ForgeDownloadsApp(Application):
__version__ = version.__version__
permissions = [ 'configure', 'read' ]
searchable=True
# installable=config['auth.method'] == 'sfx'
templates=None
def __init__(self, project, config):
Application.__init__(self, project, config)
self.root = RootController()
@property
@h.exceptionless([], log)
def sitemap(self):
menu_id = self.config.options.mount_point.title()
api = SFXProjectApi()
url='http://sf.net/downloads/' + api._unix_group_name(c.project.neighborhood, c.project.shortname) + '/'
return [SitemapEntry(menu_id, url)[self.sidebar_menu()] ]
def sidebar_menu(self):
return []
def admin_menu(self):
return super(ForgeDownloadsApp, self).admin_menu()
class RootController(object):
def __init__(self):
setattr(self, 'nav.json', self.nav)
@expose('json:')
def nav(self):
return dict(menu=[
dict(name=s.label,
url=s.url,
icon=s.ui_icon)
for s in c.project.sitemap() ])