blog.notmyidea.org/feeds/tech.atom.xml
2019-07-02 22:54:50 +00:00

2937 lines
No EOL
271 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Carnets Web - tech</title><link href="https://blog.notmyidea.org/" rel="alternate"></link><link href="https://blog.notmyidea.org/feeds/tech.atom.xml" rel="self"></link><id>https://blog.notmyidea.org/</id><updated>2018-02-25T00:00:00+01:00</updated><entry><title>Webnotes</title><link href="https://blog.notmyidea.org/webnotes.html" rel="alternate"></link><published>2018-02-25T00:00:00+01:00</published><updated>2018-02-25T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2018-02-25:/webnotes.html</id><summary type="html">&lt;p&gt;Quand je navigue en ligne, j'aime bien prendre des notes sur ce que je lis. C'est utile pour les retrouver plus tard. Il existe quelques outils pour ce genre de cas, mais j'ai vraiment eu du mal à trouver un outil qui faisais ce que je voulais, de la manière …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Quand je navigue en ligne, j'aime bien prendre des notes sur ce que je lis. C'est utile pour les retrouver plus tard. Il existe quelques outils pour ce genre de cas, mais j'ai vraiment eu du mal à trouver un outil qui faisais ce que je voulais, de la manière que je voulais, c'est à dire:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;enregistrer une sélection de texte ainsi que son contexte: heure, site web.&lt;/li&gt;
&lt;li&gt;fonctionner sur Firefox;&lt;/li&gt;
&lt;li&gt;stocker mes notes à un endroit que je contrôle (ce sont mes données, après tout !)&lt;/li&gt;
&lt;li&gt;rester en dehors de mon chemin: je suis en train de lire, pas en train d'organiser mes notes.&lt;/li&gt;
&lt;li&gt;automatiquement partager les notes sur une page web.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;J'ai donc pris un peu de temps pour fabriquer mon outil de prises de notes, que j'ai baptisé « Webnotes ». C'est &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/wwebnotes/"&gt;une extension Firefox&lt;/a&gt;, qui se configure assez simplement, et qui stocke les données dans une instance de &lt;a href="http://kinto-storage.org/"&gt;Kinto&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://github.com/almet/webnotes/blob/master/webnotes.gif?raw=true" /&gt;&lt;/p&gt;
&lt;p&gt;C'est aussi simple que sélectionner du texte, faire « clic droit » puis « save as webnote », entrer un tag et le tour est joué !&lt;/p&gt;
&lt;p&gt;Mes notes sont disponibles &lt;a href="https://notes.notmyidea.org"&gt;sur notes.notmyidea.org&lt;/a&gt;, et voici &lt;a href="https://github.com/almet/webnotes"&gt;le lien vers les sources&lt;/a&gt;, si ça vous intéresse de regarder comment ça fonctionne !&lt;/p&gt;</content></entry><entry><title>Comment est-ce que vous générez vos formulaires ?</title><link href="https://blog.notmyidea.org/comment-est-ce-que-vous-generez-vos-formulaires.html" rel="alternate"></link><published>2016-05-31T00:00:00+02:00</published><updated>2016-05-31T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2016-05-31:/comment-est-ce-que-vous-generez-vos-formulaires.html</id><summary type="html">&lt;p&gt;TL; DR: Je viens à peine de &lt;em&gt;releaser&lt;/em&gt; la première version d'un service de génération de formulaires.
Allez jeter un coup d'œil sur &lt;a href="https://www.fourmilieres.net"&gt;https://www.fourmilieres.net&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;En février 2012, je parlais ici &lt;a href="https://blog.notmyidea.org/carto-forms.html"&gt;d'un service de génération de formulaires&lt;/a&gt;.
Depuis, pas mal d'eau à coulé sous les ponts, on est …&lt;/em&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;TL; DR: Je viens à peine de &lt;em&gt;releaser&lt;/em&gt; la première version d'un service de génération de formulaires.
Allez jeter un coup d'œil sur &lt;a href="https://www.fourmilieres.net"&gt;https://www.fourmilieres.net&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;En février 2012, je parlais ici &lt;a href="https://blog.notmyidea.org/carto-forms.html"&gt;d'un service de génération de formulaires&lt;/a&gt;.
Depuis, pas mal d'eau à coulé sous les ponts, on est passé par pas mal d'étapes pour
finalement arriver à une première version de ce service de génération de
formulaires (à la &lt;/em&gt;google forms&lt;em&gt;).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;En tant qu'organisateurs d'évènements (petits et gros), je me retrouve souvent
dans une situation ou je dois créer des formulaires pour recueillir des
informations. Actuellement, la meilleure solution disponible est &lt;em&gt;Google Forms&lt;/em&gt;,
mais celle ci à plusieurs problèmes, à commencer par le fait que le code n'est
pas libre et que les données sont stockées chez Google.&lt;/p&gt;
&lt;p&gt;La plupart du temps, le besoin est assez simple: je veux spécifier quelques
questions, et donner un lien à mes amis pour qu'ils puissent y répondre.
Je reviens ensuite plus tard pour voir la liste des réponses apportées.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Capture de l'interface de création du formulaire" src="{filename}/static/formbuilder-build.png"&gt;&lt;/p&gt;
&lt;h2&gt;Fonctionnalités&lt;/h2&gt;
&lt;p&gt;Il existe pas mal de solutions techniques qui essayent de répondre à la même
problématique, mais la plupart d'entre elles sont assez souvent compliquées,
nécessitent de se créer un compte, et/ou ne vous laisse pas la main libre sur
les données générées, voire le code est assez difficile à faire évoluer ou à
déployer.&lt;/p&gt;
&lt;p&gt;Je voulais donc quelque chose de simple à utiliser &lt;em&gt;et&lt;/em&gt; pour les créateurs de
formulaires &lt;em&gt;et&lt;/em&gt; pour les utilisateurs finaux. Pas de chichis, juste quelques
vues, et des URLs à sauvegarder une fois l'opération terminée.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Capture de l'écran avec les URLs générées" src="{filename}/static/formbuilder-created.png"&gt;
&lt;img alt="Capture d'écran d'un exemple de formulaire" src="{filename}/static/formbuilder-form.png"&gt;&lt;/p&gt;
&lt;h3&gt;Pas de compte&lt;/h3&gt;
&lt;p&gt;Vous n'avez pas besoin d'avoir un compte sur le site pour commencer à l'utiliser.
Vous créez simplement un nouveau formulaire puis envoyez le lien à vos amis pour
qu'eux puissent à leur tour le remplir.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Capture de la page d'accueil, ou aucun compte n'est requis" src="{filename}/static/formbuilder-welcome.png"&gt;&lt;/p&gt;
&lt;h3&gt;Gardez la main sur vos données&lt;/h3&gt;
&lt;p&gt;Une fois que vous avez récupéré les réponses à vos questions, vous pouvez
récupérer les données sur votre machines dans un fichier &lt;code&gt;.csv&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Capture de la page de resultats, il est possible de télécharger en CSV." src="{filename}/static/formbuilder-results.png"&gt;&lt;/p&gt;
&lt;h3&gt;API&lt;/h3&gt;
&lt;p&gt;L'ensemble des données sont en fait stockées dans &lt;a href="https://kinto.readthedocs.org"&gt;Kinto&lt;/a&gt;
qui est interrogeable très facilement en HTTP. Ce qui fait qu'il est très facile de
réutiliser les formulaires que vous avez construits (ou leurs réponses) depuis
d'autres outils.&lt;/p&gt;
&lt;h3&gt;Auto-hébergeable&lt;/h3&gt;
&lt;p&gt;Un des objectifs de ce projet est de vous redonner la main sur vos données.
Bien sur, vous pouvez utiliser l'instance qui est mise à votre disposition sur
&lt;a href="https://www.fourmilieres.net"&gt;wwww.fourmilieres.net&lt;/a&gt;, mais vous pouvez
également l'héberger vous même très
simplement, et vous êtes d'ailleurs fortement encouragés à le faire ! Notre
objectif n'est pas de stocker l'ensemble des formulaires du monde, mais de
(re)donner le contrôle aux utilisateurs !&lt;/p&gt;
&lt;h2&gt;On commence petit…&lt;/h2&gt;
&lt;p&gt;Cette &lt;em&gt;release&lt;/em&gt; n'est (bien sur) pas parfaite, et il reste encore pas mal de
travail sur cet outil, mais je pense qu'il s'agit d'une base de travail
intéressante pour un futur où Google n'a pas la main sur toutes nos données.&lt;/p&gt;
&lt;p&gt;La liste des champs supportés est pour l'instant assez faible (Texte court,
Texte long, Oui/Non, choix dans une liste) mais elle à vocation à s'étendre, en
fonction des besoins de chacun.&lt;/p&gt;
&lt;p&gt;J'ai d'ailleurs créé &lt;a href="https://www.fourmilieres.net/#/form/cfd878264cec4ed2"&gt;un formulaire pour que vous puissiez me faire part de vos
retours&lt;/a&gt;, n'hésitez pas !&lt;/p&gt;
&lt;h2&gt;Et, euh, comment ça marche ?&lt;/h2&gt;
&lt;p&gt;Le &lt;em&gt;formbuilder&lt;/em&gt;, comme j'aime l'appeler se compose en fin de compte de deux
parties distinctes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kinto.readthedocs.org"&gt;Kinto&lt;/a&gt;, un service qui stocke
des données coté serveur et qui les expose via des &lt;strong&gt;APIs HTTP&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/kinto/formbuilder"&gt;Le formbuilder&lt;/a&gt;, une application
JavaScript qui ne tourne que coté client (dans votre navigateur) qui permet
de construire les formulaires et d'envoyer les données sur les &lt;em&gt;APIs&lt;/em&gt; coté
serveur.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Au niveau de la &lt;em&gt;stack&lt;/em&gt; technique, le &lt;strong&gt;formbuilder&lt;/strong&gt; est codé en ReactJS. Un
des points techniques intéressants du projet est qu'il génère en fin de compte du
&lt;a href="http://jsonschema.net/"&gt;JSON Schema&lt;/a&gt;, un format de validation de données &lt;em&gt;JSON&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Donc, reprenons! Vous arrivez sur la page d'accueil puis cliquez sur
"Create a new form", puis vous vous retrouvez face à une interface ou vous pouvez
ajouter des champs de formulaire. Une fois ce travail effectué, vous appuyez sur
"Create the form".&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le JSON Schema est alors envoyé au serveur Kinto, qui l'utilisera pour valider
les données qu'il recevra par la suite.&lt;/li&gt;
&lt;li&gt;Ce JSON Schema sera aussi utilisé lors de l'affichage du formulaire aux
personnes qui le remplissent.&lt;/li&gt;
&lt;li&gt;Un jeton d'accès est généré et ajouté à l'URL, il s'agit de l'identifiant du
formulaire.&lt;/li&gt;
&lt;li&gt;Un second jeton d'accès administrateur et généré, il vous faut le garder de
coté pour avoir accès aux réponses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bref, en espérant que ça vous serve ! Un petit pas dans la direction des données
rendues à leurs utilisateurs !&lt;/p&gt;</content></entry><entry><title>What's Hawk and how to use it?</title><link href="https://blog.notmyidea.org/whats-hawk-and-how-to-use-it.html" rel="alternate"></link><published>2014-07-31T00:00:00+02:00</published><updated>2014-07-31T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2014-07-31:/whats-hawk-and-how-to-use-it.html</id><summary type="html">&lt;p&gt;At Mozilla, we recently had to implement &lt;a class="reference external" href="https://github.com/hueniverse/hawk"&gt;the Hawk authentication scheme&lt;/a&gt; for a number of projects, and we came up
creating two libraries to ease integration into pyramid and node.js apps.&lt;/p&gt;
&lt;p&gt;But maybe you don't know Hawk.&lt;/p&gt;
&lt;p&gt;Hawk is a relatively new technology, crafted by one of the original …&lt;/p&gt;</summary><content type="html">&lt;p&gt;At Mozilla, we recently had to implement &lt;a class="reference external" href="https://github.com/hueniverse/hawk"&gt;the Hawk authentication scheme&lt;/a&gt; for a number of projects, and we came up
creating two libraries to ease integration into pyramid and node.js apps.&lt;/p&gt;
&lt;p&gt;But maybe you don't know Hawk.&lt;/p&gt;
&lt;p&gt;Hawk is a relatively new technology, crafted by one of the original &lt;a class="reference external" href="https://en.wikipedia.org/wiki/OAuth"&gt;OAuth&lt;/a&gt; specification authors, that intends to
replace the 2-legged OAuth authentication scheme using a simpler approach.&lt;/p&gt;
&lt;p&gt;It is an authentication scheme for HTTP, built around &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Hmac"&gt;HMAC digests&lt;/a&gt; of requests and responses.&lt;/p&gt;
&lt;p&gt;Every authenticated client request has an Authorization header containing a MAC
(Message Authentication Code) and some additional metadata, then each server
response to authenticated requests contains a Server-Authorization header that
authenticates the response, so the client is sure it comes from the right
server.&lt;/p&gt;
&lt;div class="section" id="exchange-of-the-hawk-id-and-hawk-key"&gt;
&lt;h2&gt;Exchange of the hawk id and hawk key&lt;/h2&gt;
&lt;p&gt;To sign the requests, a client needs to retrieve a token id and a token key
from the server.&lt;/p&gt;
&lt;p&gt;Hawk itself does not define how these credentials should be exchanged
between the server and the client. The excellent team behind &lt;a class="reference external" href="http://accounts.firefox.com"&gt;Firefox Accounts&lt;/a&gt; put together a scheme to do that, which acts
like the following:&lt;/p&gt;
&lt;div class="admonition note"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;All this derivation crazyness might seem a bit complicated, but don't worry,
we put together some libraries that takes care of that for you automatically.&lt;/p&gt;
&lt;p class="last"&gt;If you are not interested into these details, you can directly jump to the
next section to see how to use the libraries.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;When your server application needs to send you the credentials, it will return
it inside a specific &lt;cite&gt;Hawk-Session-Token&lt;/cite&gt; header. This token can be derived to
split this string in two values (hawk id and hawk key) that you will use to
sign your next requests.&lt;/p&gt;
&lt;p&gt;In order to get the hawk credentials, you'll need to:&lt;/p&gt;
&lt;p&gt;First, do an &lt;a class="reference external" href="http://en.wikipedia.org/wiki/HKDF"&gt;HKDF derivation&lt;/a&gt; on the
given session token. You'll need to use the following parameters:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
key_material = HKDF(hawk_session, &amp;quot;&amp;quot;, 'identity.mozilla.com/picl/v1/sessionToken', 32*2)
&lt;/pre&gt;
&lt;div class="admonition note"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;The &lt;tt class="docutils literal"&gt;identity.mozilla.com/picl/v1/sessionToken&lt;/tt&gt; is a reference to this way of
deriving the credentials, not an actual URL.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Then, the key material you'll get out of the HKDF need to be separated into two
parts, the first 32 hex caracters are the hawk id, and the next 32 ones are the
hawk key.&lt;/p&gt;
&lt;p&gt;Credentials:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;keyMaterial&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;key&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;keyMaterial&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;algorithm&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sha256&amp;#39;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="httpie"&gt;
&lt;h2&gt;Httpie&lt;/h2&gt;
&lt;p&gt;To showcase APIs in the documentation, I like to use &lt;a class="reference external" href="https://github.com/jakubroztocil/httpie"&gt;httpie&lt;/a&gt;, a curl-replacement with a nicer
API, built around &lt;a class="reference external" href="http://python-requests.org"&gt;the python requests library&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Luckily, HTTPie allows you to plug different authentication schemes for it, so &lt;a class="reference external" href="https://github.com/mozilla-services/requests-hawk"&gt;I wrote
a wrapper&lt;/a&gt; around &lt;a class="reference external" href="https://github.com/kumar303/mohawk"&gt;mohawk&lt;/a&gt; to add hawk support to the requests lib.&lt;/p&gt;
&lt;p&gt;Doing hawk requests in your terminal is now as simple as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ pip install requests-hawk httpie
$ http GET localhost:5000/registration --auth-type=hawk --auth='id:key'
&lt;/pre&gt;
&lt;p&gt;In addition, it will help you to craft requests using the requests library:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;requests_hawk&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HawkAuth&lt;/span&gt;
&lt;span class="n"&gt;hawk_auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HawkAuth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;key&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;algorithm&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sha256&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hawk_auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Alternatively, if you don't have the token id and key, you can pass the hawk
session token I talked about earlier and the lib will take care of the
derivation for you:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;hawk_auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HawkAuth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;hawk_session&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;hawk-session-token&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="n"&gt;server_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;server_url&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hawk_auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="integrate-with-python-pyramid-apps"&gt;
&lt;h2&gt;Integrate with python pyramid apps&lt;/h2&gt;
&lt;p&gt;If you're writing pyramid applications, you'll be happy to learn that &lt;a class="reference external" href="https://www.rfk.id.au/blog/"&gt;Ryan
Kelly&lt;/a&gt; put together a library that makes Hawk
work as an Authentication provider for them. I'm chocked how simple it
is to use it.&lt;/p&gt;
&lt;p&gt;Here is a demo of how we implemented it for Daybed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pyramid_hawkauth&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HawkAuthenticationPolicy&lt;/span&gt;
&lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HawkAuthenticationPolicy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;decode_hawk_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;get_hawk_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_authentication_policy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authn_policy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;cite&gt;get_hawk_id&lt;/cite&gt; function is a function that takes a request and
a tokenid and returns a tuple of &lt;cite&gt;(token_id, token_key)&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;How you want to store the tokens and retrieve them is up to you. The default
implementation (e.g. if you don't pass a &lt;cite&gt;decode_hawk_id&lt;/cite&gt; function) decodes the
key from the token itself, using a master secret on the server (so you don't
need to store anything).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="integrate-with-node-js-express-apps"&gt;
&lt;h2&gt;Integrate with node.js Express apps&lt;/h2&gt;
&lt;p&gt;We had to implement Hawk authentication for two node.js projects and finally
came up factorizing everything in a library for express, named &lt;a class="reference external" href="https://github.com/mozilla-services/express-hawkauth"&gt;express-hawkauth&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In order to plug it in your application, you'll need to use it as
a middleware:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;express&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;hawk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;express-hawkauth&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;hawkMiddleware&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;hawk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getMiddleware&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="nx"&gt;hawkOptions&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
&lt;span class="nx"&gt;getSession&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tokenId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// A function which pass to the cb the key and algorithm for the&lt;/span&gt;
&lt;span class="c1"&gt;// given token id. First argument of the callback is a potential&lt;/span&gt;
&lt;span class="c1"&gt;// error.&lt;/span&gt;
&lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;key&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;algorithm&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;sha256&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="nx"&gt;createSession&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// A function which stores a session for the given id and key.&lt;/span&gt;
&lt;span class="c1"&gt;// Argument returned is a potential error.&lt;/span&gt;
&lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tokenId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// A function that uses req and res, the hawkId when they&amp;#39;re known so&lt;/span&gt;
&lt;span class="c1"&gt;// that it can tweak it. For instance, you can store the tokenId as the&lt;/span&gt;
&lt;span class="c1"&gt;// user.&lt;/span&gt;
&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tokenId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/hawk-enabled-endpoint&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hawkMiddleware&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you pass the &lt;cite&gt;createSession&lt;/cite&gt; parameter, all non-authenticated requests will
create a new hawk session and return it with the response, in the
&lt;cite&gt;Hawk-Session-Token&lt;/cite&gt; header.&lt;/p&gt;
&lt;p&gt;If you want to only check a valid hawk session exists (without creating a new
one), just create a middleware which doesn't have any &lt;cite&gt;createSession&lt;/cite&gt; parameter
defined.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="some-reference-implementations"&gt;
&lt;h2&gt;Some reference implementations&lt;/h2&gt;
&lt;p&gt;As a reference, here is how we're using the libraries I'm talking about, in
case that helps you to integrate with your projects.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The Mozilla Loop server &lt;a class="reference external" href="https://github.com/mozilla-services/loop-server/blob/master/loop/index.js#L70-L133"&gt;uses hawk as authentication once you're logged in with
a valid BrowserID assertion&lt;/a&gt;;
request, to keep a session between client and server;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/spiral-project/daybed/commit/f178b4e43015fa077430798dcd3d0886c7611caf"&gt;I recently added hawk support on the Daybed project&lt;/a&gt;
(that's a pyramid / cornice) app.&lt;/li&gt;
&lt;li&gt;It's also interesting to note that Kumar put together &lt;a class="reference external" href="http://hawkrest.readthedocs.org/en/latest/"&gt;hawkrest, for the
django rest framework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content></entry><entry><title>New year python meme, 2012</title><link href="https://blog.notmyidea.org/new-year-python-meme-2012.html" rel="alternate"></link><published>2013-07-01T00:00:00+02:00</published><updated>2013-07-01T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2013-07-01:/new-year-python-meme-2012.html</id><summary type="html">&lt;p&gt;This series, also known as &amp;quot;&lt;a class="reference external" href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt; strikes again&amp;quot;,
is a good occasion to take a look back at 2012 and see what I've done related
to python. So, let's try.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Whats the coolest Python application, framework or library you have
discovered in 2012 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I discovered &lt;a class="reference external" href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html"&gt;Pyramid&lt;/a&gt; this …&lt;/p&gt;</summary><content type="html">&lt;p&gt;This series, also known as &amp;quot;&lt;a class="reference external" href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt; strikes again&amp;quot;,
is a good occasion to take a look back at 2012 and see what I've done related
to python. So, let's try.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Whats the coolest Python application, framework or library you have
discovered in 2012 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I discovered &lt;a class="reference external" href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html"&gt;Pyramid&lt;/a&gt; this year and
quite enjoyed it. I like the way they bring back some nice concepts on the
table, and how they compete with other frameworks. That's nicely decomposed and
everything fits together really well. I learned a bit about its internal
routing mechanism when working on &lt;a class="reference external" href="http://cornice.rtfd.org"&gt;Cornice&lt;/a&gt;, and
it's really well done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. What new programming technique did you learn in 2012 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I learned about asynchronous programming, something I wasn't really aware of.
(Yes, that's a shame). This was really helpful to understand some bits of
&lt;a class="reference external" href="http://circus.io"&gt;Circus&lt;/a&gt;. I also started to learn about some related
concepts present in &lt;a class="reference external" href="http://golang.org"&gt;go&lt;/a&gt; or in &lt;a class="reference external" href="http://erlang.org"&gt;erlang&lt;/a&gt; with &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Actor_model"&gt;the actor model&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Which open source project did you contribute to the most in 2012 ? What did
you do ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I worked a bunch on &lt;a class="reference external" href="http://cornice.rtfd.org"&gt;Cornice&lt;/a&gt; and &lt;a class="reference external" href="http://circus.io"&gt;Circus&lt;/a&gt;, not as much as I would like, but that was two really
interesting projects. For Cornice, I completely &lt;a class="reference external" href="http://blog.notmyidea.org/refactoring-cornice.html"&gt;refactored the internals&lt;/a&gt; back in May, and since
that, I added support for &lt;a class="reference external" href="https://github.com/SPORE/specifications"&gt;SPORE&lt;/a&gt;
and am currently working on porting it to Python 3 and adding support for &lt;a class="reference external" href="http://www.w3.org/TR/cors/"&gt;CORS&lt;/a&gt;. For Circus, I worked on the web interface and
on other bits of the projects related to stats.&lt;/p&gt;
&lt;p&gt;I didn't contributed that much to &lt;a class="reference external" href="http://getpelican.com"&gt;Pelican&lt;/a&gt;, mainly
because I'm less excited about it than I was previously: the project is
working and needs to focus more on code quality than features. We started in
this direction, hopefully it will pay-off; but I committed a lot less code than
previously.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Which Python blog or website did you read the most in 2012 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I really don't know. I found some interesting python-related news on &lt;a class="reference external" href="http://news.ycombinator.com/"&gt;hacker
news&lt;/a&gt; and on the printed version as well,
&lt;a class="reference external" href="http://hackermonthly.com/"&gt;hacker monthly&lt;/a&gt;. Twitter and IRC got me some
interesting articles as well.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. What are the three top things you want to learn in 2013 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;On the computer science side, I want to learn more about other paradigms, maybe
in other languages. I like python, but I want to learn about other concepts,
maybe some of them don't really fit with python.&lt;/p&gt;
&lt;p&gt;For instance, I don't know that much about pattern matching or about the actor
model. Well I know what it is, but I would like to make good use of them in
order to have something nice and useful.&lt;/p&gt;
&lt;p&gt;Also, I want to learn how to make a product. From scratch. Which means
designing, implementing and maintaining something. Maybe this will be the case
with &lt;a class="reference external" href="https://github.com/spiral-project/daybed"&gt;daybed&lt;/a&gt; ? Who knows.&lt;/p&gt;
&lt;p&gt;I want to get better at building communities. Working with others is something
that can be complex and quite hard sometimes. I want to learn how to handle
this better.&lt;/p&gt;
&lt;p&gt;On the other side, I want to learn about tons of other non-tech things: taking
pictures, finding a good balance between life and work, working with children,
teaching and animating workshops, writing articles, be better at reading (being
critic when I'm thinking!).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;6. What is the top software, application or library you wish someone would
write in 2013 ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The one missing thing, IMO, is a &lt;strong&gt;good&lt;/strong&gt; webmail reader, in python. One we
could contribute to, one we could write features for, and one that could come
and compete with gmail, in term of features of UI.&lt;/p&gt;
&lt;p&gt;However, most of the time, I'm just impressed by the new ideas that come from
others. I would like to have a library to handle the actor model in a nice way
in Python, I would like to see packaging fixed in python :-)&lt;/p&gt;
&lt;p&gt;Want to do your own list? Here's how:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;copy-paste the questions and answer to them in your blog&lt;/li&gt;
&lt;li&gt;tweet it with the #2012pythonmeme hashtag&lt;/li&gt;
&lt;/ul&gt;
</content></entry><entry><title>Implementing CORS in Cornice</title><link href="https://blog.notmyidea.org/cross-origin-in-cornice.html" rel="alternate"></link><published>2013-04-02T00:00:00+02:00</published><updated>2013-04-02T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2013-04-02:/cross-origin-in-cornice.html</id><summary type="html">&lt;div class="admonition note"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;I'm cross-posting &lt;a class="reference external" href="https://blog.mozilla.org/services/"&gt;on the mozilla services weblog&lt;/a&gt;. Since this is the
first time we're doing that, I though it could be useful to point you
there. Check it out and expect more technical articles there in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For security reasons, it's not possible to do cross-domain requests. In …&lt;/p&gt;</summary><content type="html">&lt;div class="admonition note"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;I'm cross-posting &lt;a class="reference external" href="https://blog.mozilla.org/services/"&gt;on the mozilla services weblog&lt;/a&gt;. Since this is the
first time we're doing that, I though it could be useful to point you
there. Check it out and expect more technical articles there in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For security reasons, it's not possible to do cross-domain requests. In other
words, if you have a page served from the domain &lt;cite&gt;lolnet.org&lt;/cite&gt;, it will not be
possible for it to get data from &lt;cite&gt;notmyidea.org&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;Well, it's possible, using tricks and techniques like &lt;a class="reference external" href="http://en.wikipedia.org/wiki/JSONP"&gt;JSONP&lt;/a&gt;, but that doesn't work all the time (see
&lt;a class="reference external" href="#how-this-is-different-from-jsonp"&gt;the section below&lt;/a&gt;). I remember myself
doing some simple proxies on my domain server to be able to query other's API.&lt;/p&gt;
&lt;p&gt;Thankfully, there is a nicer way to do this, namely, &amp;quot;Cross Origin
Resource-Sharing&amp;quot;, or &lt;a class="reference external" href="http://www.w3.org/TR/cors/"&gt;CORS&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="you-want-an-icecream-go-ask-your-dad-first"&gt;
&lt;h2&gt;You want an icecream? Go ask your dad first.&lt;/h2&gt;
&lt;p&gt;If you want to use CORS, you need the API you're querying to support it; on the
server side.&lt;/p&gt;
&lt;p&gt;The HTTP server need to answer to the &lt;cite&gt;OPTIONS&lt;/cite&gt; verb, and with the appropriate
response headers.&lt;/p&gt;
&lt;p&gt;&lt;cite&gt;OPTIONS&lt;/cite&gt; is sent as what the authors of the spec call a &amp;quot;preflight request&amp;quot;;
just before doing a request to the API, the &lt;em&gt;User-Agent&lt;/em&gt; (the browser most of
the time) asks the permission to the resource, with an &lt;cite&gt;OPTIONS&lt;/cite&gt; call.&lt;/p&gt;
&lt;p&gt;The server answers, and tell what is available and what isn't:&lt;/p&gt;
&lt;img alt="The CORS flow (from the HTML5 CORS tutorial)" src="images/cors_flow.png" /&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;1a. The User-Agent, rather than doing the call directly, asks the server, the
API, the permission to do the request. It does so with the following headers:&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Access-Control-Request-Headers&lt;/strong&gt;, contains the headers the User-Agent
want to access.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access-Control-Request-Method&lt;/strong&gt; contains the method the User-Agent want
to access.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;1b. The API answers what is authorized:&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Access-Control-Allow-Origin&lt;/strong&gt; the origin that's accepted. Can be &lt;cite&gt;*&lt;/cite&gt; or
the domain name.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access-Control-Allow-Methods&lt;/strong&gt; a &lt;em&gt;list&lt;/em&gt; of allowed methods. This can be
cached. Note than the request asks permission for one method and the
server should return a list of accepted methods.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access-Allow-Headers&lt;/strong&gt; a list of allowed headers, for all of the
methods, since this can be cached as well.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;ol class="first arabic" start="2"&gt;
&lt;li&gt;The User-Agent can do the &amp;quot;normal&amp;quot; request.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, if you want to access the &lt;cite&gt;/icecream&lt;/cite&gt; resource, and do a PUT there, you'll
have the following flow:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;gt; OPTIONS /icecream
&amp;gt; Access-Control-Request-Methods = PUT
&amp;gt; Origin: notmyidea.org
&amp;lt; Access-Control-Allow-Origin = notmyidea.org
&amp;lt; Access-Control-Allow-Methods = PUT,GET,DELETE
200 OK
&lt;/pre&gt;
&lt;p&gt;You can see that we have an &lt;cite&gt;Origin&lt;/cite&gt; Header in the request, as well as
a &lt;cite&gt;Access-Control-Request-Methods&lt;/cite&gt;. We're here asking if we have the right, as
&lt;cite&gt;notmyidea.org&lt;/cite&gt;, to do a &lt;cite&gt;PUT&lt;/cite&gt; request on &lt;cite&gt;/icecream&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;And the server tells us that we can do that, as well as &lt;cite&gt;GET&lt;/cite&gt; and &lt;cite&gt;DELETE&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;I'll not cover all the details of the CORS specification here, but bear in mind
than with CORS, you can control what are the authorized methods, headers,
origins, and if the client is allowed to send authentication information or
not.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="a-word-about-security"&gt;
&lt;h2&gt;A word about security&lt;/h2&gt;
&lt;p&gt;CORS is not an answer for every cross-domain call you want to do, because you
need to control the service you want to call. For instance, if you want to
build a feed reader and access the feeds on different domains, you can be
pretty much sure that the servers will not implement CORS, so you'll need to
write a proxy yourself, to provide this.&lt;/p&gt;
&lt;p&gt;Secondly, if misunderstood, CORS can be insecure, and cause
problems. Because the rules apply when a client wants to do a request to
a server, you need to be extra careful about who you're authorizing.&lt;/p&gt;
&lt;p&gt;An incorrectly secured CORS server can be accessed by a malicious client very easily,
bypassing network security. For instance, if you host a server on an intranet
that is only available from behind a VPN but accepts every cross-origin call. A bad guy
can inject javascript into the browser of a user who has access to your
protected server and make calls to your service, which is probably not what you want.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="how-this-is-different-from-jsonp"&gt;
&lt;h2&gt;How this is different from JSONP?&lt;/h2&gt;
&lt;p&gt;You may know the &lt;a class="reference external" href="http://en.wikipedia.org/wiki/JSONP"&gt;JSONP&lt;/a&gt; protocol. JSONP
allows cross origin, but for a particular use case, and does have some
drawbacks (for instance, it's not possible to do DELETEs or PUTs with JSONP).&lt;/p&gt;
&lt;p&gt;JSONP exploits the fact that it is possible to get information from another domain
when you are asking for javascript code, using the &lt;cite&gt;&amp;lt;script&amp;gt;&lt;/cite&gt; element.&lt;/p&gt;
&lt;blockquote&gt;
Exploiting the open policy for &amp;lt;script&amp;gt; elements, some pages use them to
retrieve JavaScript code that operates on dynamically generated
JSON-formatted data from other origins. This usage pattern is known as
JSONP. Requests for JSONP retrieve not JSON, but arbitrary JavaScript code.
They are evaluated by the JavaScript interpreter, not parsed by a JSON
parser.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="using-cors-in-cornice"&gt;
&lt;h2&gt;Using CORS in Cornice&lt;/h2&gt;
&lt;p&gt;Okay, things are hopefully clearer about CORS, let's see how we
implemented it on the server-side.&lt;/p&gt;
&lt;p&gt;Cornice is a toolkit that lets you define resources in python and takes care of
the heavy lifting for you, so I wanted it to take care of the CORS support as
well.&lt;/p&gt;
&lt;p&gt;In Cornice, you define a service like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cornice&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;
&lt;span class="n"&gt;foobar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;foobar&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/foobar&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# and then you do something with it&lt;/span&gt;
&lt;span class="nd"&gt;@foobar.get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_foobar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# do something with the request.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To add CORS support to this resource, you can go this way, with the
&lt;cite&gt;cors_origins&lt;/cite&gt; parameter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;foobar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cors_origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ta-da! You have enabled CORS for your service. &lt;strong&gt;Be aware that you're
authorizing anyone to query your server, that may not be what you want.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Of course, you can specify a list of origins you trust, and you don't need
to stick with &lt;cite&gt;*&lt;/cite&gt;, which means &amp;quot;authorize everyone&amp;quot;.&lt;/p&gt;
&lt;div class="section" id="headers"&gt;
&lt;h3&gt;Headers&lt;/h3&gt;
&lt;p&gt;You can define the headers you want to expose for the service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;foobar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cors_origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;span class="nd"&gt;@foobar.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cors_headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;X-My-Header&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_foobars_please&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;some foobar for you&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I've done some testing and it wasn't working on Chrome because I wasn't
handling the headers the right way (The missing one was &lt;cite&gt;Content-Type&lt;/cite&gt;, that
Chrome was asking for). With my first version of the implementation, I needed
the service implementers to explicitely list all the headers that should be
exposed. While this improves security, it can be frustrating while developing.&lt;/p&gt;
&lt;p&gt;So I introduced an &lt;cite&gt;expose_all_headers&lt;/cite&gt; flag, which is set to &lt;cite&gt;True&lt;/cite&gt; by
default, if the service supports CORS.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cookies-credentials"&gt;
&lt;h3&gt;Cookies / Credentials&lt;/h3&gt;
&lt;p&gt;By default, the requests you do to your API endpoint don't include the
credential information for security reasons. If you really want to do that,
you need to enable it using the &lt;cite&gt;cors_credentials&lt;/cite&gt; parameter. You can activate
this one on a per-service basis or on a per-method basis.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="caching"&gt;
&lt;h3&gt;Caching&lt;/h3&gt;
&lt;p&gt;When you do a preflight request, the information returned by the server can be
cached by the User-Agent so that it's not redone before each actual call.&lt;/p&gt;
&lt;p&gt;The caching period is defined by the server, using the &lt;cite&gt;Access-Control-Max-Age&lt;/cite&gt;
header. You can configure this timing using the &lt;cite&gt;cors_max_age&lt;/cite&gt; parameter.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="simplifying-the-api"&gt;
&lt;h3&gt;Simplifying the API&lt;/h3&gt;
&lt;p&gt;We have cors_headers, cors_enabled, cors_origins, cors_credentials,
cors_max_age, cors_expose_all_headers … a fair number of
parameters. If you want to have a specific CORS-policy for your services, that
can be a bit tedious to pass these to your services all the time.&lt;/p&gt;
&lt;p&gt;I introduced another way to pass the CORS policy, so you can do something like
that:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enabled&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;X-My-Header&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="n"&gt;origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;*.notmyidea.org&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;foobar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/foobar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cors_policy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="comparison-with-other-implementations"&gt;
&lt;h2&gt;Comparison with other implementations&lt;/h2&gt;
&lt;p&gt;I was curious to have a look at other implementations of CORS, in
django for instance, and I found &lt;a class="reference external" href="https://gist.github.com/426829.js"&gt;a gist about it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Basically, this adds a middleware that adds the &amp;quot;rights&amp;quot; headers to the answer,
depending on the request.&lt;/p&gt;
&lt;p&gt;While this approach works, it's not implementing the specification completely.
You need to add support for all the resources at once.&lt;/p&gt;
&lt;p&gt;We can think about a nice way to implement this specifying a definition of what's
supposed to be exposed via CORS and what shouldn't directly in your settings.
In my opinion, CORS support should be handled at the service definition level,
except for the list of authorized hosts.
Otherwise, you don't know exactly what's going on when you look at the definition of the service.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="resources"&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;There are a number of good resources that can be useful to you if you want to
either understand how CORS works, or if you want to implement it yourself.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://enable-cors.org/"&gt;http://enable-cors.org/&lt;/a&gt; is useful to get started when you don't know anything
about CORS.&lt;/li&gt;
&lt;li&gt;There is a W3C wiki page containing information that may be useful about
clients, common pitfalls etc: &lt;a class="reference external" href="http://www.w3.org/wiki/CORS_Enabled"&gt;http://www.w3.org/wiki/CORS_Enabled&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;HTML5 rocks&lt;/em&gt; has a tutorial explaining how to implement CORS, with &lt;a class="reference external" href="http://www.html5rocks.com/en/tutorials/cors/#toc-adding-cors-support-to-the-server"&gt;a nice
section about the server-side&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Be sure to have a look at the &lt;a class="reference external" href="http://caniuse.com/#search=cors"&gt;clients support-matrix for this feature&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;About security, &lt;a class="reference external" href="https://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity"&gt;check out this page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;If you want to have a look at the implementation code, check &lt;a class="reference external" href="https://github.com/mozilla-services/cornice/pull/98/files"&gt;on github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, the W3C specification is the best resource to rely on. This
specification isn't hard to read, so you may want to go through it. Especially
the &lt;a class="reference external" href="http://www.w3.org/TR/cors/#resource-processing-model"&gt;&amp;quot;resource processing model&amp;quot; section&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Status board</title><link href="https://blog.notmyidea.org/status-board-fr.html" rel="alternate"></link><published>2012-12-29T00:00:00+01:00</published><updated>2012-12-29T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-12-29:/status-board-fr.html</id><summary type="html">&lt;p&gt;À force de démarrer des services web pour un oui et pour un non, de proposer
à des copains d'héberger leurs sites, de faire pareil pour quelques assos etc,
je me suis retrouvé avec, comme dirait l'autre, &lt;em&gt;une bonne platrée&lt;/em&gt; de sites et
de services à gérer sur &lt;cite&gt;lolnet.org …&lt;/cite&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;À force de démarrer des services web pour un oui et pour un non, de proposer
à des copains d'héberger leurs sites, de faire pareil pour quelques assos etc,
je me suis retrouvé avec, comme dirait l'autre, &lt;em&gt;une bonne platrée&lt;/em&gt; de sites et
de services à gérer sur &lt;cite&gt;lolnet.org&lt;/cite&gt;, mon serveur.&lt;/p&gt;
&lt;p&gt;Jusqu'à très récemment, rien de tout ça n'était sauvegardé, et non plus monitoré.
Après quelques recherches, je suis tombé sur &lt;a class="reference external" href="http://www.stashboard.org/"&gt;stashboard&lt;/a&gt;, un &amp;quot;status board&amp;quot; qu'il est bien fait. Le seul
problème, c'est écrit pour se lancer sur GAE, &lt;em&gt;Google App Engine&lt;/em&gt;.
Heureusement, c'est open-source, et ça a été forké pour donner naissance
à &lt;a class="reference external" href="https://github.com/bfirsh/whiskerboard"&gt;whiskerboard&lt;/a&gt; (la planche
moustachue, pour les non anglophones).&lt;/p&gt;
&lt;img alt="Capture d'écran du site." src="images/status_board.png" /&gt;
&lt;div class="section" id="verifier-le-statut-des-services"&gt;
&lt;h2&gt;Vérifier le statut des services&lt;/h2&gt;
&lt;p&gt;Donc, c'est chouette, c'est facile à installer, tout ça, mais… mais ça ne fait
en fait pas ce que je veux: ça ne fait que m'afficher le statut des services,
mais ça ne vérifie pas que tout est bien &amp;quot;up&amp;quot;.&lt;/p&gt;
&lt;p&gt;Bon, un peu embêtant pour moi, parce que c'est vraiment ça que je voulais. Pas
grave, je sais un peu coder, autant que ça serve. J'ai ajouté quelques
fonctionnalités au soft, qui sont disponibles sur mon fork, sur
github:: &lt;a class="reference external" href="https://github.com/ametaireau/whiskerboard"&gt;https://github.com/ametaireau/whiskerboard&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;Entres autres, il est désormais possible de lancer &lt;a class="reference external" href="http://celeryproject.org/"&gt;celery&lt;/a&gt; en tache de fond et de vérifier périodiquement
que les services sont toujours bien vivants, en utilisant une tache spécifique.&lt;/p&gt;
&lt;p&gt;C'était un bonheur de développer ça (on a fait ça à deux, avec guillaume, avec
un mumble + tmux en pair prog, en une petite soirée, ça dépote).&lt;/p&gt;
&lt;p&gt;Les modifications sont assez simples, vous pouvez aller jeter un œil aux
changements ici:
&lt;a class="reference external" href="https://github.com/ametaireau/whiskerboard/compare/b539337416...master"&gt;https://github.com/ametaireau/whiskerboard/compare/b539337416...master&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;En gros:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;ajout d'une &lt;cite&gt;connection_string&lt;/cite&gt; aux services (de la forme
protocol://host:port)&lt;/li&gt;
&lt;li&gt;ajout d'une commande &lt;cite&gt;check_status&lt;/cite&gt; qui s'occupe d'itérer sur les services et
de lancer des taches celery qui vont bien, en fonction du protocole&lt;/li&gt;
&lt;li&gt;ajout des taches en question&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="deploiement"&gt;
&lt;h2&gt;Déploiement&lt;/h2&gt;
&lt;p&gt;Le plus long a été de le déployer en fin de compte, parce que je ne voulais pas
déployer mon service de supervision sur mon serveur, forcément.&lt;/p&gt;
&lt;p&gt;Après un essai (plutôt rapide en fait) sur &lt;a class="reference external" href="http://heroku.com"&gt;heroku&lt;/a&gt;, je me
suis rendu compte qu'il me fallait payer pas loin de 35$ par mois pour avoir un
process &lt;cite&gt;celeryd&lt;/cite&gt; qui tourne, donc j'ai un peu cherché ailleurs, pour
finalement déployer la chose chez &lt;a class="reference external" href="https://www.alwaysdata.com/"&gt;alwaysdata&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Après quelques péripéties, j'ai réussi à faire tourner le tout, ça à été un peu
la bataille au départ pour installer virtualenv (j'ai du faire des changements
dans mon &lt;cite&gt;PATH&lt;/cite&gt; pour que ça puisse marcher), voici mon &lt;cite&gt;.bash_profile&lt;/cite&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
export PYTHONPATH=~/modules/
export PATH=$HOME/modules/bin:$HOME/modules/:$PATH
&lt;/pre&gt;
&lt;p&gt;Et après y'a plus qu'à installer avec &lt;cite&gt;easy_install&lt;/cite&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
easy_install --install-dir ~/modules -U pip
easy_install --install-dir ~/modules -U virtualenv
&lt;/pre&gt;
&lt;p&gt;Et à créer le virtualenv:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
virtualenv venv
venv/bin/pip install -r requirements.txt
&lt;/pre&gt;
&lt;p&gt;Dernière étape, la création d'un fichier &lt;cite&gt;application.wsgi&lt;/cite&gt; qui s'occupe de
rendre l'application disponible, avec le bon venv:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;activate_this&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/home/lolnet/venv/bin/activate_this.&lt;/span&gt;
&lt;span class="nb"&gt;execfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;activate_this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__file__&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;activate_this&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/home/lolnet/public&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;django.core.handlers.wsgi&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;DJANGO_SETTINGS_MODULE&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;settings&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;django&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handlers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wsgi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WSGIHandler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="ssl-et-requests"&gt;
&lt;h2&gt;SSL et Requests&lt;/h2&gt;
&lt;p&gt;Quelques tours de manivelle plus loin, j'ai un celeryd qui tourne et qui
consomme les taches qui lui sont envoyées (pour des questions de simplicité,
j'ai utilisé le backend &lt;cite&gt;django&lt;/cite&gt; de celery, donc pas besoin d'AMQP, par
exemple).&lt;/p&gt;
&lt;p&gt;Problème, les ressources que je vérifie en SSL (HTTPS) me jettent. Je sais pas
exactement pourquoi à l'heure qu'il est, mais il semble que lorsque je fais une
requête avec &lt;a class="reference external" href="http://docs.python-requests.org/en/latest/"&gt;Requests&lt;/a&gt; je me
récupère des &lt;em&gt;Connection Refused&lt;/em&gt;. Peut être une sombre histoire de proxy ? En
attendant, les appels avec &lt;cite&gt;CURL&lt;/cite&gt; fonctionnent, donc j'ai fait &lt;a class="reference external" href="https://github.com/ametaireau/whiskerboard/blob/master/board/tasks.py#L17"&gt;un fallback
vers CURL lorsque les autres méthodes échouent&lt;/a&gt;.
Pas super propre, mais ça fonctionne.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Finalement, il se trouve que mon serveur était mal configuré.
J'utilisais haproxy + stunnel, et la négiciation SSL se passait mal. Une fois
SSL et TLS activés, et SSLv2 désactivé, tout fonctionne mieux.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="et-voila"&gt;
&lt;h2&gt;Et voilà&lt;/h2&gt;
&lt;p&gt;Finalement, j'ai mon joli status-board qui tourne à merveille sur
&lt;a class="reference external" href="http://status.lolnet.org"&gt;http://status.lolnet.org&lt;/a&gt; :-)&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Gnome 3, extensions</title><link href="https://blog.notmyidea.org/gnome-3-extensions.html" rel="alternate"></link><published>2012-12-27T00:00:00+01:00</published><updated>2012-12-27T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-12-27:/gnome-3-extensions.html</id><summary type="html">&lt;p&gt;Après avoir tenté pendant un bout de temps unity, le bureau par defaut de
ubuntu, j'ai eu envie de changements, et j'ai donc essayé un peu de regarder du
coté de gnome 3, à nouveau.&lt;/p&gt;
&lt;p&gt;Et finalement, j'ai trouvé quelques extensions qui sont vraiment utiles, que je
liste ici.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/547/antisocial-menu/"&gt;Antisocial …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;Après avoir tenté pendant un bout de temps unity, le bureau par defaut de
ubuntu, j'ai eu envie de changements, et j'ai donc essayé un peu de regarder du
coté de gnome 3, à nouveau.&lt;/p&gt;
&lt;p&gt;Et finalement, j'ai trouvé quelques extensions qui sont vraiment utiles, que je
liste ici.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/547/antisocial-menu/"&gt;Antisocial Menu&lt;/a&gt; vire les
boutons et textes en rapport avec le web social. J'en avais pas besoin
puisque je suis connecté à mon instant messenger dans un terminal, en
utilisant weechat.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/97/coverflow-alt-tab/"&gt;Coverflow Alt-Tab&lt;/a&gt; change le
switcher d'applications par defaut. Je le trouve bien plus pratique que celui
par defaut puisqu'il me permet de voir &amp;quot;en grand&amp;quot; quelle est la fenêtre que
je vais afficher.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/55/media-player-indicator/"&gt;Media player indicator&lt;/a&gt; me
permet de voir en temps réel ce qui se passe dans mon lecteur audio. Ça
semble ne pas être grand chose, mais ça me manquait. Ça s'intègre niquel avec
Spotify, et ça c'est chouette.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/149/search-firefox-bookmarks-provider/"&gt;Rechercher dans les bookmarks firefox&lt;/a&gt;
permet de… à votre avis ?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Un peu moins utile mais sait on jamais:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://extensions.gnome.org/extension/130/advanced-settings-in-usermenu/"&gt;Advanced Settings in UserMenu&lt;/a&gt;
permet d'avoir un raccourci vers les paramètres avancés dans le menu
utilisateur (en haut à droite)&lt;/li&gt;
&lt;li&gt;Une &lt;a class="reference external" href="https://extensions.gnome.org/extension/409/gtg-integration/"&gt;intégration à Getting things Gnome&lt;/a&gt; (un truc de
GTD). Je suis en train d'expérimenter avec cet outil, donc je ne sais pas
encore si ça va rester, mais pourquoi pas.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vous pouvez aller faire un tour sur &lt;a class="reference external" href="https://extensions.gnome.org/"&gt;https://extensions.gnome.org/&lt;/a&gt;
pour en trouver d'autres à votre gout.&lt;/p&gt;
</content><category term="note"></category></entry><entry><title>Cheese &amp; code - Wrap-up</title><link href="https://blog.notmyidea.org/cheese-code-wrap-up.html" rel="alternate"></link><published>2012-10-22T00:00:00+02:00</published><updated>2012-10-22T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-10-22:/cheese-code-wrap-up.html</id><summary type="html">&lt;p&gt;This week-end I hosted a &lt;em&gt;cheese &amp;amp; code&lt;/em&gt; session in the country-side of Angers,
France.&lt;/p&gt;
&lt;p&gt;We were a bunch of python hackers and it rained a lot, wich forced us to stay
inside and to code. Bad.&lt;/p&gt;
&lt;p&gt;We were not enough to get rid of all the cheese and the awesome …&lt;/p&gt;</summary><content type="html">&lt;p&gt;This week-end I hosted a &lt;em&gt;cheese &amp;amp; code&lt;/em&gt; session in the country-side of Angers,
France.&lt;/p&gt;
&lt;p&gt;We were a bunch of python hackers and it rained a lot, wich forced us to stay
inside and to code. Bad.&lt;/p&gt;
&lt;p&gt;We were not enough to get rid of all the cheese and the awesome meals, but
well, we finally managed it pretty well.&lt;/p&gt;
&lt;p&gt;Here is a summary of what we worked on:&lt;/p&gt;
&lt;div class="section" id="daybed"&gt;
&lt;h2&gt;Daybed&lt;/h2&gt;
&lt;p&gt;Daybed started some time ago, and intend to be a replacement to google forms,
in term of features, but backed as a REST web service, in python, and open
source.&lt;/p&gt;
&lt;p&gt;In case you wonder, daybed is effectively the name of a couch. We chose this
name because of the similarities (in the sound) with &lt;strong&gt;db&lt;/strong&gt;, and because
we're using &lt;strong&gt;CouchDB&lt;/strong&gt; as a backend.&lt;/p&gt;
&lt;img alt="Daybed is a big couch!" src="images/daybed.jpg" style="width: 400px;" /&gt;
&lt;p&gt;We mainly hacked on daybed and are pretty close to the release of the first
version, meaning that we have something working.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://github.com/spiral-project/daybed"&gt;The code&lt;/a&gt; is available on github,
and we also wrote &lt;a class="reference external" href="http://daybed.rtfd.org"&gt;a small documentation&lt;/a&gt; for it.&lt;/p&gt;
&lt;p&gt;Mainly, we did a lot of cleanup, rewrote a bunch of tests so that it would be
easier to continue to work on the project, and implemented some minor features.
I'm pretty confidend that we now have really good basis for this project.&lt;/p&gt;
&lt;p&gt;Also, we will have a nice todolist application, with the backend &lt;strong&gt;and&lt;/strong&gt; the
frontend, in javascript / html / css, you'll know more when it'll be ready :-)&lt;/p&gt;
&lt;p&gt;Once we have something good enough, we'll release the first version and I'll
host it somewhere so that people can play with it.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cornice"&gt;
&lt;h2&gt;Cornice&lt;/h2&gt;
&lt;p&gt;Daybed is built on top of &lt;a class="reference external" href="http://cornice.rtfd.org"&gt;Cornice&lt;/a&gt;, a framework to
ease the creation of web-services.&lt;/p&gt;
&lt;p&gt;At Pycon France, we had the opportunity to attend a good presentation about &lt;a class="reference external" href="https://github.com/SPORE/specifications"&gt;SPORE&lt;/a&gt;. SPORE is a way to describe your
REST web services, as WSDL is for WS-* services. This allows to ease the
creation of generic SPORE clients, which are able to consume any REST API with
a SPORE endpoint.&lt;/p&gt;
&lt;p&gt;Here is how you can let cornice describe your web service for you&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cornice.ext.spore&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;generate_spore_description&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cornice.service&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;get_services&lt;/span&gt;
&lt;span class="n"&gt;spore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;spore&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/spore&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;jsonp&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@spore.get&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_spore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;services&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_services&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;generate_spore_description&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Service name&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;application_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1.0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And you'll get a definition of your service, in SPORE, available at &lt;cite&gt;/spore&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;Of course, you can use it to do other things, like generating the file locally
and exporting it wherever it makes sense to you, etc.&lt;/p&gt;
&lt;p&gt;I released today &lt;a class="reference external" href="http://crate.io/packages/cornice/"&gt;Cornice 0.11&lt;/a&gt;, which adds
into other things the support for SPORE, plus some other fixes we found on our
way.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="respire"&gt;
&lt;h2&gt;Respire&lt;/h2&gt;
&lt;p&gt;Once you have the description of the service, you can do generic clients
consuming them!&lt;/p&gt;
&lt;p&gt;We first wanted to contribute to &lt;a class="reference external" href="https://github.com/bl0b/spyre"&gt;spyre&lt;/a&gt; but
it was written in a way that wasn't supporting to &lt;cite&gt;POST&lt;/cite&gt; data, and they
were using their own stack to handle HTTP. A lot of code that already exists in
other libraries.&lt;/p&gt;
&lt;p&gt;While waiting the train with &lt;a class="reference external" href="http://natim.ionyse.com/"&gt;Rémy&lt;/a&gt;, we hacked
something together, named &amp;quot;Respire&amp;quot;, a thin layer on top of the awesome
&lt;a class="reference external" href="http://python-requests.org"&gt;Requests&lt;/a&gt; library.&lt;/p&gt;
&lt;p&gt;We have a first version, feel free to have a look at it and provide
enhancements if you feel like it. We're still hacking on it so it may break
(for the better), but that had been working pretty well for us so far.&lt;/p&gt;
&lt;p&gt;You can &lt;a class="reference external" href="http://github.com/spiral-project/respire"&gt;find the project on github&lt;/a&gt;, but here is how to use it, really
quickly (these examples are how to interact with daybed)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;respire&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;client_from_url&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;# create the client from the SPORE definition&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client_from_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;http://localhost:8000/spore&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;# in daybed, create a new definition&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;todo_def&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;todo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A list of my stuff to do&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;fields&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;The item&amp;quot;&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;enum&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;choices&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;done&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;todo&amp;quot;&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;is it done or not&amp;quot;&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="p"&gt;]}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_definition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;todo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;todo_def&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;todo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;make it work&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;todo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sa"&gt;u&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;u&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;9f2c90c0529a442cfdc03c191b022cf7&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;todo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, we were out of cheese so everyone headed back to their respective
houses and cities.&lt;/p&gt;
&lt;p&gt;Until next time?&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Cheese &amp; Code party: October 20-21</title><link href="https://blog.notmyidea.org/afpy-computer-camp-october-20-21.html" rel="alternate"></link><published>2012-09-20T00:00:00+02:00</published><updated>2012-09-20T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-09-20:/afpy-computer-camp-october-20-21.html</id><summary type="html">&lt;p&gt;At PyconFR, this week-end, a few ideas were thrown in the air and one of them
was to have a /dev/fort doing some python-related coding.&lt;/p&gt;
&lt;p&gt;The concept of a /dev/fort is to put a bunch of hackers together and see what
comes out from it. Tarek is doing …&lt;/p&gt;</summary><content type="html">&lt;p&gt;At PyconFR, this week-end, a few ideas were thrown in the air and one of them
was to have a /dev/fort doing some python-related coding.&lt;/p&gt;
&lt;p&gt;The concept of a /dev/fort is to put a bunch of hackers together and see what
comes out from it. Tarek is doing something related with the Afpy Computer
Camps at his house each year, I've been there twice and it really was a nice
experience.&lt;/p&gt;
&lt;p&gt;At Djangocong 2012, in Montpellier (south of France), &lt;a class="reference external" href="http://blog.mathieu-leplatre.info/"&gt;Mathieu Leplatre&lt;/a&gt; and myself started to work on a model
validation and storage service, named &lt;a class="reference external" href="https://github.com/spiral-project/daybed/"&gt;Daybed&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I've talked about this project to some persons this week-end (I've even done &lt;a class="reference external" href="http://alexis.notmyidea.org/lightning-daybed.html"&gt;a
lightning talk&lt;/a&gt; about it)
and it gathered some interest from people in the python community, so we
thought about sprinting on this.&lt;/p&gt;
&lt;div class="section" id="and-21-october-a-computer-camp"&gt;
&lt;h2&gt;20 and 21 October - A Computer Camp !&lt;/h2&gt;
&lt;p&gt;Add to this a few beers, and the sprint turns magically into a camp. We'll be
sprinting at the end of October (the 20 and 21) near Angers, on daybed.&lt;/p&gt;
&lt;p&gt;We plan to have great food and wine, so if you feel like it and if you want to
come and work on some python-related things, you're invited!&lt;/p&gt;
&lt;p&gt;Although, I can host a limited number of persons, so you'll need to contact me
before :), that's &lt;cite&gt;alexis at notmyidea dot org&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;I've setup a wiki page to organize a bit everything (knowing how many people will
come by will allow me to handle things better), please put information there:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://wiki.python.org/moin/ComputerCampAlexis"&gt;http://wiki.python.org/moin/ComputerCampAlexis&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Circus sprint at PyconFR</title><link href="https://blog.notmyidea.org/circus-sprint-at-pyconfr.html" rel="alternate"></link><published>2012-09-17T00:00:00+02:00</published><updated>2012-09-17T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-09-17:/circus-sprint-at-pyconfr.html</id><summary type="html">&lt;p&gt;Last Thursday to Sunday, &lt;a class="reference external" href="http://pycon.fr"&gt;Pycon France&lt;/a&gt; took place, in
Paris. It was the opportunity to meet a lot of people and to talk about python
awesomness in general.&lt;/p&gt;
&lt;p&gt;We had three tracks this year, plus sprints the two first days. We sprinted on
&lt;a class="reference external" href="http://circus.io"&gt;Circus&lt;/a&gt;, the process and socket manager we're …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Last Thursday to Sunday, &lt;a class="reference external" href="http://pycon.fr"&gt;Pycon France&lt;/a&gt; took place, in
Paris. It was the opportunity to meet a lot of people and to talk about python
awesomness in general.&lt;/p&gt;
&lt;p&gt;We had three tracks this year, plus sprints the two first days. We sprinted on
&lt;a class="reference external" href="http://circus.io"&gt;Circus&lt;/a&gt;, the process and socket manager we're using
at Mozilla for some of our setups.&lt;/p&gt;
&lt;p&gt;The project gathered some interest, and we ended up with 5 persons working on
it. Of course, we spent some time explaining what is Circus, how it had been
built, a lot of time talking about use-cases and possible improvements, but we
also managed to add new features.&lt;/p&gt;
&lt;p&gt;Having people wanting to sprint on our projects is exciting because that's
when making things in the open unleashes its full potential. You can't imagine
how happy I was to have some friends come and work on this with us :)&lt;/p&gt;
&lt;p&gt;Here is a wrap-up of the sprint:&lt;/p&gt;
&lt;div class="section" id="autocompletion-on-the-command-line"&gt;
&lt;h2&gt;Autocompletion on the command-line&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://natim.ionyse.com"&gt;Remy Hubscher&lt;/a&gt; worked on the command-line
autocompletion. Now we have a fancy command-line interface which is able to
aucomplete if you're using bash. It seems that not that much work is needed to
make it happen on zsh as well :)&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://github.com/mozilla-services/circus/blob/master/extras/circusctl_bash_completion"&gt;Have a look at the feature&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On the same topic, we now have a cool shell for Circus. If you start the
&lt;cite&gt;circusctl&lt;/cite&gt; command without any option, you'll end-up with a cool shell. Thanks
&lt;a class="reference external" href="https://github.com/jojax"&gt;Jonathan Dorival&lt;/a&gt; for the work on this! You can
have a look at &lt;a class="reference external" href="https://github.com/mozilla-services/circus/pull/268"&gt;the pull request&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="future-changes-to-the-web-ui"&gt;
&lt;h2&gt;Future changes to the web ui&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://twitter.com/rachbelaid"&gt;Rachid Belaid&lt;/a&gt; had a deep look at the source
code and is much more familiarized to it now than before. We discussed the
possibility to change the implementation of the web ui, and I'm glad of this.
Currently, it's done with bottle.py and we want to switch to pyramid.&lt;/p&gt;
&lt;p&gt;He fixed some issues that were in the tracker, so we now can have the age of
watchers in the webui, for instance.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="bug-and-doc-fixing"&gt;
&lt;h2&gt;Bug and doc fixing&lt;/h2&gt;
&lt;p&gt;While reading the source code, we found some inconsistencies and fixed them,
with &lt;a class="reference external" href="http://mathieu.agopian.info/"&gt;Mathieu Agopian&lt;/a&gt;. We also tried to
improve the documentation at different levels.&lt;/p&gt;
&lt;p&gt;Documentation still needs a lot of love, and I'm planning to spend some time on
this shortly. I've gathered a bunch of feedback on this&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="circus-clustering-capabilities"&gt;
&lt;h2&gt;Circus clustering capabilities&lt;/h2&gt;
&lt;p&gt;One feature I wanted to work on during this sprint was the clustering abilities
of Circus. Nick Pellegrino made an internship on this topic at Mozilla so we
spent some time to review his pull requests.&lt;/p&gt;
&lt;p&gt;A lot of code was written for this so we discussed a bunch of things
regarding all of this. It took us more time than expected (and I still need to
spend more time on this to provide appropriate feedback), but it allowed us to
have a starting-point about what this clustering thing could be.&lt;/p&gt;
&lt;p&gt;Remy wrote &lt;a class="reference external" href="http://tech.novapost.fr/circus-clustering-management-en.html"&gt;a good summary about our brainstorming&lt;/a&gt; so I'll not do
it again here, but feel free to contact us if you have ideas on this, they're
very welcome!&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="project-management"&gt;
&lt;h2&gt;Project management&lt;/h2&gt;
&lt;p&gt;We've had some inquiries telling us that's not as easy as it should to get
started with the Circus project. Some of the reasons are that we don't
have any release schedule, and that the documentation is hairy enough to lost
people, at some point :)&lt;/p&gt;
&lt;p&gt;That's something we'll try to fix soon :)&lt;/p&gt;
&lt;p&gt;PyconFR was a very enjoyable event. I'm looking forward to meet the community
again and discuss how Circus can evolve in ways that are interesting to
everyone.&lt;/p&gt;
&lt;p&gt;Tarek and me are going to &lt;a class="reference external" href="http://python.ie/pycon/2012/"&gt;Pycon ireland&lt;/a&gt;, feel
free to reach us if you're going there, we'll be happy to meet and enjoy beers!&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Refactoring Cornice</title><link href="https://blog.notmyidea.org/refactoring-cornice.html" rel="alternate"></link><published>2012-05-14T00:00:00+02:00</published><updated>2012-05-14T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-05-14:/refactoring-cornice.html</id><summary type="html">&lt;p&gt;After working for a while with &lt;a class="reference external" href="http://cornice.readthedocs.com"&gt;Cornice&lt;/a&gt; to
define our APIs at &lt;a class="reference external" href="http://docs.services.mozilla.com"&gt;Services&lt;/a&gt;, it turned
out that the current implementation wasn't flexible enough to allow us to do
what we wanted to do.&lt;/p&gt;
&lt;p&gt;Cornice started as a toolkit on top of the &lt;a class="reference external" href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html"&gt;pyramid&lt;/a&gt; routing system,
allowing to register services in …&lt;/p&gt;</summary><content type="html">&lt;p&gt;After working for a while with &lt;a class="reference external" href="http://cornice.readthedocs.com"&gt;Cornice&lt;/a&gt; to
define our APIs at &lt;a class="reference external" href="http://docs.services.mozilla.com"&gt;Services&lt;/a&gt;, it turned
out that the current implementation wasn't flexible enough to allow us to do
what we wanted to do.&lt;/p&gt;
&lt;p&gt;Cornice started as a toolkit on top of the &lt;a class="reference external" href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html"&gt;pyramid&lt;/a&gt; routing system,
allowing to register services in a simpler way. Then we added some niceties
such as the ability to automatically generate the services documentation or
returning the correct HTTP headers &lt;a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"&gt;as defined by the HTTP specification&lt;/a&gt; without the need
from the developer to deal with them nor to know them.&lt;/p&gt;
&lt;p&gt;If you're not familiar with Cornice, here is how you define a simple service
with it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cornice.service&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;
&lt;span class="n"&gt;bar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/bar&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@bar.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;validators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;validators&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;accept&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;application/json&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_drink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# do something with the request (with moderation).&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This external API is quite cool, as it allows to do a bunch of things quite
easily. For instance, we've written our &lt;a class="reference external" href="https://github.com/mozilla-services/tokenserver"&gt;token-server&lt;/a&gt; code on top of this in a
blast.&lt;/p&gt;
&lt;div class="section" id="the-burden"&gt;
&lt;h2&gt;The burden&lt;/h2&gt;
&lt;p&gt;The problem with this was that we were mixing internally the service
description logic with the route registration one. The way we were doing this
was via an extensive use of decorators internally.&lt;/p&gt;
&lt;p&gt;The API of the &lt;cite&gt;cornice.service.Service&lt;/cite&gt; class was as following (simplified so
you can get the gist of it).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;service_kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# some information, such as the colander schemas (for validation),&lt;/span&gt;
&lt;span class="c1"&gt;# the defined methods that had been registered for this service and&lt;/span&gt;
&lt;span class="c1"&gt;# some other things were registered as instance variables.&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;schemas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;service_kwargs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;, None)&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defined_methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;definitions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;api&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;view_kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;This method is a decorator that is being used by some alias&lt;/span&gt;
&lt;span class="sd"&gt; methods.&lt;/span&gt;
&lt;span class="sd"&gt; &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wrapper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# all the logic goes here. And when I mean all the logic, I&lt;/span&gt;
&lt;span class="c1"&gt;# mean it.&lt;/span&gt;
&lt;span class="c1"&gt;# 1. we are registering a callback to the pyramid routing&lt;/span&gt;
&lt;span class="c1"&gt;# system so it gets called whenever the module using the&lt;/span&gt;
&lt;span class="c1"&gt;# decorator is used.&lt;/span&gt;
&lt;span class="c1"&gt;# 2. we are transforming the passed arguments so they conform&lt;/span&gt;
&lt;span class="c1"&gt;# to what is expected by the pyramid routing system.&lt;/span&gt;
&lt;span class="c1"&gt;# 3. We are storing some of the passed arguments into the&lt;/span&gt;
&lt;span class="c1"&gt;# object so we can retrieve them later on.&lt;/span&gt;
&lt;span class="c1"&gt;# 4. Also, we are transforming the passed view before&lt;/span&gt;
&lt;span class="c1"&gt;# registering it in the pyramid routing system so that it&lt;/span&gt;
&lt;span class="c1"&gt;# can do what Cornice wants it to do (checking some rules,&lt;/span&gt;
&lt;span class="c1"&gt;# applying validators and filters etc.&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;wrapper&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;A shortcut of the api decorator&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request_method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GET&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I encourage you to go read &lt;a class="reference external" href="https://github.com/mozilla-services/cornice/blob/4e0392a2ae137b6a11690459bcafd7325e86fa9e/cornice/service.py#L44"&gt;the entire file&lt;/a&gt;.
on github so you can get a better opinion on how all of this was done.&lt;/p&gt;
&lt;p&gt;A bunch of things are wrong:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;first, we are not separating the description logic from the registration one.
This causes problems when we need to access the parameters passed to the
service, because the parameters you get are not exactly the ones you passed
but the ones that the pyramid routing system is expecting. For instance, if
you want to get the view &lt;cite&gt;get_drink&lt;/cite&gt;, you will instead get a decorator which
contains this view.&lt;/li&gt;
&lt;li&gt;second, we are using decorators as APIs we expose. Even if decorators are
good as shortcuts, they shouldn't be the default way to deal with an API. A
good example of this is &lt;a class="reference external" href="https://github.com/mozilla-services/cornice/blob/4e0392a2ae137b6a11690459bcafd7325e86fa9e/cornice/resource.py#L56"&gt;how the resource module consumes this API&lt;/a&gt;.
This is quite hard to follow.&lt;/li&gt;
&lt;li&gt;Third, in the &lt;cite&gt;api&lt;/cite&gt; method, a bunch of things are done regarding inheritance
of parameters that are passed to the service or to its decorator methods.
This leaves you with a really hard to follow path when it comes to add new
parameters to your API.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="how-do-we-improve-this"&gt;
&lt;h2&gt;How do we improve this?&lt;/h2&gt;
&lt;p&gt;Python is great because it allows you to refactor things in an easy way. What I
did isn't breaking our APIs, but make things way simpler to hack-on. One
example is that it allowed me to add features that we wanted to bring to
Cornice really quickly (a matter of minutes), without touching the API that much.&lt;/p&gt;
&lt;p&gt;Here is the gist of the new architecture:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# we define class-level variables that will be the default values for&lt;/span&gt;
&lt;span class="c1"&gt;# this service. This makes things more extensible than it was before.&lt;/span&gt;
&lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;simplejson&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;default_validators&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DEFAULT_VALIDATORS&lt;/span&gt;
&lt;span class="n"&gt;default_filters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DEFAULT_FILTERS&lt;/span&gt;
&lt;span class="c1"&gt;# we also have some class-level parameters that are useful to know&lt;/span&gt;
&lt;span class="c1"&gt;# which parameters are supposed to be lists (and so converted as such)&lt;/span&gt;
&lt;span class="c1"&gt;# or which are mandatory.&lt;/span&gt;
&lt;span class="n"&gt;mandatory_arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;renderer&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;
&lt;span class="n"&gt;list_arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;validators&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;filters&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kw&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# setup name, path and description as instance variables&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;
&lt;span class="c1"&gt;# convert the arguments passed to something we want to store&lt;/span&gt;
&lt;span class="c1"&gt;# and then store them as attributes of the instance (because they&lt;/span&gt;
&lt;span class="c1"&gt;# were passed to the constructor&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_arguments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="nb"&gt;setattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# we keep having the defined_methods tuple and the list of&lt;/span&gt;
&lt;span class="c1"&gt;# definitions that are done for this service&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defined_methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;definitions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_arguments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Returns a dict of arguments. It does all the conversions for&lt;/span&gt;
&lt;span class="sd"&gt; you, and uses the information that were defined at the instance&lt;/span&gt;
&lt;span class="sd"&gt; level as fallbacks.&lt;/span&gt;
&lt;span class="sd"&gt; &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Add a view to this service.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="c1"&gt;# this is really simple and looks a lot like this&lt;/span&gt;
&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;definitions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defined_methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defined_methods&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;decorator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;This is only another interface to the add_view method, exposing a&lt;/span&gt;
&lt;span class="sd"&gt; decorator interface&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wrapper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;wrapper&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So, the service is now only storing the information that's passed to it and
nothing more. No more route registration logic goes here. Instead, I added this
as another feature, even in a different module. The function is named
&lt;cite&gt;register_service_views&lt;/cite&gt; and has the following signature:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;register_service_views&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To sum up, here are the changes I made:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Service description is now separated from the route registration.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;cornice.service.Service&lt;/cite&gt; now provides a &lt;cite&gt;hook_view&lt;/cite&gt; method, which is not a
decorator. decorators are still present but they are optional (you don't
need to use them if you don't want to).&lt;/li&gt;
&lt;li&gt;Everything has been decoupled as much as possible, meaning that you really
can use the &lt;cite&gt;Service&lt;/cite&gt; class as a container of information about the services
you are describing. This is especially useful when generating documentation.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As a result, it is now possible to use Cornice with other frameworks. It means
that you can stick with the service description but plug any other framework on
top of it. &lt;cite&gt;cornice.services.Service&lt;/cite&gt; is now only a description tool. To
register routes, one would need to read the information contained into this
service and inject the right parameters into their preferred routing system.&lt;/p&gt;
&lt;p&gt;However, no integration with other frameworks is done at the moment even if the
design allows it.&lt;/p&gt;
&lt;p&gt;The same way, the sphinx description layer is now only a consumer of this
service description tool: it looks at what's described and build-up the
documentation from it.&lt;/p&gt;
&lt;p&gt;The resulting branch is not merged yet. Still, you can &lt;a class="reference external" href="https://github.com/mozilla-services/cornice/tree/refactor-the-world"&gt;have a look at it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Any suggestions are of course welcome :-)&lt;/p&gt;
&lt;/div&gt;
</content><category term="python"></category><category term="Cornice"></category><category term="refactoring"></category></entry><entry><title>Thoughts about a form generation service, GIS enabled</title><link href="https://blog.notmyidea.org/carto-forms.html" rel="alternate"></link><published>2012-02-04T00:00:00+01:00</published><updated>2012-02-04T00:00:00+01:00</updated><author><name>Alexis Métaireau, Mathieu Leplatre</name></author><id>tag:blog.notmyidea.org,2012-02-04:/carto-forms.html</id><summary type="html">&lt;p&gt;We have a plan. A &amp;quot;fucking good&amp;quot; one.&lt;/p&gt;
&lt;p&gt;A bunch of friends asked me twice for quite the same thing: a webpage with a
form, tied to a map generation with some information filtering. They didn't
explicitly ask that but that's the gist of it.&lt;/p&gt;
&lt;p&gt;This idea has been stuck …&lt;/p&gt;</summary><content type="html">&lt;p&gt;We have a plan. A &amp;quot;fucking good&amp;quot; one.&lt;/p&gt;
&lt;p&gt;A bunch of friends asked me twice for quite the same thing: a webpage with a
form, tied to a map generation with some information filtering. They didn't
explicitly ask that but that's the gist of it.&lt;/p&gt;
&lt;p&gt;This idea has been stuck in my head since then and I even think that we can
come out with something a little bit more flexible and useful. I've named it
&lt;em&gt;carto-forms&lt;/em&gt; for now, but that's only the &amp;quot;codename&amp;quot;.&lt;/p&gt;
&lt;p&gt;To put it shortly: what if we had a way to build forms, ala Google forms, but
with geographic information in them?&lt;/p&gt;
&lt;p&gt;If you don't know Google forms, it means having an user-friendly way to build
forms and to use them to gather information from different users.&lt;/p&gt;
&lt;p&gt;In my opinion, Google forms is missing two important things: first, it's not
open-source, so it's not possible to hack it or even to run it on your own
server. Second, it doesn't really know how to deal with geographic data, and
there is no way to filter the information more than in a spreadsheet.&lt;/p&gt;
&lt;p&gt;I knew that &lt;a class="reference external" href="http://blog.mathieu-leplatre.info/"&gt;Mathieu&lt;/a&gt; and some folks at &lt;a class="reference external" href="http://makina-corpus.com"&gt;Makina Corpus&lt;/a&gt; would be interested
in this, so I started a discussion with him on IRC and we refined the details
of the project and its objectives.&lt;/p&gt;
&lt;p&gt;Imagine the following:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;For a mapping party, we choose a specific topic to map and design the form
(list of fields (i.e. tags) to be filled + description + type of the
information) ;&lt;/li&gt;
&lt;li&gt;In situ, users fill the form fields with what they see. Geo fields can be
pre-populated using device geolocation ;&lt;/li&gt;
&lt;li&gt;At the end of the day, we can see a map with all user contributions seized
through this particular form ;&lt;/li&gt;
&lt;li&gt;If relevant, a script could eventually import the resulting dataset and
publish/merge with OpenStreetMap.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="section" id="some-use-cases"&gt;
&lt;h2&gt;Some use cases&lt;/h2&gt;
&lt;p&gt;I can see some use cases for this. The first one is a collaborative map, with
facet filtering. Let's draw a potential user flow:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;An &amp;quot;administrator&amp;quot; goes to the website and creates a form to list all the
alternative-related events. He creates the following fields:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Name: a plain text field containing the name of the event.&lt;/li&gt;
&lt;li&gt;Category: the category of the event. Can be a finite list.&lt;/li&gt;
&lt;li&gt;Location: The location of the event. It could be provided by selecting a
point on a map or by typing an address.&lt;/li&gt;
&lt;li&gt;Date: the date of the event (a datepicker could do the trick)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each field in the form has semantic information associated with it (yes/no,
multiple selection, date-time, geocoding carto, carto selection etc)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Once finished, the form is generated and the user gets an url (say
&lt;a class="reference external" href="http://forms.notmyidea.org/alternatives"&gt;http://forms.notmyidea.org/alternatives&lt;/a&gt;) for it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;REST APIs allow third parties to get the form description and to
push/edit/get information from there.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;He can communicate the address in any way he wants to his community so they
can go to the page and add information to it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Then, it is possible to filter the results per location / date or category.
This can be done via API calls (useful for third parties) or via a nice
interface in the browser.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, as you may have noticed, this would allow us to create interactive maps really
easily. It's almost just a matter of some clicks to the users. If we also come
up with a nice Web API for this, we could do server-side validation and build
even phone applications easily.&lt;/p&gt;
&lt;p&gt;To push the cursor a bit further, if we can come with a cool description format
for the forms, we could even build the forms dynamically on different platforms,
with generic clients.&lt;/p&gt;
&lt;p&gt;As mentioned before, the idea of a simple tool to support collaborative mapping
fullfils a recurring necessity !&lt;/p&gt;
&lt;p&gt;We envision a lot of example uses for this : recycling spots, accessible spots (wheelchairs,
etc.), trees identification, mushrooms picking areas, tracking of endangered species
(e.g. Bonelli's Eagle is currently tracked by sharing a spreadsheet), spotting of dangerous
species (e.g. asian predatory wasps), map advertisement boards (most cities do not track them!),
citizen reporting (e.g. graffiti, potholes, garbage, lightning like &lt;a class="reference external" href="http://fixmystreet.ca"&gt;http://fixmystreet.ca&lt;/a&gt;),
geocaching, trajectories (e.g hiking, runners, cyclists)...&lt;/p&gt;
&lt;p&gt;Here are some other examples of where &lt;em&gt;carto-forms&lt;/em&gt; could be useful:&lt;/p&gt;
&lt;div class="section" id="simple-gis-storage-backend"&gt;
&lt;h3&gt;Simple GIS storage backend&lt;/h3&gt;
&lt;p&gt;Let's say you are a mobile developer, you don't want to bother with PostGIS
nor write a custom and insecure code to insert and retrieve your GIS data! You
need carto-forms! A simple API helps you design your models/forms and the
same API allows you to CRUD and query your data. Thus, you only need to focus
on your application, not on how GIS data will be handled.&lt;/p&gt;
&lt;p&gt;We make a distinction between storage and widgets.&lt;/p&gt;
&lt;p&gt;Besides, if you are a django / drupal / plomino... maintainer : you
can develop a module to &amp;quot;plug&amp;quot; your models (content types) and UI to carto-forms!
Carto forms are then exposed to your backoffice users (ex: drupal admin UI, django
adminsite), and likewise you can write your own HTML widgets that consume datasets
in frontend views (facets in JSON/XML, and map data in GeoJSON).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="visualization-tool"&gt;
&lt;h3&gt;Visualization tool&lt;/h3&gt;
&lt;p&gt;Since data submission can be done programmatically using the API, you could use Carto-forms
results page as a visualization tool.&lt;/p&gt;
&lt;p&gt;You can explore your dataset content using filters related to each form field. Facets filtering
is a great advantage, and a map shows the resulting features set. You feel like you're in
front of a decision support system!&lt;/p&gt;
&lt;p&gt;Of course, filtered raw data can be downloaded (GeoJSON, XML) and a permalink allows to
share the page with the state of the filters and the zoom/location of the map.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="generic-forms-service"&gt;
&lt;h3&gt;Generic forms service&lt;/h3&gt;
&lt;p&gt;If you want to generate a configuration file (or whatever, email messages, ...),
you will need a form and a template to inlay user submitted values and get the result.&lt;/p&gt;
&lt;p&gt;A form service would be really useful to create forms programmatically and retrieve
cleaned and validated input values.&lt;/p&gt;
&lt;p&gt;You could run a dedicated template service based on &lt;em&gt;carto-forms&lt;/em&gt;! Parsing a template
content, this external service could create a form dynamically and bind them together.
The output of the form service (fields =&amp;gt; values) would be bound to the input of a template
engine (variables =&amp;gt; final result).&lt;/p&gt;
&lt;p&gt;Note that for this use-case, there is no specific need of GIS data nor storage of records
for further retrieval.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-out-in-the-wild-already"&gt;
&lt;h2&gt;What's out in the wild already?&lt;/h2&gt;
&lt;p&gt;Of course, there is Google forms, which allows you to do these kind of things,
but it's closed and not exactly what we are describing here.&lt;/p&gt;
&lt;p&gt;We've discovered the interesting &lt;a class="reference external" href="https://webform.com/"&gt;https://webform.com/&lt;/a&gt; which allows one to create
forms with a nice drag-n-drop flow. I would love to reproduce something similar
for the user experience. However, the project doesn't handle APIs and
geolocation information.&lt;/p&gt;
&lt;p&gt;The idea of &lt;a class="reference external" href="http://thoth.io"&gt;http://thoth.io&lt;/a&gt; is very attractive : an extremely simple web API to store
and retrieve data. In addition, &lt;em&gt;carto-forms&lt;/em&gt; would do datatype validation and have
basic GIS fields (point, line, polygon).&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://mapbox.com"&gt;http://mapbox.com&lt;/a&gt; also did an awesome work on cartography, but didn't take into
account the form aspect we're leveraging here.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="so-let-s-get-it-real"&gt;
&lt;h2&gt;So… Let's get it real!&lt;/h2&gt;
&lt;p&gt;As you may have understood, this isn't a really complicated problem. We have
been sometimes chatting about that with Mathieu about what we would need and
how we could achieve this.&lt;/p&gt;
&lt;p&gt;We can probably come with an elegant solution without too much pain. Mathieu is
used to work with GIS systems (which is really cool because I'm not at all) and
knows his subject, so that's an opportunity to learn ;-)&lt;/p&gt;
&lt;p&gt;We will be at &lt;a class="reference external" href="http://rencontres.django-fr.org"&gt;Djangocong&lt;/a&gt; on April 14 and 15 and will probably have
a brainstorming session and a sprint on this, so if you are around and want to
help us, or just to discuss, feel free to join!&lt;/p&gt;
&lt;p&gt;We don't know yet if we will be using django for this or something else. We
have been thinking about couchdb, couchapps and geocouch but nothing is written
in stone yet. Comments and proposals are welcome!&lt;/p&gt;
&lt;p&gt;Here is the etherpad document we worked on so far:
&lt;a class="reference external" href="http://framapad.org/carto-forms"&gt;http://framapad.org/carto-forms&lt;/a&gt;. Don't hesitate to add your thoughts and edit
it, that's what it's made for!&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a class="reference external" href="http://sneakernet.fr/"&gt;Arnaud&lt;/a&gt; and &lt;a class="reference external" href="http://qwerty.fuzz.me.uk/"&gt;Fuzzmz&lt;/a&gt; for proof-reading and typo fixing.&lt;/p&gt;
&lt;/div&gt;
</content><category term="GIS"></category><category term="forms"></category></entry><entry><title>Using JPype to bridge python and Java</title><link href="https://blog.notmyidea.org/using-jpype-to-bridge-python-and-java.html" rel="alternate"></link><published>2011-11-06T00:00:00+01:00</published><updated>2011-11-06T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-11-06:/using-jpype-to-bridge-python-and-java.html</id><summary type="html">&lt;p&gt;Java provides some interesting libraries that have no exact equivalent in
python. In my case, the awesome boilerpipe library allows me to remove
uninteresting parts of HTML pages, like menus, footers and other &amp;quot;boilerplate&amp;quot;
contents.&lt;/p&gt;
&lt;p&gt;Boilerpipe is written in Java. Two solutions then: using java from python or
reimplement boilerpipe …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Java provides some interesting libraries that have no exact equivalent in
python. In my case, the awesome boilerpipe library allows me to remove
uninteresting parts of HTML pages, like menus, footers and other &amp;quot;boilerplate&amp;quot;
contents.&lt;/p&gt;
&lt;p&gt;Boilerpipe is written in Java. Two solutions then: using java from python or
reimplement boilerpipe in python. I will let you guess which one I chosen, meh.&lt;/p&gt;
&lt;p&gt;JPype allows to bridge python project with java libraries. It takes another
point of view than Jython: rather than reimplementing python in Java, both
languages are interfacing at the VM level. This means you need to start a VM
from your python script, but it does the job and stay fully compatible with
Cpython and its C extensions.&lt;/p&gt;
&lt;div class="section" id="first-steps-with-jpype"&gt;
&lt;h2&gt;First steps with JPype&lt;/h2&gt;
&lt;p&gt;Once JPype installed (you'll have to hack a bit some files to integrate
seamlessly with your system) you can access java classes by doing something
like that:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;jpype&lt;/span&gt;
&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startJVM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getDefaultJVMPath&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# you can then access to the basic java functions&lt;/span&gt;
&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;hello world&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# and you have to shutdown the VM at the end&lt;/span&gt;
&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shutdownJVM&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Okay, now we have a hello world, but what we want seems somehow more complex.
We want to interact with java classes, so we will have to load them.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="interfacing-with-boilerpipe"&gt;
&lt;h2&gt;Interfacing with Boilerpipe&lt;/h2&gt;
&lt;p&gt;To install boilerpipe, you just have to run an ant script:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ cd boilerpipe
$ ant
&lt;/pre&gt;
&lt;p&gt;Here is a simple example of how to use boilerpipe in Java, from their sources&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;de.l3s.boilerpipe.demo&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.net.URL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;de.l3s.boilerpipe.extractors.ArticleExtractor&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Oneliner&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="n"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;URL&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://notmyidea.org&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ArticleExtractor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To run it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ javac -cp dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar src/demo/de/l3s/boilerpipe/demo/Oneliner.java
$ java -cp src/demo:dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar de.l3s.boilerpipe.demo.Oneliner
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yes, this is kind of ugly, sorry for your eyes.
Let's try something similar, but from python&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;jpype&lt;/span&gt;
&lt;span class="c1"&gt;# start the JVM with the good classpaths&lt;/span&gt;
&lt;span class="n"&gt;classpath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar&amp;quot;&lt;/span&gt;
&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startJVM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getDefaultJVMPath&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-Djava.class.path=&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;classpath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# get the Java classes we want to use&lt;/span&gt;
&lt;span class="n"&gt;DefaultExtractor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JPackage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;de&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;l3s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;boilerpipe&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extractors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DefaultExtractor&lt;/span&gt;
&lt;span class="c1"&gt;# call them !&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;DefaultExtractor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jpype&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;http://blog.notmyidea.org&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And you get what you want.&lt;/p&gt;
&lt;p&gt;I must say I didn't thought it could work so easily. This will allow me to
extract text content from URLs and remove the &lt;em&gt;boilerplate&lt;/em&gt; text easily
for infuse (my master thesis project), without having to write java code, nice!&lt;/p&gt;
&lt;/div&gt;
</content><category term="python"></category><category term="java"></category></entry><entry><title>How are you handling your shared expenses?</title><link href="https://blog.notmyidea.org/how-are-you-handling-your-shared-expenses.html" rel="alternate"></link><published>2011-10-15T00:00:00+02:00</published><updated>2011-10-15T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-10-15:/how-are-you-handling-your-shared-expenses.html</id><summary type="html">&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; We're kick-starting a new application to manage your shared
expenses. Have a look at &lt;a class="reference external" href="http://ihatemoney.notmyidea.org"&gt;http://ihatemoney.notmyidea.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As a student, I lived in a lot of different locations, and the majority of them
had something in common: I lived with others. It usually was a great experience …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; We're kick-starting a new application to manage your shared
expenses. Have a look at &lt;a class="reference external" href="http://ihatemoney.notmyidea.org"&gt;http://ihatemoney.notmyidea.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As a student, I lived in a lot of different locations, and the majority of them
had something in common: I lived with others. It usually was a great experience
(and I think I will continue to live with others). Most of the time, we had to
spend some time each month to compute who had to pay what to the others.&lt;/p&gt;
&lt;p&gt;I wanted to create a pet project using flask, so I wrote a little
(~150 lines) flask application to handle this. It worked out pretty well for my
housemates and me, and as we had to move into different locations,
one of them asked me if he could continue to use it for the year to come.&lt;/p&gt;
&lt;p&gt;I said yes and gave it some more thoughts: We probably aren't the only ones
interested by such kind of software. I decided to extend a bit more the
software to have a concept of projects and persons (the list of persons was
hard-coded in the first time, boooh!).&lt;/p&gt;
&lt;p&gt;I then discussed with a friend of mine, who was excited about it and wanted to learn
python. Great! That's a really nice way to get started. Some more friends were also
interested in it and contributed some features and provided feedback (thanks
&lt;a class="reference external" href="http://www.sneakernet.fr/"&gt;Arnaud&lt;/a&gt; and Quentin!)&lt;/p&gt;
&lt;p&gt;Since that, the project now support multiple languages and provides a REST API
(android and iphone apps in the tubes!), into other things.
There is no need to register for an account or whatnot, just enter a project name,
a secret code and a contact email, invite friends and that's it (this was inspired by
doodle)!&lt;/p&gt;
&lt;img alt="Capture d'écran du site." src="images/ihatemoney.png" /&gt;
&lt;p&gt;You can try the project at &lt;a class="reference external" href="http://ihatemoney.notmyidea.org"&gt;http://ihatemoney.notmyidea.org&lt;/a&gt; for now, and the
code lives at &lt;a class="reference external" href="https://github.com/spiral-project/ihatemoney/"&gt;https://github.com/spiral-project/ihatemoney/&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="features"&gt;
&lt;h2&gt;Features&lt;/h2&gt;
&lt;p&gt;In the wild, currently, there already are some implementations of this shared
budget manager thing. The fact is that most of them are either hard to use, with
a too much fancy design or simply trying to do too much things at once.&lt;/p&gt;
&lt;p&gt;No, I don't want my budget manager to make my shopping list, or to run a blog for
me, thanks. I want it to let me focus on something else. Keep out of my way.&lt;/p&gt;
&lt;div class="section" id="no-user-registration"&gt;
&lt;h3&gt;No user registration&lt;/h3&gt;
&lt;p&gt;You don't need to register an account on the website to start using it. You
just have to create a project, set a secret code for it, and give both the url and
the code to the people you want to share it with (or the website can poke
them for you).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="keeping-things-simple"&gt;
&lt;h3&gt;Keeping things simple&lt;/h3&gt;
&lt;p&gt;&amp;quot;Keep It Simple, Stupid&amp;quot; really matches our philosophy here: you want to add a
bill? Okay. Just do it. You just have to enter who paid, for who, how much,
and a description, like you would have done when you're back from the
farmer's market on raw paper.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="no-categories"&gt;
&lt;h3&gt;No categories&lt;/h3&gt;
&lt;p&gt;Some people like to organise their stuff into different &amp;quot;categories&amp;quot;:
leisure, work, eating, etc. That's not something I want (at least to begin
with).&lt;/p&gt;
&lt;p&gt;I want things to be simple. Got that? Great. Just add your bills!&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="balance"&gt;
&lt;h3&gt;Balance&lt;/h3&gt;
&lt;p&gt;One of the most useful thing is to know what's your &amp;quot;balance&amp;quot; compared to
others. In other words, if you're negative, you owe money, if you're positive,
you have to receive money. This allows you to dispatch who has to pay for the
next thing, in order to re-equilibrate the balance.&lt;/p&gt;
&lt;p&gt;Additionally, the system is able to compute for you who has to give how
much to who, in order to reduce the number of transactions needed to restore
the balance.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="api"&gt;
&lt;h3&gt;API&lt;/h3&gt;
&lt;p&gt;All of what's possible to do with the standard web interface is also available
through a REST API. I developed a simple REST toolkit for flask for this (and
I should release it!).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="interested"&gt;
&lt;h2&gt;Interested?&lt;/h2&gt;
&lt;p&gt;This project is open source. All of us like to share what we are doing and
would be happy to work with new people and implement new ideas. If you have
a nice idea about this, if you want to tweak it or to fill bugs. Don't hesitate
a second! The project lives at &lt;a class="reference external" href="http://github.com/spiral-project/ihatemoney/"&gt;http://github.com/spiral-project/ihatemoney/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</content><category term="python"></category><category term="flask"></category><category term="budget-manager"></category></entry><entry><title>Using dbpedia to get languages influences</title><link href="https://blog.notmyidea.org/using-dbpedia-to-get-languages-influences.html" rel="alternate"></link><published>2011-08-16T00:00:00+02:00</published><updated>2011-08-16T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-08-16:/using-dbpedia-to-get-languages-influences.html</id><summary type="html">&lt;p&gt;While browsing the Python's wikipedia page, I found information about the languages
influenced by python, and the languages that influenced python itself.&lt;/p&gt;
&lt;p&gt;Well, that's kind of interesting to know which languages influenced others,
it could even be more interesting to have an overview of the connexion between
them, keeping python …&lt;/p&gt;</summary><content type="html">&lt;p&gt;While browsing the Python's wikipedia page, I found information about the languages
influenced by python, and the languages that influenced python itself.&lt;/p&gt;
&lt;p&gt;Well, that's kind of interesting to know which languages influenced others,
it could even be more interesting to have an overview of the connexion between
them, keeping python as the main focus.&lt;/p&gt;
&lt;p&gt;This information is available on the wikipedia page, but not in a really
exploitable format. Hopefully, this information is provided into the
information box present on the majority of wikipedia pages. And… guess what?
there is project with the goal to scrap and index all this information in
a more queriable way, using the semantic web technologies.&lt;/p&gt;
&lt;p&gt;Well, you may have guessed it, the project in question in dbpedia, and exposes
information in the form of RDF triples, which are way more easy to work with
than simple HTML.&lt;/p&gt;
&lt;p&gt;For instance, let's take the page about python:
&lt;a class="reference external" href="http://dbpedia.org/page/Python_%28programming_language%29"&gt;http://dbpedia.org/page/Python_%28programming_language%29&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The interesting properties here are &amp;quot;Influenced&amp;quot; and &amp;quot;InfluencedBy&amp;quot;, which
allows us to get a list of languages. Unfortunately, they are not really using
all the power of the Semantic Web here, and the list is actually a string with
coma separated values in it.&lt;/p&gt;
&lt;p&gt;Anyway, we can use a simple rule: All wikipedia pages of programming languages
are either named after the name of the language itself, or suffixed with &amp;quot;(
programming language)&amp;quot;, which is the case for python.&lt;/p&gt;
&lt;p&gt;So I've built &lt;a class="reference external" href="https://github.com/ametaireau/experiments/blob/master/influences/get_influences.py"&gt;a tiny script to extract the information from dbpedia&lt;/a&gt; and transform them into a shiny graph using graphviz.&lt;/p&gt;
&lt;p&gt;After a nice:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ python get_influences.py python dot | dot -Tpng &amp;gt; influences.png
&lt;/pre&gt;
&lt;p&gt;The result is the following graph (&lt;a class="reference external" href="http://files.lolnet.org/alexis/influences.png"&gt;see it directly here&lt;/a&gt;)&lt;/p&gt;
&lt;img alt="Graph des influances des langages les uns sur les autres." src="http://files.lolnet.org/alexis/influences.png" style="width: 800px;" /&gt;
&lt;p&gt;While reading this diagram, keep in mind that it is a) not listing all the
languages and b) keeping a python perspective.&lt;/p&gt;
&lt;p&gt;This means that you can trust the scheme by following the arrows from python to
something and from something to python, it is not trying to get the matching
between all the languages at the same time to keep stuff readable.&lt;/p&gt;
&lt;p&gt;It would certainly be possible to have all the connections between all
languages (and the resulting script would be easier) to do so, but the resulting
graph would probably be way less readable.&lt;/p&gt;
&lt;p&gt;You can find the script &lt;a class="reference external" href="https://github.com/ametaireau/experiments"&gt;on my github account&lt;/a&gt;. Feel free to adapt it for
whatever you want if you feel hackish.&lt;/p&gt;
</content><category term="dbpedia"></category><category term="sparql"></category><category term="python"></category></entry><entry><title>Pelican, 9 months later</title><link href="https://blog.notmyidea.org/pelican-9-months-later.html" rel="alternate"></link><published>2011-07-25T00:00:00+02:00</published><updated>2011-07-25T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-07-25:/pelican-9-months-later.html</id><summary type="html">&lt;p&gt;Back in October, I released &lt;a class="reference external" href="http://docs.notmyidea.org/alexis/pelican"&gt;pelican&lt;/a&gt;,
a little piece of code I wrote to power this weblog. I had simple needs: I wanted
to be able to use my text editor of choice (vim), a vcs (mercurial) and
restructured text. I started to write a really simple blog engine
in …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Back in October, I released &lt;a class="reference external" href="http://docs.notmyidea.org/alexis/pelican"&gt;pelican&lt;/a&gt;,
a little piece of code I wrote to power this weblog. I had simple needs: I wanted
to be able to use my text editor of choice (vim), a vcs (mercurial) and
restructured text. I started to write a really simple blog engine
in something like a hundred python lines and released it on github.&lt;/p&gt;
&lt;p&gt;And people started contributing. I wasn't at all expecting to see people
interested in such a little piece of code, but it turned out that they were.
I refactored the code to make it evolve a bit more by two times and eventually,
in 9 months, got 49 forks, 139 issues and 73 pull requests.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Which is clearly awesome.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I pulled features such as translations, tag
clouds, integration with different services such as twitter or piwik, import
from dotclear and rss, fixed
a number of mistakes and improved a lot the codebase. This was a proof that
there is a bunch of people that are willing to make better softwares just for
the sake of fun.&lt;/p&gt;
&lt;p&gt;Thank you, guys, you're why I like open source so much.&lt;/p&gt;
</content><category term="pelican"></category><category term="python"></category><category term="open source"></category><category term="nice story"></category></entry><entry><title>Introducing Cornice</title><link href="https://blog.notmyidea.org/introducing-cornice.html" rel="alternate"></link><published>2011-07-12T00:00:00+02:00</published><updated>2011-07-12T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-07-12:/introducing-cornice.html</id><summary type="html">&lt;p&gt;Wow, already my third working day at Mozilla. Since Monday, I've been working with
&lt;a class="reference external" href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt;, on a pyramid REST-ish toolkit named &lt;a class="reference external" href="https://github.com/mozilla-services/cornice"&gt;Cornice&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Its goal is to take care for you of what you're usually missing so you can
focus on what's important. Cornice provides you facilities
for validation of …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Wow, already my third working day at Mozilla. Since Monday, I've been working with
&lt;a class="reference external" href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt;, on a pyramid REST-ish toolkit named &lt;a class="reference external" href="https://github.com/mozilla-services/cornice"&gt;Cornice&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Its goal is to take care for you of what you're usually missing so you can
focus on what's important. Cornice provides you facilities
for validation of any kind.&lt;/p&gt;
&lt;p&gt;The goal is to simplify your work, but we don't want to reinvent the wheel, so
it is easily pluggable with validations frameworks, such as &lt;a class="reference external" href="http://docs.pylonsproject.org/projects/colander/en/latest/"&gt;Colander&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="handling-errors-and-validation"&gt;
&lt;h2&gt;Handling errors and validation&lt;/h2&gt;
&lt;p&gt;Here is how it works:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;service&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/service&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_awesome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;query&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;the awesome parameter is required&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@service.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;is_awesome&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;yay!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;All the errors collected during the validation process, or after, are collected
before returning the request. If any, a error 400 is fired up, with the list of
problems encountered returned as a nice json list response (we plan to support
multiple formats in the future)&lt;/p&gt;
&lt;p&gt;As you might have seen, &lt;cite&gt;request.errors.add&lt;/cite&gt; takes three parameters: &lt;strong&gt;location&lt;/strong&gt;,
&lt;strong&gt;name&lt;/strong&gt; and &lt;strong&gt;description&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;location&lt;/strong&gt; is where the error is located in the request. It can either be &amp;quot;body&amp;quot;,
&amp;quot;query&amp;quot;, &amp;quot;headers&amp;quot; or &amp;quot;path&amp;quot;. &lt;strong&gt;name&lt;/strong&gt; is the name of the variable causing
problem, if any, and &lt;strong&gt;description&lt;/strong&gt; contains a more detailed message.&lt;/p&gt;
&lt;p&gt;Let's run this simple service and send some queries to it:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ curl -v http://127.0.0.1:5000/service
&amp;gt; GET /service HTTP/1.1
&amp;gt; Host: 127.0.0.1:5000
&amp;gt; Accept: */*
&amp;gt;
* HTTP 1.0, assume close after body
&amp;lt; HTTP/1.0 400 Bad Request
&amp;lt; Content-Type: application/json; charset=UTF-8
[{&amp;quot;location&amp;quot;: &amp;quot;query&amp;quot;, &amp;quot;name&amp;quot;: &amp;quot;awesome&amp;quot;, &amp;quot;description&amp;quot;: &amp;quot;You lack awesomeness!&amp;quot;}
&lt;/pre&gt;
&lt;p&gt;I've removed the extra clutter from the curl's output, but you got the general idea.&lt;/p&gt;
&lt;p&gt;The content returned is in JSON, and I know exactly what I have to do: add an
&amp;quot;awesome&amp;quot; parameter in my query. Let's do it again:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ curl http://127.0.0.1:5000/service?awesome=yeah
{&amp;quot;test&amp;quot;: &amp;quot;yay!&amp;quot;}
&lt;/pre&gt;
&lt;p&gt;Validators can also convert parts of the request and store the converted value
in &lt;cite&gt;request.validated&lt;/cite&gt;. It is a standard dict automatically attached to the
requests.&lt;/p&gt;
&lt;p&gt;For instance, in our validator, we can chose to validate the parameter passed
and use it in the body of the webservice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;service&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/service&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_awesome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;query&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;the awesome parameter is required&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;validated&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;awesome &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nd"&gt;@service.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;is_awesome&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;validated&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;awesome&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output would look like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
curl http://127.0.0.1:5000/service?awesome=yeah
{&amp;quot;test&amp;quot;: &amp;quot;awesome yeah&amp;quot;}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="dealing-with-accept-headers"&gt;
&lt;h2&gt;Dealing with &amp;quot;Accept&amp;quot; headers&lt;/h2&gt;
&lt;p&gt;The HTTP spec defines a &lt;strong&gt;Accept&lt;/strong&gt; header the client can send so the response
is encoded the right way. A resource, available at an URL, can be available in
different formats. This is especially true for web services.&lt;/p&gt;
&lt;p&gt;Cornice can help you dealing with this. The services you define can tell which
&lt;cite&gt;Content-Type&lt;/cite&gt; values they can deal with and this will be checked against the
&lt;strong&gt;Accept&lt;/strong&gt; headers sent by the client.&lt;/p&gt;
&lt;p&gt;Let's refine a bit our previous example, by specifying which content-types are
supported, using the &lt;cite&gt;accept&lt;/cite&gt; parameter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nd"&gt;@service.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;is_awesome&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;accept&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;text/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;yay!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, if you specifically ask for XML, Cornice will throw a 406 with the list of
accepted &lt;cite&gt;Content-Type&lt;/cite&gt; values:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ curl -vH &amp;quot;Accept: application/xml&amp;quot; http://127.0.0.1:5000/service
&amp;gt; GET /service HTTP/1.1
&amp;gt; Host: 127.0.0.1:5000
&amp;gt; Accept: application/xml
&amp;gt;
&amp;lt; HTTP/1.0 406 Not Acceptable
&amp;lt; Content-Type: application/json; charset=UTF-8
&amp;lt; Content-Length: 33
&amp;lt;
[&amp;quot;application/json&amp;quot;, &amp;quot;text/json&amp;quot;]
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="building-your-documentation-automatically"&gt;
&lt;h2&gt;Building your documentation automatically&lt;/h2&gt;
&lt;p&gt;writing documentation for web services can be painful, especially when your
services evolve. Cornice provides a sphinx directive to automatically document
your API in your docs.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt; &lt;span class="ow"&gt;services&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;
&lt;span class="nc"&gt;:package:&lt;/span&gt; &lt;span class="nf"&gt;coolapp&lt;/span&gt;
&lt;span class="nc"&gt;:service:&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is an example of what a generated page looks like: &lt;a class="reference external" href="http://packages.python.org/cornice/exampledoc.html"&gt;http://packages.python.org/cornice/exampledoc.html&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="yay-how-can-i-get-it"&gt;
&lt;h2&gt;Yay! How can I get it?&lt;/h2&gt;
&lt;p&gt;We just cut a 0.4 release, so it's available at &lt;a class="reference external" href="http://pypi.python.org/pypi/cornice"&gt;http://pypi.python.org/pypi/cornice&lt;/a&gt;
You can install it easily using &lt;cite&gt;pip&lt;/cite&gt;, for instance:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ pip install cornice
&lt;/pre&gt;
&lt;p&gt;You can also have a look at the documentation at
&lt;a class="reference external" href="http://packages.python.org/cornice/"&gt;http://packages.python.org/cornice/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-next"&gt;
&lt;h2&gt;What's next?&lt;/h2&gt;
&lt;p&gt;We try to make our best to find how Cornice can help you build better
web services. Cool features we want for the future include the automatic
publication of a static definition of the services, so it can be used by clients
to discover services in a nice way.&lt;/p&gt;
&lt;p&gt;Of course, we are open to all your ideas and patches! If you feel haskish and
want to see the sources, &lt;a class="reference external" href="https://github.com/mozilla-services/cornice"&gt;go grab them on github&lt;/a&gt;
, commit and send us a pull request!&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Un coup de main pour mon mémoire!</title><link href="https://blog.notmyidea.org/un-coup-de-main-pour-mon-memoire-fr.html" rel="alternate"></link><published>2011-05-25T00:00:00+02:00</published><updated>2011-05-25T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-05-25:/un-coup-de-main-pour-mon-memoire-fr.html</id><summary type="html">&lt;p&gt;Ça y est, bientôt la fin. LA FIN. La fin des études, et le début du reste.
En attendant je bosse sur mon mémoire de fin d'études et j'aurais besoin d'un petit
coup de main.&lt;/p&gt;
&lt;p&gt;Mon mémoire porte sur les systèmes de recommandation. Pour ceux qui connaissent
last.fm, je …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ça y est, bientôt la fin. LA FIN. La fin des études, et le début du reste.
En attendant je bosse sur mon mémoire de fin d'études et j'aurais besoin d'un petit
coup de main.&lt;/p&gt;
&lt;p&gt;Mon mémoire porte sur les systèmes de recommandation. Pour ceux qui connaissent
last.fm, je fais quelque chose de similaire mais pour les sites internet: en me
basant sur ce que vous visitez quotidiennement et comment vous le visitez (quelles
horaires, quelle emplacement géographique, etc.) je souhaites proposer des liens
qui vous intéresseront potentiellement, en me basant sur l'avis des personnes qui
ont des profils similaires au votre.&lt;/p&gt;
&lt;p&gt;Le projet est loin d'être terminé, mais la première étape est de récupérer des
données de navigation, idéalement beaucoup de données de navigation. Donc si
vous pouvez me filer un coup de main je vous en serais éternellement
reconnaissant (pour ceux qui font semblant de pas comprendre, entendez &amp;quot;tournée
générale&amp;quot;).&lt;/p&gt;
&lt;p&gt;J'ai créé un petit site web (en anglais) qui résume un peu le concept, qui vous
propose de vous inscrire et de télécharger un plugin firefox qui m'enverra des
information sur les sites que vous visitez (si vous avez l'habitude d'utiliser
chrome vous pouvez considérer de switcher à firefox4 pour les deux prochains
mois pour me filer un coup de main). Il est possible de désactiver le plugin
d'un simple clic si vous souhaitez garder votre vie privée privée ;-)&lt;/p&gt;
&lt;p&gt;Le site est par là: &lt;a class="reference external" href="http://infuse.notmyidea.org"&gt;http://infuse.notmyidea.org&lt;/a&gt;. Une fois le plugin téléchargé
et le compte créé il faut renseigner vos identifiants dans le plugin en
question, et c'est tout!&lt;/p&gt;
&lt;p&gt;A votre bon cœur ! Je récupérerais probablement des données durant les 2
prochains mois pour ensuite les analyser correctement.&lt;/p&gt;
&lt;p&gt;Merci pour votre aide !&lt;/p&gt;
</content></entry><entry><title>Analyse users' browsing context to build up a web recommender</title><link href="https://blog.notmyidea.org/analyse-users-browsing-context-to-build-up-a-web-recommender.html" rel="alternate"></link><published>2011-04-01T00:00:00+02:00</published><updated>2011-04-01T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-04-01:/analyse-users-browsing-context-to-build-up-a-web-recommender.html</id><summary type="html">&lt;p&gt;No, this is not an april's fool ;)&lt;/p&gt;
&lt;p&gt;Wow, it's been a long time. My year in Oxford is going really well. I realized
few days ago that the end of the year is approaching really quickly.
Exams are coming in one month or such and then I'll be working full …&lt;/p&gt;</summary><content type="html">&lt;p&gt;No, this is not an april's fool ;)&lt;/p&gt;
&lt;p&gt;Wow, it's been a long time. My year in Oxford is going really well. I realized
few days ago that the end of the year is approaching really quickly.
Exams are coming in one month or such and then I'll be working full time on my dissertation topic.&lt;/p&gt;
&lt;p&gt;When I learned we'll have about 6 month to work on something, I first thought
about doing a packaging related stuff, but finally decided to start something
new. After all, that's the good time to learn.&lt;/p&gt;
&lt;p&gt;Since a long time, I'm being impressed by the &lt;a class="reference external" href="http://last.fm"&gt;last.fm&lt;/a&gt;
recommender system. They're &lt;em&gt;scrobbling&lt;/em&gt; the music I listen to since something
like 5 years now and the recommendations they're doing are really nice and
accurate (I discovered &lt;strong&gt;a lot&lt;/strong&gt; of great artists listening to the
&amp;quot;neighbour radio&amp;quot;.) (by the way, &lt;a class="reference external" href="http://lastfm.com/user/akounet/"&gt;here is&lt;/a&gt;
my lastfm account)&lt;/p&gt;
&lt;p&gt;So I decided to work on recommender systems, to better understand what is it
about.&lt;/p&gt;
&lt;p&gt;Recommender systems are usually used to increase the sales of products
(like Amazon.com does) which is not really what I'm looking for (The one who
know me a bit know I'm kind of sick about all this consumerism going on).&lt;/p&gt;
&lt;p&gt;Actually, the most simple thing I thought of was the web: I'm browsing it quite
every day and each time new content appears. I've stopped to follow &lt;a class="reference external" href="https://bitbucket.org/bruno/aspirator/"&gt;my feed
reader&lt;/a&gt; because of the
information overload, and reduced drastically the number of people I follow &lt;a class="reference external" href="http://twitter.com/ametaireau/"&gt;on
twitter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Too much information kills the information.&lt;/p&gt;
&lt;p&gt;You shall got what will be my dissertation topic: a recommender system for
the web. Well, such recommender systems already exists, so I will try to add contextual
information to them: you're probably not interested by the same topics at different
times of the day, or depending on the computer you're using. We can also
probably make good use of the way you browse to create groups into the content
you're browsing (or even use the great firefox4 tab group feature).&lt;/p&gt;
&lt;p&gt;There is a large part of concerns to have about user's privacy as well.&lt;/p&gt;
&lt;p&gt;Here is my proposal (copy/pasted from the one I had to do for my master)&lt;/p&gt;
&lt;div class="section" id="introduction-and-rationale"&gt;
&lt;h2&gt;Introduction and rationale&lt;/h2&gt;
&lt;p&gt;Nowadays, people surf the web more and more often. New web pages are created
each day so the amount of information to retrieve is more important as the time
passes. These users uses the web in different contexts, from finding cooking
recipes to technical articles.&lt;/p&gt;
&lt;p&gt;A lot of people share the same interest to various topics, and the quantity of
information is such than it's really hard to triage them efficiently without
spending hours doing it. Firstly because of the huge quantity of information
but also because the triage is something relative to each person. Although, this
triage can be facilitated by fetching the browsing information of all
particular individuals and put the in perspective.&lt;/p&gt;
&lt;p&gt;Machine learning is a branch of Artificial Intelligence (AI) which deals with how
a program can learn from data. Recommendation systems are a particular
application area of machine learning which is able to recommend things (links
in our case) to the users, given a particular database containing the previous
choices users have made.&lt;/p&gt;
&lt;p&gt;This browsing information is currently available in browsers. Even if it is not
in a very usable format, it is possible to transform it to something useful.
This information gold mine just wait to be used. Although, it is not as simple as
it can seems at the first approach: It is important to take care of the context
the user is in while browsing links. For instance, It's more likely that during
the day, a computer scientist will browse computing related links, and that during
the evening, he browse cooking recipes or something else.&lt;/p&gt;
&lt;p&gt;Page contents are also interesting to analyse, because that's what people
browse and what actually contain the most interesting part of the information.
The raw data extracted from the browsing can then be translated into
something more useful (namely tags, type of resource, visit frequency,
navigation context etc.)&lt;/p&gt;
&lt;p&gt;The goal of this dissertation is to create a recommender system for web links,
including this context information.&lt;/p&gt;
&lt;p&gt;At the end of the dissertation, different pieces of software will be provided,
from raw data collection from the browser to a recommendation system.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="background-review"&gt;
&lt;h2&gt;Background Review&lt;/h2&gt;
&lt;p&gt;This dissertation is mainly about data extraction, analysis and recommendation
systems. Two different research area can be isolated: Data preprocessing and
Information filtering.&lt;/p&gt;
&lt;p&gt;The first step in order to make recommendations is to gather some data. The
more data we have available, the better it is (T. Segaran, 2007). This data can
be retrieved in various ways, one of them is to get it directly from user's
browsers.&lt;/p&gt;
&lt;div class="section" id="data-preparation-and-extraction"&gt;
&lt;h3&gt;Data preparation and extraction&lt;/h3&gt;
&lt;p&gt;The data gathered from browsers is basically URLs and additional information
about the context of the navigation. There is clearly a need to extract more
information about the meaning of the data the user is browsing, starting by the
content of the web pages.&lt;/p&gt;
&lt;p&gt;Because the information provided on the current Web is not meant to be read by
machines (T. Berners Lee, 2001) there is a need of tools to extract meaning from
web pages. The information needs to be preprocessed before stored in a machine
readable format, allowing to make recommendations (Choochart et Al, 2004).&lt;/p&gt;
&lt;p&gt;Data preparation is composed of two steps: cleaning and structuring (
Castellano et Al, 2007). Because raw data can contain a lot of un-needed text
(such as menus, headers etc.) and need to be cleaned prior to be stored.
Multiple techniques can be used here and belongs to boilerplate removal and
full text extraction (Kohlschütter et Al, 2010).&lt;/p&gt;
&lt;p&gt;Then, structuring the information: category, type of content (news, blog, wiki)
can be extracted from raw data. This kind of information is not clearly defined
by HTML pages so there is a need of tools to recognise them.&lt;/p&gt;
&lt;p&gt;Some context-related information can also be inferred from each resource. It can go
from the visit frequency to the navigation group the user was in while
browsing. It is also possible to determine if the user &amp;quot;liked&amp;quot; a resource, and
determine a mark for it, which can be used by information filtering a later
step (T. Segaran, 2007).&lt;/p&gt;
&lt;p&gt;At this stage, structuring the data is required. Storing this kind of
information in RDBMS can be a bit tedious and require complex queries to get
back the data in an usable format. Graph databases can play a major role in the
simplification of information storage and querying.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="information-filtering"&gt;
&lt;h3&gt;Information filtering&lt;/h3&gt;
&lt;p&gt;To filter the information, three techniques can be used (Balabanovic et
Al, 1997):&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The content-based approach states that if an user have liked something in the
past, he is more likely to like similar things in the future. So it's about
establishing a profile for the user and compare new items against it.&lt;/li&gt;
&lt;li&gt;The collaborative approach will rather recommend items that other similar users
have liked. This approach consider only the relationship between users, and
not the profile of the user we are making recommendations to.&lt;/li&gt;
&lt;li&gt;the hybrid approach, which appeared recently combine both of the previous
approaches, giving recommendations when items score high regarding user's
profile, or if a similar user already liked it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grouping is also something to consider at this stage (G. Myatt, 2007).
Because we are dealing with huge amount of data, it can be useful to detect group
of data that can fit together. Data clustering is able to find such groups (T.
Segaran, 2007).&lt;/p&gt;
&lt;p&gt;References:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Balabanović, M., &amp;amp; Shoham, Y. (1997). Fab: content-based, collaborative
recommendation. Communications of the ACM, 40(3), 6672. ACM.
Retrieved March 1, 2011, from &lt;a class="reference external" href="http://portal.acm.org/citation.cfm?id=245108.245124&amp;amp;amp"&gt;http://portal.acm.org/citation.cfm?id=245108.245124&amp;amp;amp&lt;/a&gt;;.&lt;/li&gt;
&lt;li&gt;Berners-Lee, T., Hendler, J., &amp;amp; Lassila, O. (2001).
The semantic web: Scientific american. Scientific American, 284(5), 3443.
Retrieved November 21, 2010, from &lt;a class="reference external" href="http://www.citeulike.org/group/222/article/1176986"&gt;http://www.citeulike.org/group/222/article/1176986&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Castellano, G., Fanelli, A., &amp;amp; Torsello, M. (2007).
LODAP: a LOg DAta Preprocessor for mining Web browsing patterns. Proceedings of the 6th Conference on 6th WSEAS Int. Conf. on Artificial Intelligence, Knowledge Engineering and Data Bases-Volume 6 (p. 1217). World Scientific and Engineering Academy and Society (WSEAS). Retrieved March 8, 2011, from &lt;a class="reference external" href="http://portal.acm.org/citation.cfm?id=1348485.1348488"&gt;http://portal.acm.org/citation.cfm?id=1348485.1348488&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Kohlschutter, C., Fankhauser, P., &amp;amp; Nejdl, W. (2010). Boilerplate detection using shallow text features. Proceedings of the third ACM international conference on Web search and data mining (p. 441450). ACM. Retrieved March 8, 2011, from &lt;a class="reference external" href="http://portal.acm.org/citation.cfm?id=1718542"&gt;http://portal.acm.org/citation.cfm?id=1718542&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Myatt, G. J. (2007). Making Sense of Data: A Practical Guide to Exploratory
Data Analysis and Data Mining.&lt;/li&gt;
&lt;li&gt;Segaran, T. (2007). Collective Intelligence.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="privacy"&gt;
&lt;h2&gt;Privacy&lt;/h2&gt;
&lt;p&gt;The first thing that's come to people minds when it comes to process their
browsing data is privacy. People don't want to be stalked. That's perfectly
right, and I don't either.&lt;/p&gt;
&lt;p&gt;But such a system don't have to deal with people identities. It's completely
possible to process completely anonymous data, and that's probably what I'm
gonna do.&lt;/p&gt;
&lt;p&gt;By the way, if you have interesting thoughts about that, if you do know
projects that do seems related, fire the comments !&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-the-plan"&gt;
&lt;h2&gt;What's the plan ?&lt;/h2&gt;
&lt;p&gt;There is a lot of different things to explore, especially because I'm
a complete novice in that field.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;I want to develop a firefox plugin, to extract the browsing informations (
still, I need to know exactly which kind of informations to retrieve). The
idea is to provide some &lt;em&gt;raw&lt;/em&gt; browsing data, and then to transform it and to
store it in the better possible way.&lt;/li&gt;
&lt;li&gt;Analyse how to store the informations in a graph database. What can be the
different methods to store this data and to visualize the relationship
between different pieces of data? How can I define the different contexts,
and add those informations in the db?&lt;/li&gt;
&lt;li&gt;Process the data using well known recommendation algorithms. Compare the
results and criticize their value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is plenty of stuff I want to try during this experimentation:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;I want to try using Geshi to visualize the connexion between the links,
and the contexts&lt;/li&gt;
&lt;li&gt;Try using graph databases such as Neo4j&lt;/li&gt;
&lt;li&gt;Having a deeper look at tools such as scikit.learn (a machine learning
toolkit in python)&lt;/li&gt;
&lt;li&gt;Analyse web pages in order to categorize them. Processing their
contents as well, to do some keyword based classification will be done.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lot of work on its way, yay !&lt;/p&gt;
&lt;/div&gt;
</content><category term="recommendations"></category><category term="browsers"></category><category term="users"></category></entry><entry><title>Working directly on your server? How to backup and sync your dev environment with unison</title><link href="https://blog.notmyidea.org/working-directly-on-your-server-how-to-backup-and-sync-your-dev-environment-with-unison.html" rel="alternate"></link><published>2011-03-16T00:00:00+01:00</published><updated>2011-03-16T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-03-16:/working-directly-on-your-server-how-to-backup-and-sync-your-dev-environment-with-unison.html</id><summary type="html">&lt;p&gt;I have a server running freebsd since some time now, and was wondering about
the possibility to directly have a development environment ready to use when
I get a internet connexion, even if I'm not on my computer.&lt;/p&gt;
&lt;p&gt;Since I use vim to code, and spend most of my time …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I have a server running freebsd since some time now, and was wondering about
the possibility to directly have a development environment ready to use when
I get a internet connexion, even if I'm not on my computer.&lt;/p&gt;
&lt;p&gt;Since I use vim to code, and spend most of my time in a console while
developing, it's possible to work via ssh, from everywhere.&lt;/p&gt;
&lt;p&gt;The only problem is the synchronisation of the source code, config files etc.
from my machine to the server.&lt;/p&gt;
&lt;p&gt;Unison provides an interesting way to synchronise two folders, even over
a network. So let's do it !&lt;/p&gt;
&lt;div class="section" id="creating-the-jail"&gt;
&lt;h2&gt;Creating the jail&lt;/h2&gt;
&lt;p&gt;In case you don't use FreeBSD, you can skip this section.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# I have a flavour jail named default&lt;/span&gt;
$ ezjail-admin -f default workspace.notmyidea.org &lt;span class="m"&gt;172&lt;/span&gt;.19.1.6
$ ezjail-admin start workspace.notmyidea.org
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In my case, because the &amp;quot;default&amp;quot; flavour contains already a lot of interesting
things, my jail come already setup with ssh, bash and vim for instance, but
maybe you'll need it in your case.&lt;/p&gt;
&lt;p&gt;I want to be redirected to the ssh of the jail when I connect to the host with
the 20006 port. Add lines in &lt;cite&gt;/etc/pf.conf&lt;/cite&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
workspace_jail=&amp;quot;172.19.1.6&amp;quot;
rdr on $ext_if proto tcp from any to $ext_ip port 20006 -&amp;gt; $workspace_jail port 22
&lt;/pre&gt;
&lt;p&gt;Reload packet filter rules&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ /etc/rc.d/pf reload
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="working-with-unison"&gt;
&lt;h2&gt;Working with unison&lt;/h2&gt;
&lt;p&gt;Now that we've set up the jail. Set up unison on the server and on your client.
Unison is available on the freebsd ports so just install it&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ssh notmyidea.org -p &lt;span class="m"&gt;20006&lt;/span&gt;
$ make -C /usr/ports/net/unison-nox11 config-recursive
$ make -C /usr/ports/net/unison-nox11 package-recursive
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Install as well unison on your local machine. Double check to install the same
version on the client and on the server. Ubuntu contains the 2.27.57 as well as
the 2.32.52.&lt;/p&gt;
&lt;p&gt;Check that unison is installed and reachable via ssh from your machine&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ssh notmyidea.org -p &lt;span class="m"&gt;20006&lt;/span&gt; unison -version
unison version &lt;span class="m"&gt;2&lt;/span&gt;.27.157
$ unison -version
unison version &lt;span class="m"&gt;2&lt;/span&gt;.27.57
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="let-sync-our-folders"&gt;
&lt;h2&gt;Let sync our folders&lt;/h2&gt;
&lt;p&gt;The first thing I want to sync is my vim configuration. Well, it's already &lt;a class="reference external" href="http://github.com/ametaireau/dotfiles/"&gt;in
a git repository&lt;/a&gt; but let's try to use
unison for it right now.&lt;/p&gt;
&lt;p&gt;I have two machines then: &lt;cite&gt;workspace&lt;/cite&gt;, the jail, and &lt;cite&gt;ecureuil&lt;/cite&gt; my laptop.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;unison .vim ssh://notmyidea.org:20006/.vim
unison .vimrc ssh://notmyidea.org:20006/.vimrc
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is also possible to put all the informations in a config file, and then to
only run &lt;cite&gt;unison&lt;/cite&gt;. (fire up &lt;cite&gt;vim ~/.unison/default.prf&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;Here is my config:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
root = /home/alexis
root = ssh://notmyidea.org:20006
path = .vimrc
path = dotfiles
path = dev
follow = Name *
&lt;/pre&gt;
&lt;p&gt;My vimrc is in fact a symbolic link on my laptop, but I don't want to specify
each of the links to unison. That's why the &lt;cite&gt;follow = Name *&lt;/cite&gt; is for.&lt;/p&gt;
&lt;p&gt;The folders you want to synchronize are maybe a bit large. If so, considering
others options such as rsync for the first import may be a good idea (I enjoyed
my university huge upload bandwith to upload 2GB in 20mn ;)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="run-the-script-frequently"&gt;
&lt;h2&gt;Run the script frequently&lt;/h2&gt;
&lt;p&gt;Once that done, you just need to run the unison command line some times when
you want to sync your two machines. I've wrote a tiny script to get some
feedback from the sync:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="n"&gt;DEFAULT_LOGFILE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;~/unison.log&amp;quot;&lt;/span&gt;
&lt;span class="n"&gt;PROGRAM_NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Unison syncer&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;DEFAULT_LOGFILE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROGRAM_NAME&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="c1"&gt;# init&lt;/span&gt;
&lt;span class="n"&gt;display_message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="n"&gt;before&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;# call unison to make the sync&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;unison -batch &amp;gt; {0}&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logfile&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# get the duration of the operation&lt;/span&gt;
&lt;span class="n"&gt;td&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;before&lt;/span&gt;
&lt;span class="n"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;microseconds&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="c1"&gt;# check what was the last entry in the log&lt;/span&gt;
&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expanduser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logfile&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;No updates to propagate&amp;#39;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
&lt;span class="n"&gt;display_message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Synchronization&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot; It took {0}s.&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;display_message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;notify-send -i {2} &amp;quot;{0}&amp;quot; &amp;quot;{1}&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;program_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;error&amp;#39;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;info&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is probably perfectible, but that does the job.&lt;/p&gt;
&lt;p&gt;Last step is to tell you machine to run that frequently. That's what &lt;cite&gt;crontab&lt;/cite&gt;
is made for, so let's &lt;cite&gt;crontab -e&lt;/cite&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ * */3 * * * . ~/.Xdbus; /usr/bin/python /home/alexis/dev/python/unison-syncer/sync.py
&lt;/pre&gt;
&lt;p&gt;The &lt;cite&gt;~/.Xdbus&lt;/cite&gt; allows cron to communicate with your X11 session. Here is its
content.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c1"&gt;# Get the pid of nautilus&lt;/span&gt;
&lt;span class="nv"&gt;nautilus_pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;pgrep -u &lt;span class="nv"&gt;$LOGNAME&lt;/span&gt; -n nautilus&lt;span class="k"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# If nautilus isn&amp;#39;t running, just exit silently&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$nautilus_pid&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="c1"&gt;# Grab the DBUS_SESSION_BUS_ADDRESS variable from nautilus&amp;#39;s environment&lt;/span&gt;
&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="k"&gt;$(&lt;/span&gt;tr &lt;span class="s1"&gt;&amp;#39;\0&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;\n&amp;#39;&lt;/span&gt; &amp;lt; /proc/&lt;span class="nv"&gt;$nautilus_pid&lt;/span&gt;/environ &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;&amp;#39;^DBUS_SESSION_BUS_ADDRESS=&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Check that we actually found it&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$DBUS_SESSION_BUS_ADDRESS&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Failed to find bus address&amp;quot;&lt;/span&gt; &amp;gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="c1"&gt;# export it so that child processes will inherit it&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; DBUS_SESSION_BUS_ADDRESS
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And it comes from &lt;a class="reference external" href="http://ubuntuforums.org/showthread.php?p=10148738#post10148738"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A sync takes about 20s + the upload time on my machine, which stay acceptable for
all of my developments.&lt;/p&gt;
&lt;/div&gt;
</content><category term="freebsd"></category><category term="unison"></category></entry><entry><title>Wrap up of the distutils2 paris' sprint</title><link href="https://blog.notmyidea.org/wrap-up-of-the-distutils2-paris-sprint.html" rel="alternate"></link><published>2011-02-08T00:00:00+01:00</published><updated>2011-02-08T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-02-08:/wrap-up-of-the-distutils2-paris-sprint.html</id><summary type="html">&lt;p&gt;Finally, thanks to a bunch of people that helped me to pay my train and bus
tickets, I've made it to paris for the distutils2 sprint.&lt;/p&gt;
&lt;p&gt;They have been a bit more than 10 people to come during the sprint, and it was
very productive. Here's a taste of what …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Finally, thanks to a bunch of people that helped me to pay my train and bus
tickets, I've made it to paris for the distutils2 sprint.&lt;/p&gt;
&lt;p&gt;They have been a bit more than 10 people to come during the sprint, and it was
very productive. Here's a taste of what we've been working on:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the &lt;cite&gt;datafiles&lt;/cite&gt;, a way to specify and to handle the installation of files which
are not python-related (pictures, manpages and so on).&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;mkgcfg&lt;/cite&gt;, a tool to help you to create a setup.cfg in minutes (and with funny
examples)&lt;/li&gt;
&lt;li&gt;converters from setup.py scripts. We do now have a piece of code which
reads your current &lt;cite&gt;setup.py&lt;/cite&gt; file and fill in some fields in the &lt;cite&gt;setup.cfg&lt;/cite&gt;
for you.&lt;/li&gt;
&lt;li&gt;a compatibility layer for distutils1, so it can read the &lt;cite&gt;setup.cfg&lt;/cite&gt; you will
wrote for distutils2 :-)&lt;/li&gt;
&lt;li&gt;the uninstaller, so it's now possible to uninstall what have been installed
by distutils2 (see PEP 376)&lt;/li&gt;
&lt;li&gt;the installer, and the setuptools compatibility layer, which will allow you
to rely on setuptools' based distributions (and there are plenty of them!)&lt;/li&gt;
&lt;li&gt;The compilers, so they are more flexible than they were. Since that's an
obscure part of the code for distutils2 commiters (it comes directly from the
distutils1 ages), having some guys who understood the problematics here was
a must.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some people have also tried to port their packaging from distutils1 to
distutils2. They have spotted a number of bugs and made some improvements
to the code, to make it more friendly to use.&lt;/p&gt;
&lt;p&gt;I'm really pleased to see how newcomers went trough the code, and started
hacking so fast. I must say it wasn't the case when we started to work on
distutils1 so that's a very good point: people now can hack the code quicker
than they could before.&lt;/p&gt;
&lt;p&gt;Some of the features here are not &lt;em&gt;completely&lt;/em&gt; finished yet, but are on the
tubes, and will be ready for a release (hopefully) at the end of the week.&lt;/p&gt;
&lt;p&gt;Big thanks to logilab for hosting (and sponsoring my train ticket) and
providing us food, and to bearstech for providing some money for breakfast and
bears^Wbeers.&lt;/p&gt;
&lt;p&gt;Again, a big thanks to all the people who gave me money to pay the transport,
I really wasn't expecting such thing to happen :-)&lt;/p&gt;
</content></entry><entry><title>PyPI on CouchDB</title><link href="https://blog.notmyidea.org/pypi-on-couchdb.html" rel="alternate"></link><published>2011-01-20T00:00:00+01:00</published><updated>2011-01-20T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-01-20:/pypi-on-couchdb.html</id><summary type="html">&lt;p&gt;By now, there are two ways to retrieve data from PyPI (the Python Package
Index). You can both rely on xml/rpc or on the &amp;quot;simple&amp;quot; API. The simple
API is not so simple to use as the name suggest, and have several existing
drawbacks.&lt;/p&gt;
&lt;p&gt;Basically, if you want to …&lt;/p&gt;</summary><content type="html">&lt;p&gt;By now, there are two ways to retrieve data from PyPI (the Python Package
Index). You can both rely on xml/rpc or on the &amp;quot;simple&amp;quot; API. The simple
API is not so simple to use as the name suggest, and have several existing
drawbacks.&lt;/p&gt;
&lt;p&gt;Basically, if you want to use informations coming from the simple API, you will
have to parse web pages manually, to extract informations using some black
vodoo magic. Badly, magic have a price, and it's sometimes impossible to get
exactly the informations you want to get from this index. That's the technique
currently being used by distutils2, setuptools and pip.&lt;/p&gt;
&lt;p&gt;On the other side, while XML/RPC is working fine, it's requiring extra work
to the python servers each time you request something, which can lead to
some outages from time to time. Also, it's important to point out that, even if
PyPI have a mirroring infrastructure, it's only for the so-called &lt;em&gt;simple&lt;/em&gt; API,
and not for the XML/RPC.&lt;/p&gt;
&lt;div class="section" id="couchdb"&gt;
&lt;h2&gt;CouchDB&lt;/h2&gt;
&lt;p&gt;Here comes CouchDB. CouchDB is a document oriented database, that
knows how to speak REST and JSON. It's easy to use, and provides out of the box
a replication mechanism.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="so-what"&gt;
&lt;h2&gt;So, what ?&lt;/h2&gt;
&lt;p&gt;Hmm, I'm sure you got it. I've wrote a piece of software to link informations from
PyPI to a CouchDB instance. Then you can replicate all the PyPI index with only
one HTTP request on the CouchDB server. You can also access the informations
from the index directly using a REST API, speaking json. Handy.&lt;/p&gt;
&lt;p&gt;So PyPIonCouch is using the PyPI XML/RPC API to get data from PyPI, and
generate records in the CouchDB instance.&lt;/p&gt;
&lt;p&gt;The final goal is to avoid to rely on this &amp;quot;simple&amp;quot; API, and rely on a REST
insterface instead. I have set up a couchdb server on my server, which is
available at &lt;a class="reference external" href="http://couchdb.notmyidea.org/_utils/database.html?pypi"&gt;http://couchdb.notmyidea.org/_utils/database.html?pypi&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There is not a lot to
see there for now, but I've done the first import from PyPI yesterday and all
went fine: it's possible to access the metadata of all PyPI projects via a REST
interface. Next step is to write a client for this REST interface in
distutils2.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="example"&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;For now, you can use pypioncouch via the command line, or via the python API.&lt;/p&gt;
&lt;div class="section" id="using-the-command-line"&gt;
&lt;h3&gt;Using the command line&lt;/h3&gt;
&lt;p&gt;You can do something like that for a full import. This &lt;strong&gt;will&lt;/strong&gt; take long,
because it's fetching all the projects at pypi and importing their metadata:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ pypioncouch --fullimport http://your.couchdb.instance/
&lt;/pre&gt;
&lt;p&gt;If you already have the data on your couchdb instance, you can just update it
with the last informations from pypi. &lt;strong&gt;However, I recommend to just replicate
the principal node, hosted at http://couchdb.notmyidea.org/pypi/&lt;/strong&gt;, to avoid
the duplication of nodes:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ pypioncouch --update http://your.couchdb.instance/
&lt;/pre&gt;
&lt;p&gt;The principal node is updated once a day by now, I'll try to see if it's
enough, and ajust with the time.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="using-the-python-api"&gt;
&lt;h3&gt;Using the python API&lt;/h3&gt;
&lt;p&gt;You can also use the python API to interact with pypioncouch:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;gt;&amp;gt;&amp;gt; from pypioncouch import XmlRpcImporter, import_all, update
&amp;gt;&amp;gt;&amp;gt; full_import()
&amp;gt;&amp;gt;&amp;gt; update()
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-next"&gt;
&lt;h2&gt;What's next ?&lt;/h2&gt;
&lt;p&gt;I want to make a couchapp, in order to navigate PyPI easily. Here are some of
the features I want to propose:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;List all the available projects&lt;/li&gt;
&lt;li&gt;List all the projects, filtered by specifiers&lt;/li&gt;
&lt;li&gt;List all the projects by author/maintainer&lt;/li&gt;
&lt;li&gt;List all the projects by keywords&lt;/li&gt;
&lt;li&gt;Page for each project.&lt;/li&gt;
&lt;li&gt;Provide a PyPI &amp;quot;Simple&amp;quot; API equivalent, even if I want to replace it, I do
think it will be really easy to setup mirrors that way, with the out of the
box couchdb replication&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I also still need to polish the import mechanism, so I can directly store in
couchdb:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The OPML files for each project&lt;/li&gt;
&lt;li&gt;The upload_time as couchdb friendly format (list of int)&lt;/li&gt;
&lt;li&gt;The tags as lists (currently it's only a string separated by spaces&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The work I've done by now is available on
&lt;a class="reference external" href="https://bitbucket.org/ametaireau/pypioncouch/"&gt;https://bitbucket.org/ametaireau/pypioncouch/&lt;/a&gt;. Keep in mind that it's still
a work in progress, and everything can break at any time. However, any feedback
will be appreciated !&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Help me to go to the distutils2 paris' sprint</title><link href="https://blog.notmyidea.org/help-me-to-go-to-the-distutils2-paris-sprint.html" rel="alternate"></link><published>2011-01-15T00:00:00+01:00</published><updated>2011-01-15T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-01-15:/help-me-to-go-to-the-distutils2-paris-sprint.html</id><summary type="html">&lt;p&gt;&lt;strong&gt;Edit: Thanks to logilab and some amazing people, I can make it to paris for the
sprint. Many thanks to them for the support!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There will be a distutils2 sprint from the 27th to the 30th of january, thanks
to logilab which will host the event.&lt;/p&gt;
&lt;p&gt;You can find more …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Edit: Thanks to logilab and some amazing people, I can make it to paris for the
sprint. Many thanks to them for the support!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There will be a distutils2 sprint from the 27th to the 30th of january, thanks
to logilab which will host the event.&lt;/p&gt;
&lt;p&gt;You can find more informations about the sprint on the wiki page of the event
(&lt;a class="reference external" href="http://wiki.python.org/moin/Distutils/SprintParis"&gt;http://wiki.python.org/moin/Distutils/SprintParis&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I really want to go there but I'm unfortunately blocked in UK for money reasons.
The cheapest two ways I've found is about £80, which I can't afford.
Following some advices on #distutils, I've set up a ChipIn account for that, so
if some people want to help me making it to go there, they can give me some
money that way.&lt;/p&gt;
&lt;p&gt;I'll probably work on the installer (to support old distutils and
setuptools distributions) and on the uninstaller (depending on the first
task). If I can't make it to paris, I'll hang around on IRC to give some help
while needed.&lt;/p&gt;
&lt;p&gt;If you want to contribute some money to help me go there, feel free to use this
chipin page: &lt;a class="reference external" href="http://ametaireau.chipin.com/distutils2-sprint-in-paris"&gt;http://ametaireau.chipin.com/distutils2-sprint-in-paris&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your support !&lt;/p&gt;
</content></entry><entry><title>How to reboot your bebox using the CLI</title><link href="https://blog.notmyidea.org/how-to-reboot-your-bebox-using-the-cli.html" rel="alternate"></link><published>2010-10-21T00:00:00+02:00</published><updated>2010-10-21T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-21:/how-to-reboot-your-bebox-using-the-cli.html</id><summary type="html">&lt;p&gt;I've an internet connection which, for some obscure reasons, tend to be very
slow from time to time. After rebooting the box (yes, that's a hard solution),
all the things seems to go fine again.&lt;/p&gt;
&lt;div class="section" id="edit-using-grep"&gt;
&lt;h2&gt;EDIT : Using grep&lt;/h2&gt;
&lt;p&gt;After a bit of reflexion, that's also really easy to do using …&lt;/p&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;I've an internet connection which, for some obscure reasons, tend to be very
slow from time to time. After rebooting the box (yes, that's a hard solution),
all the things seems to go fine again.&lt;/p&gt;
&lt;div class="section" id="edit-using-grep"&gt;
&lt;h2&gt;EDIT : Using grep&lt;/h2&gt;
&lt;p&gt;After a bit of reflexion, that's also really easy to do using directly the
command line tools curl, grep and tail (but really harder to read).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;curl -X POST -u joel:joel http://bebox.config/cgi/b/info/restart/&lt;span class="se"&gt;\?&lt;/span&gt;be&lt;span class="se"&gt;\=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="se"&gt;\&amp;amp;&lt;/span&gt;l0&lt;span class="se"&gt;\=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="se"&gt;\&amp;amp;&lt;/span&gt;l1&lt;span class="se"&gt;\=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="se"&gt;\&amp;amp;&lt;/span&gt;tid&lt;span class="se"&gt;\=&lt;/span&gt;RESTART -d &lt;span class="s2"&gt;&amp;quot;0=17&amp;amp;2=`curl -u joel:joel http://bebox.config/cgi/b/info/restart/\?be\=0\&amp;amp;l0\=1\&amp;amp;l1\=0\&amp;amp;tid\=RESTART | grep -o &amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;2&amp;#39;&lt;/span&gt; &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;-9&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="se"&gt;\+&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; | grep -o &amp;quot;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;-9&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="se"&gt;\+&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; | tail -n 1`&amp;amp;1&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="the-python-version"&gt;
&lt;h2&gt;The Python version&lt;/h2&gt;
&lt;p&gt;Well, that's not the optimal solution, that's a bit &amp;quot;gruik&amp;quot;, but it works.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;urllib2&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;urlparse&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;argparse&lt;/span&gt;
&lt;span class="n"&gt;REBOOT_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/b/info/restart/?be=0&amp;amp;l0=1&amp;amp;l1=0&amp;amp;tid=RESTART&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;BOX_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://bebox.config/cgi&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;open_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;passman&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTTPPasswordMgrWithDefaultRealm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;passman&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_password&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;authhandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTTPBasicAuthHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passman&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;opener&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build_opener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authhandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;install_opener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opener&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reboot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;open_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;name\=&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;2&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39; value=&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;([0-9]+)&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;urllib2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;0=17&amp;amp;2=&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s1"&gt;&amp;amp;1&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__file__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArgumentParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;Reboot your bebox !&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;boxurl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;boxurl&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;BOX_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Base box url. Default is &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;BOX_URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urlparse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urljoin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;boxurl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;REBOOT_URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;reboot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
</content></entry><entry><title>Dynamically change your gnome desktop wallpaper</title><link href="https://blog.notmyidea.org/dynamically-change-your-gnome-desktop-wallpaper.html" rel="alternate"></link><published>2010-10-11T00:00:00+02:00</published><updated>2010-10-11T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-11:/dynamically-change-your-gnome-desktop-wallpaper.html</id><summary type="html">&lt;p&gt;In gnome, you can can use a XML file to have a dynamic wallpaper.
It's not so easy, and you can't just tell: use the pictures in this folder to do
so.&lt;/p&gt;
&lt;p&gt;You can have a look to the git repository if you want: &lt;a class="reference external" href="http://github.com/ametaireau/gnome-background-generator"&gt;http://github.com/ametaireau/gnome-background-generator&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Some …&lt;/p&gt;</summary><content type="html">&lt;p&gt;In gnome, you can can use a XML file to have a dynamic wallpaper.
It's not so easy, and you can't just tell: use the pictures in this folder to do
so.&lt;/p&gt;
&lt;p&gt;You can have a look to the git repository if you want: &lt;a class="reference external" href="http://github.com/ametaireau/gnome-background-generator"&gt;http://github.com/ametaireau/gnome-background-generator&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Some time ago, I've made a little python script to ease that, and you can now
use it too. It's named &amp;quot;gnome-background-generator&amp;quot;, and you can install it via
pip for instance.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pip install gnome-background-generator
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, you have just to use it this way:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ gnome-background-generator -p ~/Images/walls -s
/home/alexis/Images/walls/dynamic-wallpaper.xml generated
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is a extract of the &lt;cite&gt;--help&lt;/cite&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ gnome-background-generator --help
usage: gnome-background-generator &lt;span class="o"&gt;[&lt;/span&gt;-h&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-p PATH&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-o OUTPUT&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;-t TRANSITION_TIME&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-d DISPLAY_TIME&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-s&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;-b&lt;span class="o"&gt;]&lt;/span&gt;
A simple &lt;span class="nb"&gt;command&lt;/span&gt; line tool to generate an XML file to use &lt;span class="k"&gt;for&lt;/span&gt; gnome
wallpapers, to have dynamic walls
optional arguments:
-h, --help show this &lt;span class="nb"&gt;help&lt;/span&gt; message and &lt;span class="nb"&gt;exit&lt;/span&gt;
-p PATH, --path PATH Path to look &lt;span class="k"&gt;for&lt;/span&gt; the pictures. If no output is
specified, will be used too &lt;span class="k"&gt;for&lt;/span&gt; outputing the dynamic-
wallpaper.xml file. Default value is the current
directory &lt;span class="o"&gt;(&lt;/span&gt;.&lt;span class="o"&gt;)&lt;/span&gt;
-o OUTPUT, --output OUTPUT
Output filename. If no filename is specified, a
dynamic-wallpaper.xml file will be generated in the
path containing the pictures. You can also use &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt; to
display the xml in the stdout.
-t TRANSITION_TIME, --transition-time TRANSITION_TIME
Time &lt;span class="o"&gt;(&lt;/span&gt;in seconds&lt;span class="o"&gt;)&lt;/span&gt; transitions must last &lt;span class="o"&gt;(&lt;/span&gt;default value
is &lt;span class="m"&gt;2&lt;/span&gt; seconds&lt;span class="o"&gt;)&lt;/span&gt;
-d DISPLAY_TIME, --display-time DISPLAY_TIME
Time &lt;span class="o"&gt;(&lt;/span&gt;in seconds&lt;span class="o"&gt;)&lt;/span&gt; a picture must be displayed. Default
value is &lt;span class="m"&gt;900&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;15mn&lt;span class="o"&gt;)&lt;/span&gt;
-s, --set-background &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;try to &lt;span class="nb"&gt;set&lt;/span&gt; the background using gnome-appearance-
properties
-b, --debug
&lt;/pre&gt;&lt;/div&gt;
</content></entry><entry><title>How to install NGINX + PHP 5.3 on FreeBSD.</title><link href="https://blog.notmyidea.org/how-to-install-nginx-php-53-on-freebsd.html" rel="alternate"></link><published>2010-10-10T00:00:00+02:00</published><updated>2010-10-10T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-10:/how-to-install-nginx-php-53-on-freebsd.html</id><summary type="html">&lt;p&gt;I've not managed so far to get completely rid of php, so here's a simple
reminder about how to install php on NGINX, for FreeBSD. Nothing hard, but
that's worse to have the piece of configuration somewhere !&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# update the ports
$ portsnap fetch update
# install php5 port
$ make config-recursive -C /usr …&lt;/pre&gt;</summary><content type="html">&lt;p&gt;I've not managed so far to get completely rid of php, so here's a simple
reminder about how to install php on NGINX, for FreeBSD. Nothing hard, but
that's worse to have the piece of configuration somewhere !&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# update the ports
$ portsnap fetch update
# install php5 port
$ make config-recursive -C /usr/ports/lang/php5-extensions
$ make package-recursive -C /usr/ports/lang/php5-extensions
# install nginx
$ make config-recursive -C /usr/ports/www/nginx-devel
$ make package-recursive -C /usr/ports/www/nginx-devel
&lt;/pre&gt;
&lt;p&gt;Now we have all the dependencies installed, we need to configure a bit the
server.&lt;/p&gt;
&lt;p&gt;That's a simple thing in fact, but it could be good to have something that will
work without effort over time.&lt;/p&gt;
&lt;p&gt;Here's a sample of my configuration:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
server {
server_name ndd;
set $path /path/to/your/files;
root $path;
location / {
index index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
}
location ~ .php$ {
fastcgi_param SCRIPT_FILENAME $path$fastcgi_script_name;
fastcgi_pass backend;
include fastcgi_params;
}
}
upstream backend {
server 127.0.0.1:9000;
}
&lt;/pre&gt;
&lt;p&gt;And that's it !&lt;/p&gt;
</content></entry><entry><title>Pelican, a simple static blog generator in python</title><link href="https://blog.notmyidea.org/pelican-a-simple-static-blog-generator-in-python.html" rel="alternate"></link><published>2010-10-06T00:00:00+02:00</published><updated>2010-10-06T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-10-06:/pelican-a-simple-static-blog-generator-in-python.html</id><summary type="html">&lt;p&gt;Those days, I've wrote a little python application to fit my blogging needs.
I'm an occasional blogger, a vim lover, I like restructured text and DVCSes, so
I've made a little tool that makes good use of all that.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://docs.getpelican.com"&gt;Pelican&lt;/a&gt; (for calepin) is just a simple tool to generate your …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Those days, I've wrote a little python application to fit my blogging needs.
I'm an occasional blogger, a vim lover, I like restructured text and DVCSes, so
I've made a little tool that makes good use of all that.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://docs.getpelican.com"&gt;Pelican&lt;/a&gt; (for calepin) is just a simple tool to generate your blog as static
files, letting you using your editor of choice (vim!). It's easy to extend,
and has a template support (via jinja2).&lt;/p&gt;
&lt;p&gt;I've made it to fit &lt;em&gt;my&lt;/em&gt; needs. I hope it will fit yours, but maybe it wont, and
it have not be designed to feet everyone's needs.&lt;/p&gt;
&lt;p&gt;Need an example ? You're looking at it ! This weblog is using pelican to be
generated, also for the atom feeds.&lt;/p&gt;
&lt;p&gt;I've released it under AGPL, since I want all the modifications to be profitable
to all the users.&lt;/p&gt;
&lt;p&gt;You can find a repository to fork at &lt;a class="reference external" href="https://github.com/getpelican/pelican/"&gt;https://github.com/getpelican/pelican/&lt;/a&gt;.
feel free to hack it !&lt;/p&gt;
&lt;p&gt;If you just want to get started, use your installer of choice (pip, easy_install, …)
And then have a look to the help (&lt;cite&gt;pelican --help&lt;/cite&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pip install pelican
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="usage"&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;Here's a sample usage of pelican&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pelican .
writing /home/alexis/projets/notmyidea.org/output/index.html
writing /home/alexis/projets/notmyidea.org/output/tags.html
writing /home/alexis/projets/notmyidea.org/output/categories.html
writing /home/alexis/projets/notmyidea.org/output/archives.html
writing /home/alexis/projets/notmyidea.org/output/category/python.html
writing
/home/alexis/projets/notmyidea.org/output/pelican-a-simple-static-blog-generator-in-python.html
Done !
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You also can use the &lt;cite&gt;--help&lt;/cite&gt; option for the command line to get more
informations&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;$pelican&lt;/span&gt; --help
usage: pelican &lt;span class="o"&gt;[&lt;/span&gt;-h&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-t TEMPLATES&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-o OUTPUT&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-m MARKUP&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-s SETTINGS&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;-b&lt;span class="o"&gt;]&lt;/span&gt;
path
A tool to generate a static blog, with restructured text input files.
positional arguments:
path Path where to find the content files &lt;span class="o"&gt;(&lt;/span&gt;default is
&lt;span class="s2"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;.
optional arguments:
-h, --help show this &lt;span class="nb"&gt;help&lt;/span&gt; message and &lt;span class="nb"&gt;exit&lt;/span&gt;
-t TEMPLATES, --templates-path TEMPLATES
Path where to find the templates. If not specified,
will uses the ones included with pelican.
-o OUTPUT, --output OUTPUT
Where to output the generated files. If not specified,
a directory will be created, named &lt;span class="s2"&gt;&amp;quot;output&amp;quot;&lt;/span&gt; in the
current path.
-m MARKUP, --markup MARKUP
the markup language to use. Currently only
ReSTreucturedtext is available.
-s SETTINGS, --settings SETTINGS
the settings of the application. Default to None.
-b, --debug
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>An amazing summer of code working on distutils2</title><link href="https://blog.notmyidea.org/an-amazing-summer-of-code-working-on-distutils2.html" rel="alternate"></link><published>2010-08-16T00:00:00+02:00</published><updated>2010-08-16T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-08-16:/an-amazing-summer-of-code-working-on-distutils2.html</id><summary type="html">&lt;p&gt;The &lt;a class="reference external" href="http://code.google.com/soc/"&gt;Google Summer of Code&lt;/a&gt; I've
spent working on &lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;
is over. It was a really amazing experience, for many reasons.&lt;/p&gt;
&lt;p&gt;First of all, we had a very good team, we were 5 students working
on distutils2: &lt;a class="reference external" href="http://zubin71.wordpress.com"&gt;Zubin&lt;/a&gt;,
&lt;a class="reference external" href="http://wokslog.wordpress.com/"&gt;Éric&lt;/a&gt;,
&lt;a class="reference external" href="http://gsoc.djolonga.com/"&gt;Josip&lt;/a&gt;,
&lt;a class="reference external" href="http://konryd.blogspot.com/"&gt;Konrad&lt;/a&gt; and me. In addition,
&lt;a class="reference external" href="http://mouadino.blogspot.com/"&gt;Mouad&lt;/a&gt; have worked on the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The &lt;a class="reference external" href="http://code.google.com/soc/"&gt;Google Summer of Code&lt;/a&gt; I've
spent working on &lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;
is over. It was a really amazing experience, for many reasons.&lt;/p&gt;
&lt;p&gt;First of all, we had a very good team, we were 5 students working
on distutils2: &lt;a class="reference external" href="http://zubin71.wordpress.com"&gt;Zubin&lt;/a&gt;,
&lt;a class="reference external" href="http://wokslog.wordpress.com/"&gt;Éric&lt;/a&gt;,
&lt;a class="reference external" href="http://gsoc.djolonga.com/"&gt;Josip&lt;/a&gt;,
&lt;a class="reference external" href="http://konryd.blogspot.com/"&gt;Konrad&lt;/a&gt; and me. In addition,
&lt;a class="reference external" href="http://mouadino.blogspot.com/"&gt;Mouad&lt;/a&gt; have worked on the PyPI
testing infrastructure. You could find what each person have done
on
&lt;a class="reference external" href="http://bitbucket.org/tarek/distutils2/wiki/GSoC_2010_teams"&gt;the wiki page of distutils2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We were in contact with each others really often, helping us when
possible (in #distutils), and were continuously aware of the state
of the work of each participant. This, in my opinion, have bring us
in a good shape.&lt;/p&gt;
&lt;p&gt;Then, I've learned a lot. Python packaging was completely new to me
at the time of the GSoC start, and I was pretty unfamiliar with
python good practices too, as I've been introducing myself to
python in the late 2009.&lt;/p&gt;
&lt;p&gt;I've recently looked at some python code I wrote just three months
ago, and I was amazed to think about many improvements to made on
it. I guess this is a good indicator of the path I've traveled
since I wrote it.&lt;/p&gt;
&lt;p&gt;This summer was awesome because I've learned about python good
practices, now having some strong
&lt;a class="reference external" href="http://mercurial.selenic.com/"&gt;mercurial&lt;/a&gt; knowledge, and I've
seen a little how the python community works.&lt;/p&gt;
&lt;p&gt;Then, I would like to say a big thanks to all the mentors that have
hanged around while needed, on IRC or via mail, and especially my
mentor for this summer, &lt;a class="reference external" href="http://tarek.ziade.org"&gt;Tarek Ziadé&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks a lot for your motivation, your leadership and your
cheerfulness, even with a new-born and a new work!&lt;/p&gt;
&lt;div class="section" id="why"&gt;
&lt;h2&gt;Why ?&lt;/h2&gt;
&lt;p&gt;I wanted to work on python packaging because, as the time pass, we
were having a sort of complex tools in this field. Each one wanted
to add features to distutils, but not in a standard way.&lt;/p&gt;
&lt;p&gt;Now, we have PEPs that describes some format we agreed on (see PEP
345), and we wanted to have a tool on which users can base their
code on, that's &lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="my-job"&gt;
&lt;h2&gt;My job&lt;/h2&gt;
&lt;p&gt;I had to provide a way to crawl the PyPI indexes in a simple way,
and do some installation / uninstallation scripts.&lt;/p&gt;
&lt;p&gt;All the work done is available in
&lt;a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/"&gt;my bitbucket repository&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="crawling-the-pypi-indexes"&gt;
&lt;h3&gt;Crawling the PyPI indexes&lt;/h3&gt;
&lt;p&gt;There are two ways of requesting informations from the indexes:
using the &amp;quot;simple&amp;quot; index, that is a kind of REST index, and using
XML-RPC.&lt;/p&gt;
&lt;p&gt;I've done the two implementations, and a high level API to query
those twos. Basically, this supports the mirroring infrastructure
defined in PEP 381. So far, the work I've done is gonna be used in
pip (they've basically copy/paste the code, but this will change as
soon as we get something completely stable for distutils2), and
that's a good news, as it was the main reason for what I've done
that.&lt;/p&gt;
&lt;p&gt;I've tried to have an unified API for the clients, to switch from
one to another implementation easily. I'm already thinking of
adding others crawlers to this stuff, and it was made to be
extensible.&lt;/p&gt;
&lt;p&gt;If you want to get more informations about the crawlers/PyPI
clients, please refer to the distutils2 documentation, especially
&lt;a class="reference external" href="http://distutils2.notmyidea.org/library/distutils2.index.html"&gt;the pages about indexes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can find the changes I made about this in the
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt; source code .&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="installation-uninstallation-scripts"&gt;
&lt;h3&gt;Installation / Uninstallation scripts&lt;/h3&gt;
&lt;p&gt;Next step was to think about an installation script, and an
uninstaller. I've not done the uninstaller part, and it's a smart
part, as it's basically removing some files from the system, so
I'll probably do it in a near future.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt; provides a way to
install distributions, and to handle dependencies between releases.
For now, this support is only about the last version of the
METADATA (1.2) (See, the PEP 345), but I'm working on a
compatibility layer for the old metadata, and for the informations
provided via PIP requires.txt, for instance.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="extra-work"&gt;
&lt;h3&gt;Extra work&lt;/h3&gt;
&lt;p&gt;Also, I've done some extra work. this includes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;working on the PEP 345, and having some discussion about it
(about the names of some fields).&lt;/li&gt;
&lt;li&gt;writing a PyPI server mock, useful for tests. you can find more
information about it on the
&lt;a class="reference external" href="http://distutils.notmyidea.org"&gt;documentation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="futures-plans"&gt;
&lt;h2&gt;Futures plans&lt;/h2&gt;
&lt;p&gt;As I said, I've enjoyed working on distutils2, and the people I've
met here are really pleasant to work with. So I &lt;em&gt;want&lt;/em&gt; to continue
contributing on python, and especially on python packaging, because
there is still a lot of things to do in this scope, to get
something really usable.&lt;/p&gt;
&lt;p&gt;I'm not plainly satisfied by the work I've done, so I'll probably
tweak it a bit: the installer part is not yet completely finished,
and I want to add support for a real
&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Representational_State_Transfer"&gt;REST&lt;/a&gt;
index in the future.&lt;/p&gt;
&lt;p&gt;We'll talk again of this in the next months, probably, but we
definitely need a real
&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Representational_State_Transfer"&gt;REST&lt;/a&gt;
API for &lt;a class="reference external" href="http://pypi.python.org"&gt;PyPI&lt;/a&gt;, as the &amp;quot;simple&amp;quot; index
&lt;em&gt;is&lt;/em&gt; an ugly hack, in my opinion. I'll work on a serious
proposition about this, maybe involving
&lt;a class="reference external" href="http://couchdb.org"&gt;CouchDB&lt;/a&gt;, as it seems to be a good option
for what we want here.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="issues"&gt;
&lt;h2&gt;Issues&lt;/h2&gt;
&lt;p&gt;I've encountered some issues during this summer. The main one is
that's hard to work remotely, especially being in the same room
that we live, with others. I like to just think about a project
with other people, a paper and a pencil, no computers. This have
been not so possible at the start of the project, as I needed to
read a lot of code to understand the codebase, and then to
read/write emails.&lt;/p&gt;
&lt;p&gt;I've finally managed to work in an office, so good point for
home/office separation.&lt;/p&gt;
&lt;p&gt;I'd not planned there will be so a high number of emails to read,
in order to follow what's up in the python world, and be a part of
the community seems to takes some times to read/write emails,
especially for those (like me) that arent so confortable with
english (but this had brought me some english fu !).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="thanks"&gt;
&lt;h2&gt;Thanks !&lt;/h2&gt;
&lt;p&gt;A big thanks to &lt;a class="reference external" href="http://www.graine-libre.fr/"&gt;Graine Libre&lt;/a&gt; and
&lt;a class="reference external" href="http://www.makina-corpus.com/"&gt;Makina Corpus&lt;/a&gt;, which has offered
me to come into their offices from time to time, to share they
cheerfulness ! Many thanks too to the Google Summer of Code program
for setting up such an initiative. If you're a student, if you're
interested about FOSS, dont hesitate any second, it's a really good
opportunity to work on interesting projects!&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Introducing the distutils2 index crawlers</title><link href="https://blog.notmyidea.org/introducing-the-distutils2-index-crawlers.html" rel="alternate"></link><published>2010-07-06T00:00:00+02:00</published><updated>2010-07-06T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-07-06:/introducing-the-distutils2-index-crawlers.html</id><summary type="html">&lt;p&gt;I'm working for about a month for distutils2, even if I was being a
bit busy (as I had some class courses and exams to work on)&lt;/p&gt;
&lt;p&gt;I'll try do sum-up my general feelings here, and the work I've made
so far. You can also find, if you're interested, my …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I'm working for about a month for distutils2, even if I was being a
bit busy (as I had some class courses and exams to work on)&lt;/p&gt;
&lt;p&gt;I'll try do sum-up my general feelings here, and the work I've made
so far. You can also find, if you're interested, my weekly
summaries in
&lt;a class="reference external" href="http://wiki.notmyidea.org/distutils2_schedule"&gt;a dedicated wiki page&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="general-feelings"&gt;
&lt;h2&gt;General feelings&lt;/h2&gt;
&lt;p&gt;First, and it's a really important point, the GSoC is going very
well, for me as for other students, at least from my perspective.
It's a pleasure to work with such enthusiast people, as this make
the global atmosphere very pleasant to live.&lt;/p&gt;
&lt;p&gt;First of all, I've spent time to read the existing codebase, and to
understand what we're going to do, and what's the rationale to do
so.&lt;/p&gt;
&lt;p&gt;It's really clear for me now: what we're building is the
foundations of a packaging infrastructure in python. The fact is
that many projects co-exists, and comes all with their good
concepts. Distutils2 tries to take the interesting parts of all,
and to provide it in the python standard libs, respecting the
recently written PEP about packaging.&lt;/p&gt;
&lt;p&gt;With distutils2, it will be simpler to make &amp;quot;things&amp;quot; compatible. So
if you think about a new way to deal with distributions and
packaging in python, you can use the Distutils2 APIs to do so.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="tasks"&gt;
&lt;h2&gt;Tasks&lt;/h2&gt;
&lt;p&gt;My main task while working on distutils2 is to provide an
installation and an un-installation command, as described in PEP
376. For this, I first need to get informations about the existing
distributions (what's their version, name, metadata, dependencies,
etc.)&lt;/p&gt;
&lt;p&gt;The main index, you probably know and use, is PyPI. You can access
it at &lt;a class="reference external" href="http://pypi.python.org"&gt;http://pypi.python.org&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="pypi-index-crawling"&gt;
&lt;h2&gt;PyPI index crawling&lt;/h2&gt;
&lt;p&gt;There is two ways to get these informations from PyPI: using the
simple API, or via xml-rpc calls.&lt;/p&gt;
&lt;p&gt;A goal was to use the version specifiers defined
in`PEP 345 &amp;lt;&lt;a class="reference external" href="http://www.python.org/dev/peps/pep-0345/"&gt;http://www.python.org/dev/peps/pep-0345/&lt;/a&gt;&amp;gt;`_ and to
provides a way to sort the grabbed distributions depending our
needs, to pick the version we want/need.&lt;/p&gt;
&lt;div class="section" id="using-the-simple-api"&gt;
&lt;h3&gt;Using the simple API&lt;/h3&gt;
&lt;p&gt;The simple API is composed of HTML pages you can access at
&lt;a class="reference external" href="http://pypi.python.org/simple/"&gt;http://pypi.python.org/simple/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Distribute and Setuptools already provides a crawler for that, but
it deals with their internal mechanisms, and I found that the code
was not so clear as I want, that's why I've preferred to pick up
the good ideas, and some implementation details, plus re-thinking
the global architecture.&lt;/p&gt;
&lt;p&gt;The rules are simple: each project have a dedicated page, which
allows us to get informations about:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the distribution download locations (for some versions)&lt;/li&gt;
&lt;li&gt;homepage links&lt;/li&gt;
&lt;li&gt;some other useful informations, as the bugtracker address, for
instance.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want to find all the distributions of the &amp;quot;EggsAndSpam&amp;quot;
project, you could do the following (do not take so attention to
the names here, as the API will probably change a bit):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SimpleIndex&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;EggsAndSpam&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;EggsAndSpam&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EggsAndSpam&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EggsAndSpam&lt;/span&gt; &lt;span class="mf"&gt;1.3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We also could use version specifiers:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;EggsAndSpam (&amp;lt; =1.2)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;EggsAndSpam&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EggsAndSpam&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Internally, what's done here is the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;it process the
&lt;a class="reference external" href="http://pypi.python.org/simple/FooBar/"&gt;http://pypi.python.org/simple/FooBar/&lt;/a&gt;
page, searching for download URLs.&lt;/li&gt;
&lt;li&gt;for each found distribution download URL, it creates an object,
containing informations about the project name, the version and the
URL where the archive remains.&lt;/li&gt;
&lt;li&gt;it sort the found distributions, using version numbers. The
default behavior here is to prefer source distributions (over
binary ones), and to rely on the last &amp;quot;final&amp;quot; distribution (rather
than beta, alpha etc. ones)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, nothing hard or difficult here.&lt;/p&gt;
&lt;p&gt;We provides a bunch of other features, like relying on the new PyPI
mirroring infrastructure or filter the found distributions by some
criterias. If you're curious, please browse the
&lt;a class="reference external" href="http://distutils2.notmyidea.org/"&gt;distutils2 documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="using-xml-rpc"&gt;
&lt;h3&gt;Using xml-rpc&lt;/h3&gt;
&lt;p&gt;We also can make some xmlrpc calls to retreive informations from
PyPI. It's a really more reliable way to get informations from from
the index (as it's just the index that provides the informations),
but cost processes on the PyPI distant server.&lt;/p&gt;
&lt;p&gt;For now, this way of querying the xmlrpc client is not available on
Distutils2, as I'm working on it. The main pieces are already
present (I'll reuse some work I've made from the SimpleIndex
querying, and
&lt;a class="reference external" href="http://github.com/ametaireau/pypiclient"&gt;some code already set up&lt;/a&gt;),
what I need to do is to provide a xml-rpc PyPI mock server, and
that's on what I'm actually working on.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="processes"&gt;
&lt;h2&gt;Processes&lt;/h2&gt;
&lt;p&gt;For now, I'm trying to follow the &amp;quot;documentation, then test, then
code&amp;quot; path, and that seems to be really needed while working with a
community. Code is hard to read/understand, compared to
documentation, and it's easier to change.&lt;/p&gt;
&lt;p&gt;While writing the simple index crawling work, I must have done this
to avoid some changes on the API, and some loss of time.&lt;/p&gt;
&lt;p&gt;Also, I've set up
&lt;a class="reference external" href="http://wiki.notmyidea.org/distutils2_schedule"&gt;a schedule&lt;/a&gt;, and
the goal is to be sure everything will be ready in time, for the
end of the summer. (And now, I need to learn to follow schedules
...)&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Sprinting on distutils2 in Tours</title><link href="https://blog.notmyidea.org/sprinting-on-distutils2-in-tours.html" rel="alternate"></link><published>2010-07-06T00:00:00+02:00</published><updated>2010-07-06T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-07-06:/sprinting-on-distutils2-in-tours.html</id><summary type="html">&lt;p&gt;Yesterday, as I was traveling to Tours, I've took some time to
visit Éric, another student who's working on distutils2 this
summer, as a part of the GSoC. Basically, it was to take a drink,
discuss a bit about distutils2, our respective tasks and general
feelings, and to put a …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Yesterday, as I was traveling to Tours, I've took some time to
visit Éric, another student who's working on distutils2 this
summer, as a part of the GSoC. Basically, it was to take a drink,
discuss a bit about distutils2, our respective tasks and general
feelings, and to put a face on a pseudonym. I'd really enjoyed this
time, because Éric knows a lot of things about mercurial and python
good practices, and I'm eager to learn about those. So, we have
discussed about things, have not wrote so much code, but have some
things to propose so far, about documentation, and I also provides
here some bribes of conversations we had.&lt;/p&gt;
&lt;div class="section" id="documentation"&gt;
&lt;h2&gt;Documentation&lt;/h2&gt;
&lt;p&gt;While writing the PyPI simple index crawler documentation, I
realized that we miss some structure, or how-to about the
documentation. Yep, you read well. We lack documentation on how to
make documentation. Heh. We're missing some rules to follow, and
this lead to a not-so-structured final documentation. We probably
target three type of publics, and we can split the documentation
regarding those:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Packagers&lt;/strong&gt; who want to distribute their softwares.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;End users&lt;/strong&gt; who need to understand how to use end user
commands, like the installer/uninstaller&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;packaging coders&lt;/strong&gt; who &lt;em&gt;use&lt;/em&gt; distutils2, as a base for
building a package manager.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We also need to discuss about a pattern to follow while writing
documentation. How many parts do we need ? Where to put the API
description ? etc. That's maybe seems to be not so important, but I
guess the readers would appreciate to have the same structure all
along distutils2 documentation.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="mercurial"&gt;
&lt;h2&gt;Mercurial&lt;/h2&gt;
&lt;p&gt;I'm really &lt;em&gt;not&lt;/em&gt; a mercurial power user. I use it on daily basis,
but I lack of basic knowledge about it. Big thanks Éric for sharing
yours with me, you're of a great help. We have talked about some
mercurial extensions that seems to make the life simpler, while
used the right way. I've not used them so far, so consider this as
a personal note.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;hg histedit, to edit the history&lt;/li&gt;
&lt;li&gt;hg crecord, to select the changes to commit&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have spent some time to review a merge I made sunday, to
re-merge it, and commit the changes as a new changeset. Awesome.
These things make me say I &lt;strong&gt;need&lt;/strong&gt; to read
&lt;a class="reference external" href="http://hgbook.red-bean.com/read/"&gt;the hg book&lt;/a&gt;, and will do as
soon as I got some spare time: mercurial seems to be simply great.
So ... Great. I'm a powerful merger now !&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="on-using-tools"&gt;
&lt;h2&gt;On using tools&lt;/h2&gt;
&lt;p&gt;Because we &lt;em&gt;also&lt;/em&gt; are &lt;em&gt;hackers&lt;/em&gt;, we have shared a bit our ways to
code, the tools we use, etc. Both of us were using vim, and I've
discovered vimdiff and hgtk, which will completely change the way I
navigate into the mercurial history. We aren't &amp;quot;power users&amp;quot;, so we
have learned from each other about vim tips. You can find
&lt;a class="reference external" href="http://github.com/ametaireau/dotfiles"&gt;my dotfiles on github&lt;/a&gt;,
if it could help. They're not perfect, and not intended to be,
because changing all the time, as I learn. Don't hesitate to have a
look, and to propose enhancements if you have !&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="on-being-pythonic"&gt;
&lt;h2&gt;On being pythonic&lt;/h2&gt;
&lt;p&gt;My background as an old Java user disserves me so far, as the
paradigms are not the same while coding in python. Hard to find the
more pythonic way to do, and sometimes hard to unlearn my way to
think about software engineering. Well, it seems that the only
solution is to read code, and to re-read import this from times to
times !
&lt;a class="reference external" href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html"&gt;Coding like a pythonista&lt;/a&gt;
seems to be a must-read, so, I know what to do.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;It was really great. Next time, we'll need to focus a bit more on
distutils2, and to have a bullet list of things to do, but days
like this one are opportunities to catch ! We'll probably do
another sprint in a few weeks, stay tuned !&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Use Restructured Text (ReST) to power your presentations</title><link href="https://blog.notmyidea.org/use-restructured-text-rest-to-power-your-presentations.html" rel="alternate"></link><published>2010-06-25T00:00:00+02:00</published><updated>2010-06-25T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-06-25:/use-restructured-text-rest-to-power-your-presentations.html</id><summary type="html">&lt;p&gt;Wednesday, we give a presentation, with some friends, about the
CouchDB Database, to
&lt;a class="reference external" href="http://www.toulibre.org"&gt;the Toulouse local LUG&lt;/a&gt;. Thanks a lot
to all the presents for being there, it was a pleasure to talk
about this topic with you. Too bad the season is over now an I quit
Toulouse next …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Wednesday, we give a presentation, with some friends, about the
CouchDB Database, to
&lt;a class="reference external" href="http://www.toulibre.org"&gt;the Toulouse local LUG&lt;/a&gt;. Thanks a lot
to all the presents for being there, it was a pleasure to talk
about this topic with you. Too bad the season is over now an I quit
Toulouse next year.&lt;/p&gt;
&lt;p&gt;During our brainstorming about the topic, we
used some paper, and we wanted to make a presentation the simpler
way. First thing that come to my mind was using
&lt;a class="reference external" href="http://docutils.sourceforge.net/rst.html"&gt;restructured text&lt;/a&gt;, so
I've wrote a simple file containing our different bullet points. In
fact, there is quite nothing to do then, to have a working
presentation.&lt;/p&gt;
&lt;p&gt;So far, I've used
&lt;a class="reference external" href="http://code.google.com/p/rst2pdf/"&gt;the rst2pdf program&lt;/a&gt;, and a
simple template, to generate output. It's probably simple to have
similar results using latex + beamer, I'll try this next time, but
as I'm not familiar with latex syntax, restructured text was a
great option.&lt;/p&gt;
&lt;p&gt;Here are
&lt;a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.pdf"&gt;the final PDF output&lt;/a&gt;,
&lt;a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.rst"&gt;Rhe ReST source&lt;/a&gt;,
&lt;a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/slides.style"&gt;the theme used&lt;/a&gt;,
and the command line to generate the PDF:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
rst2pdf couchdb.rst -b1 -s ../slides.style
&lt;/pre&gt;
</content></entry><entry><title>first week working on distutils2</title><link href="https://blog.notmyidea.org/first-week-working-on-distutils2.html" rel="alternate"></link><published>2010-06-04T00:00:00+02:00</published><updated>2010-06-04T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-06-04:/first-week-working-on-distutils2.html</id><summary type="html">&lt;p&gt;As I've been working on
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt; during the past
week, taking part of the
&lt;a class="reference external" href="http://code.google.com/intl/fr/soc/"&gt;GSOC&lt;/a&gt; program, here is a
short summary of what I've done so far.&lt;/p&gt;
&lt;p&gt;As my courses are not over yet, I've not worked as much as I
wanted, and this will continues until the end of …&lt;/p&gt;</summary><content type="html">&lt;p&gt;As I've been working on
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt; during the past
week, taking part of the
&lt;a class="reference external" href="http://code.google.com/intl/fr/soc/"&gt;GSOC&lt;/a&gt; program, here is a
short summary of what I've done so far.&lt;/p&gt;
&lt;p&gt;As my courses are not over yet, I've not worked as much as I
wanted, and this will continues until the end of June. My main
tasks are about making installation and uninstallation commands, to
have a simple way to install distributions via
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To do this, we need to rely on informations provided by the Python
Package Index (&lt;a class="reference external" href="http://pypi.python.org/"&gt;PyPI&lt;/a&gt;), and there is at
least two ways to retreive informations from here: XML-RPC and the
&amp;quot;simple&amp;quot; API.&lt;/p&gt;
&lt;p&gt;So, I've been working on porting some
&lt;a class="reference external" href="http://bitbucket.org/tarek/distribute/"&gt;Distribute&lt;/a&gt; related
stuff to &lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt;, cutting
off all non distutils' things, as we do not want to depend from
Distribute's internals. My main work has been about reading the
whole code, writing tests about this and making those tests
possible.&lt;/p&gt;
&lt;p&gt;In fact, there was a need of a pypi mocked server, and, after
reading and introducing myself to the distutils behaviors and code,
I've taken some time to improve the work
&lt;a class="reference external" href="http://bitbucket.org/konrad"&gt;Konrad&lt;/a&gt; makes about this mock.&lt;/p&gt;
&lt;div class="section" id="a-pypi-server-mock"&gt;
&lt;h2&gt;A PyPI Server mock&lt;/h2&gt;
&lt;p&gt;The mock is embeded in a thread, to make it available during the
tests, in a non blocking way. We first used
&lt;a class="reference external" href="http://wsgi.org"&gt;WSGI&lt;/a&gt; and
&lt;a class="reference external" href="http://docs.python.org/library/wsgiref.html"&gt;wsgiref&lt;/a&gt; in order
control what to serve, and to log the requests made to the server,
but finally realised that
&lt;a class="reference external" href="http://docs.python.org/library/wsgiref.html"&gt;wsgiref&lt;/a&gt; is not
python 2.4 compatible (and we &lt;em&gt;need&lt;/em&gt; to be python 2.4 compatible in
Distutils2).&lt;/p&gt;
&lt;p&gt;So, we switched to
&lt;a class="reference external" href="http://docs.python.org/library/basehttpserver.html"&gt;BaseHTTPServer&lt;/a&gt;
and
&lt;a class="reference external" href="http://docs.python.org/library/simplehttpserver.html"&gt;SimpleHTTPServer&lt;/a&gt;,
and updated our tests accordingly. It's been an opportunity to
realize that &lt;a class="reference external" href="http://wsgi.org"&gt;WSGI&lt;/a&gt; has been a great step
forward for making HTTP servers, and expose a really simplest way
to discuss with HTTP !&lt;/p&gt;
&lt;p&gt;You can find
&lt;a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/changesets"&gt;the modifications I made&lt;/a&gt;,
and the
&lt;a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/src/tip/docs/source/test_framework.rst"&gt;related docs&lt;/a&gt;
about this on
&lt;a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/"&gt;my bitbucket distutils2 clone&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="the-pypi-simple-api"&gt;
&lt;h2&gt;The PyPI Simple API&lt;/h2&gt;
&lt;p&gt;So, back to the main problematic: make a python library to access
and request information stored on PyPI, via the simple API. As I
said, I've just grabbed the work made from
&lt;a class="reference external" href="http://bitbucket.org/tarek/distribute/"&gt;Distribute&lt;/a&gt;, and played
a bit with, in order to view what are the different use cases, and
started to write the related tests.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="the-work-to-come"&gt;
&lt;h2&gt;The work to come&lt;/h2&gt;
&lt;p&gt;So, once all use cases covered with tests, I'll rewrite a bit the
grabbed code, and do some software design work (to not expose all
things as privates methods, have a clear API, and other things like
this), then update the tests accordingly and write a documentation
to make this clear.&lt;/p&gt;
&lt;p&gt;Next step is to a little client, as I've
&lt;a class="reference external" href="http://github.com/ametaireau/pypiclient"&gt;already started here&lt;/a&gt;
I'll take you updated !&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>A Distutils2 GSoC</title><link href="https://blog.notmyidea.org/a-distutils2-gsoc.html" rel="alternate"></link><published>2010-05-01T00:00:00+02:00</published><updated>2010-05-01T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-05-01:/a-distutils2-gsoc.html</id><summary type="html">&lt;p&gt;WOW. I've been accepted to be a part of the
&lt;a class="reference external" href="http://code.google.com/intl/fr/soc/"&gt;Google Summer Of Code&lt;/a&gt;
program, and will work on &lt;a class="reference external" href="http://python.org/"&gt;python&lt;/a&gt;
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;, with
&lt;a class="reference external" href="http://pygsoc.wordpress.com/"&gt;a&lt;/a&gt;
&lt;a class="reference external" href="http://konryd.blogspot.com/"&gt;lot&lt;/a&gt; &lt;a class="reference external" href="http://ziade.org/"&gt;of&lt;/a&gt;
(intersting!) &lt;a class="reference external" href="http://zubin71.wordpress.com/"&gt;people&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
So, it's about building the successor of Distutils2, ie. &amp;quot;the
python package manager&amp;quot;. Today, there is too&amp;nbsp;many ways to package a
python …&lt;/blockquote&gt;</summary><content type="html">&lt;p&gt;WOW. I've been accepted to be a part of the
&lt;a class="reference external" href="http://code.google.com/intl/fr/soc/"&gt;Google Summer Of Code&lt;/a&gt;
program, and will work on &lt;a class="reference external" href="http://python.org/"&gt;python&lt;/a&gt;
&lt;a class="reference external" href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;, with
&lt;a class="reference external" href="http://pygsoc.wordpress.com/"&gt;a&lt;/a&gt;
&lt;a class="reference external" href="http://konryd.blogspot.com/"&gt;lot&lt;/a&gt; &lt;a class="reference external" href="http://ziade.org/"&gt;of&lt;/a&gt;
(intersting!) &lt;a class="reference external" href="http://zubin71.wordpress.com/"&gt;people&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
So, it's about building the successor of Distutils2, ie. &amp;quot;the
python package manager&amp;quot;. Today, there is too&amp;nbsp;many ways to package a
python application (pip, setuptools, distribute, distutils, etc.)
so&amp;nbsp;there is a huge effort to make in order to make all this
packaging stuff interoperable, as pointed out by
the&amp;nbsp;&lt;a class="reference external" href="http://www.python.org/dev/peps/pep-0376/"&gt;PEP 376&lt;/a&gt;.&lt;/blockquote&gt;
&lt;p&gt;In more details, I'm going to work on the Installer / Uninstaller
features of Distutils2, and on a PyPI XML-RPC client for distutils2.
Here are the already defined tasks:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Implement Distutils2 APIs described in PEP 376.&lt;/li&gt;
&lt;li&gt;Add the uninstall command.&lt;/li&gt;
&lt;li&gt;think about a basic installer / uninstaller script. (with deps)
-- similar to pip/easy_install&lt;/li&gt;
&lt;li&gt;in a pypi subpackage;&lt;/li&gt;
&lt;li&gt;Integrate a module similar to setuptools' package_index'&lt;/li&gt;
&lt;li&gt;PyPI XML-RPC client for distutils 2:
&lt;a class="reference external" href="http://bugs.python.org/issue8190"&gt;http://bugs.python.org/issue8190&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As I'm relatively new to python, I'll need some extra work in order
to apply all good practice, among other things that can make a
developper-life joyful. I'll post here, each week, my advancement,
and my tought about python and especialy python packaging world.&lt;/p&gt;
</content></entry><entry><title>Python ? go !</title><link href="https://blog.notmyidea.org/python-go-fr.html" rel="alternate"></link><published>2009-12-17T00:00:00+01:00</published><updated>2009-12-17T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2009-12-17:/python-go-fr.html</id><summary type="html">&lt;p&gt;Cela fait maintenant un peu plus d'un mois que je travaille sur un
projet en &lt;a class="reference external" href="http://www.djangoproject.org"&gt;django&lt;/a&gt;, et que,
nécessairement, je me forme à &lt;a class="reference external" href="http://python.org/"&gt;Python&lt;/a&gt;. Je
prends un plaisir non dissimulé à découvrir ce langage (et à
l'utiliser), qui ne cesse de me surprendre. Les premiers mots qui
me viennent à …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Cela fait maintenant un peu plus d'un mois que je travaille sur un
projet en &lt;a class="reference external" href="http://www.djangoproject.org"&gt;django&lt;/a&gt;, et que,
nécessairement, je me forme à &lt;a class="reference external" href="http://python.org/"&gt;Python&lt;/a&gt;. Je
prends un plaisir non dissimulé à découvrir ce langage (et à
l'utiliser), qui ne cesse de me surprendre. Les premiers mots qui
me viennent à l'esprit à propos de Python, sont &amp;quot;logique&amp;quot; et
&amp;quot;simple&amp;quot;. Et pourtant puissant pour autant. Je ne manque d'ailleurs
pas une occasion pour faire un peu d'&lt;em&gt;évangélisation&lt;/em&gt; auprès des
quelques personnes qui veulent bien m'écouter.&lt;/p&gt;
&lt;div class="section" id="the-zen-of-python"&gt;
&lt;h2&gt;The Zen of Python&lt;/h2&gt;
&lt;p&gt;Avant toute autre chose, je pense utile de citer Tim Peters, et
&lt;a class="reference external" href="http://www.python.org/dev/peps/pep-0020/"&gt;le PEP20&lt;/a&gt;, qui
constituent une très bonne introduction au langage, qui prends la
forme d'un &lt;em&gt;easter egg&lt;/em&gt; présent dans python&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt; import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren&lt;span class="s1"&gt;&amp;#39;t special enough to break the rules.&lt;/span&gt;
&lt;span class="s1"&gt;Although practicality beats purity.&lt;/span&gt;
&lt;span class="s1"&gt;Errors should never pass silently.&lt;/span&gt;
&lt;span class="s1"&gt;Unless explicitly silenced.&lt;/span&gt;
&lt;span class="s1"&gt;In the face of ambiguity, refuse the temptation to guess.&lt;/span&gt;
&lt;span class="s1"&gt;There should be one-- and preferably only one --obvious way to do it.&lt;/span&gt;
&lt;span class="s1"&gt;Although that way may not be obvious at first unless you&amp;#39;&lt;/span&gt;re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it&lt;span class="s1"&gt;&amp;#39;s a bad idea.&lt;/span&gt;
&lt;span class="s1"&gt;If the implementation is easy to explain, it may be a good idea.&lt;/span&gt;
&lt;span class="s1"&gt;Namespaces are one honking great idea -- let&amp;#39;&lt;/span&gt;s &lt;span class="k"&gt;do&lt;/span&gt; more of those!
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;J'ai la vague impression que c'est ce que j'ai toujours cherché à
faire en PHP, et particulièrement dans
&lt;a class="reference external" href="http://www.spiral-project.org"&gt;le framework Spiral&lt;/a&gt;, mais en
ajoutant ces concepts dans une sur-couche au langage. Ici, c'est
directement de &lt;em&gt;l'esprit&lt;/em&gt; de python qu'il s'agit, ce qui signifie
que la plupart des bibliothèques python suivent ces concepts. Elle
est pas belle la vie ?&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="comment-commencer-et-par-ou"&gt;
&lt;h2&gt;Comment commencer, et par ou ?&lt;/h2&gt;
&lt;p&gt;Pour ma part, j'ai commencé par la lecture de quelques livres et
articles intéressants, qui constituent une bonne entrée en matière
sur le sujet (La liste n'est bien évidemment pas exhaustive et vos
commentaires sont les bienvenus) :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://diveintopython.adrahon.org/"&gt;Dive into python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.swaroopch.com/notes/Python_fr:Table_des_Matières"&gt;A byte of python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.amazon.fr/Python-Petit-guide-lusage-développeur/dp/2100508830"&gt;Python: petit guide à l'usage du développeur agile&lt;/a&gt;
de &lt;a class="reference external" href="http://tarekziade.wordpress.com/"&gt;Tarek Ziadé&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://docs.python.org/index.html"&gt;La documentation officielle python&lt;/a&gt;,
bien sûr !&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://video.pycon.fr/videos/pycon-fr-2009/"&gt;Les vidéos du pyconfr 2009&lt;/a&gt;!&lt;/li&gt;
&lt;li&gt;Un peu de temps, et une console python ouverte :)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;J'essaye par ailleurs de partager au maximum les ressources que je
trouve de temps à autres, que ce soit
&lt;a class="reference external" href="http://www.twitter.com/ametaireau"&gt;via twitter&lt;/a&gt; ou
&lt;a class="reference external" href="http://delicious.com/ametaireau"&gt;via mon compte delicious&lt;/a&gt;.
Allez jeter un œil
&lt;a class="reference external" href="http://delicious.com/ametaireau/python"&gt;au tag python&lt;/a&gt; sur mon
profil, peut être que vous trouverez des choses intéressantes, qui
sait!&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="un-python-sexy"&gt;
&lt;h2&gt;Un python sexy&lt;/h2&gt;
&lt;p&gt;Quelques fonctionnalités qui devraient vous mettre l'eau à la
bouche:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://docs.python.org/library/stdtypes.html#comparisons"&gt;Le chaînage des opérateurs de comparaison&lt;/a&gt;
est possible (a&amp;lt;b &amp;lt;c dans une condition)&lt;/li&gt;
&lt;li&gt;Assignation de valeurs multiples (il est possible de faire a,b,c
= 1,2,3 par exemple)&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://docs.python.org/tutorial/datastructures.html"&gt;Les listes&lt;/a&gt;
sont simples à manipuler !&lt;/li&gt;
&lt;li&gt;Les &lt;a class="reference external" href="http://docs.python.org/tutorial/datastructures.html#list-comprehensions"&gt;list comprehension&lt;/a&gt;,
ou comment faire des opérations complexes sur les listes, de
manière simple.&lt;/li&gt;
&lt;li&gt;Les
&lt;a class="reference external" href="http://docs.python.org/library/doctest.html?highlight=doctest"&gt;doctests&lt;/a&gt;:
ou comment faire des tests directement dans la documentation de vos
classes, tout en la documentant avec de vrais exemples.&lt;/li&gt;
&lt;li&gt;Les
&lt;a class="reference external" href="http://www.python.org/doc/essays/metaclasses/meta-vladimir.txt"&gt;métaclasses&lt;/a&gt;,
ou comment contrôler la manière dont les classes se construisent&lt;/li&gt;
&lt;li&gt;Python est
&lt;a class="reference external" href="http://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language"&gt;un langage à typage fort dynamique&lt;/a&gt;:
c'est ce qui m'agaçait avec PHP qui est un langage à typage faible
dynamique.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cous pouvez également aller regarder
&lt;a class="reference external" href="http://video.pycon.fr/videos/free/53/"&gt;l'atelier donné par Victor Stinner durant le Pyconfr 09&lt;/a&gt;.
Have fun !&lt;/p&gt;
&lt;/div&gt;
</content></entry></feed>