django.contrib.sessions.models: 23 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/django/contrib/sessions/models.py

Stats: 0 executed, 20 missed, 3 excluded, 31 ignored

  1. from django.db import models
  2. from django.utils.translation import ugettext_lazy as _
  3. class SessionManager(models.Manager):
  4. def encode(self, session_dict):
  5. """
  6. Returns the given session dictionary pickled and encoded as a string.
  7. """
  8. return SessionStore().encode(session_dict)
  9. def save(self, session_key, session_dict, expire_date):
  10. s = self.model(session_key, self.encode(session_dict), expire_date)
  11. if session_dict:
  12. s.save()
  13. else:
  14. s.delete() # Clear sessions with no data.
  15. return s
  16. class Session(models.Model):
  17. """
  18. Django provides full support for anonymous sessions. The session
  19. framework lets you store and retrieve arbitrary data on a
  20. per-site-visitor basis. It stores data on the server side and
  21. abstracts the sending and receiving of cookies. Cookies contain a
  22. session ID -- not the data itself.
  23. The Django sessions framework is entirely cookie-based. It does
  24. not fall back to putting session IDs in URLs. This is an intentional
  25. design decision. Not only does that behavior make URLs ugly, it makes
  26. your site vulnerable to session-ID theft via the "Referer" header.
  27. For complete documentation on using Sessions in your code, consult
  28. the sessions documentation that is shipped with Django (also available
  29. on the Django Web site).
  30. """
  31. session_key = models.CharField(_('session key'), max_length=40,
  32. primary_key=True)
  33. session_data = models.TextField(_('session data'))
  34. expire_date = models.DateTimeField(_('expire date'), db_index=True)
  35. objects = SessionManager()
  36. class Meta:
  37. db_table = 'django_session'
  38. verbose_name = _('session')
  39. verbose_name_plural = _('sessions')
  40. def get_decoded(self):
  41. return SessionStore().decode(self.session_data)
  42. # At bottom to avoid circular import
  43. from django.contrib.sessions.backends.db import SessionStore