Ticket #6080: reusableapps.diff
File reusableapps.diff, 8.4 KB (added by , 17 years ago) |
---|
-
django/db/models/loading.py
5 5 import sys 6 6 import os 7 7 import threading 8 try: 9 from pkg_resources import working_set, DistributionNotFound, \ 10 Environment, VersionConflict, UnknownExtra 11 except ImportError: 12 pkg_resources_is_available = True 13 else: 14 pkg_resources_is_available = False 8 15 9 16 __all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models', 10 'load_app', 'app_cache_ready' )17 'load_app', 'app_cache_ready', 'get_all_apps') 11 18 12 19 class AppCache(object): 13 20 """ … … 49 56 try: 50 57 if self.loaded: 51 58 return 52 for app_name in se ttings.INSTALLED_APPS:59 for app_name in self.get_all_apps(): 53 60 if app_name in self.handled: 54 61 continue 55 62 self.load_app(app_name, True) … … 60 67 finally: 61 68 self.write_lock.release() 62 69 70 def get_all_apps(self): 71 """ 72 Looks for apps in the directories defined by the ``APP_DIRS`` setting 73 if ``pkg_resources`` (part of setuptools) is installed. 74 75 Every module having the entry point like the setting ``APP_ENTRY_POINT`` 76 will be added to the Python path, if necesary. 77 78 Returns a tuple with INSTALLED_APPS and all found apps. 79 """ 80 APP_LIST = [] 81 if pkg_resources_is_available: 82 # find every "distribution" in the app directory paths and add 83 # them to the "working_set", effectively setting the PYTHONPATH 84 app_environment = Environment(settings.APPS_DIRS) 85 map(working_set.add, working_set.find_plugins(app_environment)[0]) 86 # look for entry points in all distributions currently on the 87 # PYTHONPATH and add matching modules to INSTALLED_APPS 88 for entry in working_set.iter_entry_points(settings.APP_ENTRY_POINT): 89 app = entry.module_name 90 if app not in settings.INSTALLED_APPS and app not in APP_LIST: 91 APP_LIST.append(app_name) 92 return settings.INSTALLED_APPS + tuple(APP_LIST) 93 63 94 def load_app(self, app_name, can_postpone=False): 64 95 """ 65 96 Loads the app with the provided fully qualified name, and returns the … … 185 216 register_models = cache.register_models 186 217 load_app = cache.load_app 187 218 app_cache_ready = cache.app_cache_ready 219 get_all_apps = cache.get_all_apps -
django/conf/global_settings.py
134 134 # List of strings representing installed apps. 135 135 INSTALLED_APPS = () 136 136 137 # List of locations of reusable apps, in search order. 138 APP_DIRS = () 139 140 # Entry point name of reusable Django apps 141 APP_ENTRY_POINT = 'django.apps' 142 137 143 # List of locations of the template source files, in search order. 138 144 TEMPLATE_DIRS = () 139 145 -
setup.py
1 from distutils.core import setup 2 from distutils.command.install import INSTALL_SCHEMES 1 try: 2 from setuptools import setup 3 except ImportError: 4 from distutils.core import setup 5 from distutils.command.install import INSTALL_SCHEMES 6 # Tell distutils to put the data_files in platform-specific installation 7 # locations. See here for an explanation: 8 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb 9 for scheme in INSTALL_SCHEMES.values(): 10 scheme['data'] = scheme['purelib'] 3 11 import os 4 12 import sys 5 13 … … 17 25 return result 18 26 return fullsplit(head, [tail] + result) 19 27 20 # Tell distutils to put the data_files in platform-specific installation21 # locations. See here for an explanation:22 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb23 for scheme in INSTALL_SCHEMES.values():24 scheme['data'] = scheme['purelib']25 26 28 # Compile the list of packages available, because distutils doesn't have 27 29 # an easy way to do this. 28 30 packages, data_files = [], [] … … 46 48 # Dynamically calculate the version based on django.VERSION. 47 49 version_tuple = __import__('django').VERSION 48 50 if version_tuple[2] is not None: 49 version = "%d.%d _%s" % version_tuple51 version = "%d.%d%s" % version_tuple 50 52 else: 51 53 version = "%d.%d" % version_tuple[:2] 52 54 53 55 setup( 54 56 name = "Django", 55 57 version = version, 58 license = 'BSD', 56 59 url = 'http://www.djangoproject.com/', 57 60 author = 'Lawrence Journal-World', 58 61 author_email = 'holovaty@gmail.com', 59 62 description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.', 60 63 packages = packages, 61 64 data_files = data_files, 65 install_requires = ['setuptools>=0.6c7', 'Flup'], 62 66 scripts = ['django/bin/django-admin.py'], 67 extras_require = { 68 'MySQL': ["MySQLdb>=1.2.1p2"], 69 'SQLite': ["pysqlite>=2.0.3"], 70 'PostgreSQL': ["psycopg>=1.1.21"], 71 'PostgreSQL2': ["psycopg2>=2.0.5"], 72 'Oracle': ["cx_Oracle>=4.3.1"], 73 'PyYaml': ["PyYaml"], 74 }, 75 zip_safe = False, 63 76 ) -
docs/install.txt
224 224 command ``svn update`` from within the ``django-trunk`` directory. When you do 225 225 this, Subversion will automatically download any changes. 226 226 227 Installing using setuptools' ``develop`` command 228 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 **New in Django development version** 230 231 If you already installed setuptools_ you can skip step 3 and 4 of the 232 instructions above and use the ``develop`` command of setuptools instead:: 233 234 python setup.py develop 235 236 This adds a special file automatically to your system's ``site-packages`` 237 directory and enables the Python intepreter to find the Django checkout without the need to create a symbolic link or to set the ``PYTHONPATH`` environment variable. This is also platform-independent. 238 239 Installing using easy_install 240 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 241 **New in Django development version** 242 243 If you want to benefit from setuptools_'s package management and dependency tracking, don't hesitate to install Django with easy_install_. 244 245 1. Make sure that you have Subversion_ and setuptools_ installed, and that you 246 can run its commands from a shell. (Enter ``svn help`` or 247 ``easy_install --help`` at a shell prompt to test this.) 248 249 2. Install Django's main development branch (the 'trunk') like so:: 250 251 easy_install http://code.djangoproject.com/svn/django/trunk/ 252 253 The above line checks out Django's source automatically and runs 254 ``python setup.py install`` for you. 255 256 If you want setuptools to install one of several recommended extras or a 257 Python database binding during Django's installation, you can also use 258 easy_install_ like this:: 259 260 easy_install Django[PostgreSQL] 261 easy_install Django[SQLite, PyYaml] 262 263 To see a full list of the available extras, open ``setup.py`` and look at the 264 ``extras_require`` keyword. 265 266 227 267 .. _`download page`: http://www.djangoproject.com/download/ 228 268 .. _Subversion: http://subversion.tigris.org/ 229 269 .. _from the Control Panel: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sysdm_advancd_environmnt_addchange_variable.mspx 270 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools 271 .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall -
docs/settings.txt
216 216 then ``{% ssi /home/html/foo.txt %}`` would work, but ``{% ssi /etc/passwd %}`` 217 217 wouldn't. 218 218 219 APP_DIRS 220 -------- 221 222 Default: ``()`` (Empty tuple) 223 224 List of locations of reusable Django apps, in search order. Note that 225 these paths should use Unix-style forward slashes, even on Windows. 226 227 APP_ENTRY_POINT 228 --------------- 229 230 Default: ``'django.apps'`` 231 232 Name of the entry point which is used to load reusable Django apps. 233 219 234 APPEND_SLASH 220 235 ------------ 221 236