Add anonymous user support to the object encapsulator class

This commit is contained in:
Roberto Rosario
2012-01-07 23:22:03 -04:00
parent 28000ccfec
commit d0acea0714

View File

@@ -2,9 +2,12 @@ import logging
import sys import sys
import types import types
from django.db import models
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models.base import ModelBase from django.db.models.base import ModelBase
from common.models import AnonymousUserSingleton
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
_cache = {} _cache = {}
@@ -27,6 +30,7 @@ class EncapsulatedObject(object):
@classmethod @classmethod
def encapsulate(cls, source_object=None, app_label=None, model=None, pk=None): def encapsulate(cls, source_object=None, app_label=None, model=None, pk=None):
if source_object: if source_object:
source_object = AnonymousUserSingleton.objects.passthru_check(source_object)
content_type = ContentType.objects.get_for_model(source_object) content_type = ContentType.objects.get_for_model(source_object)
elif app_label and model: elif app_label and model:
try: try: