Solved ::
 
app.jinja_loader = WebsiteLoader(os.path.join(os.path.dirname(__file__), 
'templates'))
 
from jinja2 import FileSystemLoader, TemplateNotFound
class WebsiteLoader(FileSystemLoader):
    """
    Custom Jinja2 FileSystemLoader, that finds a template folder based on 
URL
    """
    # this is an override
    def get_source(self, environment, template):
        from models import Website
        website = 
Website.query.filter_by(domain=request.host.split(':')[0]).first()
        if website is not None:
            try:
                return super(WebsiteLoader, self).get_source(environment, 
"%s/%s" % (website.template_folder, template))
            except TemplateNotFound:
                pass
            return super(WebsiteLoader, self).get_source(environment, 
"common/%s" % template)
        else:
            # Website not found => Fallback
            # e.g. domain has not been found or domain is not active
            return super(WebsiteLoader, self).get_source(environment, 
"jord/%s" % template)
 

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to