I am finally getting around to toying with pyjamas for the first time. I have never used GWT which this is based on either. I really like the django framework so I am going to use it as the pyjamas backend.
Before you read this whole long mail, feel free to point me to the docs if I have missed something. I've read through the GWT documentation and everything I could find on pyjamas, but this is my first few hours with pyjamas so I am completely new to this.
So on that topic, are there quirks I should know about for using Django as the backend? I've worked through the basic GWT stockwatcher intro app with the help of pyjamas-django-pure-win<http://www.derekschaefer.net/2011/02/08/pyjamas-django-pure-win/>. What I am looking for now is tips on the best way to setup the integration.
I am trying to figure out the best way to setup the urls.py file. From what I have seen with the demos, the pyjamas app expects StockWatcher.html, StockWatcher.ie6.cache.html, StockWatcher.XYZ.cache.html, etc to be available from the same directory url. Is this a requirement, or just a simplification for the demo? It seems to me that the main html file, StockWatcher.html, would be considered my django template file which would be processed by django template engine to fit the application in with the site style. This template file would also provide fallback for users without javascript. I gather that the rest of the html files are loaded by the javascript code and I would not bother those, only serve them as static files. How do I tell the pyjamas app where to find those files so that I can serve them as static files and not through django?
For example, I typically use a static file manager to handle all of my media files (django-mediagenerator<https://bitbucket.org/wkornewald/django-mediagenerator/>is my favorite so far) which would typically handle cache busting, url retrieval, etc... Is there an easy way to hook into the url providers to query mediagenerator for the url to reach StockWatcher.nocache.html, StockWatcher.ie6.cache.html, or any of the other static files?
It would get very tedious to do this by hand each time the code has to be recompiled, so I am guessing it is possible. Also, I just read through the backends for mediagenerator and it seems to already have one for pyjs. Neat. I don't know how it works yet because it doesn't seem to be documented. I'll have to see if I can get it to work.
On Thu, Oct 20, 2011 at 9:35 PM, gordon pendleton <wgordo...@gmail.com> wrote: > Hi,
> I am finally getting around to toying with pyjamas for the first time. I > have never used GWT which this is based on either. I really like the django > framework so I am going to use it as the pyjamas backend.
> Before you read this whole long mail, feel free to point me to the docs if I > have missed something. I've read through the GWT documentation and > everything I could find on pyjamas, but this is my first few hours with > pyjamas so I am completely new to this.
> So on that topic, are there quirks I should know about for using Django as > the backend? I've worked through the basic GWT stockwatcher intro app with > the help of pyjamas-django-pure-win. What I am looking for now is tips on > the best way to setup the integration.
> I am trying to figure out the best way to setup the urls.py file. From what > I have seen with the demos, the pyjamas app expects StockWatcher.html, > StockWatcher.ie6.cache.html, StockWatcher.XYZ.cache.html, etc to be > available from the same directory url. Is this a requirement, or just a > simplification for the demo? It seems to me that the main html file, > StockWatcher.html, would be considered my django template file which would > be processed by django template engine to fit the application in with the > site style.
yes i've done that before.
> This template file would also provide fallback for users > without javascript. I gather that the rest of the html files are loaded by > the javascript code and I would not bother those, only serve them as static > files.
correct.
> How do I tell the pyjamas app where to find those files so that I > can serve them as static files and not through django?
you need to get more involved with how django operates.
> For example, I typically use a static file manager to handle all of my media > files (django-mediagenerator is my favorite so far) which would typically > handle cache busting, url retrieval, etc... Is there an easy way to hook > into the url providers to query mediagenerator for the url to reach > StockWatcher.nocache.html, StockWatcher.ie6.cache.html, or any of the other > static files?
the urls system works on pattern-matching. so you can do one specific line for the file you intend to serve via django templates, then the rest fall through to "static".
take a look at djangoweb and djangopages examples. .... oi! who bloody moved the django web examples into misc!! grrr
ok, yes, take a look at examples/misc for the various django examples there, ok?
On Thu, Oct 20, 2011 at 10:35 PM, gordon pendleton <wgordo...@gmail.com> wrote: > For example, I typically use a static file manager to handle all of my media > files (django-mediagenerator is my favorite so far) which would typically > handle cache busting, url retrieval, etc... Is there an easy way to hook > into the url providers to query mediagenerator for the url to reach > StockWatcher.nocache.html, StockWatcher.ie6.cache.html, or any of the other > static files?
> It would get very tedious to do this by hand each time the code has to be > recompiled, so I am guessing it is possible. Also, I just read through the > backends for mediagenerator and it seems to already have one for pyjs. > Neat. I don't know how it works yet because it doesn't seem to be > documented. I'll have to see if I can get it to work.
The only difference is that mediageneator only supports the pyjs compiler, not the pyjamas framework. You can combine pyjs with jQuery or any other framework if you want. That's the solution we use at our company.
If you want to use pyjamas I'm afraid you won't be able to use mediagenerator for the JavaScript part (but I'd still be happy if you continue to use it for CSS/Sass/etc. ;). Alternatively, you might try to integrate the pyjamas build system into mediagenerator by implementing a custom filter (maybe extending the existing pyjs filter).
> > For example, I typically use a static file manager to handle all of my > media > > files (django-mediagenerator is my favorite so far) which would typically > > handle cache busting, url retrieval, etc... Is there an easy way to hook > > into the url providers to query mediagenerator for the url to reach > > StockWatcher.nocache.html, StockWatcher.ie6.cache.html, or any of the > other > > static files?
> the urls system works on pattern-matching. so you can do one > specific line for the file you intend to serve via django templates, > then the rest fall through to "static".
> take a look at djangoweb and djangopages examples. .... oi! who > bloody moved the django web examples into misc!! grrr
> ok, yes, take a look at examples/misc for the various django examples > there, ok?
> The only difference is that mediageneator only supports the pyjs > compiler, not the pyjamas framework. You can combine pyjs with jQuery > or any other framework if you want. That's the solution we use at our > company.
> If you want to use pyjamas I'm afraid you won't be able to use > mediagenerator for the JavaScript part (but I'd still be happy if you > continue to use it for CSS/Sass/etc. ;). Alternatively, you might try > to integrate the pyjamas build system into mediagenerator by > implementing a custom filter (maybe extending the existing pyjs > filter).
> Bye, > Waldemar Kornewald
Hey Waldemar,
Fancy seeing you here hah. Once I get a feel for pyjamas I will probably work on some sort of integration with mediagenerator if I will use it frequently.
On Thu, Oct 20, 2011 at 4:44 PM, Luke Kenneth Casson Leighton <
luke.leigh...@gmail.com> wrote: > > ok, yes, take a look at examples/misc for the various django examples > >there, ok?
Those were very helpful. The djangowanted and djangoweb are what I was looking for. I just needed that basic set up. I feel silly for missing the misc folder.
Hi Gordon, I have played a little bit with pyjs and django, so hopefully can answer some of your questions, if you could make them more specific.
My general setup was: 1. Create your pyjs app and compile it, i.e. generate the html page and the js files usually in the output directory. 2. Serve the results from 1 as static media (either via the django staticfiles app or mediagenerator, both do the job) 3. If need should be (which usually is the case), create a json rpc interface in django (there is a good example in the pyjs examples).
I also tried a deeper integration between django and pyjs, but realized that with my knowledge, this would be quite tought ...
Happy to answer any further questions Regards, Juergen
> On Thu, Oct 20, 2011 at 4:45 PM, Waldemar Kornewald <wkornew...@gmail.com>wrote:
>> The only difference is that mediageneator only supports the pyjs >> compiler, not the pyjamas framework. You can combine pyjs with jQuery >> or any other framework if you want. That's the solution we use at our >> company.
>> If you want to use pyjamas I'm afraid you won't be able to use >> mediagenerator for the JavaScript part (but I'd still be happy if you >> continue to use it for CSS/Sass/etc. ;). Alternatively, you might try >> to integrate the pyjamas build system into mediagenerator by >> implementing a custom filter (maybe extending the existing pyjs >> filter).
>> Bye, >> Waldemar Kornewald
> Hey Waldemar,
> Fancy seeing you here hah. Once I get a feel for pyjamas I will probably > work on some sort of integration with mediagenerator if I will use it > frequently.
juergen.schackm...@googlemail.com> wrote: > Hi Gordon, > I have played a little bit with pyjs and django, so hopefully can answer > some of your questions, if you could make them more specific.
> My general setup was: > 1. Create your pyjs app and compile it, i.e. generate the html page and the > js files usually in the output directory. > 2. Serve the results from 1 as static media (either via the django > staticfiles app or mediagenerator, both do the job) > 3. If need should be (which usually is the case), create a json rpc > interface in django (there is a good example in the pyjs examples).
> I also tried a deeper integration between django and pyjs, but realized > that with my knowledge, this would be quite tought ...
> Happy to answer any further questions > Regards, > Juergen
Juergen,
Thanks for the response. The examples Luke pointed me to that I had missed have given me a good starting point. If I run into any more gotchas I will definitely be more specific. I just need to fool around with pyjamas for awhile before I ask any more silly questions.