jonasvp/django-beanstalkd — pull request #4 by bmathieu33 (2011-11-03 16:36:49+00:00)
Title: get bs_module from sys.modules, not directly from `__import__`()

`__import__()` returns the top-level module of a package, not the module itself. `__import__()` + `sys.modules` is the way recommanded by the python documentation:

http://docs.python.org/library/functions.html#__import__ (see last example)

My django packages are in a nested namespace (2 levels): top.package1, top.package2,...

Without this patch, the job list is located in "top" module, and the jobs are listed twice (or more if you have more packages in "top.*" and beanstalk jobs. This can be confusing for the user, although jobs are properly registered.

With my patch, the job list is properly locate in top.package.1.beanstalk_jobs, top.package2.beanstalk_jobs, and so on.

I have also set `__module__` attribute of the decorator to reflect `__module__` attribute of the decorated function (not exactly a clean functools.wraps, but it can help debugging)