本文整理汇总了Python中pvscore.model.meta.Session类的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: init_model
def init_model(engine, settings):
"""
import os
app_extension = config['app_conf']['pvs.core.extension']
extension_root = config['app_conf']['pvs.extension.root.dir']
if os.path.exists('%s/%s/model' % (extension_root, app_extension)):
m = '%s.model' % config['app_conf']['pvs.core.extension']
#print 'load_model(%s)' % m
exec 'import %s' % m
from pvscore.lib.plugin import plugin_registry
for plugin_name in plugin_registry:
plugin = plugin_registry[plugin_name]
if os.path.exists(plugin.model_path):
#print 'load_model(%s)' % plugin.model_package_name
exec 'import %s' % plugin.model_package_name
"""
# KB: [2011-09-05]: We make this check because when running under Nose,
# It nags us that this has already been done. This just eliminates the nag message.
if Session.registry and not Session.registry.has():
psycopg2.extras.register_uuid()
Session.configure(bind=engine)
#load everything from the pvs.* keys in the config file into redis
for setting in settings:
log.debug('%s = %s' % (setting, settings[setting]))
if setting.startswith('pvs.'):
util.cache_set(setting, settings[setting])
开发者ID:anonymoose,项目名称:pvscore,代码行数:30,代码来源:__init__.py
示例2: find_by_name
def find_by_name(site, name, cached=True):
if cached:
return Session.query(Content)\
.options(FromCache('Content.find_by_name', "%s/%s" % (site.site_id, name)))\
.filter(and_(Content.site == site,
Content.name == name,
Content.delete_dt == None)).first()
else:
return Session.query(Content)\
.filter(and_(Content.site == site,
Content.name == name,
Content.delete_dt == None)).first()
开发者ID:anonymoose,项目名称:pvscore,代码行数:12,代码来源:content.py
示例3: find_payments_by_order
def find_payments_by_order(order):
return Session.query(Journal).filter(and_(Journal.customer==order.customer,
Journal.order==order,
Journal.delete_dt == None,
or_(Journal.type=='PartialPayment',
Journal.type=='FullPayment')))\
.order_by(Journal.create_dt.desc()).all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:journal.py
示例4: find
def find(email, campaign):
""" KB: [2010-12-15]: Find another customer that is in the same company. """
from pvscore.model.crm.campaign import Campaign
return Session.query(Customer).join((Campaign, Campaign.campaign_id == Customer.campaign_id)) \
.filter(and_(Customer.delete_dt == None,
Campaign.company_id == campaign.company_id,
Customer.email.ilike(email))).first()
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:customer.py
示例5: find_by_customer
def find_by_customer(customer, order_id): # =None, start_dt=None, end_dt=None):
if order_id:
return (
Session.query(CustomerOrder)
.filter(and_(CustomerOrder.customer == customer, CustomerOrder.order_id == order_id))
.first()
)
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:customerorder.py
示例6: find_by_user
def find_by_user(user):
return (
Session.query(Appointment)
.filter(or_(Appointment.creator == user, Appointment.assigned == user))
.order_by(Appointment.start_dt.asc(), Appointment.start_time.asc())
.all()
)
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:appointment.py
示例7: find_by_customer
def find_by_customer(customer):
return (
Session.query(Appointment)
.filter(Appointment.customer == customer)
.order_by(Appointment.start_dt.desc(), Appointment.start_time.asc())
.all()
)
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:appointment.py
示例8: find
def find(attr, fk_id):
#pylint: disable-msg=E1101
#TODO: Fix attribute value caching: .options(FromCache('AttributeValue.find.%s.%s' % (attr.attr_id, fk_id)))\
return Session.query(AttributeValue)\
.filter(and_(AttributeValue.fk_type == attr.fk_type,
AttributeValue.fk_id == fk_id,
AttributeValue.attr_id == attr.attr_id)).first()
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:attribute.py
示例9: find_all
def find_all(enterprise_id):
#pylint: disable-msg=E1101
return Session.query(Campaign) \
.options(FromCache('Campaign.find_all', enterprise_id)) \
.join((Company, Campaign.company_id == Company.company_id)).filter(and_(Campaign.delete_dt == None,
Company.enterprise_id == enterprise_id)) \
.order_by(Company.default_campaign_id.desc(), Campaign.name).all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:campaign.py
示例10: find_all
def find_all(enterprise_id):
return Session.query(Vendor).options(FromCache('Vendor.find_all', enterprise_id)) \
.filter(and_(Vendor.delete_dt == None,
Vendor.enterprise_id == enterprise_id
)) \
.order_by(Vendor.name) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:purchase.py
示例11: find_for_object
def find_for_object(obj):
fk_type = type(obj).__name__
fk_id = getattr(obj, obj.__pk__)
#pylint: disable-msg=E1101
return Session.query(Asset) \
.options(FromCache('Asset.find_for_object', '%s/%s' % (fk_type, fk_id))) \
.filter(and_(Asset.fk_type == fk_type,
Asset.fk_id == fk_id)).all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:8,代码来源:asset.py
示例12: find_all_applicable
def find_all_applicable(enterprise_id, obj):
# KB: [2010-11-29]: Eventually this will get more complex and base its
# behavior off the current state of the customer.
return Session.query(StatusEvent)\
.filter(and_(or_(StatusEvent.enterprise_id == enterprise_id, StatusEvent.enterprise_id == None),
StatusEvent.is_system == False,
StatusEvent.event_type == type(obj).__name__))\
.order_by(StatusEvent.short_name, StatusEvent.event_type).all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:8,代码来源:statusevent.py
示例13: find_all_active
def find_all_active(enterprise_id, web_enabled=True):
return Session.query(Discount) \
.filter(and_(Discount.delete_dt == None,
Discount.enterprise_id == enterprise_id,
Discount.web_enabled == web_enabled,
or_(Discount.end_dt == None,
Discount.end_dt >= util.now())))\
.order_by(Discount.name) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:9,代码来源:discount.py
示例14: find_by_product
def find_by_product(product):
return Session.query(PurchaseOrderItem)\
.join((PurchaseOrder, PurchaseOrder.purchase_order_id == PurchaseOrderItem.purchase_order_id)) \
.filter(and_(PurchaseOrder.delete_dt == None,
PurchaseOrderItem.delete_dt == None,
PurchaseOrderItem.product == product
)) \
.order_by(PurchaseOrder.create_dt.desc()) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:9,代码来源:purchase.py
示例15: find_all_open
def find_all_open(enterprise_id):
return Session.query(PurchaseOrder)\
.options(FromCache('PurchaseOrder.find_all_open', enterprise_id)) \
.join((Company, PurchaseOrder.company_id == Company.company_id)) \
.filter(and_(PurchaseOrder.delete_dt == None,
Company.enterprise_id == enterprise_id
)) \
.order_by(PurchaseOrder.purchase_order_id.desc()) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:9,代码来源:purchase.py
示例16: find_by_product
def find_by_product(product):
return Session.query(Discount)\
.join((DiscountProduct, DiscountProduct.discount_id == Discount.discount_id))\
.filter(and_(DiscountProduct.product == product,
Discount.delete_dt == None,
or_(Discount.end_dt == None,
Discount.end_dt > util.today())))\
.order_by(Discount.create_dt.desc())\
.first()
开发者ID:anonymoose,项目名称:pvscore,代码行数:9,代码来源:discount.py
示例17: find_by_code
def find_by_code(enterprise_id, code):
return Session.query(Discount)\
.filter(and_(Discount.enterprise_id == enterprise_id,
Discount.delete_dt == None,
Discount.code.ilike(code),
or_(Discount.end_dt == None,
Discount.end_dt >= util.now())))\
.order_by(Discount.create_dt) \
.first()
开发者ID:anonymoose,项目名称:pvscore,代码行数:9,代码来源:discount.py
示例18: search
def search(name):
n_clause = ''
if name:
n_clause = "and com.name like '%s%%'" % name
sql = """SELECT com.* FROM crm_company com
where 1=1
{n}
""".format(n=n_clause)
return Session.query(Company).from_statement(sql).all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:10,代码来源:company.py
示例19: find_products
def find_products(discount_id):
from pvscore.model.crm.product import Product
#.options(FromCache('Product.find_children', parent_id))
return Session.query(DiscountProduct) \
.join((Product, DiscountProduct.product_id == Product.product_id)) \
.filter(and_(DiscountProduct.discount_id == discount_id,
Product.delete_dt == None,
Product.enabled == True,
Product.type != 'Attr')) \
.order_by(Product.name) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:11,代码来源:discount.py
示例20: find_all_automatic_cart_discounts
def find_all_automatic_cart_discounts(enterprise_id, web_enabled=True): #pylint: disable-msg=C0103
return Session.query(Discount) \
.filter(and_(Discount.delete_dt == None,
Discount.enterprise_id == enterprise_id,
Discount.cart_discount == True,
Discount.automatic == True,
Discount.web_enabled == web_enabled,
or_(Discount.end_dt == None,
Discount.end_dt >= util.now())))\
.order_by(Discount.name) \
.all()
开发者ID:anonymoose,项目名称:pvscore,代码行数:11,代码来源:discount.py
注:本文中的pvscore.model.meta.Session类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论