def processor_for(content_model_or_slug, exact_page=False):
 content_model = None
 slug = u''
 if isinstance(content_model_or_slug, (str, _str)):
  try:
   parts = content_model_or_slug.split(u'.', 1)
   content_model = apps.get_model(*parts)
  except (TypeError, ValueError, LookupError):
   slug = content_model_or_slug
 elif issubclass(content_model_or_slug, Page):
  content_model = content_model_or_slug
 else:
  raise TypeError((u'%s is not a valid argument for page_processor, which should be a model subclass of Page in class or string form (app.model), or a valid slug' % content_model_or_slug))
 def decorator(func):
  parts = (func, exact_page)
  if content_model:
   model_name = content_model._meta.object_name.lower()
   processors[model_name].insert(0, parts)
  else:
   processors[(u'slug:%s' % slug)].insert(0, parts)
  return func
 return decorator

def processor_for ( content_model_or_slug , exact_page = False ) : content_model = None slug = u'' if isinstance ( content_model_or_slug , ( str , _str ) ) : try : parts = content_model_or_slug . split ( u'.' , 1 ) content_model = apps . get_model ( * parts ) except ( TypeError , ValueError , LookupError ) : slug = content_model_or_slug elif issubclass ( content_model_or_slug , Page ) : content_model = content_model_or_slug else : raise TypeError ( ( u'%s is not a valid argument for page_processor, which should be a model subclass of Page in class or string form (app.model), or a valid slug' % content_model_or_slug ) ) def decorator ( func ) : parts = ( func , exact_page ) if content_model : model_name = content_model . _meta . object_name . lower ( ) processors [ model_name ] . insert ( 0 , parts ) else : processors [ ( u'slug:%s' % slug ) ] . insert ( 0 , parts ) return func return decorator
decorator that registers the decorated function as a page processor for the given content model or slug .