Skip to content

Commit 52ccbff

Browse files
committed
Imported django/ directory from Django-1.1.1.tar.gz
- Legacy-Id: 1850
1 parent 6b3de82 commit 52ccbff

1,039 files changed

Lines changed: 311727 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

django/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
VERSION = (1, 1, 1, 'final', 0)
2+
3+
def get_version():
4+
version = '%s.%s' % (VERSION[0], VERSION[1])
5+
if VERSION[2]:
6+
version = '%s.%s' % (version, VERSION[2])
7+
if VERSION[3:] == ('alpha', 0):
8+
version = '%s pre-alpha' % version
9+
else:
10+
if VERSION[3] != 'final':
11+
version = '%s %s %s' % (version, VERSION[3], VERSION[4])
12+
from django.utils.version import get_svn_revision
13+
svn_rev = get_svn_revision()
14+
if svn_rev != u'SVN-unknown':
15+
version = "%s %s" % (version, svn_rev)
16+
return version

django/bin/__init__.py

Whitespace-only changes.

django/bin/compile-messages.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
3+
if __name__ == "__main__":
4+
import sys
5+
name = sys.argv[0]
6+
args = ' '.join(sys.argv[1:])
7+
print >> sys.stderr, "%s has been moved into django-admin.py" % name
8+
print >> sys.stderr, 'Please run "django-admin.py compilemessages %s" instead.'% args
9+
print >> sys.stderr
10+
sys.exit(1)
11+

django/bin/daily_cleanup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Daily cleanup job.
5+
6+
Can be run as a cronjob to clean out old data from the database (only expired
7+
sessions at the moment).
8+
"""
9+
10+
from django.core import management
11+
12+
if __name__ == "__main__":
13+
management.call_command('cleanup')

django/bin/django-admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
from django.core import management
3+
4+
if __name__ == "__main__":
5+
management.execute_from_command_line()

django/bin/make-messages.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
3+
if __name__ == "__main__":
4+
import sys
5+
name = sys.argv[0]
6+
args = ' '.join(sys.argv[1:])
7+
print >> sys.stderr, "%s has been moved into django-admin.py" % name
8+
print >> sys.stderr, 'Please run "django-admin.py makemessages %s" instead.'% args
9+
print >> sys.stderr
10+
sys.exit(1)
11+

django/bin/profiling/__init__.py

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
gather_profile_stats.py /path/to/dir/of/profiles
5+
6+
Note that the aggregated profiles must be read with pstats.Stats, not
7+
hotshot.stats (the formats are incompatible)
8+
"""
9+
10+
from hotshot import stats
11+
import pstats
12+
import sys, os
13+
14+
def gather_stats(p):
15+
profiles = {}
16+
for f in os.listdir(p):
17+
if f.endswith('.agg.prof'):
18+
path = f[:-9]
19+
prof = pstats.Stats(os.path.join(p, f))
20+
elif f.endswith('.prof'):
21+
bits = f.split('.')
22+
path = ".".join(bits[:-3])
23+
prof = stats.load(os.path.join(p, f))
24+
else:
25+
continue
26+
print "Processing %s" % f
27+
if path in profiles:
28+
profiles[path].add(prof)
29+
else:
30+
profiles[path] = prof
31+
os.unlink(os.path.join(p, f))
32+
for (path, prof) in profiles.items():
33+
prof.dump_stats(os.path.join(p, "%s.agg.prof" % path))
34+
35+
if __name__ == '__main__':
36+
gather_stats(sys.argv[1])

django/bin/unique-messages.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import sys
5+
6+
def unique_messages():
7+
basedir = None
8+
9+
if os.path.isdir(os.path.join('conf', 'locale')):
10+
basedir = os.path.abspath(os.path.join('conf', 'locale'))
11+
elif os.path.isdir('locale'):
12+
basedir = os.path.abspath('locale')
13+
else:
14+
print "this script should be run from the django svn tree or your project or app tree"
15+
sys.exit(1)
16+
17+
for (dirpath, dirnames, filenames) in os.walk(basedir):
18+
for f in filenames:
19+
if f.endswith('.po'):
20+
sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
21+
pf = os.path.splitext(os.path.join(dirpath, f))[0]
22+
cmd = 'msguniq "%s.po"' % pf
23+
stdout = os.popen(cmd)
24+
msg = stdout.read()
25+
open('%s.po' % pf, 'w').write(msg)
26+
27+
if __name__ == "__main__":
28+
unique_messages()

django/conf/__init__.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
"""
2+
Settings and configuration for Django.
3+
4+
Values will be read from the module specified by the DJANGO_SETTINGS_MODULE environment
5+
variable, and then from django.conf.global_settings; see the global settings file for
6+
a list of all possible variables.
7+
"""
8+
9+
import os
10+
import re
11+
import time # Needed for Windows
12+
13+
from django.conf import global_settings
14+
from django.utils.functional import LazyObject
15+
from django.utils import importlib
16+
17+
ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
18+
19+
class LazySettings(LazyObject):
20+
"""
21+
A lazy proxy for either global Django settings or a custom settings object.
22+
The user can manually configure settings prior to using them. Otherwise,
23+
Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
24+
"""
25+
def _setup(self):
26+
"""
27+
Load the settings module pointed to by the environment variable. This
28+
is used the first time we need any settings at all, if the user has not
29+
previously configured the settings manually.
30+
"""
31+
try:
32+
settings_module = os.environ[ENVIRONMENT_VARIABLE]
33+
if not settings_module: # If it's set but is an empty string.
34+
raise KeyError
35+
except KeyError:
36+
# NOTE: This is arguably an EnvironmentError, but that causes
37+
# problems with Python's interactive help.
38+
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
39+
40+
self._wrapped = Settings(settings_module)
41+
42+
def configure(self, default_settings=global_settings, **options):
43+
"""
44+
Called to manually configure the settings. The 'default_settings'
45+
parameter sets where to retrieve any unspecified values from (its
46+
argument must support attribute access (__getattr__)).
47+
"""
48+
if self._wrapped != None:
49+
raise RuntimeError, 'Settings already configured.'
50+
holder = UserSettingsHolder(default_settings)
51+
for name, value in options.items():
52+
setattr(holder, name, value)
53+
self._wrapped = holder
54+
55+
def configured(self):
56+
"""
57+
Returns True if the settings have already been configured.
58+
"""
59+
return bool(self._wrapped)
60+
configured = property(configured)
61+
62+
class Settings(object):
63+
def __init__(self, settings_module):
64+
# update this dict from global settings (but only for ALL_CAPS settings)
65+
for setting in dir(global_settings):
66+
if setting == setting.upper():
67+
setattr(self, setting, getattr(global_settings, setting))
68+
69+
# store the settings module in case someone later cares
70+
self.SETTINGS_MODULE = settings_module
71+
72+
try:
73+
mod = importlib.import_module(self.SETTINGS_MODULE)
74+
except ImportError, e:
75+
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
76+
77+
# Settings that should be converted into tuples if they're mistakenly entered
78+
# as strings.
79+
tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")
80+
81+
for setting in dir(mod):
82+
if setting == setting.upper():
83+
setting_value = getattr(mod, setting)
84+
if setting in tuple_settings and type(setting_value) == str:
85+
setting_value = (setting_value,) # In case the user forgot the comma.
86+
setattr(self, setting, setting_value)
87+
88+
# Expand entries in INSTALLED_APPS like "django.contrib.*" to a list
89+
# of all those apps.
90+
new_installed_apps = []
91+
for app in self.INSTALLED_APPS:
92+
if app.endswith('.*'):
93+
app_mod = importlib.import_module(app[:-2])
94+
appdir = os.path.dirname(app_mod.__file__)
95+
app_subdirs = os.listdir(appdir)
96+
app_subdirs.sort()
97+
name_pattern = re.compile(r'[a-zA-Z]\w*')
98+
for d in app_subdirs:
99+
if name_pattern.match(d) and os.path.isdir(os.path.join(appdir, d)):
100+
new_installed_apps.append('%s.%s' % (app[:-2], d))
101+
else:
102+
new_installed_apps.append(app)
103+
self.INSTALLED_APPS = new_installed_apps
104+
105+
if hasattr(time, 'tzset'):
106+
# Move the time zone info into os.environ. See ticket #2315 for why
107+
# we don't do this unconditionally (breaks Windows).
108+
os.environ['TZ'] = self.TIME_ZONE
109+
time.tzset()
110+
111+
def get_all_members(self):
112+
return dir(self)
113+
114+
class UserSettingsHolder(object):
115+
"""
116+
Holder for user configured settings.
117+
"""
118+
# SETTINGS_MODULE doesn't make much sense in the manually configured
119+
# (standalone) case.
120+
SETTINGS_MODULE = None
121+
122+
def __init__(self, default_settings):
123+
"""
124+
Requests for configuration variables not in this class are satisfied
125+
from the module specified in default_settings (if possible).
126+
"""
127+
self.default_settings = default_settings
128+
129+
def __getattr__(self, name):
130+
return getattr(self.default_settings, name)
131+
132+
def get_all_members(self):
133+
return dir(self) + dir(self.default_settings)
134+
135+
settings = LazySettings()
136+

0 commit comments

Comments
 (0)