blog.notmyidea.org/feeds/technologie.atom.xml
2019-11-15 11:19:47 +01:00

5492 lines
No EOL
511 KiB
XML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>Alexis - Carnets en ligne - Technologie</title><link href="https://blog.notmyidea.org/" rel="alternate"></link><link href="https://blog.notmyidea.org/feeds/technologie.atom.xml" rel="self"></link><id>https://blog.notmyidea.org/</id><updated>2018-03-03T00:00:00+01:00</updated><entry><title>Groupement d'achats &amp; partage d'expérience</title><link href="https://blog.notmyidea.org/groupement-dachats-partage-dexperience.html" rel="alternate"></link><published>2018-03-03T00:00:00+01:00</published><updated>2018-03-03T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2018-03-03:/groupement-dachats-partage-dexperience.html</id><summary type="html">&lt;p&gt;Il y a quelques années, on s'est motivé entre copains copines pour créer un groupement d'achat.&lt;/p&gt;
&lt;p&gt;L'idée est simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;commander en gros, pour faire baisser les prix&lt;/li&gt;
&lt;li&gt;se passer d'intermédiaires et favoriser les circuits courts&lt;/li&gt;
&lt;li&gt;aller à la rencontre des producteurs locaux et échanger&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notre groupement dessert actuellement 18 foyers …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Il y a quelques années, on s'est motivé entre copains copines pour créer un groupement d'achat.&lt;/p&gt;
&lt;p&gt;L'idée est simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;commander en gros, pour faire baisser les prix&lt;/li&gt;
&lt;li&gt;se passer d'intermédiaires et favoriser les circuits courts&lt;/li&gt;
&lt;li&gt;aller à la rencontre des producteurs locaux et échanger&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notre groupement dessert actuellement 18 foyers et une 60aine de personnes.&lt;/p&gt;
&lt;p&gt;Au fur et à mesure de la vie du groupement, on a développé quelques outils pour se simplifier la vie. Voici un retour d'expérience et quelques astuces / outils, au cas où l'envie vous prenne à vous aussi :)&lt;/p&gt;
&lt;h1 id="organisation"&gt;Organisation&lt;/h1&gt;
&lt;p&gt;On organise environs trois ou quatre distributions par an. Le &lt;em&gt;modus operandi&lt;/em&gt; est le suivant:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;chaque product·eur·rice à un·e référent·e, qui s'occupe de faire le lien;&lt;/li&gt;
&lt;li&gt;une personne est désignée pour coordonner la distribution;&lt;/li&gt;
&lt;li&gt;4 semaines avant la distribution, les référent·e·s mettent à jour les prix / produits dans le tableau de commandes;·e·&lt;/li&gt;
&lt;li&gt;3 semaines avant la distribution, les commandes sont ouvertes;&lt;/li&gt;
&lt;li&gt;2 semaines avant la distribution, les commandes sont closes;&lt;/li&gt;
&lt;li&gt;Les référent·e·s ont ensuite deux semaines pour récupérer les commandes pour la distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="quels-produits"&gt;Quels produits ?&lt;/h1&gt;
&lt;p&gt;On essaye d'avoir uniquement des produits qui se conservent (on a également quelques autres produits plus frais, mais avec d'autres modalités).&lt;/p&gt;
&lt;p&gt;Entre autres: bières, légumes secs, conserves, jus, miel, pâtes, semoule, café, vinaigres, pommes de terre, oignons, huiles, farines.&lt;/p&gt;
&lt;p&gt;On essaye de faire du local puis du bio au plus proche plutôt que de trouver nécessairement les prix les plus bas. C'est une discussion qui revient assez
souvent, et donc un point à évoquer lors de la création pour avoir une posture
claire sur le sujet (tout le monde n'est pas animé par la même éthique !).&lt;/p&gt;
&lt;h1 id="paiements"&gt;Paiements&lt;/h1&gt;
&lt;p&gt;Pour les paiements, on utilise autant que possible des chèques. Chaque référent·e paye la·le product·rice·eur en son nom, et lui demande d'attendre la date de la distribution pour l'encaissement. La plupart des producteurs acceptent d'être payés sous quinzaine.&lt;/p&gt;
&lt;p&gt;Le jour de la distribution, tout le monde apporte son chéquier. Nous avons mis
en place une moulinette qui s'occupe de faire la répartition des chèques automatiquement, chaque membre se retrouve à faire en moyenne un ou deux chèques.&lt;/p&gt;
&lt;p&gt;Chaque référent·e est ainsi remboursé·e de la somme avancée, et chaque
membre du groupement d'achat paye ce qu'il doit payer. Nous n'avons
volontairement pas de structure juridique et pas de compte en banque. Les
paiements s'effectuent directement entre nous.&lt;/p&gt;
&lt;h1 id="transports"&gt;Transports&lt;/h1&gt;
&lt;p&gt;Chaque référent·e commande les produits, puis ensuite s'occupe de les rapatrier. À Rennes, on a la chance d'avoir pas mal de producteurs aux alentours, donc c'est assez simple.&lt;/p&gt;
&lt;p&gt;Le mieux est de ramener les produits juste un peu avant la distribution au lieu de distribution, ça permet d'éviter de les stocker trop longtemps, et d'éviter aux producteurs d'attendre trop longtemps avant d'encaisser les chèques.&lt;/p&gt;
&lt;p&gt;Pour les grosses commandes, les voitures se remplissent bien, mais ma petite Clio suffit, que ce soit dit !&lt;/p&gt;
&lt;h1 id="la-distribution"&gt;La distribution&lt;/h1&gt;
&lt;p&gt;Un peu en amont de la distribution, il faut organiser l'espace. Des tas par membre sont constitués pour faciliter les choses le jour de la distribution.&lt;/p&gt;
&lt;p&gt;Le jour même, on se retrouve, on charge ses marchandises, on échange quelques chèques et on papote ! On en profite pour:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;discuter de la date de la prochaine distribution;&lt;/li&gt;
&lt;li&gt;trouver une nouvelle personne pour la coordonner;&lt;/li&gt;
&lt;li&gt;discuter de nouveaux produits;&lt;/li&gt;
&lt;li&gt;refaire le monde;&lt;/li&gt;
&lt;li&gt;changer de référents pour les producteurs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et c'est reparti pour un tour ;)&lt;/p&gt;
&lt;h1 id="nos-outils"&gt;Nos outils&lt;/h1&gt;
&lt;p&gt;On utilise un tableur en ligne pour partager les prix et prendre les commandes. On a essayé d'utiliser &lt;em&gt;ethercalc&lt;/em&gt; au début mais ça ne fonctionnait pas pour nous à l'époque (trop de petits bugs). On a donc préféré utiliser Google docs (ouch).&lt;/p&gt;
&lt;p&gt;Il est d'ailleurs possible d'y intégrer de nouvelles fonctionnalités assez facilement, du coup Fred et Rémy ont planché sur un moyen d'automatiser la répartition des chèques (qu'on faisait dans un premier temps à la main - assez péniblement).&lt;/p&gt;
&lt;p&gt;Le système n'est pas parfait mais fonctionne quand même assez bien !&lt;/p&gt;
&lt;p&gt;Quelques ressources, donc:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/almet/8c77fafc9e487c02ded852ec4a91ae16"&gt;le code pour faire la répartition des chèques&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.google.com/spreadsheets/d/1bnPRSvf2Q2RDxKerWnEqUyJjuCFePnVMq6pWo8LeA_k/edit?usp=sharing"&gt;une version « à remplir » de notre tableau de commandes&lt;/a&gt; (le mieux est d'en faire une copie !).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bon groupement d'achat ;)&lt;/p&gt;</content></entry><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 id="fonctionnalites"&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 id="pas-de-compte"&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 id="gardez-la-main-sur-vos-donnees"&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 id="api"&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 id="auto-hebergeable"&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 id="on-commence-petit"&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 id="et-euh-comment-ca-marche"&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>Avez vous confiance en SSL?</title><link href="https://blog.notmyidea.org/avez-vous-confiance-en-ssl.html" rel="alternate"></link><published>2016-03-25T00:00:00+01:00</published><updated>2016-03-25T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2016-03-25:/avez-vous-confiance-en-ssl.html</id><summary type="html">&lt;p&gt;Dans le cadre &lt;a href="http://autodefense-numerique.readthedocs.org/en/latest/"&gt;des ateliers d'autodéfense numérique&lt;/a&gt;,
j'ai passé un peu de temps à creuser sur l'utilisation de SSL puisque
contrairement à ce que la plupart des personnes ont encore tendance à croire,
le petit cadenas (qui prouve qu'une connexion SSL est en cours) n'est
&lt;strong&gt;absolument&lt;/strong&gt; pas suffisant.&lt;/p&gt;
&lt;p&gt;Allez hop …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Dans le cadre &lt;a href="http://autodefense-numerique.readthedocs.org/en/latest/"&gt;des ateliers d'autodéfense numérique&lt;/a&gt;,
j'ai passé un peu de temps à creuser sur l'utilisation de SSL puisque
contrairement à ce que la plupart des personnes ont encore tendance à croire,
le petit cadenas (qui prouve qu'une connexion SSL est en cours) n'est
&lt;strong&gt;absolument&lt;/strong&gt; pas suffisant.&lt;/p&gt;
&lt;p&gt;Allez hop, c'est parti pour:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;un tour d'horizon du fonctionnement de SSl&lt;/li&gt;
&lt;li&gt;quelques moyens contourner cette "protection" en faisant une attaque en pratique&lt;/li&gt;
&lt;li&gt;un tour des solutions existantes actuellement et de pourquoi je ne les trouve
pas vraiment satisfaisantes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="comment-fonctionne-ssl"&gt;Comment fonctionne SSL?&lt;/h2&gt;
&lt;p&gt;Pour expliquer les problèmes de SSL, j'ai d'abord besoin d'expliquer comment
tout ça fonctionne.&lt;/p&gt;
&lt;p&gt;SSL repose sur l'utilisation de certificats, qui sont générés par des autorités
de certification (&lt;em&gt;Certificate Authority&lt;/em&gt; que je nomme &lt;em&gt;CA&lt;/em&gt; dans la suite de
l'article).&lt;/p&gt;
&lt;p&gt;Les certificats SSL permettent deux choses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;De garantir que les communications entre les navigateurs (vous) et les sites
Web ne sont connues que du détenteur du certificat du site et de vous même.&lt;/li&gt;
&lt;li&gt;De garantir que le site sur lequel vous vous connectez est bien celui que
vous imaginez.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le navigateur, lors d'une visite d'un site, va télécharger le certificat
associé puis vérifier que le certificat en question a bien été généré par un
des &lt;em&gt;CA&lt;/em&gt; en qui il a confiance.&lt;/p&gt;
&lt;p&gt;Imaginons maintenant qu'une des &lt;em&gt;CA&lt;/em&gt; essaye de savoir ce qui s'échange entre
mon navigateur et le site de ma banque (protégé par SSL). Comment cela se
passerait il ?&lt;/p&gt;
&lt;p&gt;N'importe quel &lt;em&gt;CA&lt;/em&gt; peut donc générer des certificats pour n'importe quel site,
et le navigateur vérifierait, lui, que le certificat a bien été généré par une
&lt;em&gt;CA&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Tout cela ne poserait pas de soucis si les &lt;em&gt;CA&lt;/em&gt; étaient gérés de manière fiable,
mais il s'agit d'un travail compliqué, et certains &lt;em&gt;CA&lt;/em&gt; ont par le passé montré
des faiblesses.&lt;/p&gt;
&lt;p&gt;Par exemple, &lt;a href="https://en.wikipedia.org/wiki/DigiNotar"&gt;DigiNotar&lt;/a&gt; (un &lt;em&gt;CA&lt;/em&gt; des Pays-Bas)
a été compromise et les attaquant.e.s ont pu générer des certificats SSL
frauduleux, ce qui leur a permis d'attaquer des sites tels que Facebook ou GMail.&lt;/p&gt;
&lt;p&gt;Vous pouvez retrouver une liste des risques et menaces autour des &lt;em&gt;CA&lt;/em&gt; &lt;a href="http://wiki.cacert.org/Risk/History"&gt;sur le
wiki de CACert&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="attaque-de-lhomme-du-milieu-avec-ssl"&gt;Attaque de l'homme du milieu avec SSL&lt;/h2&gt;
&lt;p&gt;A force de dire que c'était très facile à faire, j'ai eu envie d'essayer
d'espionner des connections protégées par SSL, et effectivement c'est
carrément flippant tellement c'est simple.&lt;/p&gt;
&lt;p&gt;En l'espace de quelques minutes, il est possible de faire une &lt;em&gt;attaque de
l'homme du milieu&lt;/em&gt; en utilisant par exemple un outil nommé &lt;a href="http://docs.mitmproxy.org/en/stable"&gt;mitm-proxy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Pour déchiffrer l'ensemble du trafic SSL, j'ai simplement eu à lancer quelques
commandes et avoir un &lt;em&gt;CA&lt;/em&gt; dans lequel le navigateur de la victime a confiance.
Je l'ai ajouté dans le navigateur cible pour simuler que je l'avais déjà
(c'est le cas si un des 1200 CA se fait pirater, ce qui me semble une surface
d'attaque assez large).&lt;/p&gt;
&lt;p&gt;Je les colle ici si ça vous intéresse:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ sudo aptitude install mitmproxy
$ mitm-proxy -T --host
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il faut faire croire à votre victime que vous êtes la passerelle vers
l'extérieur et à la passerelle que vous êtes la victime:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;arpspoof -i wlan0 -t victime gateway
arpspoof -i wlan0 -t gateway victime
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Puis dire à notre fausse passerelle de rediriger le trafic des ports 80 et 443
vers notre proxy:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo sysctl -w net.ipv4.ip_forward&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport &lt;span class="m"&gt;443&lt;/span&gt; -j REDIRECT --to-port &lt;span class="m"&gt;4443&lt;/span&gt;
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport &lt;span class="m"&gt;80&lt;/span&gt; -j REDIRECT --to-port &lt;span class="m"&gt;4443&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Et paf, &lt;strong&gt;on voit tout ce qui passe entre la machine et le serveur SSL&lt;/strong&gt;. On peut
d'ailleurs même imaginer faire tourner ces quelques commandes sur un
raspberry pi, pour aller encore plus vite…&lt;/p&gt;
&lt;h3 id="key-pinning-dans-les-navigateurs"&gt;Key-pinning dans les navigateurs&lt;/h3&gt;
&lt;p&gt;Actuellement, n'importe quel &lt;em&gt;CA&lt;/em&gt; peut générer des certificats pour
n'importe quel site, et c'est en grande partie ce qui pose souci. Une des
manières de faire évoluer la situation est d'épingler les certificats de
certains sites directement dans les navigateurs.&lt;/p&gt;
&lt;p&gt;Cette approche a le mérite de fonctionner très bien &lt;a href="https://dxr.mozilla.org/mozilla-central/source/security/manager/ssl/StaticHPKPins.h?from=StaticHPKPins.h"&gt;pour un petit nombre de
sites critiques (Google, Facebook, etc)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="http-public-key-pinning-hpkp"&gt;HTTP Public Key Pinning (HPKP)&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://developer.mozilla.org/en/docs/Web/Security/Public_Key_Pinning"&gt;&lt;em&gt;HTTP Public Key Pinning&lt;/em&gt;&lt;/a&gt;
est également une solution de &lt;em&gt;pinning&lt;/em&gt; qui permet d'établir une confiance lors
de la première connexion avec le site. C'est ce qu'on appelle du &lt;em&gt;Trust on First
Use&lt;/em&gt; ou &lt;em&gt;TOFU&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Le navigateur va alors mettre ces informations dans un cache et vérifiera que
les certificats correspondent bien lors des prochaines visites.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;HPKP&lt;/em&gt; est disponible dans Firefox depuis Janvier 2015 et dans Chrome
depuis Octobre 2015.&lt;/p&gt;
&lt;h3 id="certificate-transparency-des-journaux-auditables"&gt;Certificate transparency: des journaux auditables&lt;/h3&gt;
&lt;p&gt;Une autre approche est celle proposée par &lt;em&gt;certificate transparency&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Certificate Transparency aims to remedy these certificate-based threats by
making the issuance and existence of SSL certificates open to scrutiny by
domain owners, CAs, and domain users.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="https://www.certificate-transparency.org/what-is-ct"&gt;Certificate Transparency&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Autrement dit, avec ce système les &lt;em&gt;CA&lt;/em&gt; doivent rendre public le fait qu'ils
aient signé de nouveaux certificats intermédiaires. La signature est ajoutée à
un journal sur lequel il n'est possible que d'écrire.&lt;/p&gt;
&lt;p&gt;Les navigateurs vont alors vérifier que les certificats utilisés sont bien des
certificats qui ont été ajoutés au journal.&lt;/p&gt;
&lt;p&gt;Ici, toute l'intelligence est dans la vérification de ces journaux, qui
permettent donc de valider/invalider des certificats racines ou intermédiaires.&lt;/p&gt;
&lt;p&gt;Il me semble donc qu'il serait possible d'ajouter un certificat frauduleux le
temps d'une attaque (et celui ci serait détecté et supprimé ensuite).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Certificate-Transparency&lt;/em&gt; n'est donc pas une solution contre une écoute
globale mise en place par les gouvernements par exemple.&lt;/p&gt;
&lt;p&gt;Si vous lisez bien l'anglais, je vous invite à aller lire
&lt;a href="http://security.stackexchange.com/a/52838"&gt;cette description du problème et de la solution&lt;/a&gt;
que je trouve très bien écrite.&lt;/p&gt;
&lt;h3 id="dane-dnssec"&gt;DANE + DNSSEC&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The DANE working group has developed a framework for securely
retrieving keying information from the DNS [RFC6698]. This
framework allows secure storing and looking up server public key
information in the DNS. This provides a binding between a domain
name providing a particular service and the key that can be used
to establish encrypted connection to that service.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="https://datatracker.ietf.org/wg/dane/charter/"&gt;Dane WG&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Une autre solution est appelée "DANE" et repose par dessus le protocole
&lt;em&gt;DNSSEC&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Je connais assez mal &lt;em&gt;DNSSEC&lt;/em&gt; donc j'ai passé un peu de temps à lire des
documents. L'impression finale que ça me laisse est que le problème est
exactement le même que pour SSL: un certain nombre de personnes détiennent les
clés et toute la sécurité repose sur cette confiance. Or il est possible que
ces clés soient détenues par des personnes non dignes de confiance.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Secure DNS (DNSSEC) uses cryptographic digital signatures signed with a
trusted public key certificate to determine the authenticity of data.
-- https://en.wikipedia.org/wiki/DNS_spoofing&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Et aussi:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It is widely believed[1] that securing the DNS is critically important for
securing the Internet as a whole, but deployment of DNSSEC specifically has
been hampered (As of 22 January 2010) by several difficulties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The need to design a backward-compatible standard that can scale to the
size of the Internet&lt;/li&gt;
&lt;li&gt;Prevention of "zone enumeration" (see below) where desired&lt;/li&gt;
&lt;li&gt;Deployment of DNSSEC implementations across a wide variety of DNS servers
and resolvers (clients)&lt;/li&gt;
&lt;li&gt;Disagreement among implementers over who should own the top-level domain
root keys Overcoming the perceived complexity of DNSSEC and DNSSEC
deployment&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2 id="solutions-basees-sur-la-blockchain"&gt;Solutions basées sur la blockchain&lt;/h2&gt;
&lt;p&gt;Une dernière piste semble être l'utilisation de la &lt;em&gt;blockchain&lt;/em&gt; pour distribuer
des clés par site.&lt;/p&gt;
&lt;p&gt;La solution &lt;em&gt;DNSChain&lt;/em&gt; me paraissait tout d'abord un bon point de départ mais
la lecture de &lt;a href="https://www.indolering.com/okturtles-dnschain-unblock-us"&gt;quelques critiques&lt;/a&gt;
et interventions du développeur du projet m'ont fait changer d'avis.&lt;/p&gt;
&lt;p&gt;Reste encore la piste de &lt;em&gt;Namecoin Control&lt;/em&gt; que je n'ai pas encore creusée.
Peut-être pour un prochain billet. Toute piste de réflexion est bien sur la
bienvenue sur ces sujets!&lt;/p&gt;</content></entry><entry><title>Retours sur un atelier ZeroNet</title><link href="https://blog.notmyidea.org/retours-sur-un-atelier-zeronet.html" rel="alternate"></link><published>2016-03-17T00:00:00+01:00</published><updated>2016-03-17T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2016-03-17:/retours-sur-un-atelier-zeronet.html</id><summary type="html">&lt;p&gt;Mardi dernier se tenait &lt;a href="http://biblio.insa-rennes.fr/crypto"&gt;une &lt;em&gt;cryptoparty&lt;/em&gt;&lt;/a&gt; dans les locaux de l'INSA de Rennes.&lt;/p&gt;
&lt;p&gt;L'évènement s'étant rempli au delà de toutes les espérances, on m'a proposé de
venir y tenir un atelier, que j'ai proposé sur &lt;a href="https://zeronet.io"&gt;ZeroNet&lt;/a&gt;, un
petit projet fort sympathique qui pourrait devenir une nouvelle manière de
distribuer le …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Mardi dernier se tenait &lt;a href="http://biblio.insa-rennes.fr/crypto"&gt;une &lt;em&gt;cryptoparty&lt;/em&gt;&lt;/a&gt; dans les locaux de l'INSA de Rennes.&lt;/p&gt;
&lt;p&gt;L'évènement s'étant rempli au delà de toutes les espérances, on m'a proposé de
venir y tenir un atelier, que j'ai proposé sur &lt;a href="https://zeronet.io"&gt;ZeroNet&lt;/a&gt;, un
petit projet fort sympathique qui pourrait devenir une nouvelle manière de
distribuer le Web, permettant notamment d'éviter la censure.&lt;/p&gt;
&lt;p&gt;Avant toute autre chose, merci énormément à l'équipe de la bibliothèque de
l'INSA pour l'organisation de cet évènement qui à une réelle portée politique.&lt;/p&gt;
&lt;h2 id="un-peu-dhistoire"&gt;Un peu d'histoire&lt;/h2&gt;
&lt;p&gt;Il me semble que Tim Bernes Lee (l'inventeur du Web) avait prévu le Web comme un
protocole décentralisé. Chacun hébergerait ses données et les servirait aux
autres, qui pourraient alors y accéder.&lt;/p&gt;
&lt;p&gt;Avec ce fonctionnement, impossible alors d'accéder à des sites si leur auteur
n'est pas en ligne. Qu'à cela ne tienne, on s'est mis à avoir des machines qui
restent connectées au réseau 24 heures par jour. Et puis une machine ne
suffisant plus, on a eu des fermes de machines dans des &lt;em&gt;data centers&lt;/em&gt; etc afin
de supporter les milliers d'utilisateurs des sites.&lt;/p&gt;
&lt;h2 id="un-web-decentralise"&gt;Un Web décentralisé&lt;/h2&gt;
&lt;p&gt;ZeroNet permet (entre autres) de répondre à ce problème en proposant une manière alternative de &lt;strong&gt;distribuer le Web&lt;/strong&gt;, en pair à pair. Lors d'une visite d'un site:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Vous contactez un &lt;em&gt;tracker&lt;/em&gt; BitTorrent pour connaitre la liste des autres
visiteurs du site (les &lt;em&gt;pairs&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;Vous demandez aux &lt;em&gt;pairs&lt;/em&gt; de vous donner les fichiers du site.&lt;/li&gt;
&lt;li&gt;Vous validez que les fichiers servis sont bien les bons (en vérifiant la
signature attachée).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;N'importe quel visiteur devient alors un &lt;em&gt;pair&lt;/em&gt;, qui sert le site aux autres
visiteurs.&lt;/p&gt;
&lt;p&gt;Parmi les nombreux avantages de cette approche, je note particulièrement que:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Il est très difficile de censurer un site — Il est sur l'ensemble des machines
des visiteurs.&lt;/li&gt;
&lt;li&gt;Les attaques par &lt;em&gt;fingerprinting&lt;/em&gt; sont impossibles: le navigateur Web se
connecte à un serveur &lt;em&gt;proxy&lt;/em&gt; local.&lt;/li&gt;
&lt;li&gt;Vous détenez directement vos données et (par design) ne les donnez pas à des
silos (Facebook, Google, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Si vous êtes interessés par une démonstration rapide, j'ai enregistré une vidéo
de 10 minutes où je parle en anglais avec une voix très grave.&lt;/p&gt;
&lt;video controls="" src="http://alexis.notmyidea.org/zeronet.webm" width=800&gt;&lt;/video&gt;
&lt;h2 id="atelier"&gt;Atelier&lt;/h2&gt;
&lt;p&gt;Pour l'atelier, j'ai choisi de faire une présentation rapide du projet (&lt;a href="{filename}/static/zeronet-presentation-fr.pdf"&gt;j'ai
traduit les slides&lt;/a&gt; anglais
pour l'occasion — &lt;a href="https://docs.google.com/presentation/d/158C_-V1ueNaaKHMBMBgGOVhunb9xrXzB3hC_g1N53c0/edit?usp=sharing"&gt;accès aux sources&lt;/a&gt;)
avant d'installer ZeroNet sur les machines et de l'utiliser pour publier un
site.&lt;/p&gt;
&lt;h3 id="partager-sur-le-reseau-local"&gt;Partager sur le réseau local&lt;/h3&gt;
&lt;p&gt;Nous avons eu des soucis à cause du réseau (un peu congestionné) sur lequel
les ports utilisés pour la discussion entre &lt;em&gt;pairs&lt;/em&gt; étaient fermés. Il est bien
sur possible de faire tourner le tout de manière indépendante du reste du réseau,
mais je n'avais pas prévu le coup.&lt;/p&gt;
&lt;p&gt;Voici donc comment faire pour contourner le souci:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Installer et lancer un &lt;em&gt;tracker&lt;/em&gt; BitTorrent (De manière surprenante,
&lt;a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685575"&gt;rien n'est packagé pour debian pour l'instant&lt;/a&gt;)
J'ai choisi d'installer &lt;a href="http://erdgeist.org/arts/software/opentracker/#build-instructions"&gt;OpenTracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ensuite lancer ZeroNet avec des options spécifiques.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ python zeronet.py --trackers udp://localhost:6969 --ip_external &lt;span class="m"&gt;192&lt;/span&gt;.168.43.207
$ python zeronet.py --trackers udp://192.168.43.207:6969 --ip_external &lt;span class="m"&gt;192&lt;/span&gt;.168.43.172
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il est nécessaire de spécifier l'adresse IP externe que chaque nœud expose pour
éviter qu'elle n'essaye d'aller la trouver par elle même: nous voulons l'adresse
du réseau local, et non pas l'adresse internet.&lt;/p&gt;
&lt;p&gt;La prochaine fois je tenterais de venir avec un HotSpot Wifi et un tracker
BitTorrent dans la poche!&lt;/p&gt;
&lt;h2 id="questions-reponses"&gt;Questions / Réponses&lt;/h2&gt;
&lt;p&gt;Il y avait quelques questions intéressantes auxquelles je n'ai pas toujours su
répondre sur le moment. Après quelques recherches, je rajoute des détails ici.&lt;/p&gt;
&lt;h3 id="torrent-tor-breche-de-secu"&gt;Torrent + Tor = brèche de sécu ?&lt;/h3&gt;
&lt;p&gt;Il me semblait avoir entendu parler de problèmes de &lt;em&gt;dé-anonymisation&lt;/em&gt;
&lt;a href="https://hal.inria.fr/file/index/docid/471556/filename/TorBT.pdf"&gt;lors de l'utilisation de BitTorrent par dessus Tor&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Dans certains cas, certains clients torrents (uTorrent, BitSpirit, etc)
écrivent directement votre adresse IP dans l'information qui est envoyée
au tracker et/ou aux autres pairs.
— https://blog.torproject.org/blog/bittorrent-over-tor-isnt-good-idea&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/HelloZeroNet/ZeroNet/issues/274"&gt;Ce n'est pas le cas de ZeroNet&lt;/a&gt;, ce qui évacue le souci.&lt;/p&gt;
&lt;h3 id="zeromail-cest-lent-non"&gt;ZeroMail, c'est lent non ?&lt;/h3&gt;
&lt;p&gt;Une des applications de démo, &lt;em&gt;ZeroMail&lt;/em&gt;, propose un mécanisme qui permet de
s'envoyer des messages chiffrés sur un réseau pair à pair. L'approche choisie
est de chiffrer les messages avec la clé du destinataire et de le mettre dans
un &lt;em&gt;pot commun&lt;/em&gt;. Tout le monde essaye de déchiffrer tous les messages, mais ne
peut déchiffrer que les siens.&lt;/p&gt;
&lt;p&gt;Cela permet de ne &lt;strong&gt;pas&lt;/strong&gt; fuiter de méta-données, &lt;a href="{filename}../crypto/2015.05.pgp-problemes.rst"&gt;à l'inverse de PGP&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Je n'ai en fait pas de réponse claire à donner à cette question: l'auteur de
ZeroNet me disait que 10MB (la limite de taille d'un site, par défaut)
correspondait à beaucoup de place pour stocker des messages, et qu'il était
possible de supprimer les anciens messages une fois qu'ils sont lus par exemple.&lt;/p&gt;
&lt;p&gt;Une autre solution à laquelle je pensait était de créer un &lt;em&gt;ZeroSite&lt;/em&gt; pour
chaque récipient, mais on connait à ce moment là le nombre de messages qu'un
utilisateur peut recevoir.&lt;/p&gt;
&lt;p&gt;Je vois plusieurs problèmes avec le design actuel de ZeroMail (il me semble
assez facile d'y faire un déni de service par exemple). A creuser.&lt;/p&gt;
&lt;h3 id="comment-heberger-des-tres-gros-sites"&gt;Comment héberger des très gros sites ?&lt;/h3&gt;
&lt;p&gt;Par exemple, comment faire pour héberger Wikipedia ?&lt;/p&gt;
&lt;p&gt;Il semble que la meilleure manière de faire serait de séparer Wikipedia en
un tas de petites ressources (par catégorie par ex.). Les gros médias pourraient
être considérés optionnels (et donc téléchargés uniquement à la demande)&lt;/p&gt;
&lt;h3 id="est-ce-quon-a-vraiment-besoin-dun-tracker"&gt;Est-ce qu'on à vraiment besoin d'un tracker ?&lt;/h3&gt;
&lt;p&gt;Le support d'une DHT &lt;a href="https://github.com/HelloZeroNet/ZeroNet/issues/57"&gt;est souhaité&lt;/a&gt;,
mais pour l'instant pas encore implémenté. L'utilisation de la DHT BitTorrent
n'est pas une option puisque &lt;a href="https://github.com/HelloZeroNet/ZeroNet/issues/57"&gt;Tor ne supporte pas UDP&lt;/a&gt;.&lt;/p&gt;</content></entry><entry><title>Let's Encrypt + HAProxy</title><link href="https://blog.notmyidea.org/lets-encrypt-haproxy.html" rel="alternate"></link><published>2016-02-11T00:00:00+01:00</published><updated>2016-02-11T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2016-02-11:/lets-encrypt-haproxy.html</id><summary type="html">&lt;p&gt;&lt;em&gt;Note : Cet article n'est plus à jour. Il est maintenant (2018) possible d'installer des certificats SSL Let's Encrypt d'une manière beaucoup plus simple, en utilisant certbot (et le plugin nginx &lt;code&gt;certbot --nginx&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Its time for the Web to take a big step forward in terms of security
and privacy …&lt;/p&gt;&lt;/blockquote&gt;</summary><content type="html">&lt;p&gt;&lt;em&gt;Note : Cet article n'est plus à jour. Il est maintenant (2018) possible d'installer des certificats SSL Let's Encrypt d'une manière beaucoup plus simple, en utilisant certbot (et le plugin nginx &lt;code&gt;certbot --nginx&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Its time for the Web to take a big step forward in terms of security
and privacy. We want to see HTTPS become the default. Lets Encrypt
was built to enable that by making it as easy as possible to get and
manage certificates.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="https://letsencrypt.org/"&gt;Let's Encrypt&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Depuis début Décembre, la nouvelle &lt;em&gt;autorité de certification&lt;/em&gt; Let's
Encrypt est passée en version &lt;em&gt;Beta&lt;/em&gt;. Les certificats SSL sont un moyen
de 1. chiffrer la communication entre votre navigateur et le serveur et
2. un moyen d'être sur que le site Web auquel vous accédez est celui
auquel vous pensez vous connecter (pour éviter des &lt;a href="https://fr.wikipedia.org/wiki/Attaque_de_l'homme_du_milieu"&gt;attaques de l'homme
du milieu&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Jusqu'à maintenant, il était nécessaire de payer une entreprise pour
faire en sorte d'avoir des certificats qui évitent d'avoir ce genre
d'erreurs dans vos navigateurs:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Message de firefox lorsque une connexion n'est pas
sécurisée." src="%7Bfilename%7D/static/unsecure-connection.png"&gt;&lt;/p&gt;
&lt;p&gt;Maintenant, grâce à Let's Encrypt il est possible d'avoir des
certificats SSL &lt;strong&gt;gratuits&lt;/strong&gt;, ce qui représente un grand pas en avant
pour la sécurité de nos communications.&lt;/p&gt;
&lt;p&gt;Je viens de mettre en place un procédé (assez simple) qui permet de
configurer votre serveur pour générer des certificats SSL valides avec
Let's Encrypt et le répartiteur de charge
&lt;a href="http://www.haproxy.org/"&gt;HAProxy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Je me suis basé pour cet article sur
d'&lt;a href="https://blog.infomee.fr/p/letsencrypt-haproxy"&gt;autres&lt;/a&gt;
&lt;a href="http://blog.victor-hery.com/article22/utiliser-let-s-encrypt-avec-haproxy"&gt;articles&lt;/a&gt;,
dont je vous recommande la lecture pour un complément d'information.&lt;/p&gt;
&lt;h2 id="validation-des-domaines-par-lets-encrypt"&gt;Validation des domaines par Let's Encrypt&lt;/h2&gt;
&lt;p&gt;Je vous passe les détails d'installation du client de Let's Encrypt, qui
sont &lt;a href="https://github.com/letsencrypt/letsencrypt#installation"&gt;très bien expliqués sur leur
documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Une fois installé, vous allez taper une commande qui va ressembler à:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;certonly&lt;/span&gt; &lt;span class="c1"&gt;--renew-by-default&lt;/span&gt;
&lt;span class="c1"&gt;--webroot -w /home/www/letsencrypt-requests/ \&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="n"&gt;hurl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kinto&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="n"&gt;forums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kinto&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Le &lt;em&gt;webroot&lt;/em&gt; est l'endroit ou les preuves de détention du domaine vont
être déposées.&lt;/p&gt;
&lt;p&gt;Lorsque les serveurs de Let's Encrypt vont vouloir vérifier que vous
êtes bien à l'origine des demandes de certificats, ils vont envoyer une
requête HTTP sur &lt;code&gt;http://domaine.org/.well-known/acme-challenge&lt;/code&gt;, ou il
voudra trouver des informations qu'il aura généré via la commande
&lt;code&gt;letsencrypt-auto&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;J'ai choisi de faire une règle dans haproxy pour diriger toutes les
requêtes avec le chemin &lt;code&gt;.well-known/acme-challenge&lt;/code&gt; vers un &lt;em&gt;backend&lt;/em&gt;
nginx qui sert des fichiers statiques (ceux contenus dans
&lt;code&gt;/home/www/letsencrypt-requests/&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Voici la section de la configuration de HAProxy (et &lt;a href="https://github.com/almet/infra/blob/master/haproxy/haproxy.cfg#L63-L72"&gt;la configuration
complete&lt;/a&gt;
si ça peut être utile):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;frontend&lt;/span&gt; &lt;span class="nv"&gt;http&lt;/span&gt;
&lt;span class="nv"&gt;bind&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;:&lt;span class="mi"&gt;80&lt;/span&gt;
&lt;span class="nv"&gt;mode&lt;/span&gt; &lt;span class="nv"&gt;http&lt;/span&gt;
&lt;span class="nv"&gt;default_backend&lt;/span&gt; &lt;span class="nv"&gt;nginx_server&lt;/span&gt;
&lt;span class="nv"&gt;acl&lt;/span&gt; &lt;span class="nv"&gt;letsencrypt_check&lt;/span&gt; &lt;span class="nv"&gt;path_beg&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;.&lt;span class="nv"&gt;well&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;known&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;acme&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;challenge&lt;/span&gt;
&lt;span class="nv"&gt;use_backend&lt;/span&gt; &lt;span class="nv"&gt;letsencrypt_backend&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;letsencrypt_check&lt;/span&gt;
&lt;span class="nv"&gt;redirect&lt;/span&gt; &lt;span class="nv"&gt;scheme&lt;/span&gt; &lt;span class="nv"&gt;https&lt;/span&gt; &lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;{ &lt;span class="nv"&gt;ssl_fc&lt;/span&gt; } &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;letsencrypt_check&lt;/span&gt;
&lt;span class="nv"&gt;backend&lt;/span&gt; &lt;span class="nv"&gt;letsencrypt_backend&lt;/span&gt;
&lt;span class="nv"&gt;http&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;request&lt;/span&gt; &lt;span class="nv"&gt;set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;header&lt;/span&gt; &lt;span class="nv"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;letsencrypt&lt;/span&gt;.&lt;span class="nv"&gt;requests&lt;/span&gt;
&lt;span class="nv"&gt;dispatch&lt;/span&gt; &lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;8000&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Et celle de NGINX:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;server_name&lt;/span&gt; &lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="installation-des-certificats-dans-haproxy"&gt;Installation des certificats dans HAProxy&lt;/h2&gt;
&lt;p&gt;Vos certificats SSL devraient être générés dans &lt;code&gt;/etc/letsencrypt/live&lt;/code&gt;,
mais ils ne sont pas au format attendu par haproxy. Rien de grave, la
commande suivant convertit l'ensemble des certificats en une version
compatible avec
HAProxy:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;domaine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;privkey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;live&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;domaine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;fullchain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;domaine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Et ensuite dans la configuration de haproxy, pour le (nouveau)
&lt;em&gt;frontend&lt;/em&gt; https:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;bind&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;443&lt;/span&gt; &lt;span class="n"&gt;ssl&lt;/span&gt; &lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sslv3&lt;/span&gt; &lt;span class="n"&gt;crt&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;letsencrypt&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Faites bien attention à avoir un &lt;em&gt;frontend&lt;/em&gt; https pour tous vos sites en
HTTPS. &lt;a href="https://github.com/almet/infra/blob/master/haproxy/haproxy.cfg#L38-L60"&gt;Pour moi cela ressemble à
ça&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Une fois tout ceci fait, redémarrez votre service haproxy et zou !&lt;/p&gt;
&lt;h2 id="automatisation"&gt;Automatisation&lt;/h2&gt;
&lt;p&gt;Pour automatiser un peu tout ça, j'ai choisi de faire ça comme suit:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Un fichier domaine dans &lt;code&gt;letsencrypt/domains/domain.org&lt;/code&gt; qui
contient le script &lt;code&gt;letsencrypt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Un fichier d'installation de certificats dans
&lt;code&gt;letsencrypt/install-certs.sh&lt;/code&gt; qui s'occupe d'installer les
certificats déjà générés.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et voila ! &lt;a href="https://github.com/almet/infra/"&gt;Le tout est dans un dépot
github&lt;/a&gt;, si jamais ça peut vous servir,
tant mieux !&lt;/p&gt;</content></entry><entry><title>Ateliers d'autodéfense numérique</title><link href="https://blog.notmyidea.org/ateliers-dautodefense-numerique.html" rel="alternate"></link><published>2016-01-14T00:00:00+01:00</published><updated>2016-01-14T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2016-01-14:/ateliers-dautodefense-numerique.html</id><summary type="html">&lt;p&gt;Il y a huit mois, je me rendais compte de l'importance du choix des
outils pour faire face à la surveillance généralisée, et notamment en
rapport au chiffrement des données. Une de mes envies de l'époque était
l'animation d'ateliers.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Je compte donc:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Organiser des ateliers de sensibilisation aux outils de …&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;</summary><content type="html">&lt;p&gt;Il y a huit mois, je me rendais compte de l'importance du choix des
outils pour faire face à la surveillance généralisée, et notamment en
rapport au chiffrement des données. Une de mes envies de l'époque était
l'animation d'ateliers.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Je compte donc:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Organiser des ateliers de sensibilisation aux outils de
communication, envers mes proches;&lt;/li&gt;
&lt;li&gt;Utiliser la communication chiffrée le plus souvent possible, au
moins pour rendre le déchiffrement des messages plus longue,
"noyer le poisson".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;-- &lt;a href="http://blog.notmyidea.org/chiffrement.html"&gt;Chiffrement&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;J'ai mis un peu de temps à mettre le pied à l'étrier, mais je ressors
finalement du premier atelier que j'ai co-animé avec geb, auprès d'un
public de journalistes.&lt;/p&gt;
&lt;p&gt;Pour cette première édition l'idée était à la fois d'aller à la
rencontre d'un public que je connais mal, de leur donner des outils pour
solutionner les problèmes auxquels ils font parfois face, et de me faire
une idée de ce que pouvait être un atelier sur l'autodéfense numérique.&lt;/p&gt;
&lt;p&gt;L'objectif pour ce premier atelier était de:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Échanger autour des besoins et &lt;strong&gt;faire ressortir des histoires&lt;/strong&gt; ou
le manque d'outillage / connaissances à posé problème, dans des
situations concrètes;&lt;/li&gt;
&lt;li&gt;Se rendre compte des "conduites à risque", &lt;strong&gt;faire peur&lt;/strong&gt; aux
personnes formées pour qu'elles se rendent compte de l'état actuel
des choses;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Proposer des solutions concrètes&lt;/strong&gt; aux problèmes soulevés, ainsi
que le minimum de connaissance théorique pour les appréhender.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="146-faire-ressortir-les-problemes"&gt;1. Faire ressortir les problèmes&lt;/h2&gt;
&lt;p&gt;Afin de faire ressortir les problèmes, nous avons choisi de constituer
des petits groupes de discussion, afin de faire des "Groupes d'Interview
Mutuels", ou "GIM":&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;lanimateur invite les participants à se regrouper par trois, avec des
personnes quon connaît moins puis invite chacun à livrer une
expérience vécue en lien avec le thème de la réunion et les deux
autres à poser des questions leur permettant de bien saisir ce qui a
été vécu.&lt;/p&gt;
&lt;p&gt;-- «&lt;a href="http://www.scoplepave.org/pour-s-ecouter"&gt;Pour s'écouter&lt;/a&gt;», SCOP
Le Pavé.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;De ces &lt;em&gt;GIMs&lt;/em&gt; nous avons pu ressortir quelques histoires, gravitant
autour de:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;La protection des sources (d'information)&lt;/strong&gt;: Comment faire pour
aider quelqu'un à faire "fuiter" des données depuis l'intérieur
d'une entreprise ?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le chiffrement de ses données&lt;/strong&gt;: Comment éviter de faire "fuiter"
des données importantes lors d'une perquisition de matériel ?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="246-faire-peur"&gt;2. Faire peur&lt;/h2&gt;
&lt;p&gt;Un des premiers objectifs est de faire peur, afin que tout le monde se
rende compte à quel point il est facile d'accéder à certaines données.
&lt;a href="http://blog.barbayellow.com/"&gt;Grégoire&lt;/a&gt; m'avait conseillé quelques
petites accroches qui ont ma foi bien marché:&lt;/p&gt;
&lt;p&gt;J'ai demandé aux présent.e.s de:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;donner leur mot de passe à voix haute devant les autres: a priori
personne ne le fera;&lt;/li&gt;
&lt;li&gt;venir se connecter à leur compte email depuis mon ordinateur. J'ai
piégé une personne, qui est venu pour taper son mot de passe.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cela à été un bon moyen de parler de l'importance des traces que l'on
peut laisser sur un ordinateur, et de la confiance qu'il faut avoir dans
le matériel que l'on utilise, à fortiori si ce ne sont pas les vôtres.&lt;/p&gt;
&lt;p&gt;Pour continuer à leur faire peur, après une brève explication de ce
qu'est SSL nous avons montré comment il était facile de scruter le
réseau à la recherche de mots de passe en clair.&lt;/p&gt;
&lt;h2 id="346-proposer-des-solutions-concretes"&gt;3. Proposer des solutions concrêtes&lt;/h2&gt;
&lt;p&gt;Une fois que tout le monde avait pleinement pris sonscience des
problématiques et n'osait plus utiliser son ordinateur ou son
téléphone, on à commencé à parler de quelques solutions. Plusieurs
approches étaient possibles ici, nous avons choisi de présenter quelques
outils qui nous semblaient répondre aux attentes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On a expliqué ce qu'était &lt;a href="https://tails.boum.org"&gt;Tails&lt;/a&gt;, et
comment l'utiliser et le dupliquer.&lt;/li&gt;
&lt;li&gt;On a pu faire un tour des outils existants sur Tails, notamment
autour de l'&lt;em&gt;anonymisation&lt;/em&gt; de fichiers et la suppression effective
de contenus.&lt;/li&gt;
&lt;li&gt;Certaines personnes ont pu créer une clé tails avec la persistance
de configurée.&lt;/li&gt;
&lt;li&gt;Nous nous sommes connectés au réseau
&lt;a href="https://www.torproject.org"&gt;Tor&lt;/a&gt; et testé que nos adresses IP
changeaient bien à la demande.&lt;/li&gt;
&lt;li&gt;Nous avons utilisé &lt;a href="https://crypto.cat"&gt;CryptoCat&lt;/a&gt; par dessus Tor,
afin de voir comment avoir une conversation confidentielle dans
laquelle il est possible d'échanger des fichiers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="retours"&gt;Retours&lt;/h2&gt;
&lt;p&gt;D'une manière générale, pour une formation de trois heures et demi, je
suis assez content de l'exercice, et de l'ensemble des sujets que nous
avons pu couvrir. Il y a beaucoup de place pour l'amélioration,
notamment en amont (j'avais par exemple oublié d'amener avec moi
suffisamment de clés USB pour utiliser Tails).&lt;/p&gt;
&lt;p&gt;La plupart des retours qu'on a pu avoir jusqu'à maintenant sont
positifs, et il y a l'envie d'aller plus loin sur l'ensemble de ces
sujets.&lt;/p&gt;
&lt;h2 id="la-suite"&gt;La suite&lt;/h2&gt;
&lt;p&gt;Il y a beaucoup de sujets que nous n'avons pas abordés, ou uniquement
survolés, à cause du manque de temps disponible. Idéalement, il faudrait
au moins une journée entière pour couvrir quelques sujets plus en détail
(on peut imaginer avoir une partie théorique le matin et une partie
pratique l'après-midi par exemple).&lt;/p&gt;
&lt;p&gt;J'ai choisi volontairement de ne pas aborder le chiffrement des messages
via PGP parce que &lt;a href="%7Bfilename%7D2015.05.pgp-problemes.rst"&gt;je pense que la protection que ce média propose n'est
pas suffisante&lt;/a&gt;, mais je suis
en train de revenir sur ma décision: il pourrait être utile de présenter
l'outil, à minima, en insistant sur certaines de ses faiblesses.&lt;/p&gt;
&lt;p&gt;Un compte twitter à été créé recemment autour des crypto-party à Rennes,
si vous êtes interessés, &lt;a href="https://twitter.com/CryptoPartyRNS"&gt;allez jeter un coup
d'œil&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Je n'ai pas trouvé de ressources disponibles par rapport à des plans de
formation sur le sujet, j'ai donc décidé de publier les nôtres, afin de
co-construire avec d'autres des plans de formation.&lt;/p&gt;
&lt;p&gt;Ils sont pour l'instant disponibles &lt;a href="http://autodefense-numerique.readthedocs.org/en/latest/"&gt;sur Read The
Docs&lt;/a&gt;. Tous les
retours sont évidemment les bienvenus !&lt;/p&gt;</content></entry><entry><title>Le mail doit-il mourir ?</title><link href="https://blog.notmyidea.org/le-mail-doit-il-mourir.html" rel="alternate"></link><published>2015-11-24T00:00:00+01:00</published><updated>2015-11-24T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-11-24:/le-mail-doit-il-mourir.html</id><summary type="html">&lt;p&gt;J'utilise quotidiennement le protocole email, tant bien que mal, tout en sachant que l'ensemble de mes messages passent en clair sur le réseau pour la plupart de mes conversations, puisque trop peu de monde utilise le chiffrement des messages.&lt;/p&gt;
&lt;p&gt;Et même si j'arrive à convaincre certains de mes proches à …&lt;/p&gt;</summary><content type="html">&lt;p&gt;J'utilise quotidiennement le protocole email, tant bien que mal, tout en sachant que l'ensemble de mes messages passent en clair sur le réseau pour la plupart de mes conversations, puisque trop peu de monde utilise le chiffrement des messages.&lt;/p&gt;
&lt;p&gt;Et même si j'arrive à convaincre certains de mes proches à installer PGP, je ne suis pas satisfait du résultat: les méta-données (qui contacte qui à quel
moment, et pour lui dire quoi) transitent de toute manière, elles, en clair, à la vue de tous.&lt;/p&gt;
&lt;p&gt;Ce problème est lié directement au protocole email: il est &lt;em&gt;necessaire&lt;/em&gt; de faire fuiter ces meta-données (au moins le destinataire) pour avoir un protocole
mail fonctionnel.&lt;/p&gt;
&lt;p&gt;Le mail répond à un besoin de communication asynchrone qui permet des conversations plus réfléchies qu'un simple chat (miaou). Il est tout à fait possible d'utiliser certaines technologies existantes afin de construire le futur de l'email, pour lequel:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Les méta-données seraient chiffrées — Il n'est pas possible de savoir qui
communique avec qui, et quand;&lt;/li&gt;
&lt;li&gt;Le chiffrement serait fort (et protégé d'une phrase de passe ?);&lt;/li&gt;
&lt;li&gt;La fuite d'une clé de chiffrement utilisée dans un échange ne permette pas de
déchiffrer l'ensemble des échanges (forward secrecy);&lt;/li&gt;
&lt;li&gt;Il ne soit pas possible de réutiliser les données comme preuve pour
incriminer l'emmeteur du message (deniability);&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Avec au moins ces besoins en tête, il semble qu'une revue de l'ensemble des projets existants pointe du doigt vers &lt;a href="https://github.com/agl/pond"&gt;pond&lt;/a&gt;, ou vers &lt;a href="https://www.whispersystems.org"&gt;Signal&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Malheureusement, Pond est le projet d'une seule personne, qui veut plutôt utiliser ce code comme démonstration du concept en question.&lt;/p&gt;</content></entry><entry><title>Web distribution signing</title><link href="https://blog.notmyidea.org/web-distribution-signing.html" rel="alternate"></link><published>2015-10-12T00:00:00+02:00</published><updated>2015-10-12T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-10-12:/web-distribution-signing.html</id><summary type="html">&lt;p&gt;&lt;em&gt;I'm not a crypto expert, nor pretend to be one. These are thoughts I
want to share with the crypto community to actually see if any solution
exists to solve this particular problem.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;One &lt;a href="http://www.tonyarcieri.com/whats-wrong-with-webcrypto"&gt;often pointed&lt;/a&gt; flaw in
web-based cryptographic applications is the fact that there is no way to …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;em&gt;I'm not a crypto expert, nor pretend to be one. These are thoughts I
want to share with the crypto community to actually see if any solution
exists to solve this particular problem.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;One &lt;a href="http://www.tonyarcieri.com/whats-wrong-with-webcrypto"&gt;often pointed&lt;/a&gt; flaw in
web-based cryptographic applications is the fact that there is no way to
trust online software distributions. Put differently, you don't actually
trust the software authors but are rather trusting the software
distributors and certificate authorities (CAs).&lt;/p&gt;
&lt;p&gt;I've been talking with a few folks in the past months about that and
they suggested me to publish something to discuss the matter. So here I
come!&lt;/p&gt;
&lt;h2 id="the-problem-attack-vectors"&gt;The problem (Attack vectors)&lt;/h2&gt;
&lt;p&gt;Let's try to describe a few potential attacks:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Application Authors&lt;/em&gt; just released a new version of their open source
web crypto messaging application. An &lt;em&gt;Indie Hoster&lt;/em&gt; installs it on their
servers so a wide audience can actually use it.&lt;/p&gt;
&lt;p&gt;Someone alters the files on &lt;em&gt;Indie Hoster&lt;/em&gt; servers, effectively
replacing them with other &lt;em&gt;altered files&lt;/em&gt; with less security properties
/ a backdoor. This someone could either be an &lt;em&gt;Evil Attacker&lt;/em&gt; which
found its way trough, the &lt;em&gt;Indie Hoster&lt;/em&gt; or a CDN which delivers the
files,&lt;/p&gt;
&lt;p&gt;Trusted &lt;em&gt;Certificate Authorities&lt;/em&gt; ("governments" or "hacking team") can
also trick the User Agents (i.e. Firefox) into thinking they're talking
to &lt;em&gt;Indie Hoster&lt;/em&gt; even though they're actually talking to a different
server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Altered files&lt;/strong&gt; are then being served to the User Agents, and &lt;em&gt;Evil
Attacker&lt;/em&gt; now has a way to actually attack the end users.&lt;/p&gt;
&lt;h2 id="problem-mitigation"&gt;Problem Mitigation&lt;/h2&gt;
&lt;p&gt;Part of the problem is solved by the recently introduced &lt;a href="https://w3c.github.io/webappsec/specs/subresourceintegrity/"&gt;Sub Resource
Integrity&lt;/a&gt;
(SRI). To quote them: "[it] defines a mechanism by which user agents
may verify that a fetched resource has been delivered without unexpected
manipulation.".&lt;/p&gt;
&lt;p&gt;SRI is a good start, but isn't enough: it ensures the assets (JavaScript
files, mainly) loaded from a specific HTML page are the ones the author
of the HTML page intends. However, SRI doesn't allow the User Agent to
ensure the HTML page is the one he wants.&lt;/p&gt;
&lt;p&gt;In other words, we miss a way to create trust between &lt;em&gt;Application
Authors&lt;/em&gt; and &lt;em&gt;User Agents&lt;/em&gt;. The User-Agent currently has to trust the
&lt;em&gt;Certificate Authorities&lt;/em&gt; and the delivery (&lt;em&gt;Indie Hoster&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;For desktop software distribution: &lt;em&gt;Crypto Experts&lt;/em&gt; audit the software,
sign it somehow and then this signature can be checked locally during
installation or runtime. It's not automated, but at least it's possible.&lt;/p&gt;
&lt;p&gt;For web applications, we don't have such a mechanism, but it should be
possible. Consider the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;App Authors&lt;/em&gt; publish a new version of their software; They provide
a hash of each of their distributed files (including the HTML
files);&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Crypto Experts&lt;/em&gt; audit these files and sign the hashes somehow;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;User Agents&lt;/em&gt; can chose to trust some specific &lt;em&gt;Crypto Experts&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;When a &lt;em&gt;User Agent&lt;/em&gt; downloads files, it checks if they're signed by
a trusted party.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="chosing-who-you-trust"&gt;Chosing who you trust&lt;/h2&gt;
&lt;p&gt;In terms of user experience, handling certificates is hard, and that's
where the community matters. Distributions such as
&lt;a href="https://tails.boom.org"&gt;Tails&lt;/a&gt; could chose who they trust to verify the
files, and issue warnings / refuse to run the application in case files
aren't verified.&lt;/p&gt;
&lt;p&gt;But, as highligted earlier, CAs are hard to trust. A new instance of the
same CA system wouldn't make that much differences, expect the fact that
distributions could ship with a set of trusted authorities (for which
revocation would still need to be taken care of).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[...] users are vulnerable to MitM attacks by the authority, which
can vouch for, or be coerced to vouch for, false keys. This weakness
has been highlighted by recent CA scandals. Both schemes can also be
attacked if the authority does not verify keys before vouching for
them.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="http://cacr.uwaterloo.ca/techreports/2015/cacr2015-02.pdf"&gt;SoK : Secure
Messaging&lt;/a&gt;;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It seems that some other systems could allow for something more
reliable:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Melara et al proposed CONIKS, using a series of chained commitments to
Merkle prefix trees to build a key directory [...] for which
individual users can efficiently verify the consistency of their own
entry in the directory without relying on a third party.&lt;/p&gt;
&lt;p&gt;This “self- auditing log” approach makes the system partially have no
auditing required (as general auditing of non-equivocation is still
required) and also enables the system to be privacy preserving as the
entries in the directory need not be made public. This comes at a mild
bandwidth cost not reflected in our table, estimated to be about 10
kilobytes per client per day for self-auditing.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="http://cacr.uwaterloo.ca/techreports/2015/cacr2015-02.pdf"&gt;SoK : Secure
Messaging&lt;/a&gt;;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now, I honestly have no idea if this thing solves the whole problem, and
I'm pretty sure this design has many security problems attached to it.&lt;/p&gt;
&lt;p&gt;However, that's a problem I would really like to see solved one day, so
here the start of the discussion, don't hesitate to &lt;a href="/pages/about.html"&gt;get in
touch&lt;/a&gt;!&lt;/p&gt;
&lt;h2 id="addendum"&gt;Addendum&lt;/h2&gt;
&lt;p&gt;It seems possible to increase the level a user has in a Web Application
by adding indicators in the User-Agent. For instance, when using an
application that's actually signed by someone considered trustful by the
User-Agent (or the distributor of the User-Agent), a little green icon
could be presented to the User, so they know that they can be confident
about this.&lt;/p&gt;
&lt;p&gt;A bit like User-Agents do for SSL, but for the actual signature of the
files being viewed.&lt;/p&gt;</content></entry><entry><title>Service de nuages : Pourquoi avons-nous fait Cliquet ?</title><link href="https://blog.notmyidea.org/pourquoi-cliquet" rel="alternate"></link><published>2015-07-14T00:00:00+02:00</published><updated>2015-07-14T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-07-14:/pourquoi-cliquet</id><summary type="html">&lt;p class="first last"&gt;Basé sur Pyramid, Cliquet est un projet qui permet de se concentrer sur l'essentiel
lors de la conception d'APIs.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;em&gt;Cet article est repris depuis le blog « Service de Nuages » de mon équipe à Mozilla&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tldr; Cliquet est un toolkit Python pour construire des APIs, qui implémente
les bonnes pratiques en terme de mise en production et de protocole HTTP.&lt;/strong&gt;&lt;/p&gt;
&lt;div class="section" id="les-origines"&gt;
&lt;h2&gt;Les origines&lt;/h2&gt;
&lt;p&gt;L'objectif pour le premier trimestre 2015 était de construire un service de
stockage et de &lt;a class="reference external" href="{filename}2015.04.service-de-nuages.rst"&gt;synchronisation de listes de lecture&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Au démarrage du projet, nous avons tenté de rassembler toutes les bonnes pratiques
et recommandations, venant de différentes équipes et surtout des derniers projets déployés.&lt;/p&gt;
&lt;p&gt;De même, nous voulions tirer parti du protocole de &lt;em&gt;Firefox Sync&lt;/em&gt;, robuste et éprouvé,
pour la synchronisation des données «offline».&lt;/p&gt;
&lt;p&gt;Plutôt qu'écrire un &lt;a class="reference external" href="http://blog.octo.com/en/design-a-rest-api/"&gt;énième&lt;/a&gt;
&lt;a class="reference external" href="http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api"&gt;article&lt;/a&gt; de blog,
nous avons préféré les rassembler dans ce qu'on a appellé «un protocole».&lt;/p&gt;
&lt;p&gt;Comme pour l'architecture envisagée nous avions deux projets à construire, qui
devaient obéir globalement à ces mêmes règles, nous avons décidé de mettre en
commun l'implémentation de ce protocole et de ces bonnes pratiques dans un
«toolkit».&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Cliquet&lt;/em&gt; est né.&lt;/p&gt;
&lt;img alt="Cliquet logo" class="align-center" src="{filename}/images/cliquet-logo.png" /&gt;
&lt;div class="section" id="les-intentions"&gt;
&lt;h3&gt;Les intentions&lt;/h3&gt;
&lt;blockquote class="epigraph"&gt;
Quelle structure JSON pour mon API ? Quelle syntaxe pour filtrer la liste
via la querystring ? Comment gérer les écritures concurrentes ?
Et synchroniser les données dans mon application cliente ?&lt;/blockquote&gt;
&lt;p&gt;Désormais, quand un projet souhaite bénéficier d'une API REST pour stocker et consommer
des données, il est possible d'utiliser le &lt;strong&gt;protocole HTTP&lt;/strong&gt; proposé
et de se concentrer sur l'essentiel. Cela vaut aussi pour les clients, où
la majorité du code d'interaction avec le serveur est réutilisable.&lt;/p&gt;
&lt;blockquote class="epigraph"&gt;
Comment pouvons-nous vérifier que le service est opérationnel ? Quels indicateurs StatsD ?
Est-ce que Sentry est bien configuré ? Comment déployer une nouvelle version
sans casser les applications clientes ?&lt;/blockquote&gt;
&lt;p&gt;Comme &lt;em&gt;Cliquet&lt;/em&gt; fournit tout ce qui est nécessaire pour être conforme avec les
exigences de la &lt;strong&gt;mise en production&lt;/strong&gt;, le passage du prototype au service opérationnel
est très rapide ! De base le service répondra aux attentes en terme supervision, configuration,
déploiement et dépréciation de version. Et si celles-ci évoluent, il suffira
de faire évoluer le toolkit.&lt;/p&gt;
&lt;blockquote class="epigraph"&gt;
Quel backend de stockage pour des documents JSON ? Comment faire si l'équipe
de production impose PostgreSQL ? Et si on voulait passer à Redis ou en
mémoire pour lancer les tests ?&lt;/blockquote&gt;
&lt;p&gt;En terme d'implémentation, nous avons choisi de &lt;strong&gt;fournir des abstractions&lt;/strong&gt;.
En effet, nous avions deux services dont le coeur consistait
à exposer un &lt;em&gt;CRUD&lt;/em&gt; en &lt;em&gt;REST&lt;/em&gt;, persistant des données JSON dans un backend.
Comme &lt;em&gt;Pyramid&lt;/em&gt; et &lt;em&gt;Cornice&lt;/em&gt; ne fournissent rien de tout prêt pour ça,
nous avons voulu introduire des classes de bases pour abstraire les notions
de resource REST et de backend de stockage.&lt;/p&gt;
&lt;p&gt;Dans le but de tout rendre optionnel et «pluggable», &lt;strong&gt;tout est configurable&lt;/strong&gt;
depuis le fichier &lt;tt class="docutils literal"&gt;.ini&lt;/tt&gt; de l'application. Ainsi tous les projets qui utilisent
le toolkit se déploieront de la même manière : seuls quelques éléments de configuration
les distingueront.&lt;/p&gt;
&lt;img alt="Une réunion à Paris..." class="align-center" src="{filename}/images/cliquet-notes-whiteboard.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="le-protocole"&gt;
&lt;h2&gt;Le protocole&lt;/h2&gt;
&lt;blockquote class="epigraph"&gt;
Est-ce suffisant de parler d'«API REST» ? Est-ce bien nécessaire de
relire la spec HTTP à chaque fois ? Pourquoi réinventer un protocole complet
à chaque fois ?&lt;/blockquote&gt;
&lt;p&gt;Quand nous développons un (micro)service Web, nous dépensons généralement beaucoup
trop d'énergie à (re)faire des choix (arbitraires).&lt;/p&gt;
&lt;p&gt;Nul besoin de lister ici tout ce qui concerne la dimension
de la spécification HTTP pure, qui nous impose le format des headers,
le support de CORS, la négocation de contenus (types mime), la différence entre
authentification et autorisation, la cohérence des code status...&lt;/p&gt;
&lt;p&gt;Les choix principaux du protocole concernent surtout :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Les resources REST&lt;/strong&gt; : Les deux URLs d'une resource (pour la collection
et les enregistrements) acceptent des verbes et des headers précis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Les formats&lt;/strong&gt; : le format et la structure JSON des réponses est imposé, ainsi
que la &lt;a class="reference external" href="{filename}/2015.05.continuation-token.rst"&gt;pagination des listes&lt;/a&gt;
ou la syntaxe pour filtrer/trier les resources via la &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Query_string"&gt;querystring&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Les timestamps&lt;/strong&gt; : un numéro de révision qui s'incrémente à chaque opération
d'écriture sur une collection d'enregistrements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;La synchronisation&lt;/strong&gt; : une série de leviers pour récupérer et renvoyer des
changements sur les données, sans perte ni collision, en utilisant les timestamps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Les permissions&lt;/strong&gt; : les droits d'un utilisateur sur une collection ou un enregistrement
(&lt;em&gt;encore frais et sur le point d'être documenté&lt;/em&gt;) &lt;a class="footnote-reference" href="#id3" id="id1"&gt;[1]&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Opérations par lot&lt;/strong&gt;: une URL qui permet d'envoyer une série de requêtes
décrites en JSON et d'obtenir les réponses respectives.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Dans la dimension opérationnelle du protocole, on trouve :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;La gestion de version&lt;/strong&gt; : cohabitation de plusieurs versions en production,
avec alertes dans les entêtes pour la fin de vie des anciennes versions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le report des requêtes&lt;/strong&gt; : entêtes interprétées par les clients, activées en cas de
maintenance ou de surchage, pour ménager le serveur.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le canal d'erreurs&lt;/strong&gt; : toutes les erreurs renvoyées par le serveur ont le même
format JSON et ont un numéro précis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Les utilitaires&lt;/strong&gt; : URLs diverses pour répondre aux besoins exprimés par
l'équipe d'administrateurs (monitoring, metadonnées, paramètres publiques).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ce protocole est une compilation des bonnes pratiques pour les APIs HTTP (&lt;em&gt;c'est notre métier !&lt;/em&gt;),
des conseils des administrateurs système dont c'est le métier de mettre à disposition des services
pour des millions d'utilisateurs et des retours d'expérience de l'équipe
de &lt;em&gt;Firefox Sync&lt;/em&gt; pour la gestion de la concurrence et de l'«offline-first».&lt;/p&gt;
&lt;p&gt;Il est &lt;a class="reference external" href="http://cliquet.readthedocs.org/en/latest/api/index.html"&gt;documenté en détail&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Dans un monde idéal, ce protocole serait versionné, et formalisé dans une RFC.
En rêve, il existerait même plusieurs implémentations avec des technologies différentes
(Python, Go, Node, etc.). &lt;a class="footnote-reference" href="#id4" id="id2"&gt;[2]&lt;/a&gt;&lt;/p&gt;
&lt;table class="docutils footnote" frame="void" id="id3" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Voir notre &lt;a class="reference external" href="{filename}/2015.05.cliquet-permissions.rst"&gt;article dédié sur les permissions&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="id4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Rappel: nous sommes une toute petite équipe !&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class="section" id="le-toolkit"&gt;
&lt;h2&gt;Le toolkit&lt;/h2&gt;
&lt;div class="section" id="choix-techniques"&gt;
&lt;h3&gt;Choix techniques&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Cliquet&lt;/em&gt; implémente le protocole en Python (&lt;em&gt;2.7, 3.4+, pypy&lt;/em&gt;), avec &lt;a class="reference external" href="http://trypyramid.com/"&gt;Pyramid&lt;/a&gt; &lt;a class="footnote-reference" href="#id6" id="id5"&gt;[3]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pyramid&lt;/strong&gt; est un framework Web qui va prendre en charge tout la partie HTTP,
et qui s'avère pertinent aussi bien pour des petits projets que des plus
ambitieux.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cornice&lt;/strong&gt; est une extension de &lt;em&gt;Pyramid&lt;/em&gt;, écrite en partie par Alexis et Tarek,
qui permet d'éviter d'écrire tout le code &lt;em&gt;boilerplate&lt;/em&gt; quand on construit une
API REST avec Pyramid.&lt;/p&gt;
&lt;p&gt;Avec &lt;em&gt;Cornice&lt;/em&gt;, on évite de réécrire à chaque fois le code qui va
cabler les verbes HTTP aux méthodes, valider les entêtes, choisir le sérialiseur
en fonction des entêtes de négociation de contenus, renvoyer les codes HTTP
rigoureux, gérer les entêtes CORS, fournir la validation JSON à partir de schémas...&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cliquet&lt;/strong&gt; utilise les deux précédents pour implémenter le protocole et fournir
des abstractions, mais on a toujours &lt;em&gt;Pyramid&lt;/em&gt; et &lt;em&gt;Cornice&lt;/em&gt; sous la main pour
aller au delà de ce qui est proposé !&lt;/p&gt;
&lt;table class="docutils footnote" frame="void" id="id6" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id5"&gt;[3]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Au tout début nous avons commencé une implémentation avec &lt;em&gt;Python-Eve&lt;/em&gt;
(Flask), mais n'étions pas satisfaits de l'approche pour la configuration
de l'API. En particulier du côté magique.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class="section" id="concepts"&gt;
&lt;h3&gt;Concepts&lt;/h3&gt;
&lt;p&gt;Bien évidemment, les concepts du toolkit reflètent ceux du protocole mais il y
a des éléments supplémentaires:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Les backends&lt;/strong&gt; : abstractions pour le stockage, le cache et les permissions
(&lt;em&gt;ex. PostgreSQL, Redis, en-mémoire, ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;La supervision&lt;/strong&gt; : logging JSON et indicateurs temps-réel (&lt;em&gt;StatsD&lt;/em&gt;) pour suivre les
performances et la santé du service.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;La configuration&lt;/strong&gt; : chargement de la configuration depuis les variables
d'environnement et le fichier &lt;tt class="docutils literal"&gt;.ini&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;La flexibilité&lt;/strong&gt; : dés/activation ou substitution de la majorité des composants
depuis la configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le profiling&lt;/strong&gt; : utilitaires de développement pour trouver les &lt;a class="reference external" href="https://fr.wiktionary.org/wiki/goulet_d%E2%80%99%C3%A9tranglement"&gt;goulets
d'étranglement&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="Cliquet concepts" class="align-center" src="{filename}/images/cliquet-concepts.png" /&gt;
&lt;p&gt;Proportionnellement, l'implémentation du protocole pour les resources REST est
la plus volumineuse dans le code source de &lt;em&gt;Cliquet&lt;/em&gt;.
Cependant, comme nous l'avons décrit plus haut, &lt;em&gt;Cliquet&lt;/em&gt; fournit tout un
ensemble d'outillage et de bonnes pratiques, et reste
donc tout à fait pertinent pour n'importe quel type d'API, même sans
manipulation de données !&lt;/p&gt;
&lt;p&gt;L'objectif de la boîte à outils est de faire en sorte qu'un développeur puisse constuire
une application simplement, en étant sûr qu'elle réponde aux exigeances de la
mise en production, tout en ayant la possibilité de remplacer certaines parties
au fur et à mesure que ses besoins se précisent.&lt;/p&gt;
&lt;p&gt;Par exemple, la persistence fournie par défault est &lt;em&gt;schemaless&lt;/em&gt; (e.g &lt;em&gt;JSONB&lt;/em&gt;),
mais rien n'empêcherait d'implémenter le stockage dans un modèle relationnel.&lt;/p&gt;
&lt;p&gt;Comme les composants peuvent être remplacés depuis la configuration, il est
tout à fait possible d'étendre &lt;em&gt;Cliquet&lt;/em&gt; avec des notions métiers ou des
technologies exotiques ! Nous avons posé quelques idées dans &lt;a class="reference external" href="http://cliquet.readthedocs.org/en/latest/ecosystem.html"&gt;la documentation
de l'éco-système&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Dans les prochaines semaines, nous allons introduire la notion d'«évènements» (ou signaux),
qui permettraient aux extensions de s'interfacer beaucoup plus proprement.&lt;/p&gt;
&lt;p&gt;Nous attachons beaucoup d'importance à la clareté du code, la pertinence des
&lt;em&gt;patterns&lt;/em&gt;, des tests et de la documentation. Si vous avez des commentaires,
des critiques ou des interrogations, n'hésitez pas à &lt;a class="reference external" href="https://github.com/mozilla-services/cliquet/issues"&gt;nous en faire part&lt;/a&gt; !&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="cliquet-a-l-action"&gt;
&lt;h2&gt;Cliquet, à l'action.&lt;/h2&gt;
&lt;p&gt;Nous avons écrit un &lt;a class="reference external" href="http://cliquet.readthedocs.org/en/latest/quickstart.html"&gt;guide de démarrage&lt;/a&gt;,
qui n'exige pas de connaître &lt;em&gt;Pyramid&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Pour illustrer la simplicité et les concepts, voici quelques extraits !&lt;/p&gt;
&lt;div class="section" id="etape-1"&gt;
&lt;h3&gt;Étape 1&lt;/h3&gt;
&lt;p&gt;Activer &lt;em&gt;Cliquet&lt;/em&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="hll"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;cliquet&lt;/span&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pyramid.config&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Configurator&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;global_config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;settings&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;Configurator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="hll"&gt; &lt;span class="n"&gt;cliquet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize&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="s1"&gt;&amp;#39;1.0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt; &lt;span class="k"&gt;return&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;make_wsgi_app&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;À partir de là, la plupart des outils de &lt;em&gt;Cliquet&lt;/em&gt; sont activés et accessibles.&lt;/p&gt;
&lt;p&gt;Par exemple, les URLs &lt;em&gt;hello&lt;/em&gt; (&lt;tt class="docutils literal"&gt;/v1/&lt;/tt&gt;) ou &lt;em&gt;supervision&lt;/em&gt; (&lt;tt class="docutils literal"&gt;/v1/__heartbeat__&lt;/tt&gt;).
Mais aussi les backends de stockage, de cache, etc.
qu'il est possible d'utiliser dans des vues classiques &lt;em&gt;Pyramid&lt;/em&gt; ou &lt;em&gt;Cornice&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="etape-2"&gt;
&lt;h3&gt;Étape 2&lt;/h3&gt;
&lt;p&gt;Ajouter des vues:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;global_config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;settings&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;Configurator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cliquet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize&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="s1"&gt;&amp;#39;1.0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="hll"&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;myproject.views&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt; &lt;span class="k"&gt;return&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;make_wsgi_app&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour définir des resources CRUD, il faut commencer par définir un schéma,
avec &lt;em&gt;Colander&lt;/em&gt;, et ensuite déclarer une resource:&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;cliquet&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;schema&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BookmarkSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResourceSchema&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;schema&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="hll"&gt;&lt;span class="nd"&gt;@resource.register&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bookmark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BaseResource&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;mapping&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BookmarkSchema&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Désormais, la resource CRUD est disponible sur &lt;tt class="docutils literal"&gt;/v1/bookmarks&lt;/tt&gt;, avec toutes
les fonctionnalités de synchronisation, filtrage, tri, pagination, timestamp, etc.
De base les enregistrements sont privés, par utilisateur.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="err"&gt;http&lt;/span&gt; &lt;span class="err"&gt;GET&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://localhost:8000/v1/bookmarks&amp;quot;&lt;/span&gt;
&lt;span class="err"&gt;HTTP/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="err"&gt;OK&lt;/span&gt;
&lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nt"&gt;&amp;quot;data&amp;quot;&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="nt"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://cliquet.readthedocs.org&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;cc103eb5-0c80-40ec-b6f5-dad12e7d975e&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;&amp;quot;last_modified&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1437034418940&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="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="etape-3"&gt;
&lt;h3&gt;Étape 3&lt;/h3&gt;
&lt;p&gt;Évidemment, il est possible choisir les URLS, les verbes HTTP supportés, de modifier
des champs avant l'enregistrement, etc.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="hll"&gt;&lt;span class="nd"&gt;@resource.register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collection_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/user/bookmarks&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;record_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/user/bookmarks/{{id}}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;collection_methods&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;GET&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bookmark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BaseResource&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;mapping&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BookmarkSchema&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="hll"&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;process_record&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;new&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;old&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&gt;&lt;span class="hll"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;device&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;device&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;device&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;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&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;User-Agent&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;device&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a class="reference external" href="http://cliquet.readthedocs.org/en/latest/reference/resource.html"&gt;Plus d'infos dans la documentation dédiée&lt;/a&gt; !&lt;/p&gt;
&lt;div class="admonition note"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;Il est possible de définir des resources sans validation de schema.
&lt;a class="reference external" href="https://github.com/mozilla-services/kinto/blob/master/kinto/views/records.py"&gt;Voir le code source de Kinto&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="etape-4-optionelle"&gt;
&lt;h3&gt;Étape 4 (optionelle)&lt;/h3&gt;
&lt;p&gt;Utiliser les abstractions de &lt;em&gt;Cliquet&lt;/em&gt; dans une vue &lt;em&gt;Cornice&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Par exemple, une vue qui utilise le backend de stockage:&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;cliquet&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;score&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;score&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="s1"&gt;&amp;#39;/score/{game}&amp;#39;&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;Store game score&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@score.post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ScoreSchema&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;post_score&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;collection_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;scores-&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;match_dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;game&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;user_id&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;authenticated_userid&lt;/span&gt;
&lt;span class="n"&gt;value&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;validated&lt;/span&gt; &lt;span class="c1"&gt;# c.f. Cornice.&lt;/span&gt;
&lt;span class="hll"&gt; &lt;span class="n"&gt;storage&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;registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;
&lt;/span&gt;&lt;span class="hll"&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collection_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&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&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="vos-retours"&gt;
&lt;h2&gt;Vos retours&lt;/h2&gt;
&lt;p&gt;N'hésitez pas à nous faire part de vos retours ! Cela vous a donné envie
d'essayer ? Vous connaissez un outil similaire ?
Y-a-t-il des points qui ne sont pas clairs ? Manque de cas d'utilisation concrets ?
Certains aspects mal pensés ? Trop contraignants ? Trop de magie ? Overkill ?&lt;/p&gt;
&lt;p&gt;Nous prenons tout.&lt;/p&gt;
&lt;div class="section" id="points-faibles"&gt;
&lt;h3&gt;Points faibles&lt;/h3&gt;
&lt;p&gt;Nous sommes très fiers de ce que nous avons construit, en relativement peu
de temps. Et comme nous l'exposions dans &lt;a class="reference external" href="{filename/2015.07.whistler-use-cases.rst}"&gt;l'article précédent&lt;/a&gt;, il y a du potentiel !&lt;/p&gt;
&lt;p&gt;Cependant, nous sommes conscients d'un certain nombre de points
qui peuvent être vus comme des faiblesses.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;La documentation d'API&lt;/strong&gt; : actuellement, nous n'avons pas de solution pour qu'un
projet qui utilise &lt;em&gt;Cliquet&lt;/em&gt; puisse intégrer facilement toute
&lt;a class="reference external" href="http://cliquet.readthedocs.org/en/latest/api/index.html"&gt;la documentation de l'API&lt;/a&gt;
obtenue.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;La documentation&lt;/strong&gt; : il est très difficile d'organiser la documentation, surtout
quand le public visé est aussi bien débutant qu'expérimenté. Nous sommes probablement
victimes du «&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Curse_of_knowledge"&gt;curse of knowledge&lt;/a&gt;».&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le protocole&lt;/strong&gt; : on sent bien qu'on va devoir versionner le protocole. Au
moins pour le désolidariser des versions de &lt;em&gt;Cliquet&lt;/em&gt;, si on veut aller au
bout de la philosophie et de l'éco-système.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Le conservatisme&lt;/strong&gt; : Nous aimons la stabilité et la robustesse. Mais surtout
nous ne sommes pas tout seuls et devons nous plier aux contraintes de la mise
en production ! Cependant, nous avons très envie de faire de l'async avec Python 3 !&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Publication de versions&lt;/strong&gt; : le revers de la médaille de la factorisation. Il
arrive qu'on préfère faire évoluer le toolkit (e.g. ajouter une option) pour
un point précis d'un projet. En conséquence, on doit souvent releaser les
projets en cascade.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="quelques-questions-courantes"&gt;
&lt;h3&gt;Quelques questions courantes&lt;/h3&gt;
&lt;blockquote&gt;
Pourquoi Python ?&lt;/blockquote&gt;
&lt;p&gt;On prend beaucoup de plaisir à écrire du Python, et le calendrier annoncé
initialement était très serré: pas question de tituber avec une technologie
mal maitrisée !&lt;/p&gt;
&lt;p&gt;Et puis, après avoir passé près d'un an sur un projet Node.js, l'équipe avait
bien envie de refaire du Python.&lt;/p&gt;
&lt;blockquote&gt;
Pourquoi pas Django ?&lt;/blockquote&gt;
&lt;p&gt;On y a pensé, surtout parce qu'il y a plusieurs fans de &lt;em&gt;Django REST Framework&lt;/em&gt;
dans l'équipe.&lt;/p&gt;
&lt;p&gt;On l'a écarté principalement au profit de la légèreté et la modularité de
&lt;em&gt;Pyramid&lt;/em&gt;.&lt;/p&gt;
&lt;blockquote&gt;
Pourquoi pas avec un framework asynchrone en Python 3+ ?&lt;/blockquote&gt;
&lt;p&gt;Pour l'instant nos administrateurs système nous imposent des déploiements en
Python 2.7, à notre grand désarroi /o\&lt;/p&gt;
&lt;p&gt;Pour &lt;em&gt;Reading List&lt;/em&gt;, nous &lt;a class="reference external" href="https://github.com/mozilla-services/readinglist/blob/1.7.0/readinglist/__init__.py#L19-L26"&gt;avions activé&lt;/a&gt;
&lt;em&gt;gevent&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Puisque l'approche consiste à implémenter un protocole bien déterminé, nous n'excluons
pas un jour d'écrire un &lt;em&gt;Cliquet&lt;/em&gt; en &lt;em&gt;aiohttp&lt;/em&gt; ou &lt;em&gt;Go&lt;/em&gt; si cela s'avèrerait pertinent.&lt;/p&gt;
&lt;blockquote&gt;
Pourquoi pas JSON-API ?&lt;/blockquote&gt;
&lt;p&gt;Comme nous l'expliquions &lt;a class="reference external" href="{filename}/2015.05.retour-apidays.rst"&gt;au retour des APIdays&lt;/a&gt;,
JSON-API est une spécification qui rejoint plusieurs de nos intentions.&lt;/p&gt;
&lt;p&gt;Quand nous avons commencé le protocole, nous ne connaissions pas JSON-API.
Pour l'instant, comme notre proposition est beaucoup plus minimaliste, le
rapprochement n'a &lt;a class="reference external" href="https://github.com/mozilla-services/cliquet/issues/254"&gt;pas dépassé le stade de la discussion&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
Est-ce que Cliquet est un framework REST pour Pyramid ?&lt;/blockquote&gt;
&lt;p&gt;Non.&lt;/p&gt;
&lt;p&gt;Au delà des classes de resources CRUD de Cliquet, qui implémentent un
protocole bien précis, il faut utiliser Cornice ou Pyramid directement.&lt;/p&gt;
&lt;blockquote&gt;
Est-ce que Cliquet est suffisamment générique pour des projets hors Mozilla ?&lt;/blockquote&gt;
&lt;p&gt;Premièrement, nous faisons en sorte que tout soit contrôlable depuis la
configuration &lt;tt class="docutils literal"&gt;.ini&lt;/tt&gt; pour permettre la dés/activation ou substitution des
composants.&lt;/p&gt;
&lt;p&gt;Si le protocole HTTP/JSON des resources CRUD vous satisfait,
alors Cliquet est probablement le plus court chemin pour construire une
application qui tient la route.&lt;/p&gt;
&lt;p&gt;Mais l'utilisation des resources CRUD est facultative, donc Cliquet reste pertinent
si les bonnes pratiques en terme de mise en production ou les abstractions fournies
vous paraissent valables !&lt;/p&gt;
&lt;p&gt;Cliquet reste un moyen simple d'aller très vite pour mettre sur pied
une application Pyramid/Cornice.&lt;/p&gt;
&lt;blockquote&gt;
Est-ce que les resources JSON supporte les modèles relationnels complexes ?&lt;/blockquote&gt;
&lt;p&gt;La couche de persistence fournie est très simple, et devrait
répondre à la majorité des cas d'utilisation où les données n'ont pas de
relations.&lt;/p&gt;
&lt;p&gt;En revanche, il est tout à fait possible de bénéficier de tous les aspects
du protocole en utilisant une classe &lt;tt class="docutils literal"&gt;Collection&lt;/tt&gt; maison, qui se chargerait
elle de manipuler les relations.&lt;/p&gt;
&lt;p&gt;Le besoin de relations pourrait être un bon prétexte pour implémenter le
protocole avec Django REST Framework :)&lt;/p&gt;
&lt;blockquote&gt;
Est-il possible de faire ci ou ça avec Cliquet ?&lt;/blockquote&gt;
&lt;p&gt;Nous aimerions collecter des besoins pour écrire un ensemble de «recettes/tutoriels». Mais
pour ne pas travailler dans le vide, nous aimerions &lt;a class="reference external" href="https://github.com/mozilla-services/cliquet/issues"&gt;connaitre vos idées&lt;/a&gt; !
(&lt;em&gt;ex. brancher l'authentification Github, changer le format du logging JSON, stocker des
données cartographiques, ...&lt;/em&gt;)&lt;/p&gt;
&lt;blockquote&gt;
Est-ce que Cliquet peut manipuler des fichiers ?&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="https://github.com/mozilla-services/cliquet/issues/236"&gt;Nous l'envisageons&lt;/a&gt;,
mais pour l'instant nous attendons que le besoin survienne en interne pour se
lancer.&lt;/p&gt;
&lt;p&gt;Si c'est le cas, le protocole utilisé sera &lt;a class="reference external" href="http://remotestorage.io/"&gt;Remote Storage&lt;/a&gt;,
afin notamment de s'intégrer dans l'éco-système grandissant.&lt;/p&gt;
&lt;blockquote&gt;
Est-ce que la fonctionnalité X va être implémentée ?&lt;/blockquote&gt;
&lt;p&gt;&lt;em&gt;Cliquet&lt;/em&gt; est déjà bien garni. Plutôt qu'implémenter la fonctionnalité X,
il y a de grandes chances que nous agissions pour s'assurer que les abstractions
et les mécanismes d'extension fournis permettent de l'implémenter sous forme
d'extension.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</content></entry><entry><title>Service de nuages : Perspectives pour l'été</title><link href="https://blog.notmyidea.org/service-de-nuages-perspectives-pour-lete-fr.html" rel="alternate"></link><published>2015-07-07T00:00:00+02:00</published><updated>2015-07-07T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-07-07:/service-de-nuages-perspectives-pour-lete-fr.html</id><summary type="html">&lt;p class="first last"&gt;Le travail en cours et les fonctionnalités à venir pour les prochains mois.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;em&gt;Cet article est repris depuis le blog « Service de Nuages » de mon équipe à Mozilla&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Mozilla a pour coutume d'organiser régulièrement des semaines de travail où tous les employés
sont réunis physiquement. Pour cette dernière édition, nous avons pu retrouver
nos collègues du monde entier à &lt;a class="reference external" href="http://www.openstreetmap.org/node/268148288#map=4/50.12/-122.95"&gt;Whistler, en Colombie Britannique au Canada&lt;/a&gt; !&lt;/p&gt;
&lt;img alt="«All Hands» talk about Lego, by &amp;#64;davidcrob - CC0" class="align-center" src="{filename}/images/whistler-talks.jpg" /&gt;
&lt;p&gt;Ce fût l'occasion pour notre équipe de se retrouver, et surtout de partager notre
vision et nos idées dans le domaine du stockage, afin de collecter des cas d'utilisation pour
notre solution &lt;a class="reference external" href="https://kinto.readthedocs.org"&gt;Kinto&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Dans cet article, nous passons en revue les pistes que nous avons pour
les prochains mois.&lt;/p&gt;
&lt;div class="section" id="ateliers-et-promotion"&gt;
&lt;h2&gt;Ateliers et promotion&lt;/h2&gt;
&lt;p&gt;Nicolas a présenté &lt;a class="reference external" href="https://github.com/mozilla-services/kinto.js"&gt;Kinto.js&lt;/a&gt; dans un atelier dédié, avec comme support de
présentation le &lt;a class="reference external" href="http://kintojs.readthedocs.org/en/latest/tutorial/"&gt;tutorial d'introduction&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;L'application résultante, pourtant toute simple, permet d'appréhender les
concepts de synchronisation de Kinto. Le tout sans installation prélable,
puisque Rémy a mis en place un &lt;a class="reference external" href="https://kinto.dev.mozaws.net/v1/"&gt;serveur de dev effacé tous les jours&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous avions mis un point d'honneur à faire du Vanilla.JS, déjà pour éviter les
combats de clochers autour des frameworks, mais aussi pour mettre en évidence qu'avec
HTML5 et ES6, on n'était plus aussi démunis qu'il y a quelques années.&lt;/p&gt;
&lt;p&gt;Ce petit atelier nous a permis de nous rendre compte qu'on avait encore de
grosses lacunes en terme de documentation, surtout en ce qui concerne
l'éco-système et la vision globale des projets (Kinto, Kinto.js, Cliquet, ...).
Nous allons donc faire de notre mieux pour combler ce manque.&lt;/p&gt;
&lt;img alt="Kinto.js workshop - CC0" class="align-center" src="{filename}/images/whistler-workshop.jpg" /&gt;
&lt;/div&gt;
&lt;div class="section" id="mozilla-payments"&gt;
&lt;h2&gt;Mozilla Payments&lt;/h2&gt;
&lt;p&gt;Comme &lt;a class="reference external" href="http://www.servicedenuages.fr/la-gestion-des-permissions"&gt;décrit précédemment&lt;/a&gt;, nous avons mis en place un système de permissions pour répondre aux besoins de suivi des paiements et abonnements.&lt;/p&gt;
&lt;p&gt;Pour ce projet, Kinto sera utilisé depuis une application Django, via un client Python.&lt;/p&gt;
&lt;p&gt;Maintenant que les développements ont été livrés, il faut transformer l'essai, réussir l'intégration, l'hébergement et la montée en puissance. La solution doit être livrée à la fin de l'année.&lt;/p&gt;
&lt;div class="section" id="a-venir"&gt;
&lt;h3&gt;À venir&lt;/h3&gt;
&lt;p&gt;Nous aimerions en profiter pour implémenter une fonctionnalité qui nous tient à coeur : la construction de la liste des enregistrements accessibles en lecture sur une collection partagée.&lt;/p&gt;
&lt;img alt="Whistler Alta Lake - CC0" class="align-center" src="{filename}/images/whistler-lake.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="firefox-os-et-stockage"&gt;
&lt;h2&gt;Firefox OS et stockage&lt;/h2&gt;
&lt;p&gt;Nous avons eu beaucoup d'échanges avec l'équipe de Firefox OS, avec qui nous avions
déjà eu l'occasion de collaborer, pour le &lt;a class="reference external" href="https://github.com/mozilla-services/msisdn-gateway"&gt;serveur d'identification BrowserID par SMS&lt;/a&gt; et pour &lt;a class="reference external" href="https://github.com/mozilla-services/loop-server"&gt;Firefox Hello&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="in-app-sync"&gt;
&lt;h3&gt;In-App sync&lt;/h3&gt;
&lt;p&gt;Kinto, la solution simple promue pour la synchronisation de données dans les applications
Firefox OS ? La classe ! C'est ce qu'on avait en tête depuis longtemps, déjà à
l'époque avec &lt;a class="reference external" href="http://daybed.readthedocs.org/"&gt;Daybed&lt;/a&gt;. Voici donc une belle opportunité à saisir !&lt;/p&gt;
&lt;p&gt;Il va falloir expliciter les limitations et hypothèses simplificatrices de notre
solution, surtout en termes de gestion de la concurrence. Nous sommes persuadés
que ça colle avec la plupart des besoins, mais il ne faudrait pas décevoir :)&lt;/p&gt;
&lt;p&gt;Le fait que &lt;a class="reference external" href="https://github.com/daleharvey"&gt;Dale&lt;/a&gt;, un des auteurs de &lt;a class="reference external" href="http://pouchdb.com/"&gt;PouchDB&lt;/a&gt; et &lt;a class="reference external" href="https://github.com/michielbdejong"&gt;Michiel de Jong&lt;/a&gt;, un des auteurs de &lt;a class="reference external" href="http://remotestorage.io/"&gt;Remote Storage&lt;/a&gt;, nous aient encouragés sur nos premiers pas nous a bien motivé !&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cut-the-rope"&gt;
&lt;h3&gt;Cut the Rope&lt;/h3&gt;
&lt;p&gt;Kinto devrait être mis à profit pour synchroniser les paramètres et les scores
du &lt;a class="reference external" href="http://mozilla.cuttherope.net/"&gt;jeu&lt;/a&gt;. Un premier exercice et une première vitrine sympas !&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="syncto"&gt;
&lt;h3&gt;« SyncTo »&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://docs.services.mozilla.com/storage/apis-1.5.html"&gt;Firefox Sync&lt;/a&gt; est la solution qui permet de synchroniser les données de Firefox (favoris, extensions, historique, complétion des formulaires, mots de passe, ...) entre plusieurs périphériques, de manière chiffrée.&lt;/p&gt;
&lt;p&gt;L'implémentation du client en JavaScript est relativement complexe et date un peu maintenant.
Le code existant n'est pas vraiment portable dans &lt;em&gt;Firefox OS&lt;/em&gt; et les tentatives de réécriture
n'ont pas abouti.&lt;/p&gt;
&lt;p&gt;Nous souhaitons implémenter un pont entre &lt;em&gt;Kinto&lt;/em&gt; et &lt;em&gt;Firefox Sync&lt;/em&gt;, de manière
à pouvoir utiliser le client &lt;em&gt;Kinto.js&lt;/em&gt;, plus simple et plus moderne, pour récupérer
les contenus et les stocker dans IndexedDB. Le delta à implémenter côté serveur est faible car nous nous étions
inspirés du protocole déjà éprouvé de Sync. Côté client, il s'agira surtout de
câbler l'authentification BrowserId et la Crypto.&lt;/p&gt;
&lt;p&gt;Alexis a sauté sur l'occasion pour commencer l'écriture d'&lt;a class="reference external" href="https://github.com/mozilla-services/syncclient"&gt;un client python pour Firefox Sync&lt;/a&gt;, qui servira de brique de base pour l'écriture du service.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cloud-storage"&gt;
&lt;h3&gt;Cloud Storage&lt;/h3&gt;
&lt;p&gt;Eden Chuang et Sean Lee ont présenté les avancées sur l'intégration de services de stockages
distants (&lt;em&gt;DropBox, Baidu Yun&lt;/em&gt;) dans &lt;em&gt;Firefox OS&lt;/em&gt;. Actuellement, leur preuve de
concept repose sur &lt;a class="reference external" href="https://fr.wikipedia.org/wiki/Filesystem_in_Userspace"&gt;FUSE&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous avons évidemment en tête d'introduire la notion de fichiers attachés dans
&lt;em&gt;Kinto&lt;/em&gt;, en implémentant la specification
&lt;a class="reference external" href="https://tools.ietf.org/html/draft-dejong-remotestorage-05"&gt;*Remote Storage*&lt;/a&gt;,
mais pour l'instant les cas d'utilisations ne se sont pas encore présentés officiellement.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="id2"&gt;
&lt;h3&gt;À venir&lt;/h3&gt;
&lt;p&gt;Nous serons probablement amenés à introduire la gestion de la concurrence dans
le client JS, en complément de ce qui a été fait sur le serveur, pour permettre
les écritures simultanées et synchronisation en tâche de fond.&lt;/p&gt;
&lt;p&gt;Nous sommes par ailleurs perpétuellement preneurs de vos retours — et bien
entendu de vos contributions — tant sur le code &lt;a class="reference external" href="https://github.com/mozilla-services/kinto/"&gt;serveur&lt;/a&gt;
que &lt;a class="reference external" href="https://github.com/mozilla-services/kinto.js/"&gt;client&lt;/a&gt; !&lt;/p&gt;
&lt;img alt="Firefox OS Cloud Storage Presentation - CC0" class="align-center" src="{filename}/images/whistler-cloud-storage.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="contenus-applicatifs-de-firefox"&gt;
&lt;h2&gt;Contenus applicatifs de Firefox&lt;/h2&gt;
&lt;p&gt;Aujourd'hui Firefox a un cycle de release de six semaines. Un des objectifs
consiste à désolidariser certains contenus applicatifs de ces cycles
relativement longs (ex. &lt;em&gt;règles de securité, dictionnaires, traductions, ...&lt;/em&gt;) &lt;a class="footnote-reference" href="#id4" id="id3"&gt;[1]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Il s'agit de données JSON et binaire qui doivent être versionnées et synchronisées par
les navigateurs (&lt;em&gt;lecture seule&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Il y a plusieurs outils officiels qui existent pour gérer ça (&lt;em&gt;Balrog&lt;/em&gt;, &lt;em&gt;Shavar&lt;/em&gt;, ...),
et pour l'instant, aucun choix n'a été fait. Mais lors des conversations avec
l'équipe en charge du projet, ce fût vraiment motivant de voir que même pour
ce genre de besoins internes, &lt;em&gt;Kinto&lt;/em&gt; est tout aussi pertinent !&lt;/p&gt;
&lt;table class="docutils footnote" frame="void" id="id4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id3"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;La bonne nouvelle c'est que toutes les fonctionnalités &lt;em&gt;third-party&lt;/em&gt; qui ont
été intégrées récemment vont redevenir des &lt;em&gt;add-ons&lt;/em&gt; \o/.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;img alt="Landscape - CC0" class="align-center" src="{filename}/images/whistler-landscape.jpg" /&gt;
&lt;/div&gt;
&lt;div class="section" id="awesome-bar"&gt;
&lt;h2&gt;Awesome bar&lt;/h2&gt;
&lt;p&gt;L'équipe &lt;em&gt;Firefox Labs&lt;/em&gt;, le laboratoire qui élève des pandas roux en éprouvette,
serait vraiment intéressé par notre solution, notamment pour abreuver en données
un prototype pour améliorer &lt;em&gt;Awesome bar&lt;/em&gt;, qui fusionnerait URL, historique et recherche.&lt;/p&gt;
&lt;p&gt;Nous ne pouvons pas en dire beaucoup plus pour l'instant, mais les fonctionnalités
de collections d'enregistrements partagées entre utilisateurs de &lt;em&gt;Kinto&lt;/em&gt;
correspondent parfaitement à ce qui est envisagé pour le futur du navigateur :)&lt;/p&gt;
&lt;div class="section" id="id5"&gt;
&lt;h3&gt;À venir&lt;/h3&gt;
&lt;p&gt;Nous serons donc probablement amenés, avant de la fin de l'année, à introduire des
fonctionnalités d'indexation et de recherche &lt;em&gt;full-text&lt;/em&gt; (comprendre &lt;em&gt;ElasticSearch&lt;/em&gt;).
Cela rejoint nos plans précédents, puisque c'est quelque chose que nous avions dans
&lt;em&gt;Daybed&lt;/em&gt;, et qui figurait sur notre feuille de route !&lt;/p&gt;
&lt;img alt="Firefox Labs Meeting - CC0" class="align-center" src="{filename}/images/whistler-labs.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="browser-html"&gt;
&lt;h2&gt;Browser.html&lt;/h2&gt;
&lt;p&gt;L'équipe &lt;em&gt;Recherche&lt;/em&gt; explore les notions de plateforme, et travaille notamment
sur l'implémentation d'un navigateur en JS/HTML avec &lt;em&gt;React&lt;/em&gt;:
&lt;a class="reference external" href="https://github.com/mozilla/browser.html"&gt;browser.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Kinto&lt;/em&gt; correspond parfaitement aux attentes
de l'équipe pour synchroniser les données associées à un utilisateur.&lt;/p&gt;
&lt;p&gt;Il pourrait s'agir de données de navigation (comme Sync), mais aussi de collections
d'enregistrements diverses, comme par exemple les préférences du navigateur
ou un équivalent à &lt;em&gt;Alexa.com Top 500&lt;/em&gt; pour fournir la complétion d'URL sans
interroger le moteur de recherche.&lt;/p&gt;
&lt;p&gt;L'exercice pourrait être poussé jusqu'à la synchronisation d'états &lt;em&gt;React&lt;/em&gt;
entre périphériques (par exemple pour les onglets).&lt;/p&gt;
&lt;div class="section" id="id7"&gt;
&lt;h3&gt;À venir&lt;/h3&gt;
&lt;p&gt;Si &lt;em&gt;browser.html&lt;/em&gt; doit stocker des données de navigation, il faudra ajouter
des fonctionnalités de chiffrement sur le client JS. Ça tombe bien, c'est un
sujet passionant, et &lt;a class="reference external" href="http://www.w3.org/TR/WebCryptoAPI/"&gt;il y a plusieurs standards&lt;/a&gt; !&lt;/p&gt;
&lt;p&gt;Pour éviter d'interroger le serveur à intervalle régulier afin de synchroniser les
changements, l'introduction des &lt;a class="reference external" href="https://w3c.github.io/push-api/"&gt;*push notifications*&lt;/a&gt; semble assez naturelle.
Il s'agirait alors de la dernière pierre qui manque à l'édifice pour obtenir
un «&lt;em&gt;Mobile/Web backend as a service&lt;/em&gt;» complet.&lt;/p&gt;
&lt;img alt="Roadmap - CC0" class="align-center" src="{filename}/images/whistler-roadmap.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous sommes dans une situation idéale, puisque ce que nous avions imaginé
sur &lt;a class="reference external" href="https://github.com/mozilla-services/kinto/wiki/Roadmap"&gt;notre feuille de route&lt;/a&gt; correspond à ce qui nous est demandé par les
différentes équipes.&lt;/p&gt;
&lt;p&gt;L'enjeu consiste maintenant à se coordonner avec tout le monde, ne pas décevoir,
tenir la charge, continuer à améliorer et à faire la promotion du produit, se concentrer
sur les prochaines étapes et embarquer quelques contributeurs à nos cotés pour
construire une solution libre, générique, simple et auto-hébergeable pour le stockage
de données sur le Web :)&lt;/p&gt;
&lt;img alt="Friday Night Party - CC0" class="align-center" src="{filename}/images/whistler-top-roof.jpg" /&gt;
&lt;/div&gt;
</content></entry><entry><title>Service de nuages : Stocker et interroger les permissions avec Kinto</title><link href="https://blog.notmyidea.org/service-de-nuages-stocker-et-interroger-les-permissions-avec-kinto-fr.html" rel="alternate"></link><published>2015-05-26T00:00:00+02:00</published><updated>2015-05-26T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-05-26:/service-de-nuages-stocker-et-interroger-les-permissions-avec-kinto-fr.html</id><summary type="html">&lt;p class="first last"&gt;Comment faire pour stocker et interroger la base de données au sujet des permissions avec Kinto ?&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;em&gt;Cet article est repris depuis le blog « Service de Nuages » de mon équipe à Mozilla&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tl;dr: On a maintenant un super système de permission mais comment faire pour stocker et interroger ces permissions de manière efficace ?&lt;/strong&gt;&lt;/p&gt;
&lt;div class="section" id="la-problematique"&gt;
&lt;h2&gt;La problématique&lt;/h2&gt;
&lt;p&gt;Maintenant que nous avons défini un modèle de gestion des permissions
sur les objets qui nous satisfait, le problème est de stocker ces
permissions de manière efficace afin de pouvoir autoriser ou interdire
l'accès à un objet pour la personne qui fait la requête.&lt;/p&gt;
&lt;p&gt;Chaque requête sur notre API va générer une ou plusieurs demandes
d'accès, il faut donc que la réponse soit très rapide sous peine
d'impacter la vélocité du service.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="obtenir-la-liste-des-principals-d-un-utilisateur"&gt;
&lt;h2&gt;Obtenir la liste des &amp;quot;principals&amp;quot; d'un utilisateur&lt;/h2&gt;
&lt;p&gt;Les &lt;em&gt;principals&lt;/em&gt; de l'utilisateur correspondent à son &lt;tt class="docutils literal"&gt;user_id&lt;/tt&gt;
ainsi qu'à la liste des identifiants des groupes dans lesquels il a
été ajouté.&lt;/p&gt;
&lt;p&gt;Pour éviter de recalculer les &lt;em&gt;principals&lt;/em&gt; de l'utilisateur à chaque
requête, le mieux reste de maintenir une liste des &lt;em&gt;principals&lt;/em&gt; par
utilisateur.&lt;/p&gt;
&lt;p&gt;Ainsi lorsqu'on ajoute un utilisateur à un groupe, il faut bien penser
à ajouter le groupe à la liste des &lt;em&gt;principals&lt;/em&gt; de l'utilisateur.&lt;/p&gt;
&lt;p&gt;Ça se complexifie lorsqu'on ajoute un groupe à un groupe.&lt;/p&gt;
&lt;p&gt;Dans un premier temps interdire l'ajout d'un groupe à un groupe est
une limitation qu'on est prêts à accepter pour simplifier le
modèle.&lt;/p&gt;
&lt;p&gt;L'avantage de maintenir la liste des &lt;em&gt;principals&lt;/em&gt; d'un utilisateur
lors de la modification de cette liste c'est qu'elle est déjà
construite lors des lectures, qui sont dans notre cas plus fréquentes
que les écritures.&lt;/p&gt;
&lt;p&gt;Cela nécessite de donner un identifiant unique aux groupes pour tous
les &lt;em&gt;buckets&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Nous proposons de de les nommer avec leur URI:
&lt;tt class="docutils literal"&gt;/buckets/blog/groups/moderators&lt;/tt&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="obtenir-la-liste-des-principals-d-un-ace"&gt;
&lt;h2&gt;Obtenir la liste des &amp;quot;principals&amp;quot; d'un ACE&lt;/h2&gt;
&lt;blockquote&gt;
Rappel, un &amp;quot;ACE&amp;quot; est un &lt;em&gt;Access Control Entry&lt;/em&gt;, un des éléments
d'une ACL (e.g. &lt;em&gt;modifier un enregistrement&lt;/em&gt;).&lt;/blockquote&gt;
&lt;p&gt;Avec le &lt;a class="reference external" href="{filename}/2015.05.cliquet-permissions.rst"&gt;système de permissions choisi&lt;/a&gt;, les permissions d'un
objet héritent de celle de l'objet parent.&lt;/p&gt;
&lt;p&gt;Par exemple, avoir le droit d'écriture sur un &lt;em&gt;bucket&lt;/em&gt; permet la
création des permissions et la modification de tous ses records.&lt;/p&gt;
&lt;p&gt;Ce qui veut dire que pour obtenir la liste complète des &lt;em&gt;principals&lt;/em&gt;
ayant une permission sur un objet, il faut regarder à plusieurs
endroits.&lt;/p&gt;
&lt;p&gt;Rémy a &lt;a class="reference external" href="https://gist.github.com/Natim/77c8f61c1d42e476cef8#file-permission-py-L9-L52"&gt;décrit dans un gist la liste d'héritage de chaque permission&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Prenons l'exemple de l'ajout d'un record dans une collection.&lt;/p&gt;
&lt;p&gt;Le droit &lt;tt class="docutils literal"&gt;records:create&lt;/tt&gt; est obtenu si l'on a l'un des droits suivants:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;bucket:write&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;collection:write&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;records:create&lt;/tt&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notre première idée était de stocker les permissions sur chaque objet
et de maintenir la liste exhaustive des permissions lors d'une
modification d'ACL. Cependant cela nécessitait de construire cette
liste lors de l'ajout d'un objet et de mettre à jour tout l'arbre lors
de sa suppression. (&lt;em&gt;Je vous laisse imaginer le nombre d'opérations
nécessaires pour ajouter un administrateur sur un *bucket&lt;/em&gt; contenant
1000 collections avec 100000 records chacune.*)&lt;/p&gt;
&lt;p&gt;La solution que nous avons désormais adoptée consiste à stocker les
&lt;em&gt;principals&lt;/em&gt; de chaque &lt;em&gt;ACE&lt;/em&gt; (&lt;em&gt;qui&lt;/em&gt; a le droit de faire telle action
sur l'objet), et de faire l'union des &lt;em&gt;ACE&lt;/em&gt; hérités, afin de les
croiser avec les &lt;em&gt;principals&lt;/em&gt; de l'utilisateur :&lt;/p&gt;
&lt;blockquote&gt;
(ACE(object, permission) inherited_ACE) ∩ PRINCIPALS(user)&lt;/blockquote&gt;
&lt;p&gt;Par exemple l'ACE: &lt;tt class="docutils literal"&gt;/buckets/blog/collections/article:records:create&lt;/tt&gt; hérite de
l'ACE &lt;tt class="docutils literal"&gt;/buckets/blog/collections/article:write&lt;/tt&gt; et de &lt;tt class="docutils literal"&gt;/buckets/blog:write&lt;/tt&gt; :&lt;/p&gt;
&lt;blockquote&gt;
(ACE(/buckets/blog/collections/article:records:create) ACE(/buckets/blog/collections/article:write) ACE(/buckets/blog:write)) ∩ PRINCIPALS('fxa:alexis')&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="recuperer-les-donnees-de-l-utilisateur"&gt;
&lt;h2&gt;Récupérer les données de l'utilisateur&lt;/h2&gt;
&lt;p&gt;La situation se corse lorsqu'on souhaite limiter la liste des
&lt;em&gt;records&lt;/em&gt; d'une collection à ceux accessibles pour l'utilisateur, car
on doit faire cette intersection pour tous les &lt;em&gt;records&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Une première solution est de regarder si l'utilisateur est mentionné
dans les &lt;em&gt;ACL*s du *bucket&lt;/em&gt; ou de la &lt;em&gt;collection&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;Ensuite, si ce n'est pas le cas, alors on filtre les &lt;em&gt;records&lt;/em&gt; pour
lesquels les &lt;em&gt;principals&lt;/em&gt; correspondent à ceux de l'utilisateur.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_user_principals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;can_read_all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;has_read_perms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collection_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;principals&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;can_read_all&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;records&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_all_records&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collection_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;filters&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="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;records&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;filter_read_records&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collection_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;filters&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;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il faudra faire quelque chose de similaire pour la suppression
multiple, lorsqu'un utilisateur souhaitera supprimer des
enregistrements sur lesquels il a les droits de lecture mais pas
d'écriture.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="le-modele-de-donnees"&gt;
&lt;h2&gt;Le modèle de données&lt;/h2&gt;
&lt;p&gt;Pour avoir une idée des requêtes dans un backend SQL, voyons un peu ce
que donnerait le modèle de données.&lt;/p&gt;
&lt;div class="section" id="le-format-des-id"&gt;
&lt;h3&gt;Le format des ID&lt;/h3&gt;
&lt;p&gt;Utiliser des URI comme identifiant des objets présente de nombreux
avantages (lisibilité, unicité, cohérence avec les URLs)&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;bucket: &lt;tt class="docutils literal"&gt;/buckets/blog&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;groupe: &lt;tt class="docutils literal"&gt;/buckets/blog/group/moderators&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;collection: &lt;tt class="docutils literal"&gt;/buckets/blog/collections/articles&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;record: &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;/buckets/blog/collections/articles/records/02f3f76f-7059-4ae4-888f-2ac9824e9200&lt;/span&gt;&lt;/tt&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="les-tables"&gt;
&lt;h3&gt;Les tables&lt;/h3&gt;
&lt;p&gt;Pour le stockage des principals et des permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;principals&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;perms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ace&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;principals&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;La table &lt;em&gt;perms&lt;/em&gt; va associer des &lt;em&gt;principals&lt;/em&gt; à chaque &lt;em&gt;ACE&lt;/em&gt;
(e.g.``/buckets/blog:write``).&lt;/p&gt;
&lt;p&gt;Pour le stockage des données:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent_id&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt; &lt;span class="n"&gt;JSONB&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;write_principals&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="n"&gt;read_principals&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;La colonne &lt;em&gt;parent_id&lt;/em&gt; permet de savoir à qui appartient l'objet
(e.g. groupe d'un &lt;em&gt;bucket&lt;/em&gt;, collection d'un &lt;em&gt;bucket&lt;/em&gt;, &lt;em&gt;record&lt;/em&gt; d'une
collection, ...).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="exemple-d-utilisateur"&gt;
&lt;h3&gt;Exemple d'utilisateur&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;fxa:alexis&amp;#39;&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="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;fxa:natim&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;/buckets/blog/groups/moderators&amp;quot;}&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="exemple-d-objets"&gt;
&lt;h3&gt;Exemple d'objets&lt;/h3&gt;
&lt;div class="section" id="bucket"&gt;
&lt;h4&gt;Bucket&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;read_principals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;write_principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;bucket&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;name&amp;quot;: &amp;quot;blog&amp;quot;}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;JSONB&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="s1"&gt;&amp;#39;{&amp;quot;fxa:alexis&amp;quot;}&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="group"&gt;
&lt;h4&gt;Group&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;read_principals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;write_principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/groups/moderators&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;group&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;name&amp;quot;: &amp;quot;moderators&amp;quot;, &amp;quot;members&amp;quot;: [&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;fxa&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;natim&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="n"&gt;JSONB&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="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;Ce groupe peut être gére par &lt;tt class="docutils literal"&gt;fxa:alexis&lt;/tt&gt; puisqu'il a la permission
&lt;tt class="docutils literal"&gt;write&lt;/tt&gt; dans le &lt;em&gt;bucket&lt;/em&gt; parent.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="collection"&gt;
&lt;h4&gt;Collection&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;read_principals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;write_principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/articles&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;collection&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;name&amp;quot;: &amp;quot;article&amp;quot;}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;JSONB&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;system.Everyone&amp;quot;}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;/buckets/blog/groups/moderators&amp;quot;}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cette collection d'articles peut être lue par tout le monde,
et gérée par les membres du groupe &lt;tt class="docutils literal"&gt;moderators&lt;/tt&gt;, ainsi que
&lt;tt class="docutils literal"&gt;fxa:alexis&lt;/tt&gt;, via le &lt;em&gt;bucket&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="records"&gt;
&lt;h4&gt;Records&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;read_principals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;write_principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/articles/records/02f3f76f-7059-4ae4-888f-2ac9824e9200&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;record&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/articles&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;{&amp;quot;name&amp;quot;: &amp;quot;02f3f76f-7059-4ae4-888f-2ac9824e9200&amp;quot;,&lt;/span&gt;
&lt;span class="s1"&gt; &amp;quot;title&amp;quot;: &amp;quot;Stocker les permissions&amp;quot;, ...}&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;JSONB&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="s1"&gt;&amp;#39;{}&amp;#39;&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="interroger-les-permissions"&gt;
&lt;h3&gt;Interroger les permissions&lt;/h3&gt;
&lt;div class="section" id="id1"&gt;
&lt;h4&gt;Obtenir la liste des &amp;quot;principals&amp;quot; d'un ACE&lt;/h4&gt;
&lt;p&gt;Comme vu plus haut, pour vérifier une permission, on fait l'union des
&lt;em&gt;principals&lt;/em&gt; requis par les objets hérités, et on teste leur
intersection avec ceux de l'utilisateur:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;required_principals&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;unnest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;perms&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ace&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog:write&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog:read&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/article:write&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/article:read&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="n"&gt;user_principals&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;unnest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;fxa:natim&amp;#39;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;COUNT&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="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;user_principals&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;required_principals&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;p&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="filtrer-les-objets-en-fonction-des-permissions"&gt;
&lt;h4&gt;Filtrer les objets en fonction des permissions&lt;/h4&gt;
&lt;p&gt;Pour filtrer les objets, on fait une simple intersection de liste
(&lt;em&gt;merci PostgreSQL&lt;/em&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;record&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/buckets/blog/collections/article&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_principals&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt;
&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write_principals&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;principals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;fxa:natim&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les listes s'indexent bien, notamment grâce aux &lt;a class="reference external" href="http://www.postgresql.org/docs/current/static/indexes-types.html"&gt;index GIN&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="avec-redis"&gt;
&lt;h3&gt;Avec Redis&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Redis&lt;/em&gt; présente plusieurs avantages pour ce genre de
problématiques. Notamment, il gère les &lt;em&gt;set&lt;/em&gt; nativement (listes de
valeurs uniques), ainsi que les opérations d'intersection et d'union.&lt;/p&gt;
&lt;p&gt;Avec &lt;em&gt;Redis&lt;/em&gt; on peut écrire l'obtention des &lt;em&gt;principals&lt;/em&gt; pour un &lt;em&gt;ACE&lt;/em&gt;
comme cela :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;SUNIONSTORE temp_perm:/buckets/blog/collections/articles:write permission:/buckets/blog:write permission:/buckets/blog/collections/articles:write
SINTER temp_perm:/buckets/blog/collections/articles:write principals:fxa:alexis
&lt;/pre&gt;&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;SUNIONSTORE&lt;/tt&gt; permet de créer un set contenant les éléments de
l'union de tous les set suivants. Dans notre cas on le nomme
&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;temp_perm:/buckets/blog/collections/articles:write&lt;/span&gt;&lt;/tt&gt; et il contient
l'union des sets d'ACLs suivants:
- &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;permission:/buckets/blog:write&lt;/span&gt;&lt;/tt&gt;
- &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;permission:/buckets/blog/collections/articles:write&lt;/span&gt;&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;SINTER&lt;/tt&gt; retourne l'intersection de tous les sets passés en paramètres dans notre cas :
- &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;temp_perm:/buckets/blog/collections/articles:write&lt;/span&gt;&lt;/tt&gt;
- &lt;tt class="docutils literal"&gt;principals:fxa:alexis&lt;/tt&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Plus d'informations sur :
- &lt;a class="reference external" href="http://redis.io/commands/sinter"&gt;http://redis.io/commands/sinter&lt;/a&gt;
- &lt;a class="reference external" href="http://redis.io/commands/sunionstore"&gt;http://redis.io/commands/sunionstore&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Si le set résultant de la commande &lt;tt class="docutils literal"&gt;SINTER&lt;/tt&gt; n'est pas vide, alors
l'utilisateur possède la permission.&lt;/p&gt;
&lt;p&gt;On peut ensuite supprimer la clé temporaire &lt;tt class="docutils literal"&gt;temp_perm&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;En utilisant &lt;tt class="docutils literal"&gt;MULTI&lt;/tt&gt; on peut &lt;a class="reference external" href="https://gist.github.com/Natim/77c8f61c1d42e476cef8#file-permission-py-L117-L124"&gt;même faire tout cela au sein d'une
transaction&lt;/a&gt;
et garantir ainsi l'intégrité de la requête.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;La solution a l'air simple mais nous a demandé beaucoup de réflexion
en passant par plusieurs propositions.&lt;/p&gt;
&lt;p&gt;L'idée finale est d'avoir :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Un backend spécifique permettant de stocker les &lt;em&gt;principals&lt;/em&gt; des
utilisateurs et des &lt;em&gt;ACE&lt;/em&gt; (e.g. avec les sets Redis) ;&lt;/li&gt;
&lt;li&gt;La liste des principals read et write sur la table des objets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;C'est dommage d'avoir le concept de permissions à deux endroits, mais
cela permet de connaître rapidement la permission d'un utilisateur sur
un objet et également de pouvoir récupérer tous les objets d'une
collection pour un utilisateur si celui-ci n'a pas accès à tous les
records de la collection, ou toutes les collections du bucket.&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>Les problèmes de PGP</title><link href="https://blog.notmyidea.org/les-problemes-de-pgp.html" rel="alternate"></link><published>2015-05-25T00:00:00+02:00</published><updated>2015-05-25T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-05-25:/les-problemes-de-pgp.html</id><summary type="html">&lt;blockquote&gt;
&lt;p&gt;Flip a bit in the communication between sender and recipient and they
will experience decryption or verification errors. How high are the
chances they will start to exchange the data in the clear rather than
trying to hunt down the man in the middle?&lt;/p&gt;
&lt;p&gt;-- &lt;a href="http://secushare.org/PGP"&gt;http://secushare.org/PGP&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Une fois …&lt;/p&gt;</summary><content type="html">&lt;blockquote&gt;
&lt;p&gt;Flip a bit in the communication between sender and recipient and they
will experience decryption or verification errors. How high are the
chances they will start to exchange the data in the clear rather than
trying to hunt down the man in the middle?&lt;/p&gt;
&lt;p&gt;-- &lt;a href="http://secushare.org/PGP"&gt;http://secushare.org/PGP&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Une fois passé l'euphorie du "il faut utiliser PGP pour l'ensemble de
nos communications", j'ai réalisé lors de discussions que PGP avait
plusieurs problèmes, parmi ceux-ci:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Les &lt;em&gt;meta données&lt;/em&gt; (y compris le champ "sujet" de la conversation)
sont quand même échangées en clair (il est possible de savoir qu'un
message à été échangé entre telle et telle personne, a telle date);&lt;/li&gt;
&lt;li&gt;PGP se base sur un protocole de communication qui est lui non
chiffré, et il est donc facile de soit se tromper, soit dégrader le
mode de conversation vers une méthode non chiffrée;&lt;/li&gt;
&lt;li&gt;Il est facile de connaître votre réseau social avec PGP, puisque
tout le principe est de signer les clés des personnes dont vous
validez l'identité;&lt;/li&gt;
&lt;li&gt;En cas de fuite de votre clé privée, tous les messages que vous avez
chiffrés avec elle sont compromis. On dit que PGP ne fournit pas de
&lt;em&gt;forward secrecy&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;La découverte de la clé de pairs se passe souvent &lt;em&gt;en clair&lt;/em&gt;, sans
utiliser une connexion "sécurisée" (HTTPS). Tout le monde peut donc
voir ces échanges et savoir de qui vous cherchez la clé;&lt;/li&gt;
&lt;li&gt;Les discussions de groupes sont très difficiles: il faut chiffrer
pour chacun des destinataires (ou que ceux-ci partagent une paire de
clés).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Je suis en train de creuser à propos les alternatives à PGP, par exemple
&lt;a href="https://pond.imperialviolet.org/"&gt;Pond&lt;/a&gt;, qui lui ne construit pas par
dessus un standard déjà établi, et donc n'hérite pas de ses défauts
(mais pas non plus de son réseau déjà établi).&lt;/p&gt;
&lt;p&gt;En attendant, quelques bonnes pratiques sur PGP ;)&lt;/p&gt;
&lt;h2 id="bonnes-pratiques"&gt;Bonnes pratiques&lt;/h2&gt;
&lt;p&gt;Il est en fait assez facile d'utiliser PGP de travers. Riseup à fait &lt;a href="https://help.riseup.net/en/security/message-security/openpgp/best-practices"&gt;un
excellent
guide&lt;/a&gt;
qui explique comment configurer son installation correctement.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;J'en ai déjà parlé, mais il faut absolument choisir des phrases de
passes suffisamment longues. Pas facile de les retenir, mais
indispensable. Vous pouvez aussi avoir un document chiffré avec une
clé que vous ne mettez jamais en ligne, qui contiens ces phrases de
passe, au cas ou vous les oubliez.&lt;/li&gt;
&lt;li&gt;Générez des clés RSA de 4096 bits, en utilisant sha512;&lt;/li&gt;
&lt;li&gt;Il faut utiliser une date d'expiration de nos clés suffisamment
proche (2 ans). Il est possible de repousser cette date si
nécessaire, par la suite.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Parmi les choses les plus frappantes que j'ai rencontrées:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Utiliser le &lt;em&gt;flag&lt;/em&gt; hidden-recipient avec PGP pour ne pas dévoiler
qui est le destinataire du message;&lt;/li&gt;
&lt;li&gt;Ne pas envoyer les messages de brouillons sur votre serveur, ils le
seraient en clair !;&lt;/li&gt;
&lt;li&gt;Utilisez HPKS pour communiquer avec les serveurs de clés, sinon tout
le trafic est en clair.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le &lt;a href="https://bitmask.net/"&gt;projet Bitmask&lt;/a&gt; vise lui à rendre les outils
de chiffrement d'échanges de messages et de VPN simples à utiliser,
encore quelque chose à regarder.&lt;/p&gt;
&lt;p&gt;Enfin bref, y'a du taf.&lt;/p&gt;</content></entry><entry><title>Simplifier les preuves d'identités</title><link href="https://blog.notmyidea.org/simplifier-les-preuves-didentites.html" rel="alternate"></link><published>2015-05-11T00:00:00+02:00</published><updated>2015-05-11T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-05-11:/simplifier-les-preuves-didentites.html</id><summary type="html">
&lt;ul&gt;
&lt;li&gt;headline&lt;br&gt;
Qu'est-ce que Keybase.io et comment essayent-ils de simplifier la
création de preuves d'identité.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;L'un des problèmes non réellement résolu actuellement quant au
chiffrement des échanges est lié à l'authenticité des clés. Si quelqu'un
décide de publier une clé en mon nom, et en utilisant mon adresse email,
cela …&lt;/p&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;headline&lt;br&gt;
Qu'est-ce que Keybase.io et comment essayent-ils de simplifier la
création de preuves d'identité.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;L'un des problèmes non réellement résolu actuellement quant au
chiffrement des échanges est lié à l'authenticité des clés. Si quelqu'un
décide de publier une clé en mon nom, et en utilisant mon adresse email,
cela lui est assez facile.&lt;/p&gt;
&lt;p&gt;Il est donc nécessaire d'avoir des moyens de prouver que la clé publique
que j'utilise est réellement la mienne.&lt;/p&gt;
&lt;p&gt;Traditionnellement, il est nécessaire de faire signer ma clé publique
par d'autres personnes, via une rencontre en personne ou des échanges
hors du réseau. C'est par exemple ce qui est réalisé lors des &lt;a href="https://fr.wikipedia.org/wiki/Key_signing_party"&gt;Key
Signing parties&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Une manière simple d'effectuer ces vérifications serait, en plus de
donner son adresse email, sa signature de clé, ou a minima de donner un
mot clé pour valider que les échanges proviennent bien de la bonne
personne.&lt;/p&gt;
&lt;p&gt;PGP propose un mécanisme de signature des clés d'autrui, une fois celles
ci validées, ce qui permet de placer sa confiance dans les signataires
de la clé.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://keybase.io"&gt;Keybase.io&lt;/a&gt; est un service qui vise à rendre la
création de ces preuves plus facile, en partant du principe qu'il est
possible d'utiliser différents moyens afin de prouver l'identité des
personnes. Par exemple, leurs comptes Twitter, GitHub ou leurs noms de
domaines. De la même manière qu'il est possible de signer (valider) les
clés de nos amis, il est possible de les "tracker" selon le jargon de
keybase.&lt;/p&gt;
&lt;p&gt;Donc, en somme, &lt;em&gt;Keybase.io&lt;/em&gt; est un annuaire, qui tente de rendre plus
facile la création de preuves. Bien.&lt;/p&gt;
&lt;h2 id="quelques-points-dombre"&gt;Quelques points d'ombre&lt;/h2&gt;
&lt;p&gt;Il s'agit d'une &lt;em&gt;startup&lt;/em&gt; américaine, domiciliée dans le Delaware, qui
se trouve être un des paradis fiscaux qui &lt;a href="https://fr.wikipedia.org/wiki/Delaware"&gt;est connu pour être un
paradis fiscal au coeur même des
États-Unis&lt;/a&gt;. Je ne veux pas
faire de raccourcis trop rapides, bien évidemment, alors &lt;a href="https://github.com/keybase/keybase-issues/issues/1569"&gt;j'ai ouvert un
ticket sur GitHub pour en savoir
plus&lt;/a&gt; (après
tout, le fait d'être un paradis fiscal permet peut-être d'échapper à
certaines lois sur la requêtes de données). D'autant plus étonnant, la
startup n'a pour l'instant &lt;a href="https://github.com/keybase/keybase-issues/issues/788"&gt;pas de &lt;em&gt;business
model&lt;/em&gt;&lt;/a&gt; (ce qui en
un sens est assez rassurant, même si on peut se poser la question de
pourquoi faire une startup dans ces cas là).&lt;/p&gt;
&lt;p&gt;Le service (bien qu'en Alpha), n'est pas mis à disposition sous licence
libre, ce qui pour l'instant empêche quiconque de créer son propre
serveur Keybase. &lt;a href="https://github.com/keybase/"&gt;Une partie des composants, cependant, le sont (open
source)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;J'ai du mal à croire en des initiatives qui veulent sauver le monde,
mais dans leur coin, je ne comprends pas pourquoi il n'y à pas de
documentation sur comment monter son propre serveur, ou comment les
aider à travailler sur la fédération. Mais bon, c'est pour l'instant une
initiative encore fraîche, et je lui laisse le bénéfice du doute.&lt;/p&gt;
&lt;p&gt;Sur le long terme, une infrastructure comme &lt;em&gt;Keybase.io&lt;/em&gt;, devra
évidemment être
&lt;a href="https://github.com/keybase/keybase-issues/issues/162"&gt;distribuée&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We've been talking about a total decentralization, but we have to
solve a couple things, synchronization in particular. Right now
someone can mirror us and a client can trust a mirror just as easily
as the server at keybase.io, but there needs to be a way of announcing
proofs to any server and having them cooperate with each other. We'd
be so happy to get this right.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="http://chris.beams.io/posts/keybase/"&gt;Chris Coyne, co-founder of
Keybase&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Afin de se "passer" de leur service centralisé, les preuves générées
(qui sont la force du système qu'ils mettent en place) pourraient être
exportées sur des serveurs de clés existants. C'est quelque chose
&lt;a href="https://github.com/keybase/keybase-issues/issues/890"&gt;qu'ils souhaitent réaliser
.&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Bref, une initiative quand même importante et utile, même si elle
soulève des questions qui méritent qu'on s'y attarde un brin.&lt;/p&gt;
&lt;p&gt;Par ailleurs, &lt;a href="https://leap.se/nicknym"&gt;d'autres projets qui visent des objectifs
similaires&lt;/a&gt; existent, via le projet LEAP, mais
je n'ai pas encore creusé.&lt;/p&gt;</content></entry><entry><title>Phrases de passe et bonnes pratiques</title><link href="https://blog.notmyidea.org/phrases-de-passe-et-bonnes-pratiques.html" rel="alternate"></link><published>2015-05-09T00:00:00+02:00</published><updated>2015-05-09T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-05-09:/phrases-de-passe-et-bonnes-pratiques.html</id><summary type="html">
&lt;ul&gt;
&lt;li&gt;headline&lt;br&gt;
Communiquer de manière chiffrée n'est pas aisée, et nécessite de
mémoriser des phrases de passes complexes. Comment s'en sortir ?&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Au contraire des autres mots de passe, les mots de passe
cryptographiques ont specifiquement besoin d'être longs et extremement
difficiles à deviner. La raison est qu'un ordinateur (ou un cluster …&lt;/p&gt;&lt;/blockquote&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;headline&lt;br&gt;
Communiquer de manière chiffrée n'est pas aisée, et nécessite de
mémoriser des phrases de passes complexes. Comment s'en sortir ?&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Au contraire des autres mots de passe, les mots de passe
cryptographiques ont specifiquement besoin d'être longs et extremement
difficiles à deviner. La raison est qu'un ordinateur (ou un cluster de
plusieurs ordinateurs) peut être programmé pour faire des trillions
d'essais de manière automatique. Si le mot de passe choisi est trop
faible ou construit d'une manière trop prédictible, cette attaque par
la force pourrait se revéler fructueuse en essayant toutes les
possibilités.&lt;/p&gt;
&lt;p&gt;-- &lt;a href="https://www.eff.org/wp/defending-privacy-us-border-guide-travelers-carrying-digital-devices"&gt;The Electronic Frontier
Foundation&lt;/a&gt;
(traduction de mon fait)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Comprendre les concepts et l'écosystème qui permettent d'avoir une vie
numérique chiffrée n'est pas quelque chose d'aisé.
&lt;a href="https://emailselfdefense.fsf.org/fr/"&gt;Plusieurs&lt;/a&gt;
&lt;a href="http://www.controle-tes-donnees.net/outils/GnuPG.html"&gt;guides&lt;/a&gt; ont été
écrits à ce propos, et pour autant je me rends compte que naïvement il
est possible de mal utiliser les outils existants.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Utilisez un &lt;em&gt;bon&lt;/em&gt; mot de passe pour votre session utilisateur et une
&lt;em&gt;bonne&lt;/em&gt; phrase de passe pour proteger votre clé privée. Cette phrase
de passe est la partie la plus fragile de tout le système.&lt;/p&gt;
&lt;p&gt;-- La page de manuel de GPG.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Une phrase de passe devrait:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Être suffisamment longue pour être difficile à deviner;&lt;/li&gt;
&lt;li&gt;Ne pas être une citation connue (littérature, livres sacrés etc);&lt;/li&gt;
&lt;li&gt;Difficile à deviner même pour vos proches;&lt;/li&gt;
&lt;li&gt;Facile à se souvenir et à taper;&lt;/li&gt;
&lt;li&gt;être unique et non partagée entre différents sites / applications
etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Une des techniques consiste à utiliser des mots du dictionnaire,
sélectionnés de manière aléatoire, puis modifiés.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://imgs.xkcd.com/comics/password_strength.png"&gt;&lt;/p&gt;
&lt;p&gt;Micah Lee &lt;a href="https://github.com/micahflee/passphrases"&gt;travaille également sur un
outil&lt;/a&gt; qui vise à rendre la
mémorisation des phrases de passe plus aisée, de par leur répétition
avec des pauses de plus en plus longues.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="%7Bfilename%7D/static/passphrases.png"&gt;&lt;/p&gt;
&lt;p&gt;Oui, ce n'est pas aussi simple que ce qu'il y parait. Pour ma part, j'ai
une copie en local de mes clés, dans un fichier chiffré avec une autre
clé que j'ai généré pour l'occasion et que je ne partagerait pas. J'ai
par ailleurs &lt;a href="https://github.com/jamessan/vim-gnupg"&gt;configuré&lt;/a&gt; mon
éditeur de texte pour pouvoir chiffrer les documents textes par défaut.&lt;/p&gt;
&lt;p&gt;J'ai donc regénéré une nouvelle fois mes clés de travail et
personnelles, en utilisant des phrases de passe plus complexes.&lt;/p&gt;
&lt;p&gt;Reste encore la question de la sauvegarde de ces clés privées de manière
chiffrée, que je n'ai pas encore résolue. Bref, tout cela me semble bien
compliqué pour réussir à l'expliquer à des novices, qui pour certains ne
sont même pas sur de l'intérêt de la chose.&lt;/p&gt;</content></entry><entry><title>Eco-système et stockage générique</title><link href="https://blog.notmyidea.org/eco-systeme-et-stockage-generique.html" rel="alternate"></link><published>2015-04-30T00:00:00+02:00</published><updated>2015-04-30T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2015-04-30:/eco-systeme-et-stockage-generique.html</id><summary type="html">
&lt;p&gt;&lt;strong&gt;tl;dr Nous devons construire un service de suivi de paiements, et nous
hésitons à continuer à nous entêter avec notre propre solution de
stockage/synchronisation.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Comme nous l'écrivions &lt;a href="%7Bfilename%7D/2015.04.service-de-nuages.rst"&gt;dans l'article
précédent&lt;/a&gt;, nous
souhaitons construire une solution de stockage générique. On refait
&lt;a href="http://daybed.readthedocs.org"&gt;Daybed&lt;/a&gt; chez Mozilla !&lt;/p&gt;
&lt;p&gt;Notre objectif est simple: permettre …&lt;/p&gt;</summary><content type="html">
&lt;p&gt;&lt;strong&gt;tl;dr Nous devons construire un service de suivi de paiements, et nous
hésitons à continuer à nous entêter avec notre propre solution de
stockage/synchronisation.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Comme nous l'écrivions &lt;a href="%7Bfilename%7D/2015.04.service-de-nuages.rst"&gt;dans l'article
précédent&lt;/a&gt;, nous
souhaitons construire une solution de stockage générique. On refait
&lt;a href="http://daybed.readthedocs.org"&gt;Daybed&lt;/a&gt; chez Mozilla !&lt;/p&gt;
&lt;p&gt;Notre objectif est simple: permettre aux développeurs d'application,
internes à Mozilla ou du monde entier, de faire persister et
synchroniser facilement des données associées à un utilisateur.&lt;/p&gt;
&lt;div id="storage-specs"&gt;
Les aspects de l'architecture qui nous semblent incontournables:
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;La solution doit reposer sur un protocole, et non sur une
implémentation ;&lt;/li&gt;
&lt;li&gt;L'auto-hébergement de l'ensemble doit être simplissime ;&lt;/li&gt;
&lt;li&gt;L'authentification doit être &lt;em&gt;pluggable&lt;/em&gt;, voire décentralisée
(OAuth2, FxA, Persona) ;&lt;/li&gt;
&lt;li&gt;Les enregistrements doivent pouvoir être validés par le serveur ;&lt;/li&gt;
&lt;li&gt;Les données doivent pouvoir être stockées dans n'importe quel
backend ;&lt;/li&gt;
&lt;li&gt;Un système de permissions doit permettre de protéger des
collections, ou de partager des enregistrements de manière fine ;&lt;/li&gt;
&lt;li&gt;La résolution de conflits doit pouvoir avoir lieu sur le serveur ;&lt;/li&gt;
&lt;li&gt;Le client doit être pensé «*offline-first*» ;&lt;/li&gt;
&lt;li&gt;Le client doit pouvoir réconcilier les données simplement ;&lt;/li&gt;
&lt;li&gt;Le client doit pouvoir être utilisé aussi bien dans le navigateur
que côté serveur ;&lt;/li&gt;
&lt;li&gt;Tous les composants se doivent d´être simples et substituables
facilement.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;La première question qui nous a été posée fût «*Pourquoi vous
n'utilisez pas PouchDB ou Remote Storage ?*»&lt;/p&gt;
&lt;h2 id="remote-storage"&gt;Remote Storage&lt;/h2&gt;
&lt;p&gt;Remote Storage est un standard ouvert pour du stockage par utilisateur.
&lt;a href="http://tools.ietf.org/html/draft-dejong-remotestorage-04"&gt;La
specification&lt;/a&gt;
se base sur des standards déjà existants et éprouvés: Webfinger, OAuth
2, CORS et REST.&lt;/p&gt;
&lt;p&gt;L'API est simple, des &lt;a href="http://blog.cozycloud.cc/news/2014/08/12/when-unhosted-meets-cozy-cloud/"&gt;projets prestigieux
l'utilisent&lt;/a&gt;.
Il y a plusieurs &lt;a href="https://github.com/jcoglan/restore"&gt;implémentations&lt;/a&gt;
du serveur, et il existe &lt;a href="https://www.npmjs.com/package/remotestorage-server"&gt;un squelette
Node&lt;/a&gt; pour
construire un serveur sur mesure.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Remote Storage widget" src="%7Bfilename%7D/images/remotestorage-widget.png"&gt;&lt;/p&gt;
&lt;p&gt;Le client
&lt;a href="https://github.com/remotestorage/remotestorage.js/"&gt;remoteStorage.js&lt;/a&gt;
permet d'intégrer la solution dans les applications Web. Il se charge du
«store local», du cache, de la synchronization, et fournit un widget qui
permet aux utilisateurs des applications de choisir le serveur qui
recevra les données (via Webfinger).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/michielbdejong/ludbud"&gt;ludbud&lt;/a&gt;, la version épurée de
&lt;em&gt;remoteStorage.js&lt;/em&gt;, se limite à l'abstraction du stockage distant. Cela
permettrait à terme, d'avoir une seule bibliothèque pour stocker dans un
serveur &lt;em&gt;remoteStorage&lt;/em&gt;, &lt;em&gt;ownCloud&lt;/em&gt; ou chez les méchants comme &lt;em&gt;Google
Drive&lt;/em&gt; ou &lt;em&gt;Dropbox&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Au premier abord, la spécification correspond à ce que nous voulons
accomplir:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;La philosophie du protocole est saine;&lt;/li&gt;
&lt;li&gt;L'éco-système est bien fichu;&lt;/li&gt;
&lt;li&gt;La vision politique colle: redonner le contrôle des données aux
utilisateurs (voir &lt;a href="http://unhosted.org/"&gt;unhosted&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;Les choix techniques compatibles avec ce qu'on a commencé (CORS,
REST, OAuth 2);&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;En revanche, vis à vis de la manipulation des données, il y a plusieurs
différences avec ce que nous souhaitons faire:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;L'API suit globalement une métaphore «fichiers» (dossier/documents),
plutôt que «données» (collection/enregistrements) ;&lt;/li&gt;
&lt;li&gt;Il n'y a pas de validation des enregistrements selon un schéma (même
si &lt;a href="https://remotestorage.io/doc/code/files/baseclient/types-js.html"&gt;certaines
implémentations&lt;/a&gt;
du protocole le font) ;&lt;/li&gt;
&lt;li&gt;Il n'y a pas la possibilité de trier/filtrer les enregistrements
selon des attributs ;&lt;/li&gt;
&lt;li&gt;Les permissions &lt;a href="https://groups.google.com/forum/#!topic/unhosted/5_NOGq8BPTo"&gt;se limitent à
privé/public&lt;/a&gt;
(et &lt;a href="https://github.com/remotestorage/spec/issues/58#issue-27249452"&gt;l'auteur envisage plutôt un modèle à la
Git&lt;/a&gt;)[1]
;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;En résumé, il semblerait que ce que nous souhaitons faire avec le
stockage d'enregistrements validés est complémentaire avec &lt;em&gt;Remote
Storage&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Si des besoins de persistence orientés «fichiers» se présentent, a
priori nous aurions tort de réinventer les solutions apportées par cette
spécification. Il y a donc de grandes chances que nous l´intégrions à
terme, et que &lt;em&gt;Remote Storage&lt;/em&gt; devienne une facette de notre solution.&lt;/p&gt;
&lt;h2 id="pouchdb"&gt;PouchDB&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://pouchdb.com/"&gt;PouchDB&lt;/a&gt; est une bibliothèque JavaScript qui
permet de manipuler des enregistrements en local et de les synchroniser
vers une base distante.&lt;/p&gt;
&lt;p&gt;``` sourceCode javascript
var db = new PouchDB('dbname');&lt;/p&gt;
&lt;p&gt;db.put({
_id: 'dave@gmail.com',
name: 'David',
age: 68
});&lt;/p&gt;
&lt;p&gt;db.replicate.to('http://example.com/mydb');
```&lt;/p&gt;
&lt;p&gt;Le projet a le vent en poupe, bénéficie de nombreux contributeurs,
l'éco-système est très riche et l'adoption par des projets &lt;a href="https://github.com/hoodiehq/wip-hoodie-store-on-pouchdb"&gt;comme
Hoodie&lt;/a&gt; ne fait
que confirmer la pertinence de l'outil pour les développeurs frontend.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;PouchDB&lt;/em&gt; gère un « store » local, dont la persistence est abstraite et
&lt;a href="http://pouchdb.com/2014/07/25/pouchdb-levels-up.html"&gt;repose sur&lt;/a&gt; l'API
&lt;a href="https://github.com/level/levelup#relationship-to-leveldown"&gt;LevelDown&lt;/a&gt;
pour persister les données dans &lt;a href="https://github.com/Level/levelup/wiki/Modules#storage-back-ends"&gt;n'importe quel
backend&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Même si &lt;em&gt;PouchDB&lt;/em&gt; adresse principalement les besoins des applications
«*offline-first*», il peut être utilisé aussi bien dans le navigateur
que côté serveur, via Node.&lt;/p&gt;
&lt;h3 id="synchronisation"&gt;Synchronisation&lt;/h3&gt;
&lt;p&gt;La synchronisation (ou réplication) des données locales s'effectue sur
un &lt;a href="http://couchdb.apache.org/"&gt;CouchDB&lt;/a&gt; distant.&lt;/p&gt;
&lt;p&gt;Le projet &lt;a href="https://github.com/pouchdb/pouchdb-server"&gt;PouchDB Server&lt;/a&gt;
implémente l'API de CouchDB en NodeJS. Comme &lt;em&gt;PouchDB&lt;/em&gt; est utilisé, on
obtient un service qui se comporte comme un &lt;em&gt;CouchDB&lt;/em&gt; mais qui stocke
ses données n'importe où, dans un &lt;em&gt;Redis&lt;/em&gt; ou un &lt;em&gt;PostgreSQL&lt;/em&gt; par
exemple.&lt;/p&gt;
&lt;p&gt;La synchronisation est complète. Autrement dit, tous les enregistrements
qui sont sur le serveur se retrouvent synchronisés dans le client. Il
est possible de filtrer les collections synchronisées, mais cela &lt;a href="http://pouchdb.com/2015/04/05/filtered-replication.html"&gt;n'a
pas pour objectif de sécuriser l'accès aux
données&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;L'approche recommandée pour cloisonner les données par utilisateur
consiste à créer &lt;a href="https://github.com/nolanlawson/pouchdb-authentication#some-people-can-read-some-docs-some-people-can-write-those-same-docs"&gt;une base de données par
utilisateur&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ce n'est pas forcément un problème, CouchDB &lt;a href="https://mail-archives.apache.org/mod_mbox/couchdb-user/201401.mbox/%3C52CEB873.7080404@ironicdesign.com%3E"&gt;supporte des centaines de
milliers de bases sans
sourciller&lt;/a&gt;.
Mais selon les cas d'utilisation, le cloisement n'est pas toujours
facile à déterminer (par rôle, par application, par collection, ...).&lt;/p&gt;
&lt;h2 id="le-cas-dutilisation-payments"&gt;Le cas d'utilisation « Payments »&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Put Payments Here -- Before the Internet - CC-NC-SA Katy Silberger
https://www.flickr.com/photos/katysilbs/11163812186" src="%7Bfilename%7D/images/put-payments.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Dans les prochaines semaines, nous devrons mettre sur pied un prototype
pour tracer l'historique des paiements et abonnements d'un utilisateur.&lt;/p&gt;
&lt;p&gt;Le besoin est simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;l'application « Payment » enregistre les paiements et abonnements
d'un utilisateur pour une application donnée;&lt;/li&gt;
&lt;li&gt;l'application « Donnée » interroge le service pour vérifier qu'un
utilisateur a payé ou est abonné;&lt;/li&gt;
&lt;li&gt;l'utilisateur interroge le service pour obtenir la liste de tous ses
abonnements.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Seule l'application « Payment » a le droit de créer/modifier/supprimer
des enregistrements, les deux autres ne peuvent que consulter en lecture
seule.&lt;/p&gt;
&lt;p&gt;Une application donnée ne peut pas accéder aux paiements des autres
applications, et un utilisateur ne peut pas accéder aux paiements des
autres utilisateurs.&lt;/p&gt;
&lt;h3 id="avec-remotestorage"&gt;Avec RemoteStorage&lt;/h3&gt;
&lt;p&gt;&lt;img alt="Remote Love - CC-BY-NC Julie
https://www.flickr.com/photos/mamajulie2008/2609549461" src="%7Bfilename%7D/images/remote-love.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Clairement, l'idée de &lt;em&gt;RemoteStorage&lt;/em&gt; est de dissocier l'application
executée, et les données créées par l'utilisateur avec celle-ci.&lt;/p&gt;
&lt;p&gt;Dans notre cas, c'est l'application « Payment » qui manipule des données
concernant un utilisateur. Mais celles-ci ne lui appartiennent pas
directement: certes un utilisateur doit pouvoir les supprimer, surtout
pas en créer ou les modifier!&lt;/p&gt;
&lt;p&gt;La notion de permissions limitée à privé/publique ne suffit pas dans ce
cas précis.&lt;/p&gt;
&lt;h3 id="avec-pouchdb"&gt;Avec PouchDB&lt;/h3&gt;
&lt;p&gt;Il va falloir créer une &lt;em&gt;base de données&lt;/em&gt; par utilisateur, afin d'isoler
les enregistrements de façon sécurisée. Seule l'application « Payment »
aura tous les droits sur les databases.&lt;/p&gt;
&lt;p&gt;Mais cela ne suffit pas.&lt;/p&gt;
&lt;p&gt;Il ne faut pas qu'une application puisse voir les paiements des autres
applications, donc il va aussi falloir recloisonner, et créer une &lt;em&gt;base
de données&lt;/em&gt; par application.&lt;/p&gt;
&lt;p&gt;Quand un utilisateur voudra accéder à l'ensemble de ses paiements, il
faudra agréger les &lt;em&gt;databases&lt;/em&gt; de toutes les applications. Quand
l'équipe marketing voudra faire des statistiques sur l'ensemble des
applications, il faudra agrégér des centaines de milliers de
&lt;em&gt;databases&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Ce qui est fort dommage, puisqu'il est probable que les paiements ou
abonnements d'un utilisateur pour une application se comptent sur les
doigts d'une main. Des centaines de milliers de bases contenant moins de
5 enregistrements ?&lt;/p&gt;
&lt;p&gt;De plus, dans le cas de l'application « Payment », le serveur est
implémenté en Python. Utiliser un wrapper JavaScript comme le fait
&lt;a href="https://pythonhosted.org/Python-PouchDB/"&gt;python-pouchdb&lt;/a&gt; cela ne nous
fait pas trop rêver.&lt;/p&gt;
&lt;h2 id="un-nouvel-eco-systeme"&gt;Un nouvel éco-système ?&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Wagon wheel - CC-BY-NC-SA arbyreed
https://www.flickr.com/photos/19779889@N00/16161808220" src="%7Bfilename%7D/images/wagon-wheel.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Évidemment, quand on voit la richesse des projets &lt;em&gt;PouchDB&lt;/em&gt; et &lt;em&gt;Remote
Storage&lt;/em&gt; et la dynamique de ces communautés, il est légitime d'hésiter
avant de développer une solution alternative.&lt;/p&gt;
&lt;p&gt;Quand nous avons créé le serveur &lt;em&gt;Reading List&lt;/em&gt;, nous l'avons construit
avec &lt;a href="http://cliquet.readthedocs.org/"&gt;Cliquet&lt;/a&gt;, ce fût l'occasion de
mettre au point &lt;a href="http://cliquet.readthedocs.org/en/latest/api/"&gt;un protocole très
simple&lt;/a&gt;, fortement
inspiré de &lt;a href="http://en.wikipedia.org/wiki/Firefox_Sync"&gt;Firefox Sync&lt;/a&gt;,
pour faire de la synchronisation d'enregistrements.&lt;/p&gt;
&lt;p&gt;Et si les clients &lt;em&gt;Reading List&lt;/em&gt; ont pu être implémentés en quelques
semaines, que ce soit en JavaScript, Java (Android) et ASM (Add-on
Firefox), c'est que le principe «*offline first*» du service est
trivial.&lt;/p&gt;
&lt;h3 id="les-compromis"&gt;Les compromis&lt;/h3&gt;
&lt;p&gt;Évidemment, nous n'avons pas la prétention de concurrencer &lt;em&gt;CouchDB&lt;/em&gt;.
Nous faisons plusieurs concessions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;De base, les collections d'enregistrements sont cloisonnées par
utilisateur;&lt;/li&gt;
&lt;li&gt;Pas d'historique des révisions;&lt;/li&gt;
&lt;li&gt;Pas de diff sur les enregistrements entre révisions;&lt;/li&gt;
&lt;li&gt;De base, pas de résolution de conflit automatique;&lt;/li&gt;
&lt;li&gt;Pas de synchronisation par flux (&lt;em&gt;streams&lt;/em&gt;);&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Jusqu'à preuve du contraire, ces compromis excluent la possibilité
d'implémenter un &lt;a href="https://github.com/pouchdb/pouchdb/blob/master/lib/adapters/http/http.js#L721-L946"&gt;adapter
PouchDB&lt;/a&gt;
pour la synchronisation avec le protocole HTTP de &lt;em&gt;Cliquet&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Dommage puisque capitaliser sur l'expérience client de &lt;em&gt;PouchDB&lt;/em&gt; au
niveau synchro client semble être une très bonne idée.&lt;/p&gt;
&lt;p&gt;En revanche, nous avons plusieurs fonctionnalités intéressantes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pas de map-reduce;&lt;/li&gt;
&lt;li&gt;Synchronisation partielle et/ou ordonnée et/ou paginée ;&lt;/li&gt;
&lt;li&gt;Le client choisit, via des headers, d'écraser la donnée ou de
respecter la version du serveur ;&lt;/li&gt;
&lt;li&gt;Un seul serveur à déployer pour N applications ;&lt;/li&gt;
&lt;li&gt;Auto-hébergement simplissime ;&lt;/li&gt;
&lt;li&gt;Le client peut choisir de ne pas utiliser de « store local » du tout
;&lt;/li&gt;
&lt;li&gt;Dans le client JS, la gestion du « store local » sera externalisée
(on pense à &lt;a href="https://github.com/mozilla/localForage"&gt;LocalForage&lt;/a&gt; ou
&lt;a href="https://github.com/dfahlander/Dexie.js"&gt;Dexie.js&lt;/a&gt;) ;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et, on répond au reste des &lt;a href="#storage-specs"&gt;specifications mentionnées au début de
l'article&lt;/a&gt; !&lt;/p&gt;
&lt;h3 id="les-arguments-philosophiques"&gt;Les arguments philosophiques&lt;/h3&gt;
&lt;p&gt;Il est &lt;a href="http://en.wikipedia.org/wiki/Law_of_the_instrument"&gt;illusoire de penser qu'on peut tout faire avec un seul
outil&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous avons d'autres cas d'utilisations dans les cartons qui semblent
correspondre au scope de &lt;em&gt;PouchDB&lt;/em&gt; (&lt;em&gt;pas de notion de permissions ou de
partage, environnement JavaScript, ...&lt;/em&gt;). Nous saurons en tirer profit
quand cela s'avèrera pertinent !&lt;/p&gt;
&lt;p&gt;L'éco-système que nous voulons construire tentera de couvrir les cas
d'utilisation qui sont mal adressés par &lt;em&gt;PouchDB&lt;/em&gt;. Il se voudra:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Basé sur notre protocole très simple ;&lt;/li&gt;
&lt;li&gt;Minimaliste et multi-usages (&lt;em&gt;comme la fameuse 2CV&lt;/em&gt;) ;&lt;/li&gt;
&lt;li&gt;Naïf (&lt;em&gt;pas de rocket science&lt;/em&gt;) ;&lt;/li&gt;
&lt;li&gt;Sans magie (&lt;em&gt;explicite et facile à réimplémenter from scratch&lt;/em&gt;) ;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://cliquet.readthedocs.org/en/latest/rationale.html"&gt;La philosophie et les fonctionnalités du toolkit python
Cliquet&lt;/a&gt; seront
bien entendu à l'honneur :)&lt;/p&gt;
&lt;p&gt;Quant à &lt;em&gt;Remote Storage&lt;/em&gt;, dès que le besoin se présentera, nous serons
très fier de rejoindre l'initiative, mais pour l'instant cela nous
paraît risqué de démarrer en tordant la solution.&lt;/p&gt;
&lt;h3 id="les-arguments-pratiques"&gt;Les arguments pratiques&lt;/h3&gt;
&lt;p&gt;Avant d'accepter de déployer une solution à base de &lt;em&gt;CouchDB&lt;/em&gt;, les &lt;em&gt;ops&lt;/em&gt;
de Mozilla vont nous demander de leur prouver par A+B que ce n'est pas
faisable avec les stacks qui sont déjà rodées en interne (i.e. MySQL,
Redis, PostgreSQL).&lt;/p&gt;
&lt;p&gt;De plus, on doit s'engager sur une pérennité d'au moins 5 ans pour les
données. Avec &lt;em&gt;Cliquet&lt;/em&gt;, en utilisant le backend PostgreSQL, les données
sont persistées à plat dans un &lt;a href="https://github.com/mozilla-services/cliquet/blob/40aa33/cliquet/storage/postgresql/schema.sql#L14-L28"&gt;schéma PostgreSQL tout
bête&lt;/a&gt;.
Ce qui ne sera pas le cas d'un adapteur LevelDown qui va manipuler des
notions de révisions éclatées dans un schéma clé-valeur.&lt;/p&gt;
&lt;p&gt;Si nous basons le service sur &lt;em&gt;Cliquet&lt;/em&gt;, comme c'est le cas avec
&lt;a href="http://kinto.readthedocs.org"&gt;Kinto&lt;/a&gt;, tout le travail d'automatisation
de la mise en production (&lt;em&gt;monitoring, builds RPM, Puppet...&lt;/em&gt;) que nous
avons fait pour &lt;em&gt;Reading List&lt;/em&gt; est complètement réutilisable.&lt;/p&gt;
&lt;p&gt;De même, si on repart avec une stack complètement différente, nous
allons devoir recommencer tout le travail de rodage, de profiling et
d'optimisation effectué au premier trimestre.&lt;/p&gt;
&lt;h2 id="les-prochaines-etapes"&gt;Les prochaines étapes&lt;/h2&gt;
&lt;p&gt;Et il est encore temps de changer de stratégie :) Nous aimerions avoir
un maximum de retours ! C'est toujours une décision difficile à
prendre... &lt;code&gt;&amp;lt;/appel à troll&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tordre un éco-système existant vs. constuire sur mesure ;&lt;/li&gt;
&lt;li&gt;Maîtriser l'ensemble vs. s'intégrer ;&lt;/li&gt;
&lt;li&gt;Contribuer vs. refaire ;&lt;/li&gt;
&lt;li&gt;Guider vs. suivre.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nous avons vraiment l'intention de rejoindre l'initiative
&lt;a href="https://nobackend.org/"&gt;no-backend&lt;/a&gt;, et ce premier pas n'exclue pas que
nous convergions à terme ! Peut-être que nous allons finir par rendre
notre service compatible avec &lt;em&gt;Remote Storage&lt;/em&gt;, et peut-être que
&lt;em&gt;PouchDB&lt;/em&gt; deviendra plus agnostique quand au protocole de
synchronisation...&lt;/p&gt;
&lt;p&gt;&lt;img alt="XKCD — Standards
https://xkcd.com/927/" src="%7Bfilename%7D/images/standards.png"&gt;&lt;/p&gt;
&lt;p&gt;Utiliser ce nouvel écosystème pour le projet « Payments » va nous
permettre de mettre au point un système de permissions (&lt;em&gt;probablement
basé sur les scopes OAuth&lt;/em&gt;) qui correspond au besoin exprimé. Et nous
avons bien l'intention de puiser dans &lt;a href="http://blog.daybed.io/daybed-revival.html"&gt;notre expérience avec Daybed sur
le sujet&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous extrairons aussi le code des clients implémentés pour &lt;em&gt;Reading
List&lt;/em&gt; afin de faire un client JavaScript minimaliste.&lt;/p&gt;
&lt;p&gt;En partant dans notre coin, nous prenons plusieurs risques:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;réinventer une roue dont nous n'avons pas connaissance ;&lt;/li&gt;
&lt;li&gt;échouer à faire de l'éco-système &lt;em&gt;Cliquet&lt;/em&gt; un projet communautaire ;&lt;/li&gt;
&lt;li&gt;échouer à positionner &lt;em&gt;Cliquet&lt;/em&gt; dans la niche des cas non couverts
par PouchDB :)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Comme &lt;a href="http://pouchdb.com/2015/04/05/filtered-replication.html"&gt;le dit Giovanni
Ornaghi&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rolling out your set of webservices, push notifications, or background
services might give you more control, but at the same time it will
force you to engineer, write, test, and maintain a whole new
ecosystem.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;C'est justement l'éco-système dont est responsable l'équipe &lt;em&gt;Mozilla
Cloud Services&lt;/em&gt;!&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Il existe le &lt;a href="https://sharesome.5apps.com/"&gt;projet Sharesome&lt;/a&gt; qui
permet de partager publiquement des ressources de son &lt;em&gt;remote
Storage&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&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 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 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 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 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;h2 id="exchange-of-the-hawk-id-and-hawk-key"&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 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="note"&gt;
&lt;div class="admonition-title"&gt;
Note
&lt;/div&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.
If you are not interested into these details, you can directly jump to
the next section to see how to use the libraries.
&lt;/div&gt;
&lt;p&gt;When your server application needs to send you the credentials, it will
return it inside a specific Hawk-Session-Token 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 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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;key_material&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HKDF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hawk_session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;identity.mozilla.com/picl/v1/sessionToken&amp;#39;&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;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="note"&gt;
&lt;div class="admonition-title"&gt;
Note
&lt;/div&gt;
The `identity.mozilla.com/picl/v1/sessionToken` is a reference to this
way of deriving the credentials, not an actual URL.
&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;p&gt;``` sourceCode javascript
credentials = {
'id': keyMaterial[0:32],
'key': keyMaterial[32:64],
'algorithm': 'sha256'
}&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;## Httpie&lt;/span&gt;
&lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;showcase&lt;/span&gt; &lt;span class="n"&gt;APIs&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;documentation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;like&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;httpie&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jakubroztocil&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;httpie&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;curl&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;replacement&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;nicer&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;built&lt;/span&gt; &lt;span class="n"&gt;around&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="n"&gt;library&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&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;org&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;Luckily&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTTPie&lt;/span&gt; &lt;span class="n"&gt;allows&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;plug&lt;/span&gt; &lt;span class="n"&gt;different&lt;/span&gt; &lt;span class="n"&gt;authentication&lt;/span&gt; &lt;span class="n"&gt;schemes&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt;
&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;so&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;wrote&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="n"&gt;wrapper&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;mozilla&lt;/span&gt;&lt;span class="o"&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;requests&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;hawk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;around&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mohawk&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kumar303&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;mohawk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;hawk&lt;/span&gt; &lt;span class="n"&gt;support&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt;
&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="n"&gt;lib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;Doing&lt;/span&gt; &lt;span class="n"&gt;hawk&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;terminal&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&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;hawk&lt;/span&gt; &lt;span class="n"&gt;httpie&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;localhost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hawk&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;id:key&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;In&lt;/span&gt; &lt;span class="n"&gt;addition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;craft&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="n"&gt;library&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="sb"&gt;``&lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;python&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;p&gt;``` sourceCode python
hawk_auth = HawkAuth(
hawk_session=resp.headers['hawk-session-token'],
server_url=self.server_url
)
requests.post("/url", auth=hawk_auth)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;## Integrate with python pyramid apps&lt;/span&gt;
&lt;span class="n"&gt;If&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;re writing pyramid applications, you&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;ll&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;happy&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;learn&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Ryan&lt;/span&gt; &lt;span class="n"&gt;Kelly&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rfk&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;au&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;blog&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;put&lt;/span&gt; &lt;span class="n"&gt;together&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;library&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;
&lt;span class="n"&gt;makes&lt;/span&gt; &lt;span class="n"&gt;Hawk&lt;/span&gt; &lt;span class="n"&gt;work&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;Authentication&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;them&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;m chocked how&lt;/span&gt;
&lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;Here&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;demo&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;how&lt;/span&gt; &lt;span class="n"&gt;we&lt;/span&gt; &lt;span class="n"&gt;implemented&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;Daybed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="sb"&gt;``&lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;python&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 get_hawk_id function is a function that takes a request and a
tokenid and returns a tuple of (token_id, token_key).&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 decode_hawk_id
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;h2 id="integrate-with-nodejs-express-apps"&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 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;p&gt;``` sourceCode javascript
var express = require("express");
var hawk = require("express-hawkauth");
app = express();&lt;/p&gt;
&lt;p&gt;var hawkMiddleware = hawk.getMiddleware({
hawkOptions: {},
getSession: function(tokenId, cb) {
// A function which pass to the cb the key and algorithm for the
// given token id. First argument of the callback is a potential
// error.
cb(null, {key: "key", algorithm: "sha256"});
},
createSession: function(id, key, cb) {
// A function which stores a session for the given id and key.
// Argument returned is a potential error.
cb(null);
},
setUser: function(req, res, tokenId, cb) {
// A function that uses req and res, the hawkId when they're known so
// that it can tweak it. For instance, you can store the tokenId as the
// user.
req.user = tokenId;
}
});&lt;/p&gt;
&lt;p&gt;app.get("/hawk-enabled-endpoint", hawkMiddleware);
```&lt;/p&gt;
&lt;p&gt;If you pass the createSession parameter, all non-authenticated requests
will create a new hawk session and return it with the response, in the
Hawk-Session-Token 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
createSession parameter defined.&lt;/p&gt;
&lt;h2 id="some-reference-implementations"&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&gt;
&lt;li&gt;The Mozilla Loop server &lt;a 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 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 href="http://hawkrest.readthedocs.org/en/latest/"&gt;hawkrest, for
the django rest
framework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content></entry><entry><title>Implementing CORS in Cornice</title><link href="https://blog.notmyidea.org/implementing-cors-in-cornice.html" rel="alternate"></link><published>2013-02-04T00:00:00+01:00</published><updated>2013-02-04T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2013-02-04:/implementing-cors-in-cornice.html</id><summary type="html">
&lt;div class="note"&gt;
&lt;div class="admonition-title"&gt;
Note
&lt;/div&gt;
I'm cross-posting [on the mozilla services
weblog](https://blog.mozilla.org/services/). 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;/div&gt;
&lt;p&gt;For security reasons, it's not possible …&lt;/p&gt;</summary><content type="html">
&lt;div class="note"&gt;
&lt;div class="admonition-title"&gt;
Note
&lt;/div&gt;
I'm cross-posting [on the mozilla services
weblog](https://blog.mozilla.org/services/). 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;/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 lolnet.org, it
will not be possible for it to get data from notmyidea.org.&lt;/p&gt;
&lt;p&gt;Well, it's possible, using tricks and techniques like
&lt;a href="http://en.wikipedia.org/wiki/JSONP"&gt;JSONP&lt;/a&gt;, but that doesn't work all
the time (see &lt;a 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, "Cross Origin
Resource-Sharing", or &lt;a href="http://www.w3.org/TR/cors/"&gt;CORS&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="you-want-an-icecream-go-ask-your-dad-first"&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 OPTIONS verb, and with the
appropriate response headers.&lt;/p&gt;
&lt;p&gt;OPTIONS is sent as what the authors of the spec call a "preflight
request"; 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
OPTIONS call.&lt;/p&gt;
&lt;p&gt;The server answers, and tell what is available and what isn't:&lt;/p&gt;
&lt;p&gt;&lt;img alt="The CORS flow (from the HTML5 CORS tutorial)" src="images/cors_flow.png"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&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;/p&gt;
&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;
&lt;p&gt;1b. The API answers what is authorized:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Access-Control-Allow-Origin&lt;/strong&gt; the origin that's accepted. Can
be * 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&gt;
&lt;li&gt;The User-Agent can do the "normal" request.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, if you want to access the /icecream resource, and do a PUT there,
you'll have the following flow:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;OPTIONS&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;icecream&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Control&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;Methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PUT&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Control&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Origin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Control&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PUT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;DELETE&lt;/span&gt;
&lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="n"&gt;OK&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can see that we have an Origin Header in the request, as well as a
Access-Control-Request-Methods. We're here asking if we have the right,
as notmyidea.org, to do a PUT request on /icecream.&lt;/p&gt;
&lt;p&gt;And the server tells us that we can do that, as well as GET and DELETE.&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;h2 id="a-word-about-security"&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;h2 id="how-this-is-different-from-jsonp"&gt;How this is different from JSONP?&lt;/h2&gt;
&lt;p&gt;You may know the &lt;a 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
\&amp;lt;script&gt; element.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Exploiting the open policy for \&amp;lt;script&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;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="using-cors-in-cornice"&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;p&gt;``` sourceCode python
from cornice import Service&lt;/p&gt;
&lt;p&gt;foobar = Service(name="foobar", path="/foobar")&lt;/p&gt;
&lt;h1 id="and-then-you-do-something-with-it"&gt;and then you do something with it&lt;/h1&gt;
&lt;p&gt;@foobar.get()
def get_foobar(request):
# do something with the request.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;To&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CORS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;support&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;can&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;go&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;way&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;cors&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;_origins&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;parameter&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;```&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sourceCode&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;foobar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="k"&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="w"&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="w"&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 *, which means "authorize everyone".&lt;/p&gt;
&lt;h3 id="headers"&gt;Headers&lt;/h3&gt;
&lt;p&gt;You can define the headers you want to expose for the service:&lt;/p&gt;
&lt;p&gt;``` sourceCode python
foobar = Service(name='foobar', path='/foobar', cors_origins=('*',))&lt;/p&gt;
&lt;p&gt;@foobar.get(cors_headers=('X-My-Header', 'Content-Type'))
def get_foobars_please(request):
return "some foobar for you"&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;I&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ve done some testing and it wasn&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt; &lt;span class="nv"&gt;working&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;Chrome&lt;/span&gt; &lt;span class="nv"&gt;because&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;wasn&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;t&lt;/span&gt;
&lt;span class="nv"&gt;handling&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;headers&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;right&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;missing&lt;/span&gt; &lt;span class="nv"&gt;one&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Type&lt;/span&gt;,
&lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;Chrome&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;asking&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;. &lt;span class="nv"&gt;With&lt;/span&gt; &lt;span class="nv"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;first&lt;/span&gt; &lt;span class="nv"&gt;version&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;implementation&lt;/span&gt;, &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;needed&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;implementers&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;explicitely&lt;/span&gt; &lt;span class="nv"&gt;list&lt;/span&gt;
&lt;span class="nv"&gt;all&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;headers&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;should&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;exposed&lt;/span&gt;. &lt;span class="k"&gt;While&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;improves&lt;/span&gt; &lt;span class="nv"&gt;security&lt;/span&gt;, &lt;span class="nv"&gt;it&lt;/span&gt;
&lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;frustrating&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nv"&gt;developing&lt;/span&gt;.
&lt;span class="nv"&gt;So&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;introduced&lt;/span&gt; &lt;span class="nv"&gt;an&lt;/span&gt; &lt;span class="nv"&gt;expose&lt;/span&gt;\&lt;span class="nv"&gt;_all&lt;/span&gt;\&lt;span class="nv"&gt;_headers&lt;/span&gt; &lt;span class="nv"&gt;flag&lt;/span&gt;, &lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;True&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt;
&lt;span class="nv"&gt;default&lt;/span&gt;, &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;supports&lt;/span&gt; &lt;span class="nv"&gt;CORS&lt;/span&gt;.
### &lt;span class="nv"&gt;Cookies&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nv"&gt;Credentials&lt;/span&gt;
&lt;span class="nv"&gt;By&lt;/span&gt; &lt;span class="nv"&gt;default&lt;/span&gt;, &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;requests&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;API&lt;/span&gt; &lt;span class="nv"&gt;endpoint&lt;/span&gt; &lt;span class="nv"&gt;don&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;t include the&lt;/span&gt;
&lt;span class="nv"&gt;credential&lt;/span&gt; &lt;span class="nv"&gt;information&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;security&lt;/span&gt; &lt;span class="nv"&gt;reasons&lt;/span&gt;. &lt;span class="k"&gt;If&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;really&lt;/span&gt; &lt;span class="nv"&gt;want&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="nv"&gt;that&lt;/span&gt;, &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;need&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;enable&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;using&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_credentials&lt;/span&gt; &lt;span class="nv"&gt;parameter&lt;/span&gt;. &lt;span class="nv"&gt;You&lt;/span&gt;
&lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;activate&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;one&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;per&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;basis&lt;/span&gt; &lt;span class="nv"&gt;or&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;per&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;method&lt;/span&gt; &lt;span class="nv"&gt;basis&lt;/span&gt;.
### &lt;span class="nv"&gt;Caching&lt;/span&gt;
&lt;span class="nv"&gt;When&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;preflight&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;, &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;information&lt;/span&gt; &lt;span class="nv"&gt;returned&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;server&lt;/span&gt;
&lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;cached&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;User&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Agent&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;s not redone before each&lt;/span&gt;
&lt;span class="nv"&gt;actual&lt;/span&gt; &lt;span class="nv"&gt;call&lt;/span&gt;.
&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;caching&lt;/span&gt; &lt;span class="nv"&gt;period&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;server&lt;/span&gt;, &lt;span class="nv"&gt;using&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Control&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Max&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Age&lt;/span&gt; &lt;span class="nv"&gt;header&lt;/span&gt;. &lt;span class="nv"&gt;You&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;configure&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;timing&lt;/span&gt; &lt;span class="nv"&gt;using&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_max&lt;/span&gt;\&lt;span class="nv"&gt;_age&lt;/span&gt; &lt;span class="nv"&gt;parameter&lt;/span&gt;.
### &lt;span class="nv"&gt;Simplifying&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;API&lt;/span&gt;
&lt;span class="nv"&gt;We&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_headers&lt;/span&gt;, &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_enabled&lt;/span&gt;, &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_origins&lt;/span&gt;, &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_credentials&lt;/span&gt;,
&lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_max&lt;/span&gt;\&lt;span class="nv"&gt;_age&lt;/span&gt;, &lt;span class="nv"&gt;cors&lt;/span&gt;\&lt;span class="nv"&gt;_expose&lt;/span&gt;\&lt;span class="nv"&gt;_all&lt;/span&gt;\&lt;span class="nv"&gt;_headers&lt;/span&gt;&lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;fair&lt;/span&gt; &lt;span class="nv"&gt;number&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt;
&lt;span class="nv"&gt;parameters&lt;/span&gt;. &lt;span class="k"&gt;If&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;want&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;specific&lt;/span&gt; &lt;span class="nv"&gt;CORS&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;policy&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt;
&lt;span class="nv"&gt;services&lt;/span&gt;, &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;bit&lt;/span&gt; &lt;span class="nv"&gt;tedious&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;pass&lt;/span&gt; &lt;span class="nv"&gt;these&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;services&lt;/span&gt; &lt;span class="nv"&gt;all&lt;/span&gt;
&lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;time&lt;/span&gt;.
&lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;introduced&lt;/span&gt; &lt;span class="nv"&gt;another&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;pass&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;CORS&lt;/span&gt; &lt;span class="nv"&gt;policy&lt;/span&gt;, &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="nv"&gt;something&lt;/span&gt; &lt;span class="nv"&gt;like&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt;:
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;python&lt;/span&gt;
&lt;span class="nv"&gt;policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;dict&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;enabled&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;False&lt;/span&gt;,
&lt;span class="nv"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;X-My-Header&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;Content-Type&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
&lt;span class="nv"&gt;origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;*.notmyidea.org&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
&lt;span class="nv"&gt;credentials&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;,
&lt;span class="nv"&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="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;foobar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Service&lt;/span&gt;&lt;span class="ss"&gt;(&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;&lt;/span&gt;&lt;span class="s"&gt;foobar&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/foobar&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="nv"&gt;cors_policy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;policy&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="comparison-with-other-implementations"&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 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 "rights" 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;h2 id="resources"&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&gt;
&lt;li&gt;&lt;a 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 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 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 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 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 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 href="http://www.w3.org/TR/cors/#resource-processing-model"&gt;"resource processing model"
section&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>Status board</title><link href="https://blog.notmyidea.org/status-board.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.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 lolnet.org …&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 lolnet.org, 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 href="http://www.stashboard.org/"&gt;stashboard&lt;/a&gt;, un "status board" 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 href="https://github.com/bfirsh/whiskerboard"&gt;whiskerboard&lt;/a&gt; (la planche
moustachue, pour les non anglophones).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Capture d'écran du site." src="images/status_board.png"&gt;&lt;/p&gt;
&lt;h2 id="verifier-le-statut-des-services"&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 "up".&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 href="https://github.com/almet/whiskerboard"&gt;https://github.com/almet/whiskerboard&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;Entres autres, il est désormais possible de lancer
&lt;a 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 href="https://github.com/almet/whiskerboard/compare/b539337416...master"&gt;https://github.com/almet/whiskerboard/compare/b539337416...master&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;En gros:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ajout d'une connection_string aux services (de la forme
protocol://host:port)&lt;/li&gt;
&lt;li&gt;ajout d'une commande check_status 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;h2 id="deploiement"&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 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 celeryd qui tourne, donc j'ai un peu cherché
ailleurs, pour finalement déployer la chose chez
&lt;a 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 PATH pour que ça puisse marcher), voici mon
`.bash_profile`:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;export&lt;/span&gt; &lt;span class="n"&gt;PYTHONPATH&lt;/span&gt;&lt;span class="o"&gt;=~/&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="n"&gt;export&lt;/span&gt; &lt;span class="n"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;PATH&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Et après y'a plus qu'à installer avec `easy_install`:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;easy_install&lt;/span&gt; &lt;span class="c1"&gt;--install-dir ~/modules -U pip&lt;/span&gt;
&lt;span class="n"&gt;easy_install&lt;/span&gt; &lt;span class="c1"&gt;--install-dir ~/modules -U virtualenv&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Et à créer le virtualenv:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="n"&gt;venv&lt;/span&gt;
&lt;span class="n"&gt;venv&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="n"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dernière étape, la création d'un fichier application.wsgi qui s'occupe
de rendre l'application disponible, avec le bon venv:&lt;/p&gt;
&lt;h2 id="ssl-et-requests"&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 django 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 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 CURL fonctionnent, donc j'ai fait &lt;a 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;h2 id="et-voila"&gt;Et voilà&lt;/h2&gt;
&lt;p&gt;Finalement, j'ai mon joli status-board qui tourne à merveille sur
&lt;a href="http://status.lolnet.org"&gt;http://status.lolnet.org&lt;/a&gt; :-)&lt;/p&gt;</content></entry><entry><title>Astuces SSH</title><link href="https://blog.notmyidea.org/astuces-ssh.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:/astuces-ssh.html</id><summary type="html">
&lt;h2 id="tunelling"&gt;Tunelling&lt;/h2&gt;
&lt;p&gt;Parce que je m'en rapelle jamais (tête de linote):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ssh -f hote -L local:lolnet.org:destination -N
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="sshconfig"&gt;.ssh/config&lt;/h2&gt;
&lt;p&gt;(merci &lt;a href="http://majerti.fr"&gt;gaston&lt;/a&gt; !)&lt;/p&gt;
&lt;p&gt;La directive suivante dans .ssh/config permet de sauter d'hôte en hôte
séparés par des "+" :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;Host&lt;/span&gt; &lt;span class="o"&gt;*+*&lt;/span&gt;
&lt;span class="n"&gt;ProxyCommand&lt;/span&gt; &lt;span class="n"&gt;ssh&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;sed&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;s/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s …&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">
&lt;h2 id="tunelling"&gt;Tunelling&lt;/h2&gt;
&lt;p&gt;Parce que je m'en rapelle jamais (tête de linote):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ssh -f hote -L local:lolnet.org:destination -N
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="sshconfig"&gt;.ssh/config&lt;/h2&gt;
&lt;p&gt;(merci &lt;a href="http://majerti.fr"&gt;gaston&lt;/a&gt; !)&lt;/p&gt;
&lt;p&gt;La directive suivante dans .ssh/config permet de sauter d'hôte en hôte
séparés par des "+" :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;Host&lt;/span&gt; &lt;span class="o"&gt;*+*&lt;/span&gt;
&lt;span class="n"&gt;ProxyCommand&lt;/span&gt; &lt;span class="n"&gt;ssh&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;sed&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;s/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /&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="p"&gt;.:&lt;/span&gt;&lt;span class="err"&gt;\$&lt;/span&gt;&lt;span class="n"&gt;PATH&lt;/span&gt; &lt;span class="n"&gt;nc&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;w1&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;s/^.*+//;/:/!s/$/ %p/;s/:/ /&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On peut donc spécifier des "sauts" ssh du style:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;ssh&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="mf"&gt;@91.25.25.25&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;192.168.1.1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ensuite on peut essayer de rajouter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;Host&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;label_pour_mon_serveur_privé&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;monuser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;IdentityFile&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;chemin&lt;/span&gt; &lt;span class="n"&gt;vers&lt;/span&gt; &lt;span class="n"&gt;ma&lt;/span&gt; &lt;span class="n"&gt;clé&lt;/span&gt; &lt;span class="n"&gt;ssh&lt;/span&gt; &lt;span class="n"&gt;pour&lt;/span&gt; &lt;span class="n"&gt;le&lt;/span&gt; &lt;span class="n"&gt;serveur&lt;/span&gt; &lt;span class="n"&gt;publique&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;hostname&lt;/span&gt; &lt;span class="n"&gt;ip_serveur_publique&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;ip_serveur_privé&lt;/span&gt;
&lt;/pre&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&gt;
&lt;li&gt;&lt;a 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&gt;
&lt;li&gt;&lt;a 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 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 "en grand"
quelle est la fenêtre que je vais afficher.&lt;/li&gt;
&lt;li&gt;&lt;a 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 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&gt;
&lt;li&gt;&lt;a 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 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 href="https://extensions.gnome.org/"&gt;https://extensions.gnome.org/&lt;/a&gt; pour
en trouver d'autres à votre gout.&lt;/p&gt;</content></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;h1 id="cheese-code-wrap-up"&gt;Cheese &amp;amp; code - Wrap-up&lt;/h1&gt;
&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 …&lt;/p&gt;</summary><content type="html">&lt;h1 id="cheese-code-wrap-up"&gt;Cheese &amp;amp; code - Wrap-up&lt;/h1&gt;
&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;h2 id="daybed"&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;p&gt;&lt;img alt="Daybed is a big couch!" src="images/daybed.jpg"&gt;&lt;/p&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 href="http://github.com/spiral-project/daybed"&gt;The code&lt;/a&gt; is available on
github, and we also wrote &lt;a 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;h2 id="cornice"&gt;Cornice&lt;/h2&gt;
&lt;p&gt;Daybed is built on top of &lt;a 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 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;p&gt;``` sourceCode python
from cornice.ext.spore import generate_spore_description
from cornice.service import Service, get_services&lt;/p&gt;
&lt;p&gt;spore = Service('spore', path='/spore', renderer='jsonp')
@spore.get
def get_spore(request):
services = get_services()
return generate_spore_description(services, 'Service name',
request.application_url, '1.0')&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;And&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ll get a definition of your service, in SPORE, available at&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;spore&lt;/span&gt;.
&lt;span class="nv"&gt;Of&lt;/span&gt; &lt;span class="nv"&gt;course&lt;/span&gt;, &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;other&lt;/span&gt; &lt;span class="nv"&gt;things&lt;/span&gt;, &lt;span class="nv"&gt;like&lt;/span&gt; &lt;span class="nv"&gt;generating&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;file&lt;/span&gt;
&lt;span class="nv"&gt;locally&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;exporting&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;wherever&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;makes&lt;/span&gt; &lt;span class="nv"&gt;sense&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt;, &lt;span class="nv"&gt;etc&lt;/span&gt;.
&lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;released&lt;/span&gt; &lt;span class="nv"&gt;today&lt;/span&gt; [&lt;span class="nv"&gt;Cornice&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;11&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;crate&lt;/span&gt;.&lt;span class="nv"&gt;io&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;cornice&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
&lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;adds&lt;/span&gt; &lt;span class="nv"&gt;into&lt;/span&gt; &lt;span class="nv"&gt;other&lt;/span&gt; &lt;span class="nv"&gt;things&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;support&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;SPORE&lt;/span&gt;, &lt;span class="nv"&gt;plus&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;other&lt;/span&gt;
&lt;span class="nv"&gt;fixes&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;found&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;our&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt;.
## &lt;span class="nv"&gt;Respire&lt;/span&gt;
&lt;span class="nv"&gt;Once&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;description&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt;, &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;generic&lt;/span&gt; &lt;span class="nv"&gt;clients&lt;/span&gt;
&lt;span class="nv"&gt;consuming&lt;/span&gt; &lt;span class="nv"&gt;them&lt;/span&gt;\&lt;span class="o"&gt;!&lt;/span&gt;
&lt;span class="nv"&gt;We&lt;/span&gt; &lt;span class="nv"&gt;first&lt;/span&gt; &lt;span class="nv"&gt;wanted&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;contribute&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; [&lt;span class="nv"&gt;spyre&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;https&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;github&lt;/span&gt;.&lt;span class="nv"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;bl0b&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;spyre&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;written&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;wasn&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;t supporting to POST data, and&lt;/span&gt;
&lt;span class="nv"&gt;they&lt;/span&gt; &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;using&lt;/span&gt; &lt;span class="nv"&gt;their&lt;/span&gt; &lt;span class="nv"&gt;own&lt;/span&gt; &lt;span class="nv"&gt;stack&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;handle&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt;. &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="nv"&gt;lot&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt;
&lt;span class="nv"&gt;already&lt;/span&gt; &lt;span class="nv"&gt;exists&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;other&lt;/span&gt; &lt;span class="nv"&gt;libraries&lt;/span&gt;.
&lt;span class="k"&gt;While&lt;/span&gt; &lt;span class="nv"&gt;waiting&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;train&lt;/span&gt; &lt;span class="nv"&gt;with&lt;/span&gt; [&lt;span class="nv"&gt;R&lt;/span&gt;é&lt;span class="nv"&gt;my&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;natim&lt;/span&gt;.&lt;span class="nv"&gt;ionyse&lt;/span&gt;.&lt;span class="nv"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;hacked&lt;/span&gt;
&lt;span class="nv"&gt;something&lt;/span&gt; &lt;span class="nv"&gt;together&lt;/span&gt;, &lt;span class="nv"&gt;named&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;Respire&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;thin&lt;/span&gt; &lt;span class="nv"&gt;layer&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;top&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;awesome&lt;/span&gt;
[&lt;span class="nv"&gt;Requests&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;python&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;requests&lt;/span&gt;.&lt;span class="nv"&gt;org&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;library&lt;/span&gt;.
&lt;span class="nv"&gt;We&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;first&lt;/span&gt; &lt;span class="nv"&gt;version&lt;/span&gt;, &lt;span class="nv"&gt;feel&lt;/span&gt; &lt;span class="nv"&gt;free&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;look&lt;/span&gt; &lt;span class="nv"&gt;at&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;provide&lt;/span&gt;
&lt;span class="nv"&gt;enhancements&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;feel&lt;/span&gt; &lt;span class="nv"&gt;like&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;. &lt;span class="nv"&gt;We&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;re still hacking on it so it may&lt;/span&gt;
&lt;span class="k"&gt;break&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;better&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;had&lt;/span&gt; &lt;span class="nv"&gt;been&lt;/span&gt; &lt;span class="nv"&gt;working&lt;/span&gt; &lt;span class="nv"&gt;pretty&lt;/span&gt; &lt;span class="nv"&gt;well&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;us&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt;
&lt;span class="nv"&gt;far&lt;/span&gt;.
&lt;span class="nv"&gt;You&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; [&lt;span class="nv"&gt;find&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;project&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt;
&lt;span class="nv"&gt;github&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;github&lt;/span&gt;.&lt;span class="nv"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;spiral&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;project&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;respire&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;here&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;how&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt;
&lt;span class="nv"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;, &lt;span class="nv"&gt;really&lt;/span&gt; &lt;span class="nv"&gt;quickly&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;these&lt;/span&gt; &lt;span class="nv"&gt;examples&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;how&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;interact&lt;/span&gt; &lt;span class="nv"&gt;with&lt;/span&gt; &lt;span class="nv"&gt;daybed&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;python&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;from&lt;/span&gt; &lt;span class="nv"&gt;respire&lt;/span&gt; &lt;span class="nv"&gt;import&lt;/span&gt; &lt;span class="nv"&gt;client_from_url&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; # &lt;span class="nv"&gt;create&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;client&lt;/span&gt; &lt;span class="nv"&gt;from&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;SPORE&lt;/span&gt; &lt;span class="nv"&gt;definition&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;cl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;client_from_url&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8000/spore&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; # &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;daybed&lt;/span&gt;, &lt;span class="nv"&gt;create&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;new&lt;/span&gt; &lt;span class="nv"&gt;definition&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;todo_def&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; {
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;A list of my stuff to do&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;fields&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: [
... {
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;The item&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
... },
... {
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;enum&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;choices&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: [
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;done&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;,
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
... ],
... &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;is it done or not&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
... }
... ]}
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;cl&lt;/span&gt;.&lt;span class="nv"&gt;put_definition&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="nv"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;todo_def&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;cl&lt;/span&gt;.&lt;span class="nv"&gt;post_data&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="nv"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;dict&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;item&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;make it work&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;
{&lt;span class="nv"&gt;u&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;: &lt;span class="nv"&gt;u&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;9f2c90c0529a442cfdc03c191b022cf7&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;}
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;cl&lt;/span&gt;.&lt;span class="nv"&gt;get_data&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;todo&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&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;</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 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 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 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 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;h2 id="autocompletion-on-the-command-line"&gt;Autocompletion on the command-line&lt;/h2&gt;
&lt;p&gt;&lt;a 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 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
circusctl command without any option, you'll end-up with a cool shell.
Thanks &lt;a href="https://github.com/jojax"&gt;Jonathan Dorival&lt;/a&gt; for the work on
this! You can have a look at &lt;a href="https://github.com/mozilla-services/circus/pull/268"&gt;the pull
request&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="future-changes-to-the-web-ui"&gt;Future changes to the web ui&lt;/h2&gt;
&lt;p&gt;&lt;a 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;h2 id="bug-and-doc-fixing"&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 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;h2 id="circus-clustering-capabilities"&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 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;h2 id="project-management"&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 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;</content></entry><entry><title>Refactoring Cornice</title><link href="https://blog.notmyidea.org/refactoring-cornice.html" rel="alternate"></link><published>2012-05-01T00:00:00+02:00</published><updated>2012-05-01T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-05-01:/refactoring-cornice.html</id><summary type="html">
&lt;p&gt;After working for a while with &lt;a href="http://cornice.readthedocs.com"&gt;Cornice&lt;/a&gt;
to define our APIs at &lt;a 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 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 href="http://cornice.readthedocs.com"&gt;Cornice&lt;/a&gt;
to define our APIs at &lt;a 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 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 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;p&gt;``` sourceCode python
from cornice.service import Service
bar = Service(path="/bar")&lt;/p&gt;
&lt;p&gt;@bar.get(validators=validators, accept='application/json')
def get_drink(request):
# do something with the request (with moderation).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;This&lt;/span&gt; &lt;span class="nv"&gt;external&lt;/span&gt; &lt;span class="nv"&gt;API&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;quite&lt;/span&gt; &lt;span class="nv"&gt;cool&lt;/span&gt;, &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;allows&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;bunch&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;things&lt;/span&gt;
&lt;span class="nv"&gt;quite&lt;/span&gt; &lt;span class="nv"&gt;easily&lt;/span&gt;. &lt;span class="k"&gt;For&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt;, &lt;span class="nv"&gt;we&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ve written our&lt;/span&gt;
[&lt;span class="nv"&gt;token&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;]&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;https&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;github&lt;/span&gt;.&lt;span class="nv"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;mozilla&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;services&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;tokenserver&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt;
&lt;span class="nv"&gt;top&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;blast&lt;/span&gt;.
## &lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;burden&lt;/span&gt;
&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;problem&lt;/span&gt; &lt;span class="nv"&gt;with&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;mixing&lt;/span&gt; &lt;span class="nv"&gt;internally&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt;
&lt;span class="nv"&gt;description&lt;/span&gt; &lt;span class="nv"&gt;logic&lt;/span&gt; &lt;span class="nv"&gt;with&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;route&lt;/span&gt; &lt;span class="nv"&gt;registration&lt;/span&gt; &lt;span class="nv"&gt;one&lt;/span&gt;. &lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;doing&lt;/span&gt;
&lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;via&lt;/span&gt; &lt;span class="nv"&gt;an&lt;/span&gt; &lt;span class="nv"&gt;extensive&lt;/span&gt; &lt;span class="nv"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;decorators&lt;/span&gt; &lt;span class="nv"&gt;internally&lt;/span&gt;.
&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;API&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;cornice&lt;/span&gt;.&lt;span class="nv"&gt;service&lt;/span&gt;.&lt;span class="nv"&gt;Service&lt;/span&gt; &lt;span class="nv"&gt;class&lt;/span&gt; &lt;span class="nv"&gt;was&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;following&lt;/span&gt;
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;simplified&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;get&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;gist&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;.
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;python&lt;/span&gt;
&lt;span class="nv"&gt;class&lt;/span&gt; &lt;span class="nv"&gt;Service&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;object&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;__init__&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;service_kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
# &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;information&lt;/span&gt;, &lt;span class="nv"&gt;such&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;colander&lt;/span&gt; &lt;span class="nv"&gt;schemas&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;validation&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
# &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;methods&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;had&lt;/span&gt; &lt;span class="nv"&gt;been&lt;/span&gt; &lt;span class="nv"&gt;registered&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt;
# &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;other&lt;/span&gt; &lt;span class="nv"&gt;things&lt;/span&gt; &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;registered&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt; &lt;span class="nv"&gt;variables&lt;/span&gt;.
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;schemas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;service_kwargs&lt;/span&gt;.&lt;span class="nv"&gt;get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;schema&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;, None)&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;defined_methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; []
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;definitions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; []
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;api&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;view_kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;This method is a decorator that is being used by some alias&lt;/span&gt;
&lt;span class="nv"&gt;methods&lt;/span&gt;.
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;wrapper&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;view&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
# &lt;span class="nv"&gt;all&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;logic&lt;/span&gt; &lt;span class="nv"&gt;goes&lt;/span&gt; &lt;span class="nv"&gt;here&lt;/span&gt;. &lt;span class="nv"&gt;And&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;mean&lt;/span&gt; &lt;span class="nv"&gt;all&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;logic&lt;/span&gt;, &lt;span class="nv"&gt;I&lt;/span&gt;
# &lt;span class="nv"&gt;mean&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;.
# &lt;span class="mi"&gt;1&lt;/span&gt;. &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;registering&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;callback&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;pyramid&lt;/span&gt; &lt;span class="nv"&gt;routing&lt;/span&gt;
# &lt;span class="nv"&gt;system&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;gets&lt;/span&gt; &lt;span class="nv"&gt;called&lt;/span&gt; &lt;span class="nv"&gt;whenever&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;module&lt;/span&gt; &lt;span class="nv"&gt;using&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
# &lt;span class="nv"&gt;decorator&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;used&lt;/span&gt;.
# &lt;span class="mi"&gt;2&lt;/span&gt;. &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;transforming&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;arguments&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;they&lt;/span&gt; &lt;span class="nv"&gt;conform&lt;/span&gt;
# &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;what&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;expected&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;pyramid&lt;/span&gt; &lt;span class="nv"&gt;routing&lt;/span&gt; &lt;span class="nv"&gt;system&lt;/span&gt;.
# &lt;span class="mi"&gt;3&lt;/span&gt;. &lt;span class="nv"&gt;We&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;storing&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;arguments&lt;/span&gt; &lt;span class="nv"&gt;into&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
# &lt;span class="nv"&gt;object&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;retrieve&lt;/span&gt; &lt;span class="nv"&gt;them&lt;/span&gt; &lt;span class="nv"&gt;later&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt;.
# &lt;span class="mi"&gt;4&lt;/span&gt;. &lt;span class="nv"&gt;Also&lt;/span&gt;, &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;transforming&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;view&lt;/span&gt; &lt;span class="nv"&gt;before&lt;/span&gt;
# &lt;span class="nv"&gt;registering&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;pyramid&lt;/span&gt; &lt;span class="nv"&gt;routing&lt;/span&gt; &lt;span class="nv"&gt;system&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt;
# &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nv"&gt;what&lt;/span&gt; &lt;span class="nv"&gt;Cornice&lt;/span&gt; &lt;span class="nv"&gt;wants&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;checking&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;rules&lt;/span&gt;,
# &lt;span class="nv"&gt;applying&lt;/span&gt; &lt;span class="nv"&gt;validators&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;filters&lt;/span&gt; &lt;span class="nv"&gt;etc&lt;/span&gt;.
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;wrapper&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;A shortcut of the api decorator&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;api&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;request_method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I encourage you to go read &lt;a 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&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 get_drink, 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 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 api 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;h2 id="how-do-we-improve-this"&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;p&gt;``` sourceCode python
class Service(object):
# we define class-level variables that will be the default values for
# this service. This makes things more extensible than it was before.
renderer = 'simplejson'
default_validators = DEFAULT_VALIDATORS
default_filters = DEFAULT_FILTERS&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;# &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;also&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;class&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;level&lt;/span&gt; &lt;span class="nv"&gt;parameters&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;useful&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;know&lt;/span&gt;
# &lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;parameters&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;supposed&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;lists&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt; &lt;span class="nv"&gt;converted&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;such&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
# &lt;span class="nv"&gt;or&lt;/span&gt; &lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;mandatory&lt;/span&gt;.
&lt;span class="nv"&gt;mandatory_arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;renderer&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;,&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;list_arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;validators&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;filters&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;__init__&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="nv"&gt;name&lt;/span&gt;, &lt;span class="nv"&gt;path&lt;/span&gt;, &lt;span class="nv"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;None&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kw&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
# &lt;span class="nv"&gt;setup&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt;, &lt;span class="nv"&gt;path&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;description&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt; &lt;span class="nv"&gt;variables&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;path&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;description&lt;/span&gt;
# &lt;span class="nv"&gt;convert&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;arguments&lt;/span&gt; &lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;something&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;want&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;store&lt;/span&gt;
# &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nv"&gt;store&lt;/span&gt; &lt;span class="nv"&gt;them&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;attributes&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;because&lt;/span&gt; &lt;span class="nv"&gt;they&lt;/span&gt;
# &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;constructor&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;get_arguments&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;kw&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;key&lt;/span&gt;, &lt;span class="nv"&gt;value&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;arguments&lt;/span&gt;.&lt;span class="nv"&gt;items&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;:
&lt;span class="nv"&gt;setattr&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="nv"&gt;key&lt;/span&gt;, &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
# &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;keep&lt;/span&gt; &lt;span class="nv"&gt;having&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;defined_methods&lt;/span&gt; &lt;span class="nv"&gt;tuple&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;list&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt;
# &lt;span class="nv"&gt;definitions&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="nv"&gt;done&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;defined_methods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; []
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;definitions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; []
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;get_arguments&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="nv"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;None&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;Returns a dict of arguments. It does all the conversions for&lt;/span&gt;
&lt;span class="nv"&gt;you&lt;/span&gt;, &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;uses&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;information&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;were&lt;/span&gt; &lt;span class="nv"&gt;defined&lt;/span&gt; &lt;span class="nv"&gt;at&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt;
&lt;span class="nv"&gt;level&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;fallbacks&lt;/span&gt;.
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;add_view&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="nv"&gt;method&lt;/span&gt;, &lt;span class="nv"&gt;view&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;Add a view to this service.&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
# &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;really&lt;/span&gt; &lt;span class="nv"&gt;simple&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;looks&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;lot&lt;/span&gt; &lt;span class="nv"&gt;like&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt;
&lt;span class="nv"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;method&lt;/span&gt;.&lt;span class="nv"&gt;upper&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;definitions&lt;/span&gt;.&lt;span class="nv"&gt;append&lt;/span&gt;&lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;method&lt;/span&gt;, &lt;span class="nv"&gt;view&lt;/span&gt;, &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;method&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;defined_methods&lt;/span&gt;:
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;defined_methods&lt;/span&gt;.&lt;span class="nv"&gt;append&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;method&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;decorator&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;self&lt;/span&gt;, &lt;span class="nv"&gt;method&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;This is only another interface to the add_view method, exposing a&lt;/span&gt;
&lt;span class="nv"&gt;decorator&lt;/span&gt; &lt;span class="nv"&gt;interface&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;wrapper&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;view&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="nv"&gt;self&lt;/span&gt;.&lt;span class="nv"&gt;add_view&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;method&lt;/span&gt;, &lt;span class="nv"&gt;view&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;kwargs&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;view&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;wrapper&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;So&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="k"&gt;only&lt;/span&gt; &lt;span class="n"&gt;storing&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="n"&gt;passed&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;
&lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="k"&gt;nothing&lt;/span&gt; &lt;span class="k"&gt;more&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="k"&gt;No&lt;/span&gt; &lt;span class="k"&gt;more&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="n"&gt;logic&lt;/span&gt; &lt;span class="n"&gt;goes&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="k"&gt;Instead&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt;
&lt;span class="n"&gt;added&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;another&lt;/span&gt; &lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;even&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;different&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt;
&lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;named&lt;/span&gt; &lt;span class="n"&gt;register&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;_service&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;_views&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;has&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;following&lt;/span&gt; &lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;```&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;python&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&gt;
&lt;li&gt;Service description is now separated from the route registration.&lt;/li&gt;
&lt;li&gt;cornice.service.Service now provides a hook_view 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 Service 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. cornice.services.Service 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 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;</content></entry><entry><title>Djangocong 2012</title><link href="https://blog.notmyidea.org/djangocong-2012.html" rel="alternate"></link><published>2012-04-16T00:00:00+02:00</published><updated>2012-04-16T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-04-16:/djangocong-2012.html</id><summary type="html">
&lt;p&gt;Ce week-end, c'était &lt;a href="http://rencontres.django-fr.org"&gt;djangocong&lt;/a&gt;, une
conférence autour de &lt;a href="http://djangoproject.org"&gt;django&lt;/a&gt;, de
&lt;a href="http://python.org"&gt;python&lt;/a&gt; et du web, qui avait lieu dans le sud, à
Carnon-plage, à quelques kilomètres de Montpellier la belle.&lt;/p&gt;
&lt;p&gt;J'ai vraiment apprécié les trois jours passés avec cette bande de geeks.
Je m'attendais à des &lt;em&gt;nerds&lt;/em&gt;, j'y ai trouvé une …&lt;/p&gt;</summary><content type="html">
&lt;p&gt;Ce week-end, c'était &lt;a href="http://rencontres.django-fr.org"&gt;djangocong&lt;/a&gt;, une
conférence autour de &lt;a href="http://djangoproject.org"&gt;django&lt;/a&gt;, de
&lt;a href="http://python.org"&gt;python&lt;/a&gt; et du web, qui avait lieu dans le sud, à
Carnon-plage, à quelques kilomètres de Montpellier la belle.&lt;/p&gt;
&lt;p&gt;J'ai vraiment apprécié les trois jours passés avec cette bande de geeks.
Je m'attendais à des &lt;em&gt;nerds&lt;/em&gt;, j'y ai trouvé une qualité d'écoute, des
personnes qui partagent des valeurs qui leur sont chères, mais qui ne
limitent pas leurs discussions à du technique. Eeeh ouais, encore un
préjugé qui tombe, tiens :)&lt;/p&gt;
&lt;p&gt;En tant que &lt;em&gt;hackers&lt;/em&gt;, on a le moyen de créer des outils qui sont utiles
à tous, et qui peuvent être utiles pour favoriser la collaboration et la
mise en commun des données. J'ai eu l'occasion de discuter de projets
tournant autour de l'entraide, que ça soit pour mettre en lien des
associations d'économie sociale et solidaire (ESS) ou simplement pour
que les populations &lt;em&gt;non tech&lt;/em&gt; &lt;a href="http://blog.notmyidea.org/quels-usages-pour-linformatique-fr.html"&gt;puissent utiliser toute la puissance de
l'outil qu'est le
web&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Au niveau du format des conférences, je ne savais pas trop à quoi
m'attendre, au vu des échos de l'an dernier, mais c'était adapté: des
mini-confs de 12mn le samedi matin + début d'aprem, en mode no-wifi pour
récupérer une qualité d'écoute. Et contrairement à mes attentes, ce
n'est pas trop court. Pas mal de retours d'expérience pour le coup, et
une matinée pas vraiment techniques, mais ça pose le décor et permet de
savoir qui fait quoi.&lt;/p&gt;
&lt;p&gt;Parmi l'ensemble des conférences du matin, je retiens principalement
celle de Mathieu Leplatre, "des cartes d'un autre monde", qui m'a
réellement bluffée quand à la facilité de créer des cartes avec
&lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt;, et qui me pousse à reconsidérer
le fait que "la carto, c'est compliqué". &lt;a href="https://www.youtube.com/watch?v=7NPQo54NbJ8"&gt;La vidéo est (déja !)
disponible en ligne&lt;/a&gt;, je
vous invite à la regarder (c'est une 15aine de minutes) pour vous faire
un avis ;)&lt;/p&gt;
&lt;p&gt;Une fois les conf passées, ça reste très intéressant, voire plus: il
reste un jour et demi pour discuter avec les autres présents. On a pu se
retrouver avec Mathieu pour discuter de "notre" projet &lt;a href="http://blog.notmyidea.org/carto-forms-fr.html"&gt;"carto
forms"&lt;/a&gt;, qui à finalement
pu se redéfinir un peu plus et donner naissance à un
&lt;a href="https://github.com/spiral-project/daybed/blob/master/README.rst"&gt;README&lt;/a&gt;.
On en à profité pour lui choisir un nouveau nom: "daybed", en référence
à couchdb.&lt;/p&gt;
&lt;p&gt;Ça devrait se transformer en code d'ici peu. La curiosité aidant, on a
pu discuter du projet avec d'autres personnes et affiner les attentes de
chacun pour finalement arriver à quelque chose d'assez sympathique.&lt;/p&gt;
&lt;p&gt;J'ai aussi pu me rendre compte que pas mal de monde utilise
&lt;a href="http://pelican.notmyidea.org"&gt;pelican&lt;/a&gt;, le bout de code que j'ai codé
pour générer ce blog, et avoir des retours utiles ! Probablement des
réflexions à venir sur comment éviter qu'un projet open-source ne
devienne chronophage, et sur comment réussir à garder une qualité dans
le code source tout en ne froissant pas les contributeurs.&lt;/p&gt;
&lt;p&gt;Bien évidemment, c'était aussi l'occaz de rencontrer des gens qu'on ne
voir que sur les inter-nets, et de discuter un brin de tout ce qui fait
que notre monde est chouette et moins chouette.&lt;/p&gt;
&lt;p&gt;Entres autres faits notoires, JMad a perdu au baby-foot face à Exirel,
même en m'ayant à ses cotés pour le déconcentrer (et je suis un joueur
d'un autre monde - en d'autres termes, je suis nul), David`bgk ne s'est
pas levé pour aller courir le dimanche matin (il avait dit 5 heures!),
Les suisses ont essayé de me convertir à coup d'abricotine, j'ai perdu
au skulls-n-roses en quelques tours et on a allumé un feu chez Stéphane
le dimanche soir (oui oui, à montpellier, mi avril, je vous le dis
qu'ils mentent avec leur soit disant soleil).&lt;/p&gt;
&lt;p&gt;Et c'est sans parler de &lt;a href="http://jehaisleprintemps.net/blog/fr/2012/04/15/j-ecris-ton-nom/"&gt;la
brasucade&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Bref, vivement la prochaine (et allez, cette fois ci je ferais une
présentation !)&lt;/p&gt;</content></entry><entry><title>Génération de formulaires, geolocalisés ?</title><link href="https://blog.notmyidea.org/generation-de-formulaires-geolocalises.html" rel="alternate"></link><published>2012-04-02T00:00:00+02:00</published><updated>2012-04-02T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-04-02:/generation-de-formulaires-geolocalises.html</id><summary type="html">
&lt;p&gt;On a un plan. Un "truc de ouf".&lt;/p&gt;
&lt;p&gt;À plusieurs reprises, des amis m'ont demandé de leur coder la même
chose, à quelques détails près: une page web avec un formulaire qui
permettrait de soumettre des informations géographiques, lié à une carte
et des manières de filtrer l'information.&lt;/p&gt;
&lt;p&gt;L'idée fait …&lt;/p&gt;</summary><content type="html">
&lt;p&gt;On a un plan. Un "truc de ouf".&lt;/p&gt;
&lt;p&gt;À plusieurs reprises, des amis m'ont demandé de leur coder la même
chose, à quelques détails près: une page web avec un formulaire qui
permettrait de soumettre des informations géographiques, lié à une carte
et des manières de filtrer l'information.&lt;/p&gt;
&lt;p&gt;L'idée fait son bout de chemin, et je commence à penser qu'on peut même
avoir quelque chose de vraiment flexible et utile. J'ai nommé le projet
&lt;em&gt;carto-forms&lt;/em&gt; pour l'instant (mais c'est uniquement un nom de code).&lt;/p&gt;
&lt;p&gt;Pour résumer: et si on avait un moyen de construire des formulaires, un
peu comme Google forms, mais avec des informations géographiques en
plus?&lt;/p&gt;
&lt;p&gt;Si vous ne connaissez pas Google forms, il s'agit d'une interface simple
d'utilisation pour générer des formulaires et récupérer des informations
depuis ces derniers.&lt;/p&gt;
&lt;p&gt;Google forms est un super outil mais à mon avis manque deux choses
importantes: premièrement, il s'agit d'un outil propriétaire (oui, on
peut aussi dire privateur) et il n'est donc pas possible de le hacker un
peu pour le faire devenir ce qu'on souhaite, ni l'installer sur notre
propre serveur. Deuxièmement, il ne sait pas vraiment fonctionner avec
des informations géographiques, et il n'y à pas d'autre moyen de filtrer
les informations que l'utilisation de leur système de feuilles de
calcul.&lt;/p&gt;
&lt;p&gt;Après avoir réfléchi un petit peu à ça, j'ai contacté
&lt;a href="http://blog.mathieu-leplatre.info/"&gt;Mathieu&lt;/a&gt; et les anciens collègues
de chez &lt;a href="http://makina-corpus.com"&gt;Makina Corpus&lt;/a&gt;, puisque les projets
libres à base de carto sont à même de les intéresser.&lt;/p&gt;
&lt;p&gt;Imaginez le cas suivant:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Dans une "mapping party", on choisit un sujet particulier à
cartographier et on design un formulaire (liste des champs (tags) a
remplir + description + le type d'information) ;&lt;/li&gt;
&lt;li&gt;Sur place, les utilisateurs remplissent les champs du formulaire
avec ce qu'ils voient. Les champs géolocalisés peuvent être remplis
automatiquement avec la géolocalisation du téléphone ;&lt;/li&gt;
&lt;li&gt;À la fin de la journée, il est possible de voir une carte des
contributions, avec le formulaire choisi ;&lt;/li&gt;
&lt;li&gt;Un script peut importer les résultats et les publier vers
OpenStreetMap.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="quelques-cas-dutilisation"&gt;Quelques cas d'utilisation&lt;/h2&gt;
&lt;p&gt;J'arrive à imaginer différents cas d'utilisation pour cet outil. Le
premier est celui que j'ai approximativement décrit plus haut: la
génération de cartes de manière collaborative, avec des filtres à
facettes. Voici un flux d'utilisation général:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Un "administrateur" se rend sur le site web et crée un nouveau
formulaire pour l'ensemble des évènements alternatifs. Il crée les
champs suivants:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Nom: le champ qui contient le nom de l'évènement.&lt;/li&gt;
&lt;li&gt;Catégorie: la catégorie de l'évènement (marche, concert,
manifestation…). Il peut s'agir d'un champ à multiples
occurrences.&lt;/li&gt;
&lt;li&gt;Le lieu de l'évènement. Celui-ci peut être donné soit par une
adresse soit en sélectionnant un point sur une carte.&lt;/li&gt;
&lt;li&gt;Date: la date de l'évènement (un "date picker" peut permettre
cela facilement)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chaque champ dans le formulaire a des informations sémantiques
associées (oui/non, multiple sélection, date, heure, champ géocodé,
sélection carto, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Une fois terminé, le formulaire est généré et une URL permet d'y
accéder. (par exemple &lt;a href="http://forms.notmyidea.org/alternatives"&gt;http://forms.notmyidea.org/alternatives&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Une API REST permet à d'autres applications d'accéder aux
informations et d'en ajouter / modifier de nouvelles.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Il est maintenant possible de donner l'URL à qui voudra en faire bon
usage. N'importe qui peut ajouter des informations. On peut
également imaginer une manière de modérer les modifications si
besoin est.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bien sur, la dernière phase est la plus intéressante: il est
possible de filtrer les informations par lieu, catégorie ou date, le
tout soit via une API REST, soit via une jolie carte et quelques
contrôles bien placés, dans le navigateur.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vous avez dû remarquer que le processus de création d'un formulaire est
volontairement très simple. L'idée est que n'importe qui puisse créer
des cartes facilement, en quelques clics. Si une API bien pensée suit,
on peut imaginer faire de la validation coté serveur et même faire des
applications pour téléphone assez simplement.&lt;/p&gt;
&lt;p&gt;Pour aller un peu plus loin, si on arrive à penser un format de
description pour le formulaire, il sera possible de construire les
formulaires de manière automatisée sur différentes plateformes et
également sur des clients génériques.&lt;/p&gt;
&lt;p&gt;On imagine pas mal d'exemples pour ce projet: des points de recyclage,
les endroits accessibles (pour fauteuils roulants etc.), identification
des arbres, bons coins à champignons, recensement des espèces en voie de
disparition (l'aigle de Bonelli est actuellement suivi en utilisant une
feuille de calcul partagée !), suivi des espèces dangereuses (le frelon
asiatique par exemple), cartographier les points d'affichage
publicitaires, participation citoyenne (graffitis, nids de poule, voir
&lt;a href="http://fixmystreet.ca"&gt;http://fixmystreet.ca&lt;/a&gt;), geocaching, trajectoires (randonnées,
coureurs, cyclistes)…&lt;/p&gt;
&lt;p&gt;Voici quelques exemples où ce projet pourrait être utile (la liste n'est
pas exhaustive):&lt;/p&gt;
&lt;h3 id="un-backend-sig-simple-a-utiliser"&gt;Un backend SIG simple à utiliser&lt;/h3&gt;
&lt;p&gt;Disons que vous êtes développeur mobile. Vous ne voulez pas vous
encombrer avec PostGIS ou écrire du code spécifique pour récupérer et
insérer des données SIG! Vous avez besoin de &lt;em&gt;Carto-Forms&lt;/em&gt;! Une API
simple vous aide à penser vos modèles et vos formulaires, et cette même
API vous permet d'insérer et de récupérer des données. Vous pouvez vous
concentrer sur votre application et non pas sur la manière dont les
données géographiques sont stockées et gérées.&lt;/p&gt;
&lt;p&gt;En d'autres termes, vous faites une distinction entre le stockage des
informations et leur affichage.&lt;/p&gt;
&lt;p&gt;Si vous êtes un développeur django, plomino, drupal etc. vous pouvez
développer un module pour "plugger" vos modèles et votre interface
utilisateur avec celle de &lt;em&gt;Carto-Forms&lt;/em&gt;. De cette manière, il est
possible d'exposer les formulaires aux utilisateurs de vos backoffices.
De la même manière, il est possible d'écrire des widgets qui consomment
des données et les affichent (en utilisant par exemple une bibliothèque
javascript de webmapping).&lt;/p&gt;
&lt;h3 id="un-outil-de-visualisation"&gt;Un outil de visualisation&lt;/h3&gt;
&lt;p&gt;Puisque les données peuvent être proposées de manière automatisée en
utilisant l'API, vous pouvez utiliser la page de résultat de Carto-forms
comme un outil de visualisation.&lt;/p&gt;
&lt;p&gt;Il est possible d'explorer mon jeu de données en utilisant des filtres
sur chacun des champs. La recherche à facettes peut être une idée pour
faciliter ce filtrage. Une carte affiche le résultat. Vous avez
l'impressoin d'être en face d'un système d'aide à la décision !&lt;/p&gt;
&lt;p&gt;Évidemment, il est possible de télécharger les données brutes (geojson,
xml). Idéalement, le mieux serait d'obtenir ces données filtrées
directement depuis une API Web, et un lien permet de partager la page
avec l'état des filtres et le niveau de zoom / la localisation de la
carte.&lt;/p&gt;
&lt;h3 id="un-service-generique-pour-gerer-les-formulaires"&gt;Un service générique pour gérer les formulaires&lt;/h3&gt;
&lt;p&gt;Si vous souhaitez générer un fichier de configuration (ou ce que vous
voulez, messages emails, …) vous aurez besoin d'un formulaire et d'un
template pour injecter les données proposées par les utilisateurs et
récupérer un résultat.&lt;/p&gt;
&lt;p&gt;Un service de gestion des formulaires pourrait être utile pour créer des
formulaires de manière automatique et récupérer les données "nettoyées"
et "validées".&lt;/p&gt;
&lt;p&gt;On peut imaginer par exemple l'utilisation d'un système de templates
externe reposant sur &lt;em&gt;carto-forms&lt;/em&gt;. Celui-ci "parserait" le contenu des
templates et pourrait le lier aux informations ajoutées par les
utilisateurs via un formulaire.&lt;/p&gt;
&lt;p&gt;Pour ce cas particulier, il n'y a pas besoin d'informations
géographiques (SIG). Il s'agit quasiment du service proposé
actuellement par Google forms.&lt;/p&gt;
&lt;h2 id="ca-nexiste-pas-deja-tout-ca"&gt;Ça n'existe pas déjà tout ça ?&lt;/h2&gt;
&lt;p&gt;Bien sur, il y a Google forms, qui vous permet de faire ce genre de
choses, mais comme je l'ai précisé plus haut, il ne s'agit pas
exactement de la même chose.&lt;/p&gt;
&lt;p&gt;Nous avons découvert &lt;a href="https://webform.com"&gt;https://webform.com&lt;/a&gt; qui permet de créer des
formulaires avec un système de drag'n'drop. J'adorerais reproduire
quelque chose de similaire pour l'interface utilisateur. Par contre ce
projet ne gère pas les appels via API et les informations de
géolocalisation …&lt;/p&gt;
&lt;p&gt;L'idée de &lt;a href="http://thoth.io"&gt;http://thoth.io&lt;/a&gt; est également assez sympathique: une api
très simple pour stocker et récupérer des données. En plus de ça,
&lt;em&gt;carto-forms&lt;/em&gt; proposerait de la validation de données et proposerait un
support des points SIG (point, ligne, polygone).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://mapbox.com"&gt;http://mapbox.com&lt;/a&gt; fait également un superbe travail autour de la
cartographie, mais ne prends pas en compte le coté auto-génération de
formulaires…&lt;/p&gt;
&lt;h2 id="on-est-parti-33"&gt;On est parti ?!&lt;/h2&gt;
&lt;p&gt;Comme vous avez pu vous en rendre compte, il ne s'agit pas d'un problème
outrageusement complexe. On a pas mal discuté avec Mathieu, à propos de
ce qu'on souhaite faire et du comment. Il se trouve qu'on peut sûrement
s'en sortir avec une solution élégante sans trop de problèmes. Mathieu
est habitué à travailler autour des projets de SIG (ce qui est parfait
parce que ce n'est pas mon cas) et connaît son sujet. Une bonne
opportunité d'apprendre!&lt;/p&gt;
&lt;p&gt;On sera tous les deux à &lt;a href="http://rencontres.django-fr.org"&gt;Djangocong&lt;/a&gt; le
14 et 15 Avril, et on prévoit une session de &lt;em&gt;tempête de cerveau&lt;/em&gt; et un
sprint sur ce projet. Si vous êtes dans le coin et que vous souhaitez
discuter ou nous filer un coup de patte, n'hésitez pas!&lt;/p&gt;
&lt;p&gt;On ne sait pas encore si on utilisera django ou quelque chose d'autre.
On a pensé un peu à CouchDB, son système de couchapps et geocouch, mais
rien n'est encore gravé dans le marbre ! N'hésitez pas à proposer vos
solutions ou suggestions.&lt;/p&gt;
&lt;p&gt;Voici le document etherpad sur lequel on a travaillé jusqu'à maintenant:
&lt;a href="http://framapad.org/carto-forms"&gt;http://framapad.org/carto-forms&lt;/a&gt;. N'hésitez pas à l'éditer et à ajouter
vos commentaires, c'est son objectif!&lt;/p&gt;
&lt;p&gt;Merci à &lt;a href="http://sneakernet.fr/"&gt;Arnaud&lt;/a&gt; pour la relecture et la
correction de quelques typos dans le texte :)&lt;/p&gt;</content></entry><entry><title>Thoughts about a form generation service, GIS enabled</title><link href="https://blog.notmyidea.org/thoughts-about-a-form-generation-service-gis-enabled.html" rel="alternate"></link><published>2012-04-02T00:00:00+02:00</published><updated>2012-04-02T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2012-04-02:/thoughts-about-a-form-generation-service-gis-enabled.html</id><summary type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;slug&lt;br&gt;
carto-forms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
02-04-2012&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;author&lt;br&gt;
Alexis Métaireau, Mathieu Leplatre&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tags&lt;br&gt;
GIS, forms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;lang&lt;br&gt;
en&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have a plan. A "fucking good" 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 …&lt;/p&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;slug&lt;br&gt;
carto-forms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
02-04-2012&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;author&lt;br&gt;
Alexis Métaireau, Mathieu Leplatre&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tags&lt;br&gt;
GIS, forms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;lang&lt;br&gt;
en&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have a plan. A "fucking good" 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 "codename".&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 href="http://blog.mathieu-leplatre.info/"&gt;Mathieu&lt;/a&gt; and some folks
at &lt;a 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&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;h2 id="some-use-cases"&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&gt;An "administrator" 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&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&gt;Once finished, the form is generated and the user gets an url (say
&lt;a 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&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&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&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 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;h3 id="simple-gis-storage-backend"&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 "plug" 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;h3 id="visualization-tool"&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;h3 id="generic-forms-service"&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 =&gt; values) would be bound to the input of a template engine
(variables =&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;h2 id="whats-out-in-the-wild-already"&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 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 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 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;h2 id="so-lets-get-it-real33"&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 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 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 href="http://sneakernet.fr/"&gt;Arnaud&lt;/a&gt; and
&lt;a href="http://qwerty.fuzz.me.uk/"&gt;Fuzzmz&lt;/a&gt; for proof-reading and typo fixing.&lt;/p&gt;</content></entry><entry><title>Introducing Cornice</title><link href="https://blog.notmyidea.org/introducing-cornice.html" rel="alternate"></link><published>2011-12-07T00:00:00+01:00</published><updated>2011-12-07T00:00:00+01:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-12-07:/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 href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt;, on a pyramid REST-ish
toolkit named &lt;a 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 href="http://ziade.org"&gt;Tarek Ziadé&lt;/a&gt;, on a pyramid REST-ish
toolkit named &lt;a 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 href="http://docs.pylonsproject.org/projects/colander/en/latest/"&gt;Colander&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="handling-errors-and-validation"&gt;Handling errors and validation&lt;/h2&gt;
&lt;p&gt;Here is how it works:&lt;/p&gt;
&lt;p&gt;``` sourceCode python
service = Service(name="service", path="/service")&lt;/p&gt;
&lt;p&gt;def is_awesome(request):
if not 'awesome' in request.GET:
request.errors.add('query', 'awesome',
'the awesome parameter is required')&lt;/p&gt;
&lt;p&gt;@service.get(validator=is_awesome)
def get1(request):
return {"test": "yay!"}&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;All&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;errors&lt;/span&gt; &lt;span class="nv"&gt;collected&lt;/span&gt; &lt;span class="nv"&gt;during&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;validation&lt;/span&gt; &lt;span class="nv"&gt;process&lt;/span&gt;, &lt;span class="nv"&gt;or&lt;/span&gt; &lt;span class="nv"&gt;after&lt;/span&gt;, &lt;span class="nv"&gt;are&lt;/span&gt;
&lt;span class="nv"&gt;collected&lt;/span&gt; &lt;span class="nv"&gt;before&lt;/span&gt; &lt;span class="nv"&gt;returning&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;. &lt;span class="k"&gt;If&lt;/span&gt; &lt;span class="nv"&gt;any&lt;/span&gt;, &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;error&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;fired&lt;/span&gt; &lt;span class="nv"&gt;up&lt;/span&gt;,
&lt;span class="nv"&gt;with&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;list&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;problems&lt;/span&gt; &lt;span class="nv"&gt;encountered&lt;/span&gt; &lt;span class="nv"&gt;returned&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;nice&lt;/span&gt; &lt;span class="nv"&gt;json&lt;/span&gt; &lt;span class="nv"&gt;list&lt;/span&gt;
&lt;span class="nv"&gt;response&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;plan&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;support&lt;/span&gt; &lt;span class="nv"&gt;multiple&lt;/span&gt; &lt;span class="nv"&gt;formats&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;future&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;As&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;might&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;seen&lt;/span&gt;, &lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;errors&lt;/span&gt;.&lt;span class="nv"&gt;add&lt;/span&gt; &lt;span class="nv"&gt;takes&lt;/span&gt; &lt;span class="nv"&gt;three&lt;/span&gt; &lt;span class="nv"&gt;parameters&lt;/span&gt;:
&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;location&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;, &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;description&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;.
&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;location&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;where&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;error&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;located&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;. &lt;span class="nv"&gt;It&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;either&lt;/span&gt;
&lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;query&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;headers&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="nv"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;. &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;variable&lt;/span&gt; &lt;span class="nv"&gt;causing&lt;/span&gt; &lt;span class="nv"&gt;problem&lt;/span&gt;, &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;any&lt;/span&gt;, &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nv"&gt;description&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nv"&gt;contains&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;more&lt;/span&gt;
&lt;span class="nv"&gt;detailed&lt;/span&gt; &lt;span class="nv"&gt;message&lt;/span&gt;.
&lt;span class="nv"&gt;Let&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;s run this simple service and send some queries to it:&lt;/span&gt;
$ &lt;span class="nv"&gt;curl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;v&lt;/span&gt; &lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;Host&lt;/span&gt;: &lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;Accept&lt;/span&gt;: &lt;span class="o"&gt;*/*&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;, &lt;span class="nv"&gt;assume&lt;/span&gt; &lt;span class="nv"&gt;close&lt;/span&gt; &lt;span class="nv"&gt;after&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="nv"&gt;Bad&lt;/span&gt; &lt;span class="nv"&gt;Request&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Type&lt;/span&gt;: &lt;span class="nv"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;json&lt;/span&gt;&lt;span class="c1"&gt;; charset=UTF-8&lt;/span&gt;
[{&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;location&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;query&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;You lack awesomeness!&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;}
&lt;span class="nv"&gt;I&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ve removed the extra clutter from the curl&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="nv"&gt;s&lt;/span&gt; &lt;span class="nv"&gt;output&lt;/span&gt;, &lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;got&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;general&lt;/span&gt; &lt;span class="nv"&gt;idea&lt;/span&gt;.
&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;content&lt;/span&gt; &lt;span class="nv"&gt;returned&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;JSON&lt;/span&gt;, &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;know&lt;/span&gt; &lt;span class="nv"&gt;exactly&lt;/span&gt; &lt;span class="nv"&gt;what&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;:
&lt;span class="nv"&gt;add&lt;/span&gt; &lt;span class="nv"&gt;an&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="nv"&gt;parameter&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;query&lt;/span&gt;. &lt;span class="nv"&gt;Let&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;s do it again:&lt;/span&gt;
$ &lt;span class="nv"&gt;curl&lt;/span&gt; &lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt;?&lt;span class="nv"&gt;awesome&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;yeah&lt;/span&gt;
{&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;test&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;yay!&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;}
&lt;span class="nv"&gt;Validators&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;also&lt;/span&gt; &lt;span class="nv"&gt;convert&lt;/span&gt; &lt;span class="nv"&gt;parts&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;store&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;converted&lt;/span&gt;
&lt;span class="nv"&gt;value&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;validated&lt;/span&gt;. &lt;span class="nv"&gt;It&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;standard&lt;/span&gt; &lt;span class="nv"&gt;dict&lt;/span&gt; &lt;span class="nv"&gt;automatically&lt;/span&gt; &lt;span class="nv"&gt;attached&lt;/span&gt;
&lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;requests&lt;/span&gt;.
&lt;span class="k"&gt;For&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt;, &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;our&lt;/span&gt; &lt;span class="nv"&gt;validator&lt;/span&gt;, &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;chose&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;validate&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;parameter&lt;/span&gt;
&lt;span class="nv"&gt;passed&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;webservice&lt;/span&gt;:
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;python&lt;/span&gt;
&lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Service&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;service&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;/service&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;is_awesome&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;request&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;GET&lt;/span&gt;:
&lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;errors&lt;/span&gt;.&lt;span class="nv"&gt;add&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;query&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;,
&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;the awesome parameter is required&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;:
&lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;validated&lt;/span&gt;[&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;] &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;GET&lt;/span&gt;[&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;]
@&lt;span class="nv"&gt;service&lt;/span&gt;.&lt;span class="nv"&gt;get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;is_awesome&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;def&lt;/span&gt; &lt;span class="nv"&gt;get1&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;request&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
&lt;span class="k"&gt;return&lt;/span&gt; {&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;test&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;: &lt;span class="nv"&gt;request&lt;/span&gt;.&lt;span class="nv"&gt;validated&lt;/span&gt;[&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;awesome&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;]}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output would look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;curl&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&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="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&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;awesome&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yeah&lt;/span&gt;
&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;awesome yeah&amp;quot;&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="dealing-with-accept-headers"&gt;Dealing with "Accept" 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 Content-Type 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 accept
parameter:&lt;/p&gt;
&lt;p&gt;``` sourceCode python
@service.get(validator=is_awesome, accept=("application/json", "text/json"))
def get1(request):
return {"test": "yay!"}&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;Now&lt;/span&gt;, &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;specifically&lt;/span&gt; &lt;span class="nv"&gt;ask&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;XML&lt;/span&gt;, &lt;span class="nv"&gt;Cornice&lt;/span&gt; &lt;span class="nv"&gt;will&lt;/span&gt; &lt;span class="nv"&gt;throw&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="mi"&gt;406&lt;/span&gt; &lt;span class="nv"&gt;with&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;list&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;accepted&lt;/span&gt; &lt;span class="nv"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Type&lt;/span&gt; &lt;span class="nv"&gt;values&lt;/span&gt;:
$ &lt;span class="nv"&gt;curl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;vH&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;Accept: application/xml&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="nv"&gt;http&lt;/span&gt;:&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;service&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;Host&lt;/span&gt;: &lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;Accept&lt;/span&gt;: &lt;span class="nv"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;xml&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;406&lt;/span&gt; &lt;span class="nv"&gt;Not&lt;/span&gt; &lt;span class="nv"&gt;Acceptable&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Type&lt;/span&gt;: &lt;span class="nv"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;json&lt;/span&gt;&lt;span class="c1"&gt;; charset=UTF-8&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Length&lt;/span&gt;: &lt;span class="mi"&gt;33&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
[&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;application/json&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;text/json&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;]
## &lt;span class="nv"&gt;Building&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;documentation&lt;/span&gt; &lt;span class="nv"&gt;automatically&lt;/span&gt;
&lt;span class="nv"&gt;writing&lt;/span&gt; &lt;span class="nv"&gt;documentation&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;web&lt;/span&gt; &lt;span class="nv"&gt;services&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;painful&lt;/span&gt;, &lt;span class="nv"&gt;especially&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt;
&lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;services&lt;/span&gt; &lt;span class="nv"&gt;evolve&lt;/span&gt;. &lt;span class="nv"&gt;Cornice&lt;/span&gt; &lt;span class="nv"&gt;provides&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;sphinx&lt;/span&gt; &lt;span class="nv"&gt;directive&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt;
&lt;span class="nv"&gt;automatically&lt;/span&gt; &lt;span class="nv"&gt;document&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;API&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;your&lt;/span&gt; &lt;span class="nv"&gt;docs&lt;/span&gt;.
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;rst&lt;/span&gt;
.. &lt;span class="nv"&gt;services&lt;/span&gt;::
:&lt;span class="nv"&gt;package&lt;/span&gt;: &lt;span class="nv"&gt;coolapp&lt;/span&gt;
:&lt;span class="nv"&gt;service&lt;/span&gt;: &lt;span class="nv"&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 href="http://packages.python.org/cornice/exampledoc.html"&gt;http://packages.python.org/cornice/exampledoc.html&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="yay33-how-can-i-get-it"&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 href="http://pypi.python.org/pypi/cornice"&gt;http://pypi.python.org/pypi/cornice&lt;/a&gt; You can install it easily using
pip, for instance:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pip install cornice
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also have a look at the documentation at
&lt;a href="http://packages.python.org/cornice/"&gt;http://packages.python.org/cornice/&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="whats-next"&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 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;</content></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 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 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 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;p&gt;&lt;img alt="Capture d'écran du site." src="images/ihatemoney.png"&gt;&lt;/p&gt;
&lt;p&gt;You can try the project at &lt;a href="http://ihatemoney.notmyidea.org"&gt;http://ihatemoney.notmyidea.org&lt;/a&gt; for now,
and the code lives at &lt;a href="https://github.com/spiral-project/ihatemoney/"&gt;https://github.com/spiral-project/ihatemoney/&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="features"&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;h3 id="no-user-registration"&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;h3 id="keeping-things-simple"&gt;Keeping things simple&lt;/h3&gt;
&lt;p&gt;"Keep It Simple, Stupid" 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;h3 id="no-categories"&gt;No categories&lt;/h3&gt;
&lt;p&gt;Some people like to organise their stuff into different "categories":
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;h3 id="balance"&gt;Balance&lt;/h3&gt;
&lt;p&gt;One of the most useful thing is to know what's your "balance" 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;h3 id="api"&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;h2 id="interested"&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 href="http://github.com/spiral-project/ihatemoney/"&gt;http://github.com/spiral-project/ihatemoney/&lt;/a&gt;&lt;/p&gt;</content></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 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 "Influenced" and "InfluencedBy",
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 "( programming language)", which is the case for python.&lt;/p&gt;
&lt;p&gt;So I've built &lt;a 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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ python get_influences.py python dot &lt;span class="p"&gt;|&lt;/span&gt; dot -Tpng &amp;gt; influences.png
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result is the following graph (&lt;a href="http://files.lolnet.org/alexis/influences.png"&gt;see it directly
here&lt;/a&gt;)&lt;/p&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"&gt;&lt;/p&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 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></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 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 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></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-06-11T00:00:00+02:00</published><updated>2011-06-11T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2011-06-11:/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
"boilerplate" 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
"boilerplate" 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;h2 id="first-steps-with-jpype"&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;h2 id="interfacing-with-boilerpipe"&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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; boilerpipe
$ ant
&lt;/pre&gt;&lt;/div&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;</content></entry><entry><title>Un coup de main pour mon mémoire33</title><link href="https://blog.notmyidea.org/un-coup-de-main-pour-mon-memoire33.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-memoire33.html</id><summary type="html">&lt;h1 id="un-coup-de-main-pour-mon-memoire33"&gt;Un coup de main pour mon mémoire!&lt;/h1&gt;
&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 …&lt;/p&gt;</summary><content type="html">&lt;h1 id="un-coup-de-main-pour-mon-memoire33"&gt;Un coup de main pour mon mémoire!&lt;/h1&gt;
&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 "tournée générale").&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 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 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 "neighbour radio".) (by the way, &lt;a 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 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 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;h2 id="introduction-and-rationale"&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;h2 id="background-review"&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;h3 id="data-preparation-and-extraction"&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
"liked" 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;h3 id="information-filtering"&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&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&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 href="http://portal.acm.org/citation.cfm?id=245108.245124&amp;amp;"&gt;http://portal.acm.org/citation.cfm?id=245108.245124&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 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 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 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;h2 id="privacy"&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;h2 id="whats-the-plan"&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&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&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;</content></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;h2 id="creating-the-jail"&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="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;flavour&lt;/span&gt; &lt;span class="n"&gt;jail&lt;/span&gt; &lt;span class="n"&gt;named&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;ezjail&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;admin&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="n"&gt;workspace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt; &lt;span class="mi"&gt;172&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;19&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="mi"&gt;6&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;ezjail&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;admin&lt;/span&gt; &lt;span class="k"&gt;start&lt;/span&gt; &lt;span class="n"&gt;workspace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In my case, because the "default" 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;code&gt;/etc/pf.conf&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt; &lt;span class="nv"&gt;workspace_jail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.19.1.6&amp;quot;&lt;/span&gt;
rdr on &lt;span class="nv"&gt;$ext_if&lt;/span&gt; proto tcp from any to &lt;span class="nv"&gt;$ext_ip&lt;/span&gt; port &lt;span class="m"&gt;20006&lt;/span&gt; -&amp;gt; &lt;span class="nv"&gt;$workspace_jail&lt;/span&gt; port &lt;span class="m"&gt;22&lt;/span&gt;
&lt;/pre&gt;&lt;/div&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;h2 id="working-with-unison"&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;h2 id="let-sync-our-folders"&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 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: workspace, the jail, and ecureuil 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 unison. (fire up vim \~/.unison/default.prf.&lt;/p&gt;
&lt;p&gt;Here is my config:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt; &lt;span class="na"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/home/alexis&lt;/span&gt;
&lt;span class="s"&gt; root = ssh://notmyidea.org:20006&lt;/span&gt;
&lt;span class="na"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;.vimrc&lt;/span&gt;
&lt;span class="s"&gt; path = dotfiles&lt;/span&gt;
&lt;span class="s"&gt; path = dev&lt;/span&gt;
&lt;span class="na"&gt;follow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;Name *&lt;/span&gt;
&lt;/pre&gt;&lt;/div&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 follow = Name * 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;h2 id="run-the-script-frequently"&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
crontab is made for, so let's &lt;code&gt;crontab -e&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;*/&lt;/span&gt;&lt;span class="mi"&gt;3&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;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="n"&gt;Xdbus&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;unison&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;syncer&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The \~/.Xdbus 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 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;</content></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&gt;
&lt;li&gt;the datafiles, 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;mkgcfg, 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 setup.py file and fill in some fields in
the setup.cfg for you.&lt;/li&gt;
&lt;li&gt;a compatibility layer for distutils1, so it can read the setup.cfg
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 "simple" 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 "simple" 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;h2 id="couchdb"&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;h2 id="so-what"&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 "simple" API, and rely on a
REST insterface instead. I have set up a couchdb server on my server,
which is available at
&lt;a 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;h2 id="example"&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;h3 id="using-the-command-line"&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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pypioncouch&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;fullimport&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;couchdb&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;/pre&gt;&lt;/div&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
&lt;a href="http://couchdb.notmyidea.org/pypi/"&gt;http://couchdb.notmyidea.org/pypi/&lt;/a&gt;&lt;/strong&gt;, to avoid the duplication of
nodes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pypioncouch --update http://your.couchdb.instance/
&lt;/pre&gt;&lt;/div&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;h3 id="using-the-python-api"&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;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;pypioncouch&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;XmlRpcImporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;import_all&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;full_import&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;update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="whats-next"&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&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 "Simple" 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&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 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;</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 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 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;h2 id="edit-using-grep"&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;</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;h2 id="edit-using-grep"&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;p&gt;&lt;code&gt;`` sourceCode bash
curl -X POST -u joel:joel http://bebox.config/cgi/b/info/restart/\?be\=0\&amp;amp;l0\=1\&amp;amp;l1\=0\&amp;amp;tid\=RESTART -d "0=17&amp;amp;2=&lt;/code&gt;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 "name='2' value='[0-9]+" | grep -o "[0-9]+" | tail -n 1`&amp;amp;1"&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;## The Python version&lt;/span&gt;
&lt;span class="n"&gt;Well&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;s not the optimal solution, that&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;bit&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;gruik&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;but&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;
&lt;span class="n"&gt;works&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="sb"&gt;``&lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;python&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;</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 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 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 "gnome-background-generator", and you can
install it via pip for instance.&lt;/p&gt;
&lt;p&gt;``` sourceCode shell
$ pip install gnome-background-generator&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;Then&lt;/span&gt;, &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;have&lt;/span&gt; &lt;span class="nv"&gt;just&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;use&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;way&lt;/span&gt;:
``` &lt;span class="nv"&gt;sourceCode&lt;/span&gt; &lt;span class="nv"&gt;shell&lt;/span&gt;
$ &lt;span class="nv"&gt;gnome&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;background&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;generator&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;p&lt;/span&gt; &lt;span class="o"&gt;~/&lt;/span&gt;&lt;span class="nv"&gt;Images&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;walls&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;s&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;Images&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;walls&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;dynamic&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;wallpaper&lt;/span&gt;.&lt;span class="nv"&gt;xml&lt;/span&gt; &lt;span class="nv"&gt;generated&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is a extract of the `--help`:&lt;/p&gt;
&lt;p&gt;``` sourceCode shell
$ gnome-background-generator --help
usage: gnome-background-generator [-h] [-p PATH] [-o OUTPUT]
[-t TRANSITION_TIME] [-d DISPLAY_TIME] [-s]
[-b]&lt;/p&gt;
&lt;p&gt;A simple command line tool to generate an XML file to use for gnome
wallpapers, to have dynamic walls&lt;/p&gt;
&lt;p&gt;optional arguments:
-h, --help show this help message and exit
-p PATH, --path PATH Path to look for the pictures. If no output is
specified, will be used too for outputing the dynamic-
wallpaper.xml file. Default value is the current
directory (.)
-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 "-" to
display the xml in the stdout.
-t TRANSITION_TIME, --transition-time TRANSITION_TIME
Time (in seconds) transitions must last (default value
is 2 seconds)
-d DISPLAY_TIME, --display-time DISPLAY_TIME
Time (in seconds) a picture must be displayed. Default
value is 900 (15mn)
-s, --set-background '''try to set the background using gnome-appearance-
properties
-b, --debug
```&lt;/p&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;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-10-10&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="k"&gt;update&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;ports&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;portsnap&lt;/span&gt; &lt;span class="k"&gt;fetch&lt;/span&gt; &lt;span class="k"&gt;update&lt;/span&gt;
&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;php5&lt;/span&gt; &lt;span class="n"&gt;port …&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-10-10&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="k"&gt;update&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;ports&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;portsnap&lt;/span&gt; &lt;span class="k"&gt;fetch&lt;/span&gt; &lt;span class="k"&gt;update&lt;/span&gt;
&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;php5&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;recursive&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ports&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;php5&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;extensions&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;recursive&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ports&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;php5&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;extensions&lt;/span&gt;
&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;nginx&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;recursive&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;devel&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;recursive&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;devel&lt;/span&gt;
&lt;/pre&gt;&lt;/div&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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt; {
&lt;span class="nv"&gt;server_name&lt;/span&gt; &lt;span class="nv"&gt;ndd&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;set&lt;/span&gt; $&lt;span class="nv"&gt;path&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;to&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;your&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;files&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;root&lt;/span&gt; $&lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; {
&lt;span class="nv"&gt;index&lt;/span&gt; &lt;span class="nv"&gt;index&lt;/span&gt;.&lt;span class="nv"&gt;php&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
&lt;span class="nv"&gt;location&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;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;jpg&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;jpeg&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;gif&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;css&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;png&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;js&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;ico&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nv"&gt;xml&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;$ {
&lt;span class="nv"&gt;access_log&lt;/span&gt; &lt;span class="nv"&gt;off&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;expires&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="nv"&gt;d&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
&lt;span class="nv"&gt;location&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; .&lt;span class="nv"&gt;php&lt;/span&gt;$ {
&lt;span class="nv"&gt;fastcgi_param&lt;/span&gt; &lt;span class="nv"&gt;SCRIPT_FILENAME&lt;/span&gt; $&lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="mh"&gt;$fa&lt;/span&gt;&lt;span class="nv"&gt;stcgi_script_name&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;fastcgi_pass&lt;/span&gt; &lt;span class="nv"&gt;backend&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="nv"&gt;fastcgi_params&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
}
&lt;span class="nv"&gt;upstream&lt;/span&gt; &lt;span class="nv"&gt;backend&lt;/span&gt; {
&lt;span class="nv"&gt;server&lt;/span&gt; &lt;span class="mi"&gt;127&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;0&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;:&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&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 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 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 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 (pelican --help)&lt;/p&gt;
&lt;p&gt;``` sourceCode bash
$ pip install pelican&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;##&lt;/span&gt; &lt;span class="k"&gt;Usage&lt;/span&gt;
&lt;span class="n"&gt;Here&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;sample&lt;/span&gt; &lt;span class="k"&gt;usage&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;pelican&lt;/span&gt;
&lt;span class="o"&gt;```&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;bash&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pelican&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;categories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;archives&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;writing&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;alexis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;notmyidea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;simple&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;blog&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="n"&gt;Done&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You also can use the --help option for the command line to get more
informations&lt;/p&gt;
&lt;p&gt;``` sourceCode bash
$pelican --help
usage: pelican [-h] [-t TEMPLATES] [-o OUTPUT] [-m MARKUP] [-s SETTINGS] [-b]
path&lt;/p&gt;
&lt;p&gt;A tool to generate a static blog, with restructured text input files.&lt;/p&gt;
&lt;p&gt;positional arguments:
path Path where to find the content files (default is
"content").&lt;/p&gt;
&lt;p&gt;optional arguments:
-h, --help show this help message and exit
-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 "output" 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;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&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 href="http://code.google.com/soc/"&gt;Google Summer of Code&lt;/a&gt; I've spent
working on &lt;a 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 href="http://zubin71.wordpress.com"&gt;Zubin&lt;/a&gt;,
&lt;a href="http://wokslog.wordpress.com/"&gt;Éric&lt;/a&gt;,
&lt;a href="http://gsoc.djolonga.com/"&gt;Josip&lt;/a&gt;,
&lt;a href="http://konryd.blogspot.com/"&gt;Konrad&lt;/a&gt; and me. In addition,
&lt;a 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 href="http://code.google.com/soc/"&gt;Google Summer of Code&lt;/a&gt; I've spent
working on &lt;a 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 href="http://zubin71.wordpress.com"&gt;Zubin&lt;/a&gt;,
&lt;a href="http://wokslog.wordpress.com/"&gt;Éric&lt;/a&gt;,
&lt;a href="http://gsoc.djolonga.com/"&gt;Josip&lt;/a&gt;,
&lt;a href="http://konryd.blogspot.com/"&gt;Konrad&lt;/a&gt; and me. In addition,
&lt;a 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 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 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 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;h2 id="why"&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 href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="my-job"&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 href="http://bitbucket.org/ametaireau/distutils2/"&gt;my bitbucket
repository&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="crawling-the-pypi-indexes"&gt;Crawling the PyPI indexes&lt;/h3&gt;
&lt;p&gt;There are two ways of requesting informations from the indexes: using
the "simple" 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 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 href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt; source code .&lt;/p&gt;
&lt;h3 id="installation-uninstallation-scripts"&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 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;h3 id="extra-work"&gt;Extra work&lt;/h3&gt;
&lt;p&gt;Also, I've done some extra work. this includes:&lt;/p&gt;
&lt;ul&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 href="http://distutils.notmyidea.org"&gt;documentation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="futures-plans"&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 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 href="http://en.wikipedia.org/wiki/Representational_State_Transfer"&gt;REST&lt;/a&gt; API
for &lt;a href="http://pypi.python.org"&gt;PyPI&lt;/a&gt;, as the "simple" 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 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;h2 id="issues"&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;h2 id="thanks-33"&gt;Thanks !&lt;/h2&gt;
&lt;p&gt;A big thanks to &lt;a href="http://www.graine-libre.fr/"&gt;Graine Libre&lt;/a&gt; and &lt;a 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;</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-10T00:00:00+02:00</published><updated>2010-07-10T00:00:00+02:00</updated><author><name>Alexis Métaireau</name></author><id>tag:blog.notmyidea.org,2010-07-10:/sprinting-on-distutils2-in-tours.html</id><summary type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-07-06&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&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 …&lt;/p&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-07-06&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&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;h2 id="documentation"&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&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;h2 id="mercurial"&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&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 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;h2 id="on-using-tools"&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 "power users", so we have learned from
each other about vim tips. You can find &lt;a 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;h2 id="on-being-pythonic"&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 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;h2 id="conclusion"&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;</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 href="http://wiki.notmyidea.org/distutils2_schedule"&gt;a
dedicated wiki page&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="general-feelings"&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 "things" 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;h2 id="tasks"&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 href="http://pypi.python.org"&gt;http://pypi.python.org&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="pypi-index-crawling"&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&lt;a href="http://www.python.org/dev/peps/pep-0345/"&gt;PEP 345&lt;/a&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;h3 id="using-the-simple-api"&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 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&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 "EggsAndSpam" 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;p&gt;``` sourceCode python&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;index = SimpleIndex()
index.find("EggsAndSpam")
[EggsAndSpam 1.1, EggsAndSpam 1.2, EggsAndSpam 1.3]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;We&lt;/span&gt; &lt;span class="n"&gt;also&lt;/span&gt; &lt;span class="n"&gt;could&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt; &lt;span class="n"&gt;specifiers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;```&lt;/span&gt; &lt;span class="n"&gt;sourceCode&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&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="mi"&gt;1&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;EggsAndSpam&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;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&gt;
&lt;li&gt;it process the &lt;a 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 "final" 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 href="http://distutils2.notmyidea.org/"&gt;distutils2
documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="using-xml-rpc"&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 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;h2 id="processes"&gt;Processes&lt;/h2&gt;
&lt;p&gt;For now, I'm trying to follow the "documentation, then test, then code"
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 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;</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;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-06-25&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Wednesday, we give a presentation, with some friends, about the CouchDB
Database, to &lt;a 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 …&lt;/p&gt;</summary><content type="html">
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;date&lt;br&gt;
2010-06-25&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;category&lt;br&gt;
tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Wednesday, we give a presentation, with some friends, about the CouchDB
Database, to &lt;a 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 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 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 href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.pdf"&gt;the final PDF
output&lt;/a&gt;,
&lt;a href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.rst"&gt;Rhe ReST
source&lt;/a&gt;,
&lt;a 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;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;rst2pdf&lt;/span&gt; &lt;span class="n"&gt;couchdb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rst&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;b1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;slides&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt;
&lt;/pre&gt;&lt;/div&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 href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt;
during the past week, taking part of the
&lt;a 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 href="http://hg.python.org/distutils2/"&gt;Distutils2&lt;/a&gt;
during the past week, taking part of the
&lt;a 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 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 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 "simple"
API.&lt;/p&gt;
&lt;p&gt;So, I've been working on porting some
&lt;a href="http://bitbucket.org/tarek/distribute/"&gt;Distribute&lt;/a&gt; related stuff to
&lt;a 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 href="http://bitbucket.org/konrad"&gt;Konrad&lt;/a&gt;
makes about this mock.&lt;/p&gt;
&lt;h2 id="a-pypi-server-mock"&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 href="http://wsgi.org"&gt;WSGI&lt;/a&gt; and
&lt;a 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 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 href="http://docs.python.org/library/basehttpserver.html"&gt;BaseHTTPServer&lt;/a&gt; and
&lt;a 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 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 href="http://bitbucket.org/ametaireau/distutils2/changesets"&gt;the modifications I
made&lt;/a&gt;, and the
&lt;a href="http://bitbucket.org/ametaireau/distutils2/src/tip/docs/source/test_framework.rst"&gt;related
docs&lt;/a&gt;
about this on &lt;a href="http://bitbucket.org/ametaireau/distutils2/"&gt;my bitbucket distutils2
clone&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="the-pypi-simple-api"&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 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;h2 id="the-work-to-come"&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 href="http://github.com/ametaireau/pypiclient"&gt;already started
here&lt;/a&gt; I'll take you updated !&lt;/p&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 href="http://code.google.com/intl/fr/soc/"&gt;Google Summer Of
Code&lt;/a&gt; program, and will work on
&lt;a href="http://python.org/"&gt;python&lt;/a&gt; &lt;a href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;, with &lt;a href="http://pygsoc.wordpress.com/"&gt;a&lt;/a&gt; &lt;a href="http://konryd.blogspot.com/"&gt;lot&lt;/a&gt; &lt;a href="http://ziade.org/"&gt;of&lt;/a&gt; (intersting !) &lt;a href="http://zubin71.wordpress.com/"&gt;people&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So, it's about building the successor of Distutils2, ie. "the python
package manager". Today, there is too many ways to package a python …&lt;/p&gt;&lt;/blockquote&gt;</summary><content type="html">
&lt;p&gt;WOW. I've been accepted to be a part of the &lt;a href="http://code.google.com/intl/fr/soc/"&gt;Google Summer Of
Code&lt;/a&gt; program, and will work on
&lt;a href="http://python.org/"&gt;python&lt;/a&gt; &lt;a href="http://hg.python.org/distutils2/"&gt;distutils2&lt;/a&gt;, with &lt;a href="http://pygsoc.wordpress.com/"&gt;a&lt;/a&gt; &lt;a href="http://konryd.blogspot.com/"&gt;lot&lt;/a&gt; &lt;a href="http://ziade.org/"&gt;of&lt;/a&gt; (intersting !) &lt;a href="http://zubin71.wordpress.com/"&gt;people&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So, it's about building the successor of Distutils2, ie. "the python
package manager". Today, there is too many ways to package a python
application (pip, setuptools, distribute, distutils, etc.) so there is
a huge effort to make in order to make all this packaging stuff
interoperable, as pointed out by
the &lt;a href="http://www.python.org/dev/peps/pep-0376/"&gt;PEP 376&lt;/a&gt;.&lt;/p&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&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 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.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.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 href="http://www.djangoproject.org"&gt;django&lt;/a&gt;, et que,
nécessairement, je me forme à &lt;a 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 href="http://www.djangoproject.org"&gt;django&lt;/a&gt;, et que,
nécessairement, je me forme à &lt;a 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 "logique" et "simple". 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;h2 id="the-zen-of-python"&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 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;p&gt;``` sourceCode bash&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;import this
The Zen of Python, by Tim Peters&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;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't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than &lt;em&gt;right&lt;/em&gt; now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
```&lt;/p&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 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;h2 id="comment-commencer-et-par-ou"&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&gt;
&lt;li&gt;&lt;a href="http://diveintopython.adrahon.org/"&gt;Dive into python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a 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 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 href="http://tarekziade.wordpress.com/"&gt;Tarek Ziadé&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a 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 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 href="http://www.twitter.com/ametaireau"&gt;via
twitter&lt;/a&gt; ou &lt;a href="http://delicious.com/ametaireau"&gt;via mon compte
delicious&lt;/a&gt;. Allez jeter un œil &lt;a 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;h2 id="un-python-sexy"&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&gt;
&lt;li&gt;&lt;a 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 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 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 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 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 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 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;</content></entry></feed>