From 130c7eee8058847083ad58f1f9abdcf51e879032 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 10 Jun 2007 02:00:46 +0000 Subject: [PATCH] Fixed #4517 -- Made sure that URL_VALIDATOR_USER_AGENT includes the up-to-date Django version number. Thanks, James Wheare. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5451 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/__init__.py | 7 +++++++ django/conf/global_settings.py | 3 ++- django/core/management.py | 13 ++++--------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index fde35507a05..06c1a90e035 100644 --- a/AUTHORS +++ b/AUTHORS @@ -234,6 +234,7 @@ answer newbie questions, and generally made Django that much better: wangchun Dan Watson Chris Wesseling + James Wheare charly.wilhelm@gmail.com Rachel Willmer Gary Wilson diff --git a/django/__init__.py b/django/__init__.py index 7a24af2b4eb..17d8c519ccf 100644 --- a/django/__init__.py +++ b/django/__init__.py @@ -1 +1,8 @@ VERSION = (0, 97, 'pre') + +def get_version(): + "Returns the version as a human-format string." + v = '.'.join([str(i) for i in VERSION[:-1]]) + if VERSION[-1]: + v += '-' + VERSION[-1] + return v diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 2be6a4ef957..8bdeb64efcd 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -241,7 +241,8 @@ TRANSACTIONS_MANAGED = False # The User-Agent string to use when checking for URL validity through the # isExistingURL validator. -URL_VALIDATOR_USER_AGENT = "Django/0.96pre (http://www.djangoproject.com)" +from django import get_version +URL_VALIDATOR_USER_AGENT = "Django/%s (http://www.djangoproject.com)" % get_version() ############## # MIDDLEWARE # diff --git a/django/core/management.py b/django/core/management.py index b763a5cb1c1..213eb4602cd 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -3,14 +3,17 @@ import django from django.core.exceptions import ImproperlyConfigured -import os, re, shutil, sys, textwrap from optparse import OptionParser from django.utils import termcolors +import os, re, shutil, sys, textwrap # For Python 2.3 if not hasattr(__builtins__, 'set'): from sets import Set as set +# For backwards compatibility: get_version() used to be in this module. +get_version = django.get_version + MODULE_TEMPLATE = ''' {%% if perms.%(app)s.%(addperm)s or perms.%(app)s.%(changeperm)s %%} {%% if perms.%(app)s.%(changeperm)s %%}{%% endif %%}%(name)s{%% if perms.%(app)s.%(changeperm)s %%}{%% endif %%} @@ -93,14 +96,6 @@ def _get_sequence_list(): # field as the field to which it points. get_rel_data_type = lambda f: (f.get_internal_type() in ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' or f.get_internal_type() -def get_version(): - "Returns the version as a human-format string." - from django import VERSION - v = '.'.join([str(i) for i in VERSION[:-1]]) - if VERSION[-1]: - v += '-' + VERSION[-1] - return v - def get_sql_create(app): "Returns a list of the CREATE TABLE SQL statements for the given app." from django.db import get_creation_module, models