当前位置: 首页>>代码示例>>Python>>正文


Python meta.Session类代码示例

本文整理汇总了Python中freepybx.model.meta.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:9,代码来源:base.py

示例2: authenticate_admin

def authenticate_admin(username, password):
    
    auth_user = AdminUser.query.filter(AdminUser.username==username).first()

    if not auth_user:
        log.debug("No user named: '%s'", username)
        return False        
    elif not auth_user.password:
        log.error("Bad username/pass:'%s'")
        return False
    elif password != auth_user.password:
        log.debug("Database password for user '%s'", username)
        return False
    else:
        request.environ["REMOTE_USER"] = auth_user.username
        request.environ["HTTP_REMOTE_USER"] = auth_user.username

    session["perms"]= auth_user.permissions
    session["user"] = auth_user
    session["name"] = auth_user.name
    session['user_id'] = auth_user.id

    auth_user.register_login(username, session, request)  
    db.commit()
    db.flush()
    session.save()
    return True
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:27,代码来源:auth.py

示例3: getUsers

    def getUsers(self, sid):
        users = []
        ep_stats = []
        user = User.query.filter_by(session_id=sid).first()

        if user:
            context = user.get_context()
        else:
            raise Exception("No session id in db matching the user calling this method.")

        for r in db.execute("SELECT DISTINCT users.first_name, users.last_name, users.id, users.customer_id, "
                            "customers.context AS context, users.portal_extension, "
                            "users.tel, users.mobile, users.username, sip_dialogs.uuid AS uuid "
                            "FROM users "
                            "INNER JOIN customers ON users.customer_id = customers.id "
                            "LEFT JOIN sip_dialogs ON sip_dialogs.presence_id = users.portal_extension || '@' || customers.context "
                            "WHERE customers.context = :context ORDER BY users.id", {'context': context}):

            for pbx_reg in PbxRegistration.query.filter(PbxRegistration.sip_realm==context).filter(PbxRegistration.sip_user==r[5]).all():
                ep_stats.append({'ip': pbx_reg.network_ip, 'port':pbx_reg.network_port})

            is_online = True if len(ep_stats) > 0 else False
            ep_stats = []

            # make_broker_user(name, id, customer_id, email, tel, mobile, ext, uuid, is_online):
            users.append(make_broker_user(r[0]+' '+r[1], r[2], r[3], r[8], r[6], r[7], r[5], r[9], is_online))

        db.remove()
        return users
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:29,代码来源:flash_gateway.py

示例4: getCallers

    def getCallers(self, sid):
        callers = []
        user = User.query.filter_by(session_id=sid).first()
        if user:
            context = user.get_context()

        for row in PbxDid.query.filter(PbxDid.context==context).all():
            for cal in db.execute("SELECT * FROM channels WHERE dest like :did", {'did': "%"+row.did}).fetchall():
                #PbxChannel.query.filter(PbxChannel.dest.like('%'+row.did).all():
                l =  PbxChannel.query.filter_by(uuid=cal.uuid).first()
                if l:
                    to_user = l.dest
                    status = l.callstate
                else:
                    to_user = ""
                    status = ""
                direction = "inbound"
                if len(cal.cid_num) > 10:
                    cid_num = cal.cid_num[len(cal.cid_num)-10:]
                else:
                    cid_num = cal.cid_num

                time_in_queue = db.execute("SELECT now() FROM channels WHERE uuid = :uuid", {'uuid': cal.uuid}).fetchone()
                callers.append(make_caller(cal.dest, cal.cid_name,cid_num, direction, cal.created, time_in_queue[0], to_user, cal.uuid, status))

        for cal in PbxChannel.query.filter_by(context=context).distinct(PbxChannel.call_uuid).all():
            if len(cal.presence_id)>3:
                if cal.presence_id.split("@")[1] == context:
                    time_in_queue = db.execute("SELECT now() FROM channels WHERE uuid = :uuid", {'uuid': cal.uuid}).fetchone()
            callers.append(make_caller(cal.dest, cal.cid_name, cal.cid_num, "outbound", cal.created, "", cal.dest, cal.uuid, cal.callstate))

        db.remove()
        return callers
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:33,代码来源:flash_gateway.py

示例5: account_by_id

    def account_by_id(self, id):
        items = []
        for account in (
            CrmAccount.query.join(CrmCampaign)
            .filter(CrmAccount.customer_id == session["customer_id"])
            .filter(CrmAccount.user_id == session["user_id"])
            .filter(CrmCampaign.name == id)
            .all()
        ):
            items.append(
                {
                    "id": account.id,
                    "name": str(account.first_name) + " " + str(account.last_name),
                    "address": account.address,
                    "city": account.city,
                    "state": account.state,
                    "zip": account.zip,
                    "tel": account.tel,
                    "mobile": account.mobile,
                    "email": account.email,
                    "crm_campaign_id": account.crm_campaign_id,
                }
            )
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:30,代码来源:crm.py

示例6: ad_audio

    def ad_audio(self):
        items = []
        dir = fs_vm_dir + session["context"] + "/recordings/"
        try:
            for i in os.listdir(dir):
                fo = generateFileObject(i, "", dir)
                items.append(
                    {
                        "id": "1," + fo["name"],
                        "name": "Recording: " + fo["name"],
                        "data": fo["path"],
                        "type": 1,
                        "real_id": "",
                    }
                )

            db.remove()
        except:
            pass
        out = dict({"identifier": "id", "label": "name", "items": items})

        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:25,代码来源:call_center.py

示例7: queue_delete

def queue_delete(q):
    for queue in CallCenterQueue.query.filter(CallCenterQueue.id==q.id).filter(CallCenterQueue.context==session['context']).all():
        PbxRoute.query.filter(PbxRoute.pbx_route_type_id==10).filter(PbxRoute.pbx_to_id==queue.id).delete()
        CallCenterTier.query.filter(CallCenterTier.queue_id==queue.id).delete()
    CallCenterQueue.query.filter(CallCenterQueue.id==q.id).filter(CallCenterQueue.context==session['context']).delete()
    db.commit()
    db.flush()
    return True
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:8,代码来源:util.py

示例8: get_talk_time

def get_talk_time(ext, context):
    rows =  db.execute("SELECT coalesce(sum(billsec)/60,0) AS mins FROM cdr "
                       "WHERE (caller_id_number=:ext OR destination_number=:ext) "
                       "AND start_stamp BETWEEN CURRENT_DATE AND CURRENT_TIMESTAMP "
                       "AND bleg_uuid IS NOT NULL AND context = :context",
            {'ext':ext, 'context': context})
    r = rows.fetchone()
    db.remove()
    return r.mins
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:9,代码来源:flash_gateway.py

示例9: delete_ivr

def delete_ivr(name):
    for ivr in PbxIVR.query.filter_by(name=name).filter_by(context=session['context']).all():

        r = PbxRoute.query.filter(PbxRoute.pbx_route_type_id==5).\
        filter(PbxRoute.name==ivr.name).filter(PbxRoute.context==session['context']).first()
        did = PbxDid.did.query.filter(PbxDid.pbx_route_id==r.id).first()

        if did:
            msg = "Error: IVR is in use by Inbound DID: "+str(did.did)+"!"

        tod = db.execute("select * from pbx_tod_routes where match_route_id = :id or nomatch_route_id = :id", {'id': r.id}).first()

        if tod:
            msg = "Error: IVR is in a TOD route!"

        ivr_opt = PbxIVROption.query.filter(PbxIVROption.pbx_route_id==r.id).first()

        if ivr_opt:
            msg = "Error: IVR belongs to another IVR Option."


        if not did and not ivr_opt and not tod:
            PbxRoute.query.filter(PbxRoute.pbx_route_type_id==5).\
            filter(PbxRoute.name==ivr.name).filter(PbxRoute.context==session['context']).delete()
            PbxIVROption.query.filter(PbxIVROption.pbx_ivr_id==ivr.id).delete()
            PbxIVR.query.filter(PbxIVR.name==name).filter(PbxIVR.context==session['context']).delete()
            db.commit()
            db.flush()
            db.remove()
        else:
            return msg

        db.remove()
        return "Successfully deleted IVR: "+name+"."
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:34,代码来源:util.py

示例10: get_volume

def get_volume(ext, context):
    rows =  db.execute("SELECT count(*) AS ct "
                       "FROM cdr "
                       "WHERE  (caller_id_number=:ext OR destination_number=:ext) "
                       "AND start_stamp BETWEEN CURRENT_DATE "
                       "AND CURRENT_TIMESTAMP AND bleg_uuid IS NOT NULL "
                       "AND context = :context",
            {'ext':ext, 'context': context})
    r = rows.fetchone()
    db.remove()
    return r.ct
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:11,代码来源:flash_gateway.py

示例11: account_lead_types

    def account_lead_types(self):
        items = []
        for act in CrmLeadType.query.filter(context=session["context"]).all():
            items.append({"id": act.id, "name": act.name, "desc": act.description})
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:11,代码来源:crm.py

示例12: get_route_labels_ids

def get_route_labels_ids():
    route_labels = []
    route_ids = []

    for row in db.execute("SELECT sr.id, srt.name|| ':' ||sr.name AS name "
                          "FROM pbx_routes sr "
                          "INNER JOIN pbx_route_types srt ON sr.pbx_route_type_id = srt.id "
                          "WHERE sr.context = :context", {'context': session['context']}):
        route_labels.append(row.name)
        route_ids.append(row.id)
    db.remove()
    return (route_labels,route_ids)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:12,代码来源:util.py

示例13: billing_service_types

    def billing_service_types(self):
        items=[]
        for bs in BillingServiceType.query.all():
            items.append({'id': bs.id, 'name': bs.name, 'description': bs.description})

        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [("Content-type", 'application/json'),]

        return response(request.environ, self.start_response)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:12,代码来源:services.py

示例14: campaigns_ids

    def campaigns_ids(self):
        names = []
        ids = []
        for row in CrmCampaign.query.filter(context=session["context"]).all():
            names.append(row.name)
            ids.append(row.id)
        db.remove()
        headers = [("Content-type", "application/json")]
        out = dict({"names": names, "ids": ids})
        response = make_response(out)

        return response(request.environ, self.start_response)
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:12,代码来源:crm.py

示例15: authenticate

def authenticate(username, password):
    auth_user = User.query.filter(User.username==username).first()
    if not auth_user:
        log.debug("No user named: '%s'", username)
        return False        
    elif not auth_user.password:
        log.error("Bad user/pass:'%s'")
        return False
    elif password != auth_user.password:
        log.debug("database password for user '%s'", username)
        return False
    else:
        session['username'] = auth_user.username
        session['password'] = auth_user.password
        session['customer_id'] = auth_user.customer_id
        session['user_id'] = auth_user.id
        session['name'] = auth_user.first_name+' '+auth_user.last_name
        session["last_login"] = auth_user.last_login
        session['has_crm'] = auth_user.has_crm 
        session['customer_name'] = auth_user.get_customer_name(auth_user.customer_id)

        if auth_user.has_crm:
            ea = auth_user.get_email_account()
            session['email_server'] = ea.mail_server
            session['email'] = ea.email
            session['email_password'] = ea.password    
                
        if auth_user.has_call_center():
            session['has_call_center'] = True
        else:
            session['has_call_center'] = False
            
        session['is_agent'] = auth_user.is_agent()
        session['context'] = auth_user.get_context()
        session['ext'] = auth_user.get_extension()

        request.environ["REMOTE_USER"] = auth_user.username
        request.environ["HTTP_REMOTE_USER"] = auth_user.username      
      
    if auth_user and not auth_user.active: 
        return False
       
    log.info("authenticated user %s", auth_user.username)

    session["perms"] = auth_user.permissions
    session['group_id'] = auth_user.group_id
    session["user"] = auth_user     
    session.save()
    auth_user.register_login(username, session, request)  
    db.commit()
    db.flush()
    
    return True
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:53,代码来源:auth.py


注:本文中的freepybx.model.meta.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。