Alvin Wang wrote:
> - project is called newwidget. I zipped up everything.
> The grid2.py must be copied to the widget directory.
> http://www.alvinwang.com/newwidget.zip
>
(snip very promosing stuff)
> Ajax Version
> I am not really clear on how kid output gets converted to JSON.
I didn't look at the code now, but I don't know if kid is used here.
AFAICT, it's TG itself that do the job.
for what I saw, both representations are really close... Must be
something along the line of getting a correct repr() for each obj in the
dict. For simple things, it could even be as dumb as this:
>>> data = {'cps_filter_sets': {'operator': 'and', 'query':
['searchable']}, 'start': {'query': '2005/12/01', 'range': 'min'},
'portal_type': ('CPMReunionInterne', 'CPMCongres', 'EventDoc',
'CPMJourneeThematique', 'Event', 'CPMFormationsSpecifiques'), 'end':
{'query': '2005/12/31 23:59:59 GMT+1', 'range': 'max'}, 'review_state':
'published', 'foo': None}
>>> js = repr(data).replace('(', '[').replace(')', ']').replace('None',
'null')
>>> js
"{'end': {'query': '2005/12/31 23:59:59 GMT+1', 'range': 'max'},
'portal_type': ['CPMReunionInterne', 'CPMCongres', 'EventDoc',
'CPMJourneeThematique', 'Event', 'CPMFormationsSpecifiques'], 'start':
{'query': '2005/12/01', 'range': 'min'}, 'cps_filter_sets': {'operator':
'and', 'query': ['searchable']}, 'review_state': 'published', 'foo': null}"
>>>
Then send this back to the calling js func, that just need to eval() it.
(... 5 minutes later ...)
Part of the answer here:
http://trac.turbogears.org/turbogears/browser/trunk/turbogears/jsonify.py
> I was
> thinking that a pagin grid with Ajax would be interesting next step.
Yeps. Paging, and also sorting and filtering...
<thinking-out-loud>
It sure makes web-apps far more reactive (Catwalk and ModelDesigner are
really impressive) - but then this is not RESTfull anymore, since
paging/sort/filter infos are not part of the url anymore.
Anyone to comment on this ?
</thinking-out-loud>
--
bruno desthuilliers
développeur
[EMAIL PROTECTED]
http://www.modulix.com