示例#1
0
文件: commands.py 项目: 28sui/uliweb
 def handle(self, options, global_options, *args):
     from uliweb.manage import make_simple_application
     from uliweb import orm
     from getpass import getpass
     
     app = make_simple_application(apps_dir=global_options.apps_dir, 
         settings_file=global_options.settings, local_settings_file=global_options.local_settings)
     db = orm.get_connection()
     
     username = ''
     while not username:
         username = raw_input("Please enter the super user's name: ")
     email = ''
     while not email:
         email = raw_input("Please enter the email of [%s]: " % username)
         
     password = ''
     while not password:
         password = getpass("Please enter the password for [%s(%s)]: " % (username, email))
     repassword = ''
     while not repassword:
         repassword = getpass("Please enter the password again: ")
     
     if password != repassword:
         print "The password is not matched, can't create super user!"
         return
     
     orm.set_dispatch_send(False)
     
     User = orm.get_model('user', options.engine)
     user = User(username=username, email=email)
     user.set_password(password)
     user.is_superuser = True
     user.save()
示例#2
0
    def handle(self, options, global_options, *args):
        from uliweb.manage import make_simple_application
        from uliweb import orm
        from getpass import getpass

        self.get_application(global_options)

        username = ''
        while not username:
            username = input("Please enter the super user's name: ")
        email = ''
        while not email:
            email = input("Please enter the email of [{}]: ".format(username))

        password = ''
        while not password:
            password = getpass(
                "Please enter the password for [{}({})]: ".format(
                    username, email))
        repassword = ''
        while not repassword:
            repassword = getpass("Please enter the password again: ")

        if password != repassword:
            print("The password is not matched, can't create super user!")
            return

        orm.set_dispatch_send(False)

        User = orm.get_model('user', options.engine)
        user = User(username=username, email=email)
        user.set_password(password)
        user.is_superuser = True
        user.save()
示例#3
0
 def handle(self, options, global_options, *args):
     from uliweb.core.SimpleFrame import Dispatcher
     from uliweb import orm
     from getpass import getpass
     
     app = Dispatcher(project_dir=global_options.project, start=False)
     orm.set_auto_create(True)
     db = orm.get_connection(app.settings.ORM.CONNECTION)
     
     username = ''
     while not username:
         username = raw_input("Please enter the super user's name: ")
     email = ''
     while not email:
         email = raw_input("Please enter the email of [%s]: " % username)
         
     password = ''
     while not password:
         password = getpass("Please enter the password for [%s(%s)]: " % (username, email))
     repassword = ''
     while not repassword:
         repassword = getpass("Please enter the password again: ")
     
     if password != repassword:
         print "The password is not matched, can't create super user!"
         return
     
     orm.set_dispatch_send(False)
     
     User = orm.get_model('user')
     user = User(username=username, email=email)
     user.set_password(password)
     user.is_superuser = True
     user.save()
示例#4
0
    def handle(self, options, global_options, *args):
        from uliweb.manage import make_simple_application
        from uliweb import orm
        from getpass import getpass

        app = make_simple_application(
            apps_dir=global_options.apps_dir,
            settings_file=global_options.settings,
            local_settings_file=global_options.local_settings)
        db = orm.get_connection()

        username = ''
        while not username:
            username = raw_input("Please enter the super user's name: ")
        email = ''
        while not email:
            email = raw_input("Please enter the email of [%s]: " % username)

        password = ''
        while not password:
            password = getpass("Please enter the password for [%s(%s)]: " %
                               (username, email))
        repassword = ''
        while not repassword:
            repassword = getpass("Please enter the password again: ")

        if password != repassword:
            print "The password is not matched, can't create super user!"
            return

        orm.set_dispatch_send(False)

        User = orm.get_model('user', options.engine)
        user = User(username=username, email=email)
        user.set_password(password)
        user.is_superuser = True
        user.save()
示例#5
0
文件: dbinit.py 项目: znanl/uliweb
import uliweb
from uliweb.utils.common import safe_str
from uliweb.orm import get_model, set_dispatch_send

set_dispatch_send(False)

Role = get_model('role')
Perm = get_model('permission')
Rel = get_model('role_perm_rel')

r = uliweb.settings.get('ROLES', {})
for name, v in r.items():
    if isinstance(v, (tuple, list)):
        if len(v) == 2:
            description, method = v
            reserve = False
        else:
            description, method, reserve = v
    else:
        description, reserve = v, True
    role = Role.get(Role.c.name == name)
    if not role:
        role = Role(name=safe_str(name),
                    description=safe_str(description),
                    reserve=reserve)
        msg = 'Add Role(%s)...' % name
    else:
        role.update(description=description, reserve=reserve)
        msg = 'Update Role(%s)...' % name
    flag = role.save()
    if flag:
#! /usr/bin/env python
# coding=utf-8

from uliweb import settings, functions
from uliweb.manage import make_simple_application
from uliweb.orm import Begin, Commit, Rollback
from uliweb.orm import set_dispatch_send


set_dispatch_send(False)


def import_mock_data():
    panel = functions.get_model('dashboardpanel')
    panellayout = functions.get_model('dashboardpanellayout')

    for data in settings.PANEL_MOCKDATA.panels:
        obj = panel(**data)
        obj.save()

    for data in settings.PANEL_DASHBOARD_MOCKDATA.layout:
        board, panel_layout, pane, row, col = data
        layout = {}

        layout['dashboard_name'] = board
        layout['panel'] = panel.get(panel.c.name == pane)
        layout['row'] = row
        layout['col'] = col
        layout['layout'] = panel_layout
        obj = panellayout(**layout)
        obj.save()
示例#7
0
 def process_request(self, request):
     set_echo(False)
     set_dispatch_send(True)