Caching at grono
I posted article (in polish) about caching at Grono, with description of the caching decorator called memoize.
It's a very simple decorator, but it's working perfectly. Without it the site wouldn't be working :)
I posted article (in polish) about caching at Grono, with description of the caching decorator called memoize.
It's a very simple decorator, but it's working perfectly. Without it the site wouldn't be working :)
Posted by
majek
at
11:19
0
comments
Labels: Django
I mentioned the idea in previous post about asychronous wsgi.
Now we have working example of simple chat application. The chat is nothing special, but it's made in Django! To make this possible I created special server, django-evserver. It's quite light wrapper to libevent http layer (several hundred of lines in python/ctypes).
Using this technology it's now possible to create asynchronous WSGI applications. Currently I implemented the Comet javascript library and some wrappers for Django views, to make easier writing comet applications in Django.
Here is how example chat application evserver-chat looks like:
The code is commited to code.google.com, maybe in future I'll write some more code and documentation. For example it could be interesting how I used named fifos (mkfifo) to pass events.
Posted by
majek
at
22:45
25
comments
Comet on python?
I was looking for comet server implementation in python. There are many projects that claim to provide this, but none of them is working for me. Most of the projects are just proofs of concepts that never been deployed for real usage.
Here is the list of projects that my friend found:
# Url handler of the basic url.Here is how it looks from the browser:
# Headers only from this response are used.
# The same with status code, this function
# response status code is served to the client.
def comet_main(request):
response = HttpResponse('First content<br /> ') # return something
response.stage = 0
return defer_in_time(response,
1, '/stage/') # after one second run the '/stage/' url handler
@deferred_view()
def comet_stage(request, response_prev=None):
response = HttpResponse('stage%i<br /> ' % (response_prev.stage + 1) )
response.stage = response_prev.stage + 1
if response.stage < 3: # loop here three times
url = '/stage/'
else:
url = '/stage_last/' # than end the connection
return defer_in_time(response,
1, url) # after one second run the url
@deferred_view()
def comet_stage_last(request, response_prev=None):
# no magic here. just regular response
return HttpResponse('last_stage%i<br /> ' % (response_prev.stage +1))
Posted by
majek
at
23:46
9
comments