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


Python settings.SETTINGS_MODULE屬性代碼示例

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


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

示例1: _get_default_data_dir

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def _get_default_data_dir(directory, abspath=True):
    settings_mod = import_module(settings.SETTINGS_MODULE)

    project_dir = os.path.dirname(settings_mod.__name__)
    if abspath:
        project_dir = os.path.abspath(project_dir)
    return os.path.join(project_dir, directory) 
開發者ID:mgaitan,項目名稱:waliki,代碼行數:9,代碼來源:settings.py

示例2: empty_urlconf

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def empty_urlconf(request):
    "Create an empty URLconf 404 error response."
    t = Template(EMPTY_URLCONF_TEMPLATE, name='Empty URLConf template')
    c = Context({
        'project_name': settings.SETTINGS_MODULE.split('.')[0]
    })
    return HttpResponse(t.render(c), content_type='text/html')

#
# Templates are embedded in the file so that we know the error handler will
# always work even if the template loader is broken.
# 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:14,代碼來源:debug.py

示例3: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def render(self, context):
        from django.core.urlresolvers import reverse, NoReverseMatch
        args = [arg.resolve(context) for arg in self.args]
        kwargs = dict([(smart_text(k, 'ascii'), v.resolve(context))
                       for k, v in self.kwargs.items()])

        view_name = self.view_name.resolve(context)

        if not view_name:
            raise NoReverseMatch("'url' requires a non-empty first argument. "
                "The syntax changed in Django 1.5, see the docs.")

        # Try to look up the URL twice: once given the view name, and again
        # relative to what we guess is the "main" app. If they both fail,
        # re-raise the NoReverseMatch unless we're using the
        # {% url ... as var %} construct in which case return nothing.
        url = ''
        try:
            url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
        except NoReverseMatch as e:
            if settings.SETTINGS_MODULE:
                project_name = settings.SETTINGS_MODULE.split('.')[0]
                try:
                    url = reverse(project_name + '.' + view_name,
                              args=args, kwargs=kwargs,
                              current_app=context.current_app)
                except NoReverseMatch:
                    if self.asvar is None:
                        # Re-raise the original exception, not the one with
                        # the path relative to the project. This makes a
                        # better error message.
                        raise e
            else:
                if self.asvar is None:
                    raise e

        if self.asvar:
            context[self.asvar] = url
            return ''
        else:
            return url 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:43,代碼來源:defaulttags.py

示例4: _get_messages

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def _get_messages(self):
        # Emulate batch messages by polling rabbitmq server multiple times
        pool = ThreadPool(settings.POLLER_CONFIG['batchsize'])
        for i in range(settings.POLLER_CONFIG['batchsize']):
            if settings.QUEUE_TYPE in ['SQS', 'sqs']:
                pool.spawn(self._get_sqs_messages)
            elif settings.QUEUE_TYPE in ['RABBITMQ', 'rabbitmq']:
                pool.spawn(self._get_rabbitmq_messages,i)
            else:
                raise ValueError('Incorrect value "%s" for QUEUE_TYPE in %s' %
                                 (settings.QUEUE_TYPE, settings.SETTINGS_MODULE)) 
開發者ID:CitoEngine,項目名稱:cito_engine,代碼行數:13,代碼來源:event_poller.py

示例5: post

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def post(self, request):
        """
        Accepts JSON
            {
                "event":
                {
                    "eventid": <int>,
                    "element": <string>,
                    "message": <string>,
                },
                "timestamp": <int>
            }
        :return JSON response:
        """

        try:
            parsed_json = json.loads(request.body)
        except Exception as e:
            return json_error('Invalid JSON' % e)

        for k in settings.INCIDENT_PARAMS:
            if k not in parsed_json:
                return json_error('Missing JSON key:%s' % k)

        if settings.QUEUE_TYPE in ['SQS', 'sqs']:
            queue_writer = sqs_writer.send_to_sqs
        elif settings.QUEUE_TYPE in ['RABBITMQ', 'rabbitmq']:
            queue_writer = rabbitmq_writer.send_to_rabbitmq
        else:
            raise ValueError('Incorrect value "%s" for QUEUE_TYPE in %s' %
                             (settings.QUEUE_TYPE, settings.SETTINGS_MODULE))

        gevent.spawn(queue_writer, request.body)
        gevent.sleep(0)
        return json_ok('accepted') 
開發者ID:CitoEngine,項目名稱:cito_engine,代碼行數:37,代碼來源:incident_listener.py

示例6: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def render(self, context):
        from django.core.urlresolvers import reverse, NoReverseMatch
        args = [arg.resolve(context) for arg in self.args]
        kwargs = dict((smart_text(k, 'ascii'), v.resolve(context))
                      for k, v in self.kwargs.items())

        view_name = self.view_name.resolve(context)

        try:
            current_app = context.request.current_app
        except AttributeError:
            # Change the fallback value to None when the deprecation path for
            # Context.current_app completes in Django 1.10.
            current_app = context.current_app

        # Try to look up the URL twice: once given the view name, and again
        # relative to what we guess is the "main" app. If they both fail,
        # re-raise the NoReverseMatch unless we're using the
        # {% url ... as var %} construct in which case return nothing.
        url = ''
        try:
            url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
        except NoReverseMatch:
            exc_info = sys.exc_info()
            if settings.SETTINGS_MODULE:
                project_name = settings.SETTINGS_MODULE.split('.')[0]
                try:
                    url = reverse(project_name + '.' + view_name,
                              args=args, kwargs=kwargs,
                              current_app=current_app)
                except NoReverseMatch:
                    if self.asvar is None:
                        # Re-raise the original exception, not the one with
                        # the path relative to the project. This makes a
                        # better error message.
                        six.reraise(*exc_info)
            else:
                if self.asvar is None:
                    raise

        if self.asvar:
            context[self.asvar] = url
            return ''
        else:
            return url 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:47,代碼來源:defaulttags.py

示例7: inner_run

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def inner_run(self, *args, **options):
        from django.conf import settings
        from django.utils import translation

        threading = options.get('use_threading')
        shutdown_message = options.get('shutdown_message', '')
        quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C'

        self.stdout.write("Performing system checks...\n\n")
        self.validate(display_num_errors=True)
        try:
            self.check_migrations()
        except ImproperlyConfigured:
            pass
        now = datetime.now().strftime('%B %d, %Y - %X')
        if six.PY2:
            now = now.decode(get_system_encoding())
        self.stdout.write((
            "%(started_at)s\n"
            "Django version %(version)s, using settings %(settings)r\n"
            "Starting development server at http://%(addr)s:%(port)s/\n"
            "Quit the server with %(quit_command)s.\n"
        ) % {
            "started_at": now,
            "version": self.get_version(),
            "settings": settings.SETTINGS_MODULE,
            "addr": '[%s]' % self.addr if self._raw_ipv6 else self.addr,
            "port": self.port,
            "quit_command": quit_command,
        })
        # django.core.management.base forces the locale to en-us. We should
        # set it up correctly for the first request (particularly important
        # in the "--noreload" case).
        translation.activate(settings.LANGUAGE_CODE)

        try:
            handler = self.get_handler(*args, **options)
            run(self.addr, int(self.port), handler,
                ipv6=self.use_ipv6, threading=threading)
        except socket.error as e:
            # Use helpful error messages instead of ugly tracebacks.
            ERRORS = {
                errno.EACCES: "You don't have permission to access that port.",
                errno.EADDRINUSE: "That port is already in use.",
                errno.EADDRNOTAVAIL: "That IP address can't be assigned-to.",
            }
            try:
                error_text = ERRORS[e.errno]
            except KeyError:
                error_text = force_text(e)
            self.stderr.write("Error: %s" % error_text)
            # Need to use an OS exit because sys.exit doesn't work in a thread
            os._exit(1)
        except KeyboardInterrupt:
            if shutdown_message:
                self.stdout.write(shutdown_message)
            sys.exit(0) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:59,代碼來源:runserver.py

示例8: inner_run

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def inner_run(self, *args, **options):
        from django.conf import settings
        from django.utils import translation

        threading = options.get('use_threading')
        shutdown_message = options.get('shutdown_message', '')
        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'

        self.stdout.write("Validating models...\n\n")
        self.validate(display_num_errors=True)
        self.stdout.write((
            "%(started_at)s\n"
            "Django version %(version)s, using settings %(settings)r\n"
            "Development server is running at http://%(addr)s:%(port)s/\n"
            "Quit the server with %(quit_command)s.\n"
        ) % {
            "started_at": datetime.now().strftime('%B %d, %Y - %X'),
            "version": self.get_version(),
            "settings": settings.SETTINGS_MODULE,
            "addr": self._raw_ipv6 and '[%s]' % self.addr or self.addr,
            "port": self.port,
            "quit_command": quit_command,
        })
        # django.core.management.base forces the locale to en-us. We should
        # set it up correctly for the first request (particularly important
        # in the "--noreload" case).
        translation.activate(settings.LANGUAGE_CODE)

        try:
            handler = self.get_handler(*args, **options)
            run(self.addr, int(self.port), handler,
                ipv6=self.use_ipv6, threading=threading)
        except WSGIServerException as e:
            # Use helpful error messages instead of ugly tracebacks.
            ERRORS = {
                13: "You don't have permission to access that port.",
                98: "That port is already in use.",
                99: "That IP address can't be assigned-to.",
            }
            try:
                error_text = ERRORS[e.args[0].args[0]]
            except (AttributeError, KeyError):
                error_text = str(e)
            self.stderr.write("Error: %s" % error_text)
            # Need to use an OS exit because sys.exit doesn't work in a thread
            os._exit(1)
        except KeyboardInterrupt:
            if shutdown_message:
                self.stdout.write(shutdown_message)
            sys.exit(0)


# Kept for backward compatibility 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:55,代碼來源:runserver.py

示例9: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SETTINGS_MODULE [as 別名]
def render(self, context):
        from django.core.urlresolvers import reverse, NoReverseMatch
        args = [arg.resolve(context) for arg in self.args]
        kwargs = {
            smart_text(k, 'ascii'): v.resolve(context)
            for k, v in self.kwargs.items()
        }

        view_name = self.view_name.resolve(context)

        try:
            current_app = context.request.current_app
        except AttributeError:
            # Leave only the else block when the deprecation path for
            # Context.current_app completes in Django 1.10.
            # Can also remove the Context.is_current_app_set property.
            if context.is_current_app_set:
                current_app = context.current_app
            else:
                try:
                    current_app = context.request.resolver_match.namespace
                except AttributeError:
                    current_app = None

        # Try to look up the URL twice: once given the view name, and again
        # relative to what we guess is the "main" app. If they both fail,
        # re-raise the NoReverseMatch unless we're using the
        # {% url ... as var %} construct in which case return nothing.
        url = ''
        try:
            url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
        except NoReverseMatch:
            exc_info = sys.exc_info()
            if settings.SETTINGS_MODULE:
                project_name = settings.SETTINGS_MODULE.split('.')[0]
                try:
                    url = reverse(project_name + '.' + view_name,
                              args=args, kwargs=kwargs,
                              current_app=current_app)
                except NoReverseMatch:
                    if self.asvar is None:
                        # Re-raise the original exception, not the one with
                        # the path relative to the project. This makes a
                        # better error message.
                        six.reraise(*exc_info)
            else:
                if self.asvar is None:
                    raise

        if self.asvar:
            context[self.asvar] = url
            return ''
        else:
            if context.autoescape:
                url = conditional_escape(url)
            return url 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:58,代碼來源:defaulttags.py


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