code
stringlengths
1
1.72M
language
stringclasses
1 value
from django.core import signals from django.dispatch import dispatcher from django import http import sys class BaseHandler(object): def __init__(self): self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None def load_middleware(self): "...
Python
import hotshot, time, os from django.core.handlers.modpython import ModPythonHandler PROFILE_DATA_DIR = "/var/log/cmsprofile" def handler(req): ''' Handler that uses hotshot to store profile data. Stores profile data in PROFILE_DATA_DIR. Since hotshot has no way (that I know of) to append profile da...
Python
from django.core.handlers.base import BaseHandler from django.core import signals from django.dispatch import dispatcher from django.utils import datastructures from django import http from pprint import pformat from shutil import copyfileobj try: from cStringIO import StringIO except ImportError: from StringIO...
Python
from django.core import validators from django.core.exceptions import PermissionDenied from django.utils.html import escape from django.conf import settings from django.utils.translation import gettext, ngettext FORM_FIELD_ID_PREFIX = 'id_' class EmptyValue(Exception): "This is raised when empty data is provided"...
Python
from django.conf import settings from django import http from django.core.mail import mail_managers import md5 import re class CommonMiddleware(object): """ "Common" middleware for taking care of some basic operations: - Forbids access to User-Agents in settings.DISALLOWED_USER_AGENTS - URL r...
Python
from django.conf import settings from django.core.cache import cache from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers class CacheMiddleware(object): """ Cache middleware. If this is enabled, each Django-powered page will be cached for CACHE_MIDDLEWARE_SECONDS seconds. C...
Python
import re from django.utils.text import compress_string from django.utils.cache import patch_vary_headers re_accepts_gzip = re.compile(r'\bgzip\b') class GZipMiddleware(object): """ This middleware compresses content if the browser allows gzip compression. It sets the Vary header accordingly, so that cach...
Python
"this is the locale selecting middleware that will look at accept headers" from django.utils.cache import patch_vary_headers from django.utils import translation class LocaleMiddleware(object): """ This is a very simple middleware that parses a request and decides what translation object to install in the...
Python
from django.conf import settings from django import http class XViewMiddleware(object): """ Adds an X-View header to internal HEAD requests -- used by the documentation system. """ def process_view(self, request, view_func, view_args, view_kwargs): """ If the request method is HEAD and ...
Python
import datetime class ConditionalGetMiddleware(object): """ Handles conditional GET operations. If the response has a ETag or Last-Modified header, and the request has If-None-Match or If-Modified-Since, the response is replaced by an HttpNotModified. Removes the content from any response to a HEA...
Python
from django.db import transaction class TransactionMiddleware(object): """ Transaction middleware. If this is enabled, each view function will be run with commit_on_response activated - that way a save() doesn't do a direct commit, the commit is done when a successful response is created. If an exc...
Python
def curry(_curried_func, *args, **kwargs): def _curried(*moreargs, **morekwargs): return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) return _curried class Promise: """ This is just a base class for the proxy class created in the closure of the lazy function. It can be used...
Python
""" termcolors.py """ color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white') foreground = dict([(color_names[x], '3%s' % x) for x in range(8)]) background = dict([(color_names[x], '4%s' % x) for x in range(8)]) del color_names RESET = '0' opt_dict = {'bold': '1', 'underscore': '4', 'bli...
Python
import os import sys if os.name == 'posix': def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null'): "Robustly turn into a UNIX daemon, running in our_home_dir." # First fork try: if os.fork() > 0: sys.exit(0) # kill off parent e...
Python
""" Synchronization primitives: - reader-writer lock (preference to writers) (Contributed to Django by eugene@lazutkin.com) """ try: import threading except ImportError: import dummy_threading as threading class RWLock: """ Classic implementation of reader-writer lock with preference to writ...
Python
# Performance note: I benchmarked this code using a set instead of # a list for the stopwords and was surprised to find that the list # performed /better/ than the set - maybe because it's only a small # list. stopwords = ''' i a an are as at be by for from how in is it of on or that the this to was what when where ''...
Python
"""Thread-local objects (Note that this module provides a Python version of thread threading.local class. Depending on the version of Python you're using, there may be a faster one available. You should always import the local class from threading.) Thread-local objects support the management of thread-local dat...
Python
""" Utilities for XML generation/parsing. """ from xml.sax.saxutils import XMLGenerator class SimplerXMLGenerator(XMLGenerator): def addQuickElement(self, name, contents=None, attrs=None): "Convenience method for adding an element with no children" if attrs is None: attrs = {} self.startEl...
Python
"HTML utilities suitable for global use." import re, string # Configuration for urlize() function LEADING_PUNCTUATION = ['(', '<', '&lt;'] TRAILING_PUNCTUATION = ['.', ',', ')', '>', '\n', '&gt;'] # list of possible strings used for bullets in bulleted lists DOTS = ['&middot;', '*', '\xe2\x80\xa2', '&#149;', '&bull...
Python
"Implementation of tzinfo classes for use with datetime.datetime." import time from datetime import timedelta, tzinfo class FixedOffset(tzinfo): "Fixed offset in minutes east from UTC." def __init__(self, offset): self.__offset = timedelta(minutes=offset) self.__name = "%+03d%02d" % (offset //...
Python
# Autoreloading launcher. # Borrowed from Peter Hunt and the CherryPy project (http://www.cherrypy.org). # Some taken from Ian Bicking's Paste (http://pythonpaste.org/). # # Portions copyright (c) 2004, CherryPy Team (team@cherrypy.org) # All rights reserved. # # Redistribution and use in source and binary forms, with ...
Python
""" This module contains helper functions for controlling caching. It does so by managing the "Vary" header of responses. It includes functions to patch the header of response objects directly and decorators that change functions to do that header-patching themselves. For information on the Vary header, see: http...
Python
"Commonly-used date structures" from django.utils.translation import gettext_lazy as _ WEEKDAYS = { 0:_('Monday'), 1:_('Tuesday'), 2:_('Wednesday'), 3:_('Thursday'), 4:_('Friday'), 5:_('Saturday'), 6:_('Sunday') } WEEKDAYS_REV = { 'monday':0, 'tuesday':1, 'wednesday':2, 'thursday':3, 'friday':4, 'satu...
Python
""" Providing iterator functions that are not in all version of Python we support. Where possible, we try to use the system-native version and only fall back to these implementations if necessary. """ import itertools def compat_tee(iterable): """Return two independent iterators from a single iterable. Based...
Python
""" Utility functions for handling images. Requires PIL, as you might imagine. """ import ImageFile def get_image_dimensions(path): """Returns the (width, height) of an image at a given path.""" p = ImageFile.Parser() fp = open(path, 'rb') while 1: data = fp.read(1024) if not data: ...
Python
""" Iterator based sre token scanner """ import sre_parse, sre_compile, sre_constants from sre_constants import BRANCH, SUBPATTERN from re import VERBOSE, MULTILINE, DOTALL import re __all__ = ['Scanner', 'pattern'] FLAGS = (VERBOSE | MULTILINE | DOTALL) class Scanner(object): def __init__(self, lexicon, flags=FL...
Python
from django.utils import simplejson import cgi class JSONFilter(object): def __init__(self, app, mime_type='text/x-json'): self.app = app self.mime_type = mime_type def __call__(self, environ, start_response): # Read JSON POST input to jsonfilter.json if matching mime type resp...
Python
""" Implementation of JSONDecoder """ import re from django.utils.simplejson.scanner import Scanner, pattern FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL def _floatconstants(): import struct import sys _BYTES = '7FF80000000000007FF0000000000000'.decode('hex') if sys.byteorder != 'big': _BYTE...
Python
""" Implementation of JSONEncoder """ import re ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]') ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])') ESCAPE_DCT = { # escape all forward slashes to prevent </script> attack '/': '\\/', '\\': '\\\\', '"': '\\"', '\b': '\\b', '\f': '\\f', '\n': '\\n'...
Python
r""" A simple, fast, extensible JSON encoder and decoder JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. simplejson exposes an API familiar to uses of the standard library marshal and pickle modules. Encoding b...
Python
"Translation helper functions" import locale import os import re import sys import gettext as gettext_module from cStringIO import StringIO from django.utils.functional import lazy try: import threading hasThreads = True except ImportError: hasThreads = False if hasThreads: currentThread = threading....
Python
from django.conf import settings if settings.USE_I18N: from trans_real import * else: from trans_null import * del settings
Python
# These are versions of the functions in django.utils.translation.trans_real # that don't actually do anything. This is purely for performance, so that # settings.USE_I18N = False can use this module rather than trans_real.py. from django.conf import settings def ngettext(singular, plural, number): if number == 1...
Python
"Functions that help with dynamically creating decorators for views." def decorator_from_middleware(middleware_class): """ Given a middleware class (not an instance), returns a view decorator. This lets you use middleware functionality on a per-view basis. """ def _decorator_from_middleware(view_fu...
Python
""" PHP date() style date formatting See http://www.php.net/date for format strings Usage: >>> import datetime >>> d = datetime.datetime.now() >>> df = DateFormat(d) >>> print df.format('jS F Y H:i') 7th October 2003 11:39 >>> """ from django.utils.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS from django.utils....
Python
class MergeDict(object): """ A simple class for creating new "virtual" dictionaries that actualy look up values in more than one dictionary, passed in the constructor. """ def __init__(self, *dicts): self.dicts = dicts def __getitem__(self, key): for dict in self.dicts: ...
Python
import re from django.conf import settings # Capitalizes the first letter of a string. capfirst = lambda x: x and x[0].upper() + x[1:] def wrap(text, width): """ A word-wrap function that preserves existing line breaks and most spaces in the text. Expects that existing line breaks are posix newlines. ...
Python
""" Syndication feed generation library -- used for generating RSS, etc. Sample usage: >>> feed = feedgenerator.Rss201rev2Feed( ... title=u"Poynter E-Media Tidbits", ... link=u"http://www.poynter.org/column.asp?id=31", ... description=u"A group weblog by the sharpest minds in online media/journalism/publi...
Python
import datetime, math, time from django.utils.tzinfo import LocalTimezone from django.utils.translation import ngettext def timesince(d, now=None): """ Takes two datetime objects and returns the time between then and now as a nicely formatted string, e.g "10 minutes" Adapted from http://blog.natbat.co....
Python
import os from Cookie import SimpleCookie from pprint import pformat from urllib import urlencode, quote from django.utils.datastructures import MultiValueDict RESERVED_CHARS="!*'();:@&=+$,/?%#[]" try: # The mod_python version is more efficient, so try importing it first. from mod_python.util import parse_qsl...
Python
DATA_TYPES = {}
Python
from django.db.backends.dummy.base import complain get_table_list = complain get_table_description = complain get_relations = complain get_indexes = complain DATA_TYPES_REVERSE = {}
Python
""" Dummy database backend for Django. Django uses this if the DATABASE_ENGINE setting is empty (None or empty string). Each of these API functions, except connection.close(), raises ImproperlyConfigured. """ from django.core.exceptions import ImproperlyConfigured def complain(*args, **kwargs): raise Improperly...
Python
from django.db.backends.dummy.base import complain runshell = complain
Python
# This dictionary maps Field objects to their associated MySQL column # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. DATA_TYPES = { 'AutoFi...
Python
from django.db.backends.mysql.base import quote_name from MySQLdb import ProgrammingError, OperationalError from MySQLdb.constants import FIELD_TYPE import re foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") def get_table_list(cursor): "Returns a li...
Python
""" MySQL database backend for Django. Requires MySQLdb: http://sourceforge.net/projects/mysql-python """ from django.db.backends import util try: import MySQLdb as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading MySQLdb mo...
Python
from django.conf import settings import os def runshell(): args = [''] db = settings.DATABASE_OPTIONS.get('db', settings.DATABASE_NAME) user = settings.DATABASE_OPTIONS.get('user', settings.DATABASE_USER) passwd = settings.DATABASE_OPTIONS.get('passwd', settings.DATABASE_PASSWORD) host = settings.D...
Python
# SQLite doesn't actually support most of these types, but it "does the right # thing" given more verbose field definitions, so leave them as is so that # schema inspection is more useful. DATA_TYPES = { 'AutoField': 'integer', 'BooleanField': 'bool', 'CharField': ...
Python
from django.db.backends.sqlite3.base import quote_name def get_table_list(cursor): "Returns a list of table names in the current database." # Skip the sqlite_sequence system table used for autoincrement key # generation. cursor.execute(""" SELECT name FROM sqlite_master WHERE type='tabl...
Python
""" SQLite3 backend for django. Requires pysqlite2 (http://pysqlite.org/). """ from django.db.backends import util try: try: from sqlite3 import dbapi2 as Database except ImportError: from pysqlite2 import dbapi2 as Database except ImportError, e: import sys from django.core.exceptions...
Python
from django.conf import settings import os def runshell(): args = ['', settings.DATABASE_NAME] os.execvp('sqlite3', args)
Python
from django.db.backends.postgresql.creation import *
Python
from django.db.backends.postgresql_psycopg2.base import quote_name def get_table_list(cursor): "Returns a list of table names in the current database." cursor.execute(""" SELECT c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WH...
Python
""" PostgreSQL database backend for Django. Requires psycopg 2: http://initd.org/projects/psycopg2 """ from django.db.backends import util try: import psycopg2 as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading psycopg2 mod...
Python
from django.db.backends.postgresql.client import *
Python
import datetime from time import time class CursorDebugWrapper(object): def __init__(self, cursor, db): self.cursor = cursor self.db = db def execute(self, sql, params=()): start = time() try: return self.cursor.execute(sql, params) finally: stop...
Python
# This dictionary maps Field objects to their associated PostgreSQL column # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. DATA_TYPES = { 'A...
Python
from django.db.backends.postgresql.base import quote_name def get_table_list(cursor): "Returns a list of table names in the current database." cursor.execute(""" SELECT c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.rel...
Python
""" PostgreSQL database backend for Django. Requires psycopg 1: http://initd.org/projects/psycopg1 """ from django.db.backends import util try: import psycopg as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading psycopg modul...
Python
from django.conf import settings import os def runshell(): args = ['psql'] if settings.DATABASE_USER: args += ["-U", settings.DATABASE_USER] if settings.DATABASE_PASSWORD: args += ["-W"] if settings.DATABASE_HOST: args.extend(["-h", settings.DATABASE_HOST]) if settings.DATAB...
Python
# This dictionary maps Field objects to their associated MySQL column # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. DATA_TYPES = { 'AutoFi...
Python
from django.db.backends.mysql_old.base import quote_name from MySQLdb import ProgrammingError, OperationalError from MySQLdb.constants import FIELD_TYPE import re foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") def get_table_list(cursor): "Returns ...
Python
""" MySQL database backend for Django. Requires MySQLdb: http://sourceforge.net/projects/mysql-python """ from django.db.backends import util try: import MySQLdb as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading MySQLdb mo...
Python
from django.conf import settings import os def runshell(): args = [''] args += ["--user=%s" % settings.DATABASE_USER] if settings.DATABASE_PASSWORD: args += ["--password=%s" % settings.DATABASE_PASSWORD] if settings.DATABASE_HOST: args += ["--host=%s" % settings.DATABASE_HOST] if se...
Python
DATA_TYPES = { 'AutoField': 'number(38)', 'BooleanField': 'number(1)', 'CharField': 'varchar2(%(maxlength)s)', 'CommaSeparatedIntegerField': 'varchar2(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'date', 'FileField': 'varchar2(100)', 'Fi...
Python
import re foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") def get_table_list(cursor): "Returns a list of table names in the current database." cursor.execute("SELECT TABLE_NAME FROM USER_TABLES") return [row[0] for row in cursor.fetchall()]...
Python
""" Oracle database backend for Django. Requires cx_Oracle: http://www.python.net/crew/atuining/cx_Oracle/ """ from django.db.backends import util try: import cx_Oracle as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading cx_...
Python
from django.conf import settings import os def runshell(): args = '' args += settings.DATABASE_USER if settings.DATABASE_PASSWORD: args += "/%s" % settings.DATABASE_PASSWORD args += "@%s" % settings.DATABASE_NAME os.execvp('sqlplus', args)
Python
DATA_TYPES = { 'AutoField': 'int IDENTITY (1, 1)', 'BooleanField': 'bit', 'CharField': 'varchar(%(maxlength)s)', 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'smalldatetime', 'DateTimeField': 'smalldatetime', 'FileField': 'varc...
Python
def get_table_list(cursor): raise NotImplementedError def get_table_description(cursor, table_name): raise NotImplementedError def get_relations(cursor, table_name): raise NotImplementedError def get_indexes(cursor, table_name): raise NotImplementedError DATA_TYPES_REVERSE = {}
Python
""" ADO MSSQL database backend for Django. Requires adodbapi 2.0.1: http://adodbapi.sourceforge.net/ """ from django.db.backends import util try: import adodbapi as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading adodbapi m...
Python
def runshell(): raise NotImplementedError
Python
class BoundRelatedObject(object): def __init__(self, related_object, field_mapping, original): self.relation = related_object self.field_mappings = field_mapping[related_object.name] def template_name(self): raise NotImplementedError def __repr__(self): return repr(self.__d...
Python
class_prepared = object() pre_init= object() post_init = object() pre_save = object() post_save = object() pre_delete = object() post_delete = object() post_syncdb = object()
Python
from django.db import backend, connection, transaction from django.db.models.fields import DateField, FieldDoesNotExist from django.db.models.fields.generic import GenericRelation from django.db.models import signals from django.dispatch import dispatcher from django.utils.datastructures import SortedDict import operat...
Python
import django.db.models.manipulators import django.db.models.manager from django.core import validators from django.core.exceptions import ObjectDoesNotExist from django.db.models.fields import AutoField, ImageField, FieldDoesNotExist from django.db.models.fields.related import OneToOneRel, ManyToOneRel from django.db....
Python
from django.core.exceptions import ObjectDoesNotExist from django import oldforms from django.core import validators from django.db.models.fields import FileField, AutoField from django.dispatch import dispatcher from django.db.models import signals from django.utils.functional import curry from django.utils.datastruct...
Python
from django.conf import settings from django.db.models.related import RelatedObject from django.db.models.fields.related import ManyToManyRel from django.db.models.fields import AutoField, FieldDoesNotExist from django.db.models.loading import get_models from django.db.models.query import orderlist2sql from django.db.m...
Python
""" Classes allowing "generic" relations through ContentType and object-id fields. """ from django import oldforms from django.core.exceptions import ObjectDoesNotExist from django.db import backend from django.db.models import signals from django.db.models.fields.related import RelatedField, Field, ManyToManyRel from...
Python
from django.db import backend, transaction from django.db.models import signals, get_model from django.db.models.fields import AutoField, Field, IntegerField, get_ul_class from django.db.models.related import RelatedObject from django.utils.text import capfirst from django.utils.translation import gettext_lazy, string_...
Python
from django.db.models import signals from django.dispatch import dispatcher from django.conf import settings from django.core import validators from django import oldforms from django import newforms as forms from django.core.exceptions import ObjectDoesNotExist from django.utils.functional import curry from django.uti...
Python
from django.db.models.query import QuerySet, EmptyQuerySet from django.dispatch import dispatcher from django.db.models import signals from django.db.models.fields import FieldDoesNotExist # Size of each "chunk" for get_iterator calls. # Larger values are slightly faster at the expense of more storage space. GET_ITERA...
Python
from django.conf import settings from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured from django.core import validators from django.db import backend, connection from django.db.models.loading import get_apps, get_app, get_models, get_model, register_models from django.db.models.query import Q fr...
Python
"Utilities for loading models and the modules that contain them." from django.conf import settings from django.core.exceptions import ImproperlyConfigured import sys import os __all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models') _app_list = [] # Cache of installed apps. ...
Python
""" This module implements a transaction manager that can be used to define transaction handling in a request or view function. It is used by transaction control middleware and decorators. The transaction manager can be in managed or in auto state. Auto state means the system is using a commit-on-save strategy (actual...
Python
from django.conf import settings from django.core import signals from django.dispatch import dispatcher __all__ = ('backend', 'connection', 'DatabaseError') if not settings.DATABASE_ENGINE: settings.DATABASE_ENGINE = 'dummy' try: backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE, {...
Python
# Default Django settings. Override these with settings in the module # pointed-to by the DJANGO_SETTINGS_MODULE environment variable. # This is defined here as a do-nothing function because we can't import # django.utils.translation -- that module depends on the settings. gettext_noop = lambda s: s #################...
Python
from django.db import models # Create your models here.
Python
# Create your views here.
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', # Example: # (r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')), # Uncomment this for admin: # (r'^admin/', include('django.contrib.admin.urls')), )
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
# Django settings for {{ project_name }} project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. DATABASE_NAME = '' # Or path to data...
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
""" Settings and configuration for Django. Values will be read from the module specified by the DJANGO_SETTINGS_MODULE environment variable, and then from django.conf.global_settings; see the global settings file for a list of all possible variables. """ import os import time # Needed for Windows from django.conf...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('django.views', (r'^(?P<content_type_id>\d+)/(?P<object_id>\d+)/$', 'defaults.shortcut'), )
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^setlang/$', 'django.views.i18n.set_language'), )
Python
from django.core.urlresolvers import RegexURLPattern, RegexURLResolver __all__ = ['handler404', 'handler500', 'include', 'patterns'] handler404 = 'django.views.defaults.page_not_found' handler500 = 'django.views.defaults.server_error' include = lambda urlconf_module: [urlconf_module] def patterns(prefix, *tuples): ...
Python
from django.oldforms import *
Python
# This module collects helper functions and classes that "span" multiple levels # of MVC. In other words, these functions/classes introduce controlled coupling # for convenience's sake. from django.template import loader from django.http import HttpResponse, Http404 from django.db.models.manager import Manager def re...
Python