Great exercise for python expert !

manatlan manatlan at gmail.com
Fri Nov 28 11:25:47 EST 2008


On 28 nov, 16:53, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> > I just want to make a jquery wrapper, and let people use it to write
> > jquery call on the server side in a python way ...
>
> > o is a object, imagine a widget : like a textarea or input box
> > "js" is a special attribut of "o", which will let you write javascript
> > for this object.
>
> > o=MyObject()
> > o.js.toggleClass("clean").hide()
>
> > When I will render the object to a http/html output : it will generate
> > something like (a javascript call): $("#idOfMyObject").toggleClass
> > ("clean").hide();
>
> > It's all what I want in the real world.
> > I wouldn't do something like that (with the "()" tricks at the end on
> > the chain, because I don't find it really readable/natural)
>
> > o=MyObject()
> > o.js.toggleClass("clean").hide()()
>
> > The code I gave before (the JQueryCaller) was just my try to do what I
> > want ... If there is another way : I take ;-)
>
> But there must be *something* on this end of the chain, because how is
> python otherwise to distinguish betwenn
>
> os.js.toggleClass().hide()
> os.js.toggleClass().hide().show()
>
> ?
>
> Now the question is if the action that is to take must be on the object
> itself. Maybe it works for you to make the assignment to some other object
> do the trick, or additon. Something like this:
>
> self.js_calls += os.js.toggleClass().hide()
>
> Then in the __iadd__-method of js_calls you can render the right side.
>
> Diez

nice idea ...
but you use an action on the "+=" and __add__ ... it makes sense.

but peter has found the way !



More information about the Python-list mailing list