silpa-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[silpa-discuss] framework changes


From: Santhosh Thottingal
Subject: [silpa-discuss] framework changes
Date: Sun, 30 May 2010 20:40:04 +0530

Friends,
Following framework changes are done:
* cleaned up the request handling mechanism, added support for direct
get requests for the modules. All the request properties will be
available for a module in an object called request which is of type
SilpaRequest.
* Modules can optionally implement a method get_json_result. This
method should return the json result corresponding to the request. The
default implementation is done in silpamodule class which just returns
empty string. If any module want to provide json result, then override
it. For example

The url 
http://thottingal.in/silpa/Dictionary?word=service&dictionary=en-hi&json=1
will give you

{"error":null,"result":"service <N.>\n\n1. सेवा\n     \"The person
does the service in the office.\"\n2. विभाग\n     \"He is working in
the Health service.\"\n3. सहायता\n     \"Her services to the state
have been immense.\"\n4. व्यवस्था\n     \"A good postal service is
needed for every village.\"\n5. उपासना, अनुष्टान\n     \"He attended
the morning service in the temple.\"\n6. सफ़ाई-धुलाई\n     \"Take your
car for service every 3,000 miles.\"\n7. सेट, बरतन\n     \"He bought a
30-piece dinner service.\"\n8. तामील\n     \"--\"9.सर्विस{टेनिस
में}\"\"\n     \"Her service has improved. \"\n\n\nservice <V.>\n\n1.
सफ़ाई-धुलाई करना\n     \"This machine has already been serviced.\"\n
  \"--\"की आपूर्ति करना\"\"\n     \"The power station is serviced by
road transport.\"\n\n\n","id":0}

[Dictionary module need some changes to redefine the json output in
much more cleaner way.]

The advantage for this json URL for each module is, this will make
very easy for a third party to write javascript clients, say a firefox
extension.


The latest code is running only on http://thottingal.in/silpa instance
and did not pulled to http://smc.org.in/silpa. I wanted to do some
more testing.

A note for using with apache + mod_wsgi,
the mod_rewrite rules require a small change to accept get parameters in URL.
The rule
RewriteRule (.*) dispatch.fcgi?action=$1
should be
RewriteRule (.*) dispatch.fcgi?action=$1&%{QUERY_STRING}

Thanks
Santhosh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]