Les premières images d’Android 3.0 me rappellent quelque chose
Le site Ars Technica nous offre ce matin un avant goût du futur Android 3.0.
Peut être est-ce un hasard mais l'interface et le thème me font penser à GNOME Shell. Si GNOME Shell devient une source d'inspiration en design, c'est un vrai succès dans un domaine inhabituel à l'Open Source.
http://static.arstechnica.com/honeycombscreens/thumb-screenshot7.png
http://static.arstechnica.com/honeycombscreens/thumb-screenshot10.png
Cerise sur le gâteau, quand Fred écrit un courriel, Ars Technica en fait un article (ou presque, en fait juste une capture, un bout, l'entête) !
Fred est partout
Dynamic OR’d Queryset Creation with Django
To complete posts and comments published on Elf Sternberg's blog, this is the method I found to create dynamic complex queryset with Django (Q and or):
field = 'toto' qs = Q(**{field + '__slug': 'AL'}) qs |= Q(**{field + '__isnull': True}) Document.objects.filter(qs)
PS: You can start with qs = Q() if you need a loop.
libmodbus v2.9.3 is out!
During this development cycle, I've received more feedback than for any other releases. That's really cool, thank you! With this new release, you can consider to migrate from the previous 2.0.x series for your applications.
libmodbus v2.9.3 (2011-01-14)
- Major rewriting of the message reading (no more timeouts on exception)
- New function to reply to an indication with an exception message modbus_reply_exception()
- New function modbus_get_header_length(modbus_t *ctx)
- New functions to manipulate data:
- MODBUS_GET_INT32_FROM_INT16
- MODBUS_GET_INT16_FROM_INT8
- MODBUS_SET_INT16_TO_INT8
- Fix GH-2. Read/write were swapped in _FC_READ_AND_WRITE_REGISTERS
- Install an ignore handler for SIGPIPE on *BSD.
Original patch by Jason Oster. - Fix closing of Win32 socket.
Reported by Petr Parýzek. - Fix unit identifier not copied by the TCP server.
Reported by Antti Manninen - Fix missing modbus_flush() in unit tests.
- Fixes for OpenBSD by Barry Grumbine and Jason Oster
This time, the release is not only availabe as tarball but also as Fedora and Ubuntu packages on the download page.
For the next release, I've already merged my ipv6 branch (based on the work of Florian Forster), the rtai branch of Chris Cole is waiting for review (ah, RTAI, like in the good old days
and I hope to take care of the gtk-doc work done by Luis Matos.
libsoup and Django
If you need to interface C code with a Django app, you should consider to use libsoup. It's a nice HTTP client/server library based on GObject and integrated with the glib main loop.
This is the code I used to authenticate with libsoup against my Django application (and the code is similar for any forms):
#include <stdio.h> #include <unistd.h> #include <string.h> #include <glib.h> #include <libsoup/soup.h> #include <libsoup/soup-auth.h> static char* django_get_csrftoken_from_body(SoupMessage *msg) { char *csrftoken = NULL; char *p_found; p_found = g_strrstr_len(msg->response_body->data, msg->response_body->length, "csrfmiddlewaretoken"); if (p_found != NULL) { csrftoken = g_strndup(p_found + strlen("csrfmiddlewaretoken' value='"), strlen("c711343cd20077a3aa869fcc9b931ff3")); } return csrftoken; } static int django_authenticate(SoupSession *session, const char *base_uri) { char *uri; SoupMessage *msg; char *csrftoken; uri = g_strconcat(base_uri, "login/", NULL); msg = soup_message_new(SOUP_METHOD_GET, uri); soup_session_send_message(session, msg); printf("Login Status Code: %d\n", msg->status_code); if (msg->status_code != 200) { g_object_unref(msg); g_free(uri); return -1; } csrftoken = django_get_csrftoken_from_body(msg); g_object_unref(msg); printf("CSRF token %s\n", csrftoken); msg = soup_form_request_new("POST", uri, "username", "MYUSERNAME", "password", "MYPASSWORD", "csrfmiddlewaretoken", csrftoken, NULL); soup_session_send_message(session, msg); printf("POST Login Status Code: %d\n", msg->status_code); printf("Message %s\n", msg->response_body->data); g_free(csrftoken); g_object_unref(msg); g_free(uri); return 0; } int main(int argc, char** argv) { SoupSession *session; SoupCookieJar *jar; g_type_init(); session = soup_session_sync_new(); /* Accept all cookies */ soup_session_add_feature_by_type(session, SOUP_TYPE_COOKIE_JAR); jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR)); soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_ALWAYS); django_authenticate(session, "http://localhost:8000/"); soup_session_abort(session); g_object_unref(session); return 0; }