You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
788 B

  1. from __future__ import unicode_literals
  2. from django.utils.encoding import python_2_unicode_compatible
  3. @python_2_unicode_compatible
  4. class RequestSite(object):
  5. """
  6. A class that shares the primary interface of Site (i.e., it has
  7. ``domain`` and ``name`` attributes) but gets its data from a Django
  8. HttpRequest object rather than from a database.
  9. The save() and delete() methods raise NotImplementedError.
  10. """
  11. def __init__(self, request):
  12. self.domain = self.name = request.get_host()
  13. def __str__(self):
  14. return self.domain
  15. def save(self, force_insert=False, force_update=False):
  16. raise NotImplementedError('RequestSite cannot be saved.')
  17. def delete(self):
  18. raise NotImplementedError('RequestSite cannot be deleted.')