Change import in permalink decorator from function to module
|Database layer (models, ORM)
|Patch needs improvement:
permalink decorator uses the
urlresolvers.reverse function to generate a permanent link to objects. It imports the
reverse function itself instead of the
urlresolvers module. This causes trouble in projects that also use the
localeurl application, because this application monkey-patches the
reverse function in order to add a prefix. Although monkey-patching a core Django function is bad form, it is currently the only way I see to provide this functionality. Additionally, importing elements from a module instead of the module itself is slightly frowned upon in general (Python docs, Python FAQ: "Guido van Rossum recommends...", Fredrik Lundh). It is common in Django, though, so that might not impress anyone.
The attached patch changes the
permalink decorator to import the
urlresolvers module instead of the
reverse function. Because the change is small, I hope the patch will be accepted.