Ask Your Question
0

Unable to integrate a 3rd party app template loader with askbot

asked 2013-07-03 10:21:29 -0600

vikas.gulati gravatar image

updated 2013-07-08 04:59:45 -0600

I'm trying to integrate django_mobile with my askbot app. But I'm unable to integrate it because django_mobile's custom template_loader is not identified by coffin and is ignored.

It throws this warning UserWarning:

Cannot translate loader: django_mobile.loader.Loader

My TEMPLATE_LOADERS setting is something like this:

TEMPLATE_LOADERS = (
    'askbot.skins.loaders.Loader',
    'django_mobile.loader.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader'
)

I have tried tracing it down and fixing it but haven't yet hit a solution. What I could workout so far is this.

Coffin translates each of the template loader into a corresponding Jinja loader and warns if it can't be translated. This is where the translation is done. Now coffin can't find a suitable translation for 'django_mobile.loader.Loader' as it only translates some specific loaders with jinja_loader_from_django_loader.

What could be done to solve this?

edit retag flag offensive close merge delete

Comments

I think it will help you to understand the problem better by looking into the askbot/skins/loaders.py. Also look at the askbot documentation about the "custom skins". Perhaps it's a good idea to build "mobile" loader into the askbot skin loader, not replace it. Unfortunately I don't have a good answer for you.

Evgeny gravatar imageEvgeny ( 2013-07-03 13:10:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-07-04 11:02:25 -0600

Evgeny gravatar image

It should be possible to implement such functionality by subclassing askbot.skins.loaders.Loader.

In the load_template method somehow apply mobile browser detection (there is no direct access to request object and you'll need some workaround), then load corresponding template.

edit flag offensive delete link more

Comments

But I would need to keep my newly created loader (by subclassing askbot.skins.loaders.Loader) at the beginning of the TEMPLATE_LOADERS property and askbot won't allow any loader before the askbot.skins.loaders.Loader. Also there seems to be no way to turn off the startup tests and hence I won't be able to use my custom loader.

vikas.gulati gravatar imagevikas.gulati ( 2013-07-08 04:56:19 -0600 )edit

Regarding mobile detection without the request object. That would be easily handled with the get_flavous() function provided by django_mobile (as it sets the flavour in middleware itself.)

vikas.gulati gravatar imagevikas.gulati ( 2013-07-08 04:57:51 -0600 )edit

Any updates on this? Facing a similar problem

snigdha gravatar imagesnigdha ( 2014-04-23 15:09:50 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-07-03 10:21:29 -0600

Seen: 190 times

Last updated: Jul 08 '13