當前位置: 首頁>>代碼示例>>Python>>正文


Python db.reset_queries方法代碼示例

本文整理匯總了Python中django.db.reset_queries方法的典型用法代碼示例。如果您正苦於以下問題:Python db.reset_queries方法的具體用法?Python db.reset_queries怎麽用?Python db.reset_queries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.db的用法示例。


在下文中一共展示了db.reset_queries方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_password

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def check_password(environ, username, password):
    """
    Authenticates against Django's auth database

    mod_wsgi docs specify None, True, False as return value depending
    on whether the user exists and authenticates.
    """

    UserModel = auth.get_user_model()
    # db connection state is managed similarly to the wsgi handler
    # as mod_wsgi may call these functions outside of a request/response cycle
    db.reset_queries()

    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return None
        if not user.is_active:
            return None
        return user.check_password(password)
    finally:
        db.close_old_connections() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:25,代碼來源:modwsgi.py

示例2: groups_for_user

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def groups_for_user(environ, username):
    """
    Authorizes a user based on groups
    """

    UserModel = auth.get_user_model()
    db.reset_queries()

    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return []
        if not user.is_active:
            return []
        return [force_bytes(group.name) for group in user.groups.all()]
    finally:
        db.close_old_connections() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:20,代碼來源:modwsgi.py

示例3: check_password

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def check_password(environ, username, password):
    """
    Authenticate against Django's auth database.

    mod_wsgi docs specify None, True, False as return value depending
    on whether the user exists and authenticates.
    """
    # db connection state is managed similarly to the wsgi handler
    # as mod_wsgi may call these functions outside of a request/response cycle
    db.reset_queries()
    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return None
        if not user.is_active:
            return None
        return user.check_password(password)
    finally:
        db.close_old_connections() 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:22,代碼來源:modwsgi.py

示例4: check_password

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def check_password(environ, username, password):
    """
    Authenticates against Django's auth database

    mod_wsgi docs specify None, True, False as return value depending
    on whether the user exists and authenticates.
    """

    # db connection state is managed similarly to the wsgi handler
    # as mod_wsgi may call these functions outside of a request/response cycle
    db.reset_queries()

    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return None
        if not user.is_active:
            return None
        return user.check_password(password)
    finally:
        db.close_old_connections() 
開發者ID:bpgc-cte,項目名稱:python2017,代碼行數:24,代碼來源:modwsgi.py

示例5: groups_for_user

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def groups_for_user(environ, username):
    """
    Authorizes a user based on groups
    """

    db.reset_queries()

    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return []
        if not user.is_active:
            return []
        return [force_bytes(group.name) for group in user.groups.all()]
    finally:
        db.close_old_connections() 
開發者ID:bpgc-cte,項目名稱:python2017,代碼行數:19,代碼來源:modwsgi.py

示例6: __enter__

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def __enter__(self):
        self.force_debug_cursor = self.connection.force_debug_cursor
        self.connection.force_debug_cursor = True
        self.initial_queries = len(self.connection.queries_log)
        self.final_queries = None
        request_started.disconnect(reset_queries)
        return self 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:9,代碼來源:utils.py

示例7: __exit__

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
        self.connection.force_debug_cursor = self.force_debug_cursor
        request_started.connect(reset_queries)
        if exc_type is not None:
            return
        self.final_queries = len(self.connection.queries_log) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:8,代碼來源:utils.py

示例8: __enter__

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def __enter__(self):
        self.force_debug_cursor = self.connection.force_debug_cursor
        self.connection.force_debug_cursor = True
        # Run any initialization queries if needed so that they won't be
        # included as part of the count.
        self.connection.ensure_connection()
        self.initial_queries = len(self.connection.queries_log)
        self.final_queries = None
        request_started.disconnect(reset_queries)
        return self 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:12,代碼來源:utils.py

示例9: groups_for_user

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def groups_for_user(environ, username):
    """
    Authorize a user based on groups
    """
    db.reset_queries()
    try:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            return []
        if not user.is_active:
            return []
        return [force_bytes(group.name) for group in user.groups.all()]
    finally:
        db.close_old_connections() 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:17,代碼來源:modwsgi.py

示例10: run

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def run(self):
        os.umask(022)
        while True:
            ddb.reset_queries()
            jobs = queue.Job.objects.filter(state=1, account__host__state=1,
                    created__lt=datetime.now() - timedelta(seconds=-200000000))
            for job in jobs:
                check_die()
                if job.is_done():
                    jlogger.info('Collected %s' % job)
                    job.collect()
            check_die(20) 
開發者ID:wolverton-research-group,項目名稱:qmpy,代碼行數:14,代碼來源:manager.py

示例11: django_context

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def django_context(f):

    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        with log_django_context_metric(f.__name__):
            db.reset_queries()
            db.close_old_connections()
            try:
                return f(*args, **kwargs)
            finally:
                db.close_old_connections()

    return wrapper 
開發者ID:anyant,項目名稱:rssant,代碼行數:15,代碼來源:actor_helper.py

示例12: queryset_iterator

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def queryset_iterator(qs, complex_popolo_fields):
    # To save building up a huge list of queries when DEBUG = True,
    # call reset_queries:
    reset_queries()
    start_index = 0
    while True:
        chunk_qs = qs.order_by('pk')[start_index:start_index + FETCH_AT_A_TIME]
        empty = True
        for person_extra in chunk_qs.joins_for_csv_output():
            empty = False
            person_extra.complex_popolo_fields = complex_popolo_fields
            yield person_extra
        if empty:
            return
        start_index += FETCH_AT_A_TIME 
開發者ID:mysociety,項目名稱:yournextrepresentative,代碼行數:17,代碼來源:candidates_create_csv.py

示例13: __enter__

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def __enter__(self):
        self.force_debug_cursor = self.connection.force_debug_cursor
        self.connection.force_debug_cursor = True
        self.starting_count = len(self.connection.queries)
        request_started.disconnect(reset_queries)
        return self 
開發者ID:maas,項目名稱:maas,代碼行數:8,代碼來源:djangotestcase.py

示例14: __exit__

# 需要導入模塊: from django import db [as 別名]
# 或者: from django.db import reset_queries [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
        self.connection.force_debug_cursor = self.force_debug_cursor
        request_started.connect(reset_queries)
        if exc_type is not None:
            return
        final_count = len(self.connection.queries)
        self.num_queries = final_count - self.starting_count 
開發者ID:maas,項目名稱:maas,代碼行數:9,代碼來源:djangotestcase.py


注:本文中的django.db.reset_queries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。