def get_template_from_request(request, obj=None, no_current_page=False):
 template = None
 if (len(get_cms_setting('TEMPLATES')) == 1):
  return get_cms_setting('TEMPLATES')[0][0]
 if (hasattr(request, 'POST') and ('template' in request.POST)):
  template = request.POST['template']
 elif (hasattr(request, 'GET') and ('template' in request.GET)):
  template = request.GET['template']
 if ((not template) and (obj is not None)):
  template = obj.get_template()
 if ((not template) and (not no_current_page) and hasattr(request, 'current_page')):
  current_page = request.current_page
  if hasattr(current_page, 'get_template'):
   template = current_page.get_template()
 if ((template is not None) and (template in dict(get_cms_setting('TEMPLATES')).keys())):
  if ((template == constants.TEMPLATE_INHERITANCE_MAGIC) and obj):
   return obj.get_template()
  return template
 return get_cms_setting('TEMPLATES')[0][0]

def get_template_from_request ( request , obj = None , no_current_page = False ) : template = None if ( len ( get_cms_setting ( 'TEMPLATES' ) ) == 1 ) : return get_cms_setting ( 'TEMPLATES' ) [ 0 ] [ 0 ] if ( hasattr ( request , 'POST' ) and ( 'template' in request . POST ) ) : template = request . POST [ 'template' ] elif ( hasattr ( request , 'GET' ) and ( 'template' in request . GET ) ) : template = request . GET [ 'template' ] if ( ( not template ) and ( obj is not None ) ) : template = obj . get_template ( ) if ( ( not template ) and ( not no_current_page ) and hasattr ( request , 'current_page' ) ) : current_page = request . current_page if hasattr ( current_page , 'get_template' ) : template = current_page . get_template ( ) if ( ( template is not None ) and ( template in dict ( get_cms_setting ( 'TEMPLATES' ) ) . keys ( ) ) ) : if ( ( template == constants . TEMPLATE_INHERITANCE_MAGIC ) and obj ) : return obj . get_template ( ) return template return get_cms_setting ( 'TEMPLATES' ) [ 0 ] [ 0 ]
gets a valid template from different sources or falls back to the default template .