Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > HTTP (WWW)

    django-cuser 1.0

    Download button

    No screenshots available
    Downloads: 122  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Alireza Savand | More programs
    Other/Proprietary Li... / FREE
    May 14th, 2012, 12:40 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    django-cuser description

    Middleware to make user information always available

    django-cuser is a Django app that will bring you current user of your Django application from anywhere in your code.

    Installing

    djang-cuser is also avilable at http://pypi.python.org/pypi/django-cuser. So it can be install it by pip or easy_install:

     python pip install django-cuser

    Or you can grap the latest version tarball:

     python setup.py install

    To enable django-cuser in your project

    - Add 'cuser' to INSTALLED_APPS in your settings.py
    - Add 'cuser.middleware.CuserMiddleware' to MIDDLEWARE_CLASSES after the authentication and session middleware

    Who is the current user

    To set/get the user info, there is the following API:

    from cuser.middleware import CuserMiddleware

    Set the current user for this thread. Accepts user objects and login names:

    CuserMiddleware.set_user(some_user)

    Get the current user or None:

    user = CuserMiddleware.get_user()

    This will return some_user if there is no current user:

    user = CuserMiddleware.get_user(some_user)

    Forget the current user. It is always safe to call this, even if there is no urrent user:

    CuserMiddleware.del_user()

    The middleware automatically sets/deletes the current user for HTTP requests. For other uses (management commands, scripts), you will need to do this yourself.

    echelon also provides a CurrentUserField, which can be used for auditing purposes. Use it as follows:

    from echelon.fields import CurrentUserField:

    class MyModel(models.Model):
     ....
     creator = CurrentUserField(add_only=True, related_name="created_mymodels")
     last_editor = CurrentUserField(related_name="last_edited_mymodels")
     ...


    This field is a ForeignKey to the django.contrib.auth.models.User model and you can treat it as such.


    Product's homepage

    Requirements:

    · Python
    · Django

      


    TAGS:

    user information | current user | Django | user | information

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM