diff --git a/feeds/all-en.atom.xml b/feeds/all-en.atom.xml index 41dee3f..650ac53 100644 --- a/feeds/all-en.atom.xml +++ b/feeds/all-en.atom.xml @@ -1,18 +1,49 @@ -Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, this is my second working day at mozilla. I've been working, yesterday and -today, on a pyramid REST-ish toolkit, <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> -<p>Cornice allows you to take out from you all the repetitive stuff you do when -writing a web service. I'm mainly thinking about different kinds of validation.</p> +Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, already my third working day at mozilla. Since Monday, I've been working with +Tarek Ziadé, on a pyramid REST-ish toolkit named <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> +<p>Its goal is to take all the hard bits appart from you when implementing a web +service, so you can focus on what's important. Cornice provides you facilities +for validation of any kind.</p> +<p>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 Collander.</p> +<div class="section" id="handling-errors-and-validation"> +<h2>Handling errors and validation</h2> +<p>We have changed the way errors are handled. Here is how it works:</p> +<div class="highlight"><pre><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;service&quot;</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s">&quot;/service&quot;</span><span class="p">)</span> + + +<span class="k">def</span> <span class="nf">is_awesome</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="s">&#39;awesome&#39;</span> <span class="ow">in</span> <span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="p">:</span> + <span class="n">request</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;body&#39;</span><span class="p">,</span> <span class="s">&#39;awesome&#39;</span><span class="p">,</span> <span class="s">&#39;You lack awesomeness!&#39;</span><span class="p">)</span> + + +<span class="nd">@service.get</span><span class="p">(</span><span class="n">validator</span><span class="o">=</span><span class="p">(</span><span class="n">is_awesome</span><span class="p">))</span> +<span class="k">def</span> <span class="nf">get1</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">return</span> <span class="p">{</span><span class="s">&quot;test&quot;</span><span class="p">:</span> <span class="s">&quot;succeeded&quot;</span><span class="p">}</span> +</pre></div> +<p>All the errors collected during the validation process, or after, are collected +before returning the request. If any, a error 400 is fired up, with the list of +problems encoutred encoded as a nice json list (we plan to support multiple +formats in the future)</p> +<p>As you might have seen, <cite>request.errors.add</cite> takes three parameters: <strong>location</strong>, +<strong>name</strong> and <strong>description</strong>.</p> +<p><strong>location</strong> is where the error arised. It can either be &quot;body&quot;, &quot;query&quot;, &quot;headers&quot; +or &quot;path&quot;. <strong>name</strong> is the name of the variable causing problem, if any, and +<strong>description</strong> contains a more detailled message.</p> +<p>Here is an example of a malformed request:</p> +<pre class="literal-block"> +$ # run a demo app +</pre> <p>To describe a web service in <em>cornice</em>, you have to write something like this</p> <div class="system-message"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 14)</p> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 54)</p> <p>Content block expected for the &quot;code-block&quot; directive; none found.</p> <pre class="literal-block"> .. code-block:: python - </pre> </div> +</div> How are you handling your shared expenses?2011-10-15T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-10-15:/how-are-you-handling-your-shared-expenses.html/<p><strong>TL;DR:</strong> We're kick-starting a new application to manage your shared expenses. Have a look at <a class="reference external" href="http://ihatemoney.notmyidea.org">http://ihatemoney.notmyidea.org</a></p> <p>As a student, I lived in a lot of different locations, and the majority of them diff --git a/feeds/all.atom.xml b/feeds/all.atom.xml index 25b595b..2e4fdc1 100644 --- a/feeds/all.atom.xml +++ b/feeds/all.atom.xml @@ -1,18 +1,49 @@ -Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, this is my second working day at mozilla. I've been working, yesterday and -today, on a pyramid REST-ish toolkit, <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> -<p>Cornice allows you to take out from you all the repetitive stuff you do when -writing a web service. I'm mainly thinking about different kinds of validation.</p> +Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, already my third working day at mozilla. Since Monday, I've been working with +Tarek Ziadé, on a pyramid REST-ish toolkit named <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> +<p>Its goal is to take all the hard bits appart from you when implementing a web +service, so you can focus on what's important. Cornice provides you facilities +for validation of any kind.</p> +<p>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 Collander.</p> +<div class="section" id="handling-errors-and-validation"> +<h2>Handling errors and validation</h2> +<p>We have changed the way errors are handled. Here is how it works:</p> +<div class="highlight"><pre><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;service&quot;</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s">&quot;/service&quot;</span><span class="p">)</span> + + +<span class="k">def</span> <span class="nf">is_awesome</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="s">&#39;awesome&#39;</span> <span class="ow">in</span> <span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="p">:</span> + <span class="n">request</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;body&#39;</span><span class="p">,</span> <span class="s">&#39;awesome&#39;</span><span class="p">,</span> <span class="s">&#39;You lack awesomeness!&#39;</span><span class="p">)</span> + + +<span class="nd">@service.get</span><span class="p">(</span><span class="n">validator</span><span class="o">=</span><span class="p">(</span><span class="n">is_awesome</span><span class="p">))</span> +<span class="k">def</span> <span class="nf">get1</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">return</span> <span class="p">{</span><span class="s">&quot;test&quot;</span><span class="p">:</span> <span class="s">&quot;succeeded&quot;</span><span class="p">}</span> +</pre></div> +<p>All the errors collected during the validation process, or after, are collected +before returning the request. If any, a error 400 is fired up, with the list of +problems encoutred encoded as a nice json list (we plan to support multiple +formats in the future)</p> +<p>As you might have seen, <cite>request.errors.add</cite> takes three parameters: <strong>location</strong>, +<strong>name</strong> and <strong>description</strong>.</p> +<p><strong>location</strong> is where the error arised. It can either be &quot;body&quot;, &quot;query&quot;, &quot;headers&quot; +or &quot;path&quot;. <strong>name</strong> is the name of the variable causing problem, if any, and +<strong>description</strong> contains a more detailled message.</p> +<p>Here is an example of a malformed request:</p> +<pre class="literal-block"> +$ # run a demo app +</pre> <p>To describe a web service in <em>cornice</em>, you have to write something like this</p> <div class="system-message"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 14)</p> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 54)</p> <p>Content block expected for the &quot;code-block&quot; directive; none found.</p> <pre class="literal-block"> .. code-block:: python - </pre> </div> +</div> Quels usages pour l'informatique ?2011-12-01T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-01:/quels-usages-pour-linformatique-fr.html/<p>Quand on termine ses études, on s'en pose un tas, des questions. Sur le métier que l'on veut faire, sur ce que ça signifie, sur le sens et la valeur du travail. Et j'en suis arrivé à faire un constat simple: l'informatique, c'est diff --git a/feeds/mozilla.atom.xml b/feeds/mozilla.atom.xml index 6a63bb5..9669fc0 100644 --- a/feeds/mozilla.atom.xml +++ b/feeds/mozilla.atom.xml @@ -1,16 +1,47 @@ -Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, this is my second working day at mozilla. I've been working, yesterday and -today, on a pyramid REST-ish toolkit, <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> -<p>Cornice allows you to take out from you all the repetitive stuff you do when -writing a web service. I'm mainly thinking about different kinds of validation.</p> +Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, already my third working day at mozilla. Since Monday, I've been working with +Tarek Ziadé, on a pyramid REST-ish toolkit named <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> +<p>Its goal is to take all the hard bits appart from you when implementing a web +service, so you can focus on what's important. Cornice provides you facilities +for validation of any kind.</p> +<p>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 Collander.</p> +<div class="section" id="handling-errors-and-validation"> +<h2>Handling errors and validation</h2> +<p>We have changed the way errors are handled. Here is how it works:</p> +<div class="highlight"><pre><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;service&quot;</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s">&quot;/service&quot;</span><span class="p">)</span> + + +<span class="k">def</span> <span class="nf">is_awesome</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="s">&#39;awesome&#39;</span> <span class="ow">in</span> <span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="p">:</span> + <span class="n">request</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;body&#39;</span><span class="p">,</span> <span class="s">&#39;awesome&#39;</span><span class="p">,</span> <span class="s">&#39;You lack awesomeness!&#39;</span><span class="p">)</span> + + +<span class="nd">@service.get</span><span class="p">(</span><span class="n">validator</span><span class="o">=</span><span class="p">(</span><span class="n">is_awesome</span><span class="p">))</span> +<span class="k">def</span> <span class="nf">get1</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> + <span class="k">return</span> <span class="p">{</span><span class="s">&quot;test&quot;</span><span class="p">:</span> <span class="s">&quot;succeeded&quot;</span><span class="p">}</span> +</pre></div> +<p>All the errors collected during the validation process, or after, are collected +before returning the request. If any, a error 400 is fired up, with the list of +problems encoutred encoded as a nice json list (we plan to support multiple +formats in the future)</p> +<p>As you might have seen, <cite>request.errors.add</cite> takes three parameters: <strong>location</strong>, +<strong>name</strong> and <strong>description</strong>.</p> +<p><strong>location</strong> is where the error arised. It can either be &quot;body&quot;, &quot;query&quot;, &quot;headers&quot; +or &quot;path&quot;. <strong>name</strong> is the name of the variable causing problem, if any, and +<strong>description</strong> contains a more detailled message.</p> +<p>Here is an example of a malformed request:</p> +<pre class="literal-block"> +$ # run a demo app +</pre> <p>To describe a web service in <em>cornice</em>, you have to write something like this</p> <div class="system-message"> -<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 14)</p> +<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 54)</p> <p>Content block expected for the &quot;code-block&quot; directive; none found.</p> <pre class="literal-block"> .. code-block:: python - </pre> </div> +</div> \ No newline at end of file diff --git a/introducing-cornice.html b/introducing-cornice.html index 02cd4d5..3c1a3b2 100644 --- a/introducing-cornice.html +++ b/introducing-cornice.html @@ -14,20 +14,51 @@

Introducing cornice

Published on Tue 06 December 2011

-

Wow, this is my second working day at mozilla. I've been working, yesterday and -today, on a pyramid REST-ish toolkit, cornice.

-

Cornice allows you to take out from you all the repetitive stuff you do when -writing a web service. I'm mainly thinking about different kinds of validation.

+

Wow, already my third working day at mozilla. Since Monday, I've been working with +Tarek Ziadé, on a pyramid REST-ish toolkit named cornice.

+

Its goal is to take all the hard bits appart from you when implementing a web +service, so you can focus on what's important. Cornice provides you facilities +for validation of any kind.

+

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 Collander.

+
+

Handling errors and validation

+

We have changed the way errors are handled. Here is how it works:

+
service = Service(name="service", path="/service")
+
+
+def is_awesome(request):
+    if not 'awesome' in request.GET:
+        request.errors.add('body', 'awesome', 'You lack awesomeness!')
+
+
+@service.get(validator=(is_awesome))
+def get1(request):
+    return {"test": "succeeded"}
+
+

All the errors collected during the validation process, or after, are collected +before returning the request. If any, a error 400 is fired up, with the list of +problems encoutred encoded as a nice json list (we plan to support multiple +formats in the future)

+

As you might have seen, request.errors.add takes three parameters: location, +name and description.

+

location is where the error arised. It can either be "body", "query", "headers" +or "path". name is the name of the variable causing problem, if any, and +description contains a more detailled message.

+

Here is an example of a malformed request:

+
+$ # run a demo app
+

To describe a web service in cornice, you have to write something like this

-

System Message: ERROR/3 (./content/mozilla/introducing-cornice.rst, line 14)

+

System Message: ERROR/3 (./content/mozilla/introducing-cornice.rst, line 54)

Content block expected for the "code-block" directive; none found.

 .. code-block:: python
 
-
 
+