[Repoze-checkins] r615 - www/trunk/blog.repoze.org/entries

root at laguna.palladion.com root at laguna.palladion.com
Tue Dec 18 22:37:04 UTC 2007


Author: root
Date: Tue Dec 18 22:37:04 2007
New Revision: 615

Log:
Cosmetics.

Modified:
   www/trunk/blog.repoze.org/entries/repoze.tm_with_pylons-20071218.txt

Modified: www/trunk/blog.repoze.org/entries/repoze.tm_with_pylons-20071218.txt
==============================================================================
--- www/trunk/blog.repoze.org/entries/repoze.tm_with_pylons-20071218.txt	(original)
+++ www/trunk/blog.repoze.org/entries/repoze.tm_with_pylons-20071218.txt	Tue Dec 18 22:37:04 2007
@@ -15,9 +15,11 @@
     the <code>sqlite</code> backend for simplicity.  Once done,
     I looked at the code in the application which did manual / explicit
     transaction handline in the controller method for the blog
-    add form POST::</p>
+    add form POST:
+</p>
 
 <pre>
+
     def blog_add_process(self):
         # Create a new Blog object and populate it.
         newpost = model.Blog()
@@ -34,6 +36,7 @@
         # (This sends the SQL INSERT command due to autoflushing.)
         model.Session.commit()
         redirect_to("/blog")
+
 </pre>
 
 <h3>Using the <code>transaction</code> Framework in the Application</h3>
@@ -41,9 +44,11 @@
 I decided to knock together a simple "data manager" for this application,
 following Chris' <a href="http://repoze.org/tmdemo.html">Transactions
 in WSGI</a> tutorial.  The class implements the <code>IDataManager</code>
-API, using the ORM session to do the real work::</p>
+API, using the ORM session to do the real work:
+</p>
 
 <pre>
+
 class DataManager(object):
 
     transaction_manager = None
@@ -83,15 +88,18 @@
         """ See IDataManager.
         """
         return 'myblog-sql'
+
 </pre>
 
 <p> I then modified the controller method such that it registers
     an instance of the DataManager class with the transaction.  Note
     the addition of pseudo-validation logic, which triggers an exception
     in order to demonstrate the "auto-rollback" feature of
-    <code>repoze.tm</code>::</p>
+    <code>repoze.tm</code>:
+</p>
 
 <pre>
+
 import transaction
 ...
     def blog_add_process(self):
@@ -111,6 +119,7 @@
             raise ValueError('Invalid data')
 
         redirect_to("/blog")
+
 </pre>
 
 <h3>Configuring the Application</h3>
@@ -119,7 +128,9 @@
    dependencies:</p>
 
 <pre>
+
   $ ../bin/easy_install -i http://dist.repoze.org/simple repoze.tm
+
 </pre>
 
 <p>Then, I needed to wire the <code>repoze.tm</code> middleware into
@@ -127,6 +138,7 @@
    middleware, I renamed the <code>[app:main]<code> section::</p>
 
 <pre>
+
 [app:myblog]
 use = egg:MyBlog
 # Let pipeline handle errors
@@ -136,6 +148,7 @@
 beaker.session.secret = somesecret
 sqlalchemy.url = sqlite:///%(here)s/db.sqlite
 sqlalchemy.convert_unicode = true
+
 </pre>
 
 <p>Note that I turned off the <code>full_stack</code> option, because
@@ -146,12 +159,14 @@
    the transaction middleware and some error handling::</p>
 
 <pre>
+
 [pipeline:main]
 pipeline =
            egg:Paste#cgitb
            egg:Paste#httpexceptions
            egg:repoze.tm#tm
            myblog
+
 </pre>
 
 <p>At this point, the application works as desired:</p>


More information about the Repoze-checkins mailing list