tfroehlich82 / django-app-plugins

Automatically exported from code.google.com/p/django-app-plugins
Other
0 stars 0 forks source link

Registering plugins results in error. #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This patch addresses two issues - trying to register a plugin causes errors
on syncdb due to a bug, and after fixing this bug, multiple
sync_app_plugins calls cause any plugin registrations to break. Attached is
a patch to fix the issues discussed.

Thanks for all the work on this! This app is great, but would also
appreciate a bit more documentation - understanding how to use plugins and
user preferences wasn't overly apparent, even from the source.

Cheers,

Ben

What steps will reproduce the problem?
(Tracebacks are listed at end of report)

1. In an app, add a new plugin and its appropriate template:
import app_plugins
register = app_plugins.Library()
def my_plugin(point, context, user, *args, **kwargs):
    return {}
register.plugin(takes_context=True, takes_user=True)(my_plugin)

2. Run a syncdb - Traceback #1 appears. Fix that by changing the typo cal
to call in library.py

3. Run a syncdb again - Traceback #2 appears. The joiner . is not being
stripped from the point_label (line 118 of sync_plugins.py), so correct for
this by stripping any dots.

4. Run syncdb again everything works without error.

5. Run another syncdb. Check the status of
PluginPoint.objects.get(label='my_plugin'). It will be 2 (removed). This is
due to section 2 in sync_app_plugins that removes any unregistered
plugin_points. Since our plugin_point is associated with a plugin, it is
unregistered, but should not be removed. Add in a check to line 105 of
sync_plugins.py to keep any PluginPoints with active Plugins enabled.

What version of the product are you using? On what operating system?
Same bug appears in pinax0.7-beta2 and pinax-0.7-beta3, although the patch
is against the svn trunk. Bug appears to remain in the trunk as well.
Running on Ubuntu 9.04, python2.6.

Please provide any additional information below.

Tracebacks:
Traceback #1:
Traceback (most recent call last):
  File "./manage.py", line 28, in <module>
    execute_from_command_line()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/__init__.py",
line 331, in execute_from_command_line
    utility.execute()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/__init__.py",
line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/base.py",
line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/base.py",
line 210, in execute
    translation.activate('en-us')
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/utils/translation/__init__.py",
line 73, in activate
    return real_activate(language)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/utils/translation/__init__.py",
line 43, in delayed_loader
    return g['real_%s' % caller](*args, **kwargs)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/utils/translation/trans_real.py",
line 209, in activate
    _active[currentThread()] = translation(language)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/utils/translation/trans_real.py",
line 198, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/utils/translation/trans_real.py",
line 183, in _fetch
    app = __import__(appname, {}, {}, [])
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_db_
log-1.0.1-py2.6.egg/djangodblog/__init__.py",
line 1, in <module>
    import djangodblog.admin
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_db_
log-1.0.1-py2.6.egg/djangodblog/admin.py",
line 14, in <module>
    admin.site.register(ErrorBatch, ErrorBatchAdmin)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/contrib/admin/sites.py",
line 76, in register
    validate(admin_class, model)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/contrib/admin/validation.py",
line 22, in validate
    models.get_apps()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 97, in get_apps
    self._populate()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 57, in _populate
    self.load_app(app_name, True)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_ope
nid-0.1.1-py2.6.egg/django_openid/models.py",
line 118, in <module>
    user_model = models.get_model('auth', 'User')
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 153, in get_model
    self._populate()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 57, in _populate
    self.load_app(app_name, True)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_mes
sages-0.4.0-py2.6.egg/messages/models.py",
line 101, in <module>
    notification = get_app('notification')
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 111, in get_app
    self._populate()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 57, in _populate
    self.load_app(app_name, True)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/db/models/loading.py",
line 72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File "/home/bbest/PinaxProjects/myewb/myewb/apps/ideas_app/__init__.py",
line 8, in <module>
    register.plugin(takes_context=True, takes_user=True)(my_plugin)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_app
_plugins-0.1.0-py2.6.egg/app_plugins/library.py",
line 57, in plugin
    if not callable(call) and cal is not None:
NameError: global name 'cal' is not defined

Traceback #2:
Traceback (most recent call last):
  File "./manage.py", line 28, in <module>
    execute_from_command_line()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/__init__.py",
line 331, in execute_from_command_line
    utility.execute()
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/__init__.py",
line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/base.py",
line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/base.py",
line 219, in execute
    output = self.handle(*args, **options)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/base.py",
line 348, in handle
    return self.handle_noargs(**options)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/commands/syncdb.py",
line 101, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/core/management/sql.py",
line 205, in emit_post_sync_signal
    interactive=interactive)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/Django-1.0
.2_final-py2.6.egg/django/dispatch/dispatcher.py",
line 148, in send
    response = receiver(signal=self, sender=sender, **named)
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_app
_plugins-0.1.0-py2.6.egg/app_plugins/management/__init__.py",
line 6, in do_sync
    sync_app_plugins(verbosity=kwdargs.get("verbosity", 1))
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_app
_plugins-0.1.0-py2.6.egg/app_plugins/management/commands/sync_plugins.py",
line 145, in sync_app_plugins
    options = lib.get_plugin_call(point_label).options
  File
"/home/bbest/.virtualenvs/pinax-env-beta2/lib/python2.6/site-packages/django_app
_plugins-0.1.0-py2.6.egg/app_plugins/library.py",
line 51, in get_plugin_call
    return self.plugin_calls[name]
KeyError: '.my_plugin'

Original issue reported on code.google.com by ben.b...@gmail.com on 11 Aug 2009 at 9:26

Attachments:

GoogleCodeExporter commented 9 years ago
This is a fun one. I can't accept the patch as is due to some additional 
problems
which can come up. I should have this patched for 0.1.2 next week.

Sorry for the delays.

Original comment by doug.nap...@gmail.com on 14 Oct 2009 at 9:48

GoogleCodeExporter commented 9 years ago

Original comment by doug.nap...@gmail.com on 14 Oct 2009 at 9:50

GoogleCodeExporter commented 9 years ago
r22

Original comment by doug.nap...@gmail.com on 24 Oct 2009 at 1:58