from django import template

from ..schema import is_shared_model as _is_shared_model
from ..schema import _get_schema

register = template.Library()

@register.filter
def is_schema_aware(obj):
    return obj and not _is_shared_model(obj)

@register.filter
def is_shared_model(obj):
    return obj and _is_shared_model(obj)

@register.filter
def schema_name(schema):
    try:
        return _get_schema(schema).name
    except AttributeError:
        return "no schema"

from django import template

from ..schema import is_shared_model as _is_shared_model
from ..schema import get_schema_model

Schema = get_schema_model()

register = template.Library()

@register.filter
def is_schema_aware(obj):
    return obj and not _is_shared_model(obj)

@register.filter
def is_shared_model(obj):
    return obj and _is_shared_model(obj)

@register.filter
def schema_name(pk):
    try:
        return Schema.objects.get(pk=pk).name
    except Schema.DoesNotExist:
        return "no schema"

--- 
+++ 
@@ -1,9 +1,7 @@
 from django import template
 
 from ..schema import is_shared_model as _is_shared_model
-from ..schema import get_schema_model
-
-Schema = get_schema_model()
+from ..schema import _get_schema
 
 register = template.Library()
 
@@ -16,8 +14,8 @@
     return obj and _is_shared_model(obj)
 
 @register.filter
-def schema_name(pk):
+def schema_name(schema):
     try:
-        return Schema.objects.get(pk=pk).name
-    except Schema.DoesNotExist:
+        return _get_schema(schema).name
+    except AttributeError:
         return "no schema"
Remove a database access from the template tag.

--HG--
branch : schema-invitations
