obviously if you aren't busy etc.it's not like I have you for anything :) - it's a shame more pyjamas devs don;t hang out on #pyjamas.
I ideas could be thrashed out alot faster/easier than using the group, plus it's all logged so people won;t miss out on good info. On Wed, Dec 7, 2011 at 5:30 PM, Apexi 200sx <[email protected]> wrote: > Hi Lex, I am currently on #pyjamas it looks like you are on the channel it > would be easier to talk there. > > > On Wed, Dec 7, 2011 at 5:25 PM, Lex Berezhny <[email protected]> wrote: > >> I see two possible solutions to this problem: >> >> 1. Write the google maps specific stuff using pure javascript. Then >> interact between the javascript code and the python code using events >> or pass data back and forth by manipulating the DOM. For example, in >> Python code create a hidden div and set some attributes on it, then on >> the javascript side read those attributes. I have no idea if this will >> work but it's worth investigating I think. In your index.html that you >> execute with pyjd make sure to include that javascript code. >> >> 2. Implement a mock version of the Maps API in pure Python. So that >> you can still run/debug/unittest your Python code using the mock but >> when compiling to javascript it would use the JS() enabled Maps API. >> >> For google maps I would go with option 1 if it works. For things like >> websockets I would investigate the problem more but probably go with >> something like option 2. Do you know if mshtml or webkit expose >> websockets API to Python? If those are exposed you may not even need >> to do JS(). But I haven't looked too deeply into pyjamas as far as how >> it implements the translation of APIs (like DOM) that are built-in for >> both pyjd and pyjs, I would think there is some special code that >> takes care of this. >> >> - lex >> >> On Wed, Dec 7, 2011 at 11:49 AM, Apexi 200sx <[email protected]> >> wrote: >> > Hi Lex, >> > >> > I understand what you are saying and if you can do everything to meet >> > your requirements in python then yes I agree stay pure python and have >> > the luxury of using pyjd. Unfortunately What happens if you want to >> > use google maps ? Now unless this becomes a builtin component of the >> > browser engines like trident(mshtml) and you can script it using a COM >> > interface then you have to have the JS() interface. the things i am >> > doing will need to interface with third party JS libs and i will have >> > to live without pyjd because of it. my query was more about how to >> > structure this, how are other people doing this. >> > >> > An example is the google app engine channel javascript API which is >> > built to allow real time comet like communication with the backend. >> > >> > Do people find it worth wrapping like the rectangle.js example in the >> > pyjamas book or do u just use it at the end of the day when all said >> > and done its all compiled to JS anyway (excluding pyjd) >> > >> > Cheers >> > >> > BH >> > >> > On 7 Dec 2011, at 16:20, Lex Berezhny <[email protected]> wrote: >> > >> >> On Wed, Dec 7, 2011 at 10:08 AM, Apexi 200sx <[email protected]> >> wrote: >> >>> Is there no particular reason for the comment regarding JS() will >> >>> cause you grief >> >> >> >> By including JS() you have essentially eliminated the entire Python >> >> toolchain and are just using Python syntax and semantics as a medium >> >> to write JavaScript. In that case why not skip the complexity of >> >> compiling and write directly in JavaScript? >> >> >> >> I guess most people that use Pyjamas use it because they like >> >> programming in Python and enjoy all of the tools that come with it to >> >> do development. It doesn't make sense to invest in Pyjamas if you are >> >> going to then make it difficult/impossible to actually run the app >> >> with Python during development. >> >> >> >> The "grief" mentioned I think is in the sense that by using JS() you >> >> can no longer debug your code using CPython. >> >> >> >> There are a lot of disadvantages to using Pyjamas such as the code >> >> being generated is significantly larger than hand written javascript, >> >> it is also nowhere near as performant as hand written javascript. >> >> Given these significant downsides and then adding more downsides by >> >> eliminating the Python tool chain the only thing you're left with is >> >> the Python syntax and semantics. >> >> >> >> Why not just use CoffeeScript then? You'd have much less generated >> >> code and it would likely run faster than pyjamas generated javascript. >> >> And you'd still have a nicer syntax than pure javascript. CoffeeScript >> >> also interacts directly with JavaScript libraries so there will be no >> >> wrapping necessary. >> >> >> >>> and also unless I want to provide a nicer OO wrapper >> >>> around a JS library (like the widgets do with pyjamas as they wrap >> >>> HTML elements) there's no particular need for wrapping JS libs with a >> >>> python wrapper like GWT has to do because of static checking ? >> >> >> >> The widgets in Pyjamas use the DOM, this DOM is available to Python >> >> through web browser bindings. So, when you run the Python desktop >> >> version of pyjamas your python code is directly interacting with the >> >> DOM model exactly as the javascript code would be doing. This lets you >> >> debug and run your application with no javascript in sight using all >> >> of the standard Python tools, debuggers, etc. >> >> >> >> By calling JS() you are introducing something that doesn't exist in >> >> the desktop version of pyjamas, can't be debugged in Python, etc. >> >> >> >> In summary, pyjamas wrapping HTML elements (via the DOM) is nothing >> >> like using JS() to wrap a javascript library, at least not when it >> >> comes to desktop version of pyjamas (in pyjs all of this is irrelevant >> >> of course). >> >> >> >>> Are there any pitfalls to watch out for when using JS libs >> >> >> >> Other than not being able to run/test/debug your app with CPython I >> >> don't know. Given the downsides I never bothered to try using JS(). >> >> >> >> - lex >> > >

