Dear Pylons/ piramid developers,
I am forwarding this email from mailing list for GNUKhata www.gnukhata.org, a free and open source accounting software which I am leading.
Basically we use Pylons version 1.0 for the front end.
We are now planning to use some ui refinement library like bootstrap in particular.
OUr developers have faced a problem integrating the tmpl_context (c) related data with javascript.
The details on the problem follow in the forwarded email.
Kindly help.
happy hacking.
Krishnakant.
-------- Original Message --------
Subject: [Gnukhata-devel] separation of js code from mako files
Date: Thu, 25 Oct 2012 20:00:34 +0530
From: ujwala pawade <pawadeso...@gmail.com>
To: gnukhata dev <gnukhata-de...@cis-india.org>
Hello Developers,
All of you are aware that I and Mukesh have started working on Bootstrap which will give very nice refinements to GNUKhata front-end.
I have almost separated js code from mako files and problem here i m facing is about accessing python values from controllers i.e. tmpl_context as c
Since javascript code is been separated from mako files and for some files in the document.ready function this template context variable value has been used.
Now javascript file can't locate its value. So whatever value or message is attached in that tmpl_context is not getting accessed or displayed.
Currently i am finding a way to fix this problem.
If anyone have any idea, solution or suggestion for this , I welcome them.
Thank You :-)
-- Ujwala...
Freedom Matters, Not The Cost... :)
Before Editing :
Your javascript was embedded in mako. and you had variables set in
javascript
After Editing :
Your javascript is outside of mako, and you need to set variables
If that is your problem, the solution is to re-architect your
javascript so you can set variables in mako but call functions in a
static file.
I have this problem in a Pylons applicaition I'm converting to
Pyrmaid. Right now I'm leaving the Javascript in place, but I'm
thinking about moving it to separate templates (not static files).
Then I can inject variables without having the Javascript mixed with
the HTML. It'll work if it doesn't need any request-specific data, or
if all the data can be passed as a few query parameters or is in the
session. That should cover most of my use cases but I'm not sure if
it'll cover all of them; I'm waiting till I convert the rest of the
application to tell.
On Fri, Oct 26, 2012 at 8:49 AM, Jonathan Vanasco <jonat...@findmeon.com> wrote:
> If i understand you correctly:
> Before Editing :
> Your javascript was embedded in mako. and you had variables set in
> javascript
> After Editing :
> Your javascript is outside of mako, and you need to set variables
> If that is your problem, the solution is to re-architect your
> javascript so you can set variables in mako but call functions in a
> static file.
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
> Dear Pylons/ piramid developers,
> I am forwarding this email from mailing list for GNUKhatawww.gnukhata.org, a free and open source accounting software which I am
> leading.
> Basically we use Pylons version 1.0 for the front end.
> We are now planning to use some ui refinement library like bootstrap in
> particular.
> OUr developers have faced a problem integrating the tmpl_context (c)
> related data with javascript.
> The details on the problem follow in the forwarded email.
> Kindly help.
> happy hacking.
> Krishnakant.
> -------- Original Message --------
> Subject: [Gnukhata-devel] separation of js code from mako files
> Date: Thu, 25 Oct 2012 20:00:34 +0530
> From: ujwala pawade <pawadeso...@gmail.com>
> To: gnukhata dev <gnukhata-de...@cis-india.org>
> Hello Developers,
> All of you are aware that I and Mukesh have started working on Bootstrap
> which will give very nice refinements to GNUKhata front-end.
> I have almost separated js code from mako files and problem here i m
> facing is about accessing python values from controllers i.e.
> tmpl_context as c
> Since javascript code is been separated from mako files and for some
> files in the document.ready function this template context variable
> value has been used.
> Now javascript file can't locate its value. So whatever value or message
> is attached in that tmpl_context is not getting accessed or displayed.
> Currently i am finding a way to fix this problem.
> If anyone have any idea, solution or suggestion for this , I welcome them.
> Thank You :-)
> --
> Ujwala...
> Freedom Matters, Not The Cost... :)
On Oct 28, 1:58 pm, Mike Orr <sluggos...@gmail.com> wrote:
> I have this problem in a Pylons applicaition I'm converting to
> Pyrmaid. Right now I'm leaving the Javascript in place, but I'm
> thinking about moving it to separate templates (not static files).
> Then I can inject variables without having the Javascript mixed with
> the HTML. It'll work if it doesn't need any request-specific data, or
> if all the data can be passed as a few query parameters or is in the
> session. That should cover most of my use cases but I'm not sure if
> it'll cover all of them; I'm waiting till I convert the rest of the
> application to tell.
If you can, i strongly suggest the method I had above. It makes it
really simple for maintaining in team environments, because the JS
team just writes their 'api' , and the backend/frontend team just has
to integrate it.