Download this file

prweb.py    110 lines (90 with data), 3.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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#-*- 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()
prweb_email_password = widgets.PRWebEmailPassword()
class VHostApp(SFXBaseApp):
'''This is the VHOST app for PyForge'''
tool_label='VHOST'
default_mount_label='VHOST'
default_mount_point='sfx-vhost'
status='alpha'
ordinal=9
class AdminController(DefaultAdminController):
@with_trailing_slash
@expose('jinja:sfx/vhost_admin.html')
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'
status='alpha'
ordinal=10
class AdminController(DefaultAdminController):
@with_trailing_slash
@expose('jinja:sfx/mysql_admin.html')
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('.')
class PRWebEmailApp(SFXBaseApp):
'''This is the Project Web Email Password app for PyForge'''
tool_label='Project Web Outgoing Email'
default_mount_label='PRWebEmail'
default_mount_point='sfx-smtp'
status='alpha'
ordinal=11
class AdminController(DefaultAdminController):
@with_trailing_slash
@expose('jinja:sfx/prweb_email_admin.html')
def index(self, **kw):
c.form = W.prweb_email_password
return dict(value=SM.PRWebEmailAddress())
@without_trailing_slash
@validate(W.prweb_email_password, error_handler=index)
@expose()
def save(self, **kw):
db = SM.PRWebEmailAddress()
if db.passwd is None:
SM.PRWebEmailAddress.create(**kw)
flash('Password set')
else:
db.update(**kw)
flash('Password updated')
redirect('.')