コード例 #1
0
ファイル: user.py プロジェクト: mobyle2-legacy/mobyle2.core
 def construct(self):
    base_user = self.base_user
    if not len(self.projects):
         # we do not have yet an project even the default one, 
         # creating the user project
         will, tries, project = -1, 10 , None 
         message = ''
         while tries:
             tries -= 1
             will += 1
             try:
                 pname = 'Default project of %s' % base_user.username
                 if will:
                     pname = '%s (%s)' % (pname, will)
                 project = Project.create(pname, _('Default project created on sign in'), self)
                 break
             except Exception, e:
                 raise
                 message = '%s' % e
                 tries -= 1
         if message:
             error = 'Default project for %s cannot be created' % base_user.username
             if message: error += ' : %s' % message
             logging.getLogger('mobyle2.create_user').error(error)
コード例 #2
0
# -*- coding: utf-8 -*-
__docformat__ = 'restructuredtext en'

from lxml import etree
from glob import glob
import sys, os
import logging
import shutil

from pyramid.paster import bootstrap

from mobyle2.core.models.project import Project, Service
from mobyle2.core.models import DBSession as session

public_project = Project.get_public_project()
public_user = public_project.owner

def insert_update_service(name,stype,description,package,classification):
    """Insert a service in the database as belonging
    to the local - and only - server of the public project."""
    try:
	svc = session.query(Service).filter_by(name=name,
				             server=public_project.servers[0],
				             project=public_project).first()
	if not svc:
	    logging.info("service %s new, adding to the server" % name)
            svc = Service()
            svc.name = name
            svc.server = public_project.servers[0]
            svc.project = public_project
	    session.add(svc)