From f4f6471555573b314055e73cecfb4eb7d94c3f36 Mon Sep 17 00:00:00 2001 From: Artur Barseghyan Date: Wed, 4 Mar 2015 01:11:31 +0100 Subject: [PATCH] prepare 0.4.24; rename migrate_03_to_04 command to fobi_migrate_03_to_04; add missing app config declarations for the db_store form handler plugin; add missing app config for the main package; improved plugins and modules autodiscover for django>=1.7 when full dotted path to the AppConfig class is provided, instead of a dotted path to the module --- CHANGELOG.rst | 16 ++++- LICENSES.rst | 9 +++ scripts/test_django_1_6.sh | 0 setup.py | 11 ++-- src/fobi/__init__.py | 6 +- src/fobi/apps.py | 14 +++++ .../form_handlers/db_store/__init__.py | 2 +- src/fobi/discover.py | 62 ++++++++++++------- ...e_03_to_04.py => fobi_migrate_03_to_04.py} | 0 9 files changed, 91 insertions(+), 29 deletions(-) mode change 100644 => 100755 scripts/test_django_1_6.sh create mode 100644 src/fobi/apps.py rename src/fobi/management/commands/{migrate_03_to_04.py => fobi_migrate_03_to_04.py} (100%) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6fb6ceb69..92110d15a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,18 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.4.24 +------------------------------------- +2015-03-04 + +- The management command `migrate_03_to_04` intended to migrate 0.3.x branch + data to > 0.4.x branch data, has been renamed to `fobi_migrate_03_to_04`. +- Add missing app config declaration for the `db_store` form handler plugin. +- Add missing app config for the core `fobi` package. +- Improved autodiscover for Django>=1.7. Fix exception when using a dotted + path to an `AppConfig` in `INSTALLED_APPS` (instead of using the path to + the app). + 0.4.23 ------------------------------------- 2015-03-04 @@ -213,7 +225,9 @@ are used for versioning (schema follows below): 'fobi.contrib.plugins.form_elements.fields.date_drop_down' - 3. Run the ``migrate_03_to_04`` management command:: + 3. Run the ``migrate_03_to_04`` management command. Note, that as of version + 0.4.24, the `migrate_03_to_04` command has been renamed to + `fobi_migrate_03_to_04`.:: ./manage.py migrate_03_to_04 diff --git a/LICENSES.rst b/LICENSES.rst index d6e851820..3102f7936 100644 --- a/LICENSES.rst +++ b/LICENSES.rst @@ -19,6 +19,15 @@ Licensing information: - LGPL 3 (https://www.gnu.org/licenses/lgpl.html) +django-nine +============================== +https://github.com/barseghyanartur/django-nine + +Licensing information: + +- GPL 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) +- LGPL 2.1 (https://www.gnu.org/licenses/lgpl-2.1.html) + easy-thumbnails ============================== https://github.com/SmileyChris/easy-thumbnails diff --git a/scripts/test_django_1_6.sh b/scripts/test_django_1_6.sh old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py index 05e48e600..d0ffdaea3 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ for locale_dir in locale_dirs: locale_files += [os.path.join(locale_dir, f) for f in os.listdir(locale_dir)] -version = '0.4.23' +version = '0.4.24' install_requires = [ 'Pillow>=2.0.0', @@ -96,7 +96,8 @@ setup( name = 'django-fobi', version = version, - description = ("Customisable, modular user- and developer- friendly form generator/builder application for Django"), + description = ("Customisable, modular user- and developer- friendly form " + "generator/builder application for Django"), long_description = "{0}{1}".format(readme, screenshots), classifiers = [ "Programming Language :: Python :: 2.6", @@ -105,13 +106,15 @@ "Programming Language :: Python :: 3.3", "Environment :: Web Environment", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", + "License :: OSI Approved :: GNU Lesser General Public License v2 or " + "later (LGPLv2+)", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Development Status :: 4 - Beta", ], - keywords = 'django, form generator, form builder, visual form designer, user generated forms', + keywords = "django, form generator, form builder, visual form designer, " + "user generated forms", author = 'Artur Barseghyan', author_email = 'artur.barseghyan@gmail.com', url = 'https://github.com/barseghyanartur/django-fobi/', diff --git a/src/fobi/__init__.py b/src/fobi/__init__.py index 3a1acc07d..6d0e22288 100644 --- a/src/fobi/__init__.py +++ b/src/fobi/__init__.py @@ -1,6 +1,8 @@ __title__ = 'django-fobi' -__version__ = '0.4.23' -__build__ = 0x000026 +__version__ = '0.4.24' +__build__ = 0x000027 __author__ = 'Artur Barseghyan ' __copyright__ = '2014-2015 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' + +default_app_config = 'fobi.apps.Config' diff --git a/src/fobi/apps.py b/src/fobi/apps.py new file mode 100644 index 000000000..c2e034631 --- /dev/null +++ b/src/fobi/apps.py @@ -0,0 +1,14 @@ +__title__ = 'fobi.apps' +__author__ = 'Artur Barseghyan ' +__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan' +__license__ = 'GPL 2.0/LGPL 2.1' +__all__ = ('Config',) + +try: + from django.apps import AppConfig + + class Config(AppConfig): + name = label = 'fobi' + +except ImportError: + pass diff --git a/src/fobi/contrib/plugins/form_handlers/db_store/__init__.py b/src/fobi/contrib/plugins/form_handlers/db_store/__init__.py index 15e8124f0..1c886ff02 100644 --- a/src/fobi/contrib/plugins/form_handlers/db_store/__init__.py +++ b/src/fobi/contrib/plugins/form_handlers/db_store/__init__.py @@ -4,6 +4,6 @@ __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('default_app_config', 'UID',) -#default_app_config = 'fobi.contrib.plugins.form_handlers.db_store.apps.Config' +default_app_config = 'fobi.contrib.plugins.form_handlers.db_store.apps.Config' UID = 'db_store' diff --git a/src/fobi/discover.py b/src/fobi/discover.py index c3ca5818a..8becf4e60 100644 --- a/src/fobi/discover.py +++ b/src/fobi/discover.py @@ -8,29 +8,24 @@ import logging from django.conf import settings -from fobi.conf import get_setting -logger = logging.getLogger(__file__) +from nine.versions import DJANGO_GTE_1_7 -def autodiscover(): - """ - Autodiscovers files that should be found by fobi. - """ - FORM_ELEMENT_PLUGINS_MODULE_NAME = get_setting('FORM_ELEMENT_PLUGINS_MODULE_NAME') - FORM_HANDLER_PLUGINS_MODULE_NAME = get_setting('FORM_HANDLER_PLUGINS_MODULE_NAME') - THEMES_MODULE_NAME = get_setting('THEMES_MODULE_NAME') - FORM_CALLBACKS_MODULE_NAME = get_setting('FORM_CALLBACKS_MODULE_NAME') - - #FORM_IMPORTER_PLUGINS_MODULE_NAME = get_setting('FORM_IMPORTER_PLUGINS_MODULE_NAME') - - def do_discover(module_name): +# In Django a dotted path can be used up to the app config class. In +# such cases the old-school autodiscovery of modules doesn't work but we +# have a great Django `autodiscover_modules` tool then. In cases if Django +# version is >= 1.7, we use the Django `autodiscover_modules` tool falling back +# to our own implementation of it otherwise. +if DJANGO_GTE_1_7: + from django.utils.module_loading import autodiscover_modules +else: + def autodiscover_modules(module_name): for app in settings.INSTALLED_APPS: try: app = str(app) app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__ except (AttributeError, TypeError) as e: logger.debug(str(e)) - #import ipdb; ipdb.set_trace() continue try: @@ -40,11 +35,36 @@ def do_discover(module_name): continue __import__('{0}.{1}'.format(app, module_name)) - # Discover plugins - do_discover(FORM_ELEMENT_PLUGINS_MODULE_NAME) - do_discover(FORM_HANDLER_PLUGINS_MODULE_NAME) - do_discover(THEMES_MODULE_NAME) - do_discover(FORM_CALLBACKS_MODULE_NAME) +from fobi.conf import get_setting + +logger = logging.getLogger(__file__) + +def autodiscover(): + """ + Autodiscovers files that should be found by fobi. + """ + FORM_ELEMENT_PLUGINS_MODULE_NAME = get_setting( + 'FORM_ELEMENT_PLUGINS_MODULE_NAME' + ) + FORM_HANDLER_PLUGINS_MODULE_NAME = get_setting( + 'FORM_HANDLER_PLUGINS_MODULE_NAME' + ) + THEMES_MODULE_NAME = get_setting( + 'THEMES_MODULE_NAME' + ) + FORM_CALLBACKS_MODULE_NAME = get_setting( + 'FORM_CALLBACKS_MODULE_NAME' + ) + + #FORM_IMPORTER_PLUGINS_MODULE_NAME = get_setting( + # 'FORM_IMPORTER_PLUGINS_MODULE_NAME' + # ) + + # Discover modules + autodiscover_modules(FORM_ELEMENT_PLUGINS_MODULE_NAME) + autodiscover_modules(FORM_HANDLER_PLUGINS_MODULE_NAME) + autodiscover_modules(THEMES_MODULE_NAME) + autodiscover_modules(THEMES_MODULE_NAME) # Do not yet discover form importers - #do_discover(FORM_IMPORTER_PLUGINS_MODULE_NAME) + #autodiscover_modules(FORM_IMPORTER_PLUGINS_MODULE_NAME) diff --git a/src/fobi/management/commands/migrate_03_to_04.py b/src/fobi/management/commands/fobi_migrate_03_to_04.py similarity index 100% rename from src/fobi/management/commands/migrate_03_to_04.py rename to src/fobi/management/commands/fobi_migrate_03_to_04.py