--
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
ajax built in ? .. do you mean generate javascript code? ..
imo, ajax is a problem on the browser side programming rather than on
the server side, and thats the realm of the javascript curly braces,
not the realm for python, or any other language for that sake, as
browser primarily only accept javascript (theres vbscript and all, but
they sucks) ..
@ycloh
what you are looking for are javascript libraries that simplify the
interaction between the client and server, but a python framework that
help doing ajax, because python cant do ajax, as its on the server
side.
if you are looking for a python framework that simplify long polling
http request (which is useful if you want to do real-time chat or
something), theres tornado.
--
Mohd Izhar Firdaus Bin Ismail / KageSenshi
Inigo Consulting (FOSS/Plone Development, Training & Services)
http://www.inigo-tech.com
Fedora Malaysia Contributor & Ambassador
http://blog.kagesenshi.org
92C2 B295 B40B B3DC 6866 5011 5BD2 584A 8A5D 7331
* but NOT a python framework that help doing ajax
> help doing ajax, because python cant do ajax, as its on the server
> side.
In python now, no such thing exist, I use django, it doesn't exist on it, same for other frameworks(didn't exist when I last check, that I could really be wrong), not sure about zope(because I didn't use it before).
you practically have to implement it differently. How I would do it, using jquery. attach a event on a button field in templates, which read the value in the text field, and do ajax call to the views(or what ever else you call it), to receive json output from the server. from the jquery ajax function, populate the otherfield, by playing around with dome.
and you need a django views to output json(you can just encode result of an operation, and send it to httpresponse.
for other web framework, it is roughly the same. you just need to call the url to call the component that output json via http.
yes, it is not handled automatically by most web framework.
is that even html ?
>
> What this will do is that it will call the doSomething method the
> myBean instance and then update the other_field. No custom javascript
> is required to handle this.
I dont know about primefaces, but it sound like the framework generate
the javascript to handle it for u, or already using some sort of
javascript library that read the information in the html element and
submit it accordingly to the server.
using jquery, submitting a form through ajax is rather easy imo .. and
nothing fancy on the server side, just yet another view which accept
data and returns json ..
theres also jquery datalink [1] library which bind a javascript
object, to a form field, any changes in the field will be delegated to
the object .. and that object, you can submit it to the server or do
something with it .. again, nothing fancy on the server side.
most python framework only handles the backend side of stuff. The
frontend is usually up to the dev. Some might include widget
libraries, but thats just it ..
In zope, theres one thing that might be close, and that is called KSS
[2] .. but I hate it because lots of flexibility was lost .. the docs
in site might be a bit plone-centric and not clear, the doc in the
grok website [3] describe KSS clearer
[1] http://api.jquery.com/link/
[2] http://kssproject.org/
[3] http://grok.zope.org/documentation/how-to/adding-ajax-with-kss-to-grok
There are errors in the code snippet. Was in a hurry when i wrote it.
It should be
<h:outputText id="otherField"
value="userBean.someField" />
...
...
<p:commandButton value="Yes" update="otherField"
actionListener="#{myBean.doSomething}" />
Had a bit of a think about what KageSenshi was saying. I believe that
JSF is more than just a bunch of js libraries. I would consider it as
more of a framework that uses some js scripts rather than just a js
library. In the case of primefaces, the js library that is being used
is jQuery & YUI i think and also Jquery UI for some of the theming
support.
The framework spews out the js snippets based on the tag attributes
(e.g. <p:commandButton action="bean.doSomething" ajax="true" ..../> in
the template. I guess a bit like in Django if you created a
AutoCompleteField that when it is rendered, it will also render the js
snippet based on the options specified when you declare the field.
As far as i can tell, there isn't something similar in the python web
frameworks. Perhaps, i should ask the question another way; what
libraries are available to help with doing ajax with the more popular
python web frameworks (e.g. django, web2py, pyramid...)?
--
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
then the framework is also a javascript generator .. :-) .. unlike the
java world, stuff in python world tend to be less monolithic ..
(except for that darned zope2, huge monolithic giant mess, zope3 is
better) .. python frameworks are usually a set of separate libraries,
which work together .. and i'm sure they also have javascript
libraries included in the pages to help do all the magic ..
>
> As far as i can tell, there isn't something similar in the python web
> frameworks. Perhaps, i should ask the question another way; what
> libraries are available to help with doing ajax with the more popular
> python web frameworks (e.g. django, web2py, pyramid...)?
jQuery .. works with any server side language that can speak http ..
and yep, like sweemeng said, let the backend be just the backend ..
and frontend be just the frontend .. the backend and frontend talks
using some sort of protocol, and in this case, bunch of json object ..
IMHO, separating the back and front end is referred to as the MVC
Design Pattern, (Model, View, Controller) and dates back to the early
days of OOP, in the days of SmallTalk I believe.
The concept here is we have
'Models' - which models the real world objects we want to emulate, ie:
our eComm back end, Inventory, Order Processing and CRM system etc...
It has the classes like Customer, Order, InvemtoryItem, with its
attributes and methods and any other business logic.
'Views' - present the information obtained form the Models to the
User. So in the case of a Web app, the View 'generates' HTML page for
the presentation. It will also handle User Interaction(UI), hence
maybe the need for JS.
Controllers - mediate between the Model and the Views, it does things
like authentication, session management (in Web), passing data between
the View and the Model.
The concept of the pattern makes the entire app modular. And lends to
reusability of code. For example, I can replace the 'View' with a
text-based curses UI, Just need to change the View and Controller. The
Model remains the same.
Or similarly if I had a Web app for eComm, ...and I develop a web CRM
App, I can make use of the eComm app's Model, and I can talk to it
using HTTP protocols, use its business-logic via RPC etc.
As a counter example, years back I worked on a Web App that intermixed
logic into the presentation, ie: code embedded into the HTML ala
ASP/PHP... The App had about 300+ pages of HTML + code. When there was
a requirement to add a language, add BM to the existing English, all
those 300+ pages had to be reworked!
If the MVC pattern and a good templating system was used, the work
would have been much easier! In the end, the cost was too great and
time to do it too long after the estimates were done, so the changes
was abandoned.
So in my mind, its always better to separate the front end from the
back-end, despite the initial pain. Plus as you mention earlier, you
have a real understanding about what is going on, and can therefore
tweak things if necessary.
--
#-------
regds,
Boh Heong, Yap
As for using JS, even with all the hidden powers of VS and C# on web
development, sometimes you just
need to know the basic JS to improve on it further.
The mailnow UI is done by the team entirely with nearly "zero" knowledge
on javascript and
all via VS,C# and Telerik libs, you can try out the web UI here, "heavy"
desktop like feel (drag-drop, right click,
ajax response).
Engine is done from ground up using Python, C#, C. (i love to put it in
that order ;-))
http://hq.internetnow.com.my:8383
login : test
pass : user123
(Err kindly don't use it to send spam or any dangerous mails!, just for
this community viewing)
But ultimately we had to fine-tune its performance by shrinking the JS
libraries and some custom codes and
that means learning up basic JS in detail. But it is totally possible to
code front Web UI end entirely separated from
the backend and with no knowledge of JS. You just need VS.
(note : i am going to quote this mail to ask MS for sponsorship for
pycon 2012! yeah baby! LOL)
>>>>> is jQuery& YUI i think and also Jquery UI for some of the theming
>>>>> support.
>>>>> The framework spews out the js snippets based on the tag attributes
>>>>> (e.g.<p:commandButton action="bean.doSomething" ajax="true" ..../> in
>>>>> the template. I guess a bit like in Django if you created a
>>>>> AutoCompleteField that when it is rendered, it will also render the js
>>>>> snippet based on the options specified when you declare the field.
>>>> then the framework is also a javascript generator .. :-) .. unlike the
>>>> java world, stuff in python world tend to be less monolithic ..
>>>> (except for that darned zope2, huge monolithic giant mess, zope3 is
>>>> better) .. python frameworks are usually a set of separate libraries,
>>>> which work together .. and i'm sure they also have javascript
>>>> libraries included in the pages to help do all the magic ..
>>>>> As far as i can tell, there isn't something similar in the python web
>>>>> frameworks. Perhaps, i should ask the question another way; what
>>>>> libraries are available to help with doing ajax with the more popular
>>>>> python web frameworks (e.g. django, web2py, pyramid...)?
>>>> jQuery .. works with any server side language that can speak http ..
>>>> and yep, like sweemeng said, let the backend be just the backend ..
>>>> and frontend be just the frontend .. the backend and frontend talks
>>>> using some sort of protocol, and in this case, bunch of json object ..
>>>> --
>>>> Mohd Izhar Firdaus Bin Ismail / KageSenshi
>>>> Inigo Consulting (FOSS/Plone Development, Training& Services)
>>>> http://www.inigo-tech.com
>>>> Fedora Malaysia Contributor& Ambassador