Parent: [c2da1b] (diff)

Child: [2be128] (diff)

Download this file

prweb.py    77 lines (62 with data), 2.2 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#-*- python -*-
import logging
from tg import expose, redirect, validate, flash
from tg.decorators import with_trailing_slash, without_trailing_slash
from pylons import c
from allura.app import DefaultAdminController
from . import widgets
from . import model as SM
from .app_base import SFXBaseApp
log = logging.getLogger(__name__)
class W:
new_vhost = widgets.NewVHost()
mysql_password = widgets.MySQLPassword()
class VHostApp(SFXBaseApp):
'''This is the VHOST app for PyForge'''
tool_label='VHOST'
default_mount_label='VHOST'
default_mount_point='sfx-vhost'
ordinal=9
class AdminController(DefaultAdminController):
@with_trailing_slash
@expose('sfx.templates.vhost_admin')
def index(self, **kw):
c.new = W.new_vhost
return dict(vhosts=list(SM.VHost.find()))
@expose()
def create(self, name=None):
SM.VHost.create(name)
flash('Virtual host scheduled for creation.')
redirect('.')
@expose()
def delete(self, vhostid=None):
vhost = SM.VHost.get(vhostid)
if vhost is None:
flash('Virtual host %s not found' % vhostid, 'error')
vhost.delete()
flash('Virtual host %s deleted' % vhost.vhost_name)
redirect('.')
class MySQLApp(SFXBaseApp):
'''This is the MySQL app for PyForge'''
tool_label='MySQL Databases'
default_mount_label='MySQL'
default_mount_point='sfx-mysql'
ordinal=10
class AdminController(DefaultAdminController):
@with_trailing_slash
@expose('sfx.templates.mysql_admin')
def index(self, **kw):
c.form = W.mysql_password
return dict(value=SM.MySQL())
@without_trailing_slash
@validate(W.mysql_password, error_handler=index)
@expose()
def save(self, **kw):
db = SM.MySQL()
if db.passwd_rouser is None:
SM.MySQL.create(**kw)
flash('Passwords set')
else:
db.update(**kw)
flash('Passwords updated')
redirect('.')