本文整理汇总了Python中autonomie.models.company.Company.get方法的典型用法代码示例。如果您正苦于以下问题:Python Company.get方法的具体用法?Python Company.get怎么用?Python Company.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie.models.company.Company
的用法示例。
在下文中一共展示了Company.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import get [as 别名]
def upgrade():
from autonomie.models.company import Company
from autonomie.models.files import File
from autonomie.models import DBSESSION
from alembic.context import get_bind
from autonomie.models.config import ConfigFiles
for i in ('header_id', 'logo_id',):
col = sa.Column(i, sa.Integer, sa.ForeignKey('file.id'))
op.add_column('company', col)
query = "select id, header, logo from company;"
conn = get_bind()
result = conn.execute(query)
session = DBSESSION()
for id_, header, logo in result:
company = Company.get(id_)
basepath = u"%scompany/%s" % (BASEFILEPATH, id_,)
if header:
header_path = u"%s/header/%s" % (basepath, header)
try:
file_datas = load_file_struct(header_path, header)
except:
print("Error while loading a header")
print(id_)
file_datas = None
if file_datas:
company.header = file_datas
session.add(company.header_file)
session.flush()
if logo:
logo_path = u"%s/logo/%s" % (basepath, logo)
try:
file_datas = load_file_struct(logo_path, logo)
except:
print("Error while loading a logo")
print(id_)
file_datas = None
if file_datas:
company.logo = file_datas
company = session.merge(company)
session.flush()
filepath = u"%s/main/logo.png" % BASEFILEPATH
if os.path.isfile(filepath):
ConfigFiles.set('logo.png', load_file_struct(filepath, 'logo.png'))
filepath = u"%s/main/accompagnement_header.png" % BASEFILEPATH
if os.path.isfile(filepath):
ConfigFiles.set(
'accompagnement_header.png',
load_file_struct(filepath, 'accompagnement_header.png')
)