Found an oddity - possibly in my code.  Can't seem to work around it.

Code in question (current multi-tenant middleware implementation):

middleware.py ......................

from projectname.models import Tenant, HostEntry
from django.http import HttpResponseNotFound
from django.core.exceptions import ObjectDoesNotExist

class MultiTenantMiddleware(object):
        """Multi tenant middleware"""
        def process_request(self, request):
                http_host = request.META['HTTP_HOST']
                try:
                        host_entry = HostEntry.objects.get(host=http_host)
                except ObjectDoesNotExist:
                        return HttpResponseNotFound("Host not found")
                request.tenant = host_entry.tenant
                return None

-----

Exception details ....................

Environment:

Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.0.2 final
Python Version: 2.6.0
Installed Applications:
['django.contrib.sessions', 'productname']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'vhdesk.middleware.MultiTenantMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in
get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)

Exception Type: TypeError at /
Exception Value: test() takes exactly 1 argument (2 given)

-----

Only occurs after i "return None".  If the host entry is not found it
works correctly.

Any ideas?  Is it something silly I've done?

Cheers,

Chris.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to