本文整理匯總了Python中pvscore.model.meta.Session類的典型用法代碼示例。如果您正苦於以下問題:Python Session類的具體用法?Python Session怎麽用?Python Session使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Session類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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])
示例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()
示例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()
示例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()
示例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()
)
示例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()
)
示例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()
)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()