Introducing django-publicmanager

I use nearly in all projects something like an is_public and a pub_date field in my models. But using this introduces many possibilities to forget to check this values in all places you use the model which would open up everything for information leaks.

django-publicmanager tries to fix this issue with two custom managers.

The app provides the managers GenericPublicManager and PublicOnlyManager. The first one behaves exactly like the django's default manager except that it provides a public() method which will return only public objects. PublicOnlyManager is used in cases were you only want to act on public objects.

The managers are using a custom queryset to handle the logic behind the scenes. I think its a good example for a custom queryset and the integration into the managers. Its very basic but I think there is no documentation out there for custom querysets.

You can download and install it from the python package index with a easy_install django-publicmanager. The source is available on launchpad. A simple bzr branch lp:django-publicmanager will give you a clean checkout of the code.

Just create a branch or a bug report on launchpad to tell me what you miss in this application. Feedback is always welcomed.


Comments

blog comments powered by Disqus