<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Python Blog - All about python &#187; Python</title>
	<atom:link href="http://www.python-blog.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.python-blog.com</link>
	<description>and technologies around</description>
	<lastBuildDate>Tue, 27 Jul 2010 19:58:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Documenting project using Sphinx</title>
		<link>http://www.python-blog.com/2010/02/21/documenting-project-using-sphinx/</link>
		<comments>http://www.python-blog.com/2010/02/21/documenting-project-using-sphinx/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 17:10:15 +0000</pubDate>
		<dc:creator>Łukasz Balcerzak</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[documentation sphinx]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=257</guid>
		<description><![CDATA[We have no time for creating documentation for our project&#8230; wrong! Documentation and tests are crucial in all software projects. Sure, it is more important that our software would work fine but package of unit tests almost always save time (in future as less bugs are produced) and without documentation shouldn&#8217;t be treated as &#8220;user [...]]]></description>
			<content:encoded><![CDATA[<p>We have no time for creating documentation for our project&#8230; wrong! Documentation and tests are crucial in all software projects. Sure, it is more important that our software would work fine but package of unit tests almost always save time (in future as less bugs are produced) and without documentation shouldn&#8217;t be treated as &#8220;user guide&#8221;.</p>
<p>It doesn&#8217;t matter if you are creating project for your company or you plan to release it as an open source &#8211; by providing documentation you make life easier for other contributors and end-users, of course. And if you know how to write <a href="http://docutils.sourceforge.net/rst.html">restructuredText</a> documents then you already own necessary skills to create documentation lighting fast!</p>
<h2>Prepare!</h2>
<p>First of all, you would need to have <a href="http://docutils.sourceforge.net/rst.html">Distutils</a> and <a href="http://sphinx.pocoo.org/">Sphinx</a> installed. You can install it using one of the Python package management tools, in example <i>easy_install</i> would do the job. I prefer to use <a href="http://pypi.python.org/pypi/pip">pip</a>:</p>
<pre class="brush:bash">
pip install distutils
pip install sphinx
</pre>
<p>Simply use any project you&#8217;d like to create documentation for, I would use <a href="http://bitbucket.org/lukaszb/django-richtemplates/">django-richtemplates</a>. Create a new directory for your documentation and run <i>sphinx-quickstart</i> command:</p>
<pre class="brush:bash">
hg clone https://bitbucket.org/lukaszb/django-richtemplates/ django-richtemplates-temp
cd django-richtemplates-temp
sphinx-quickstart
</pre>
<p>Just answer some questions &#8211; they are very straightforward. You should probably turn <i>autodoc</i> option on.<br />
Sphinx would create some directories for internal usage and static content storage (<i>_build</i>, <i>_static</i> and <i>_templates</i>), configuration file (<i>conf.py</i>) and index file (<i>index.html</i>). Ok, enough of this crap, lets create our first documentation page! </p>
<h2>First page</h2>
<p>Create new file, lets call it <i>installation.rst</i> and write the document itself:</p>
<pre class="brush:plain">
.. _installation:

============
Installation
============

Fake installation for `django-richtemplates`_ project.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.

.. note::
   Yeah, this would be a note.
   Very simple, indeed.

Some more crap
--------------

If you would like to highlight a code snippet, it is as easy as::

   from mycompany.auth import AuthenticationBackend

   class MyClass(object):
       """
       Docstring.
       """
       def __init__(self, *args, **kwargs):
           """
           Some *business* logic.
           """
           pass
       def authenticate(self, username, password):
           """
           External authentication process.
           """
           auth = AuthenticationBackend(username, password)
           return auth.is_authenticated()

Or choose language explicit:

.. code-block:: bash

   cd django-richtemplates
   sudo python setup.py install

Yeah, `restructuredText <http://docutils.sourceforge.net/rst.html>`_ is great!
And easy, too.

External-internal hyperlinks
----------------------------

You may also use ``sphinx`` features, like linking to other *documents*, like
this: go to :ref:`configuration`.

.. _django-richtemplates: http://bitbucket.org/lukaszb/django-richtemplates/
</pre>
<p>This is standard restructured text document. The only sphinx specific parts are first line (need to add relation with file itself &#8211; this is needed for table of contents generation) and reference to other file (which is done with <i>ref:`configuration`</i>). Yup, we haven&#8217;t created <i>configuration.rst</i> file, yet. So do this now, and paste following:</p>
<pre class="brush:plain">
.. _configuration:

=========================
Configuring richtemplates
=========================

I hope you have already read chapter :ref:`installation`.

Lorem ipsum!
------------

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
</pre>
<h2>Don&#8217;t forget about the main page!</h2>
<p>I once hoped that the first page (namely <i>index.rst</i>) is generated automatically, yet, I was wrong. But in order<br />
to supply needed data for sphinx generator you have to make very simple changes to the <i>index.rst</i>. Just add<br />
<i>:glob:</i> option to the <i>toctree</i> directive. Finally, mark that all (<i>*</i>) restructuredText documents should<br />
be used.</p>
<pre class="brush:plain">
.. django-richtemplates documentation master file, created by
   sphinx-quickstart on Sat Feb 20 21:42:53 2010.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to django-richtemplates's documentation!
================================================

Contents:

.. toctree::
   :maxdepth: 2
   :glob:

   *

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
</pre>
<p>Now in <i>mydocs</i> directory run</p>
<pre class="brush:bash">
make html
</pre>
<p>and open file located at <i>mydocs/_build/html/index.html</i>. You should see your documentation!</p>
<h2>Final words</h2>
<p>Ok, this was very simple and the effect is &#8211; for such a little work done &#8211; quite amazing if you&#8217;d ask me.<br />
However, we still haven&#8217;t used <i>autodoc</i> Sphinx&#8217;s extension. Let&#8217;s do that now &#8211; create new file<br />
<i>api.rst</i> and paste whats below:</p>
<pre class="brush:plain">
.. _api:

===
API
===

You can find some basic API information here.

Forms API
---------

In this section we cover some basics about the `django-richtemplates`'s forms
API.

.. automodule:: richtemplates.forms
   :members:

.. _django-richtemplates: http://bitbucket.org/lukaszb/django-richtemplates/
</pre>
<p>Again, run make command and see your documentation. Ok, so where is your API, you ask? Well, if you look at the output<br />
of <i>make html</i> command you&#8217;d see that there was a warning &#8211; <i>richtemplates.forms</i> couldn&#8217;t be found.<br />
Which is completely correct, as Sphinx doesn&#8217;t try to guess where your modules are, you have to configure it by yourself.<br />
Change <i>sys.path</i> by uncommenting existing line and change it to this:</p>
<pre class="brush:python">
sys.path.append(os.path.abspath('..'))
</pre>
<p>If you are not sure why why put <i>..</i> there, it&#8217;s simple &#8211; Sphinx would go a one directory up (<i>..</i>) and try to find <i>richtemplates</i> there. Try to build your documentation now. Warning again? Yeah, Sphinx now complains about not<br />
having <i>DJANGO_SETTINGS_MODULE</i> which is, again, totally correct. As importing <i>richtemplates</i> won&#8217;t<br />
raise exception, but trying to get deeper into the module (<i>richtemplates.forms</i>) would be impossible without<br />
being within Django context (same would happen if you try to run python interpreter and run <i>from django import forms</i>).<br />
So add this line into your <i>conf.py</i> file:</p>
<pre class="brush:python">
os.environ['DJANGO_SETTINGS_MODULE'] = 'django.conf.global_settings'
</pre>
<p>More information about <i>autodoc</i> extension could be found <a href="http://sphinx.pocoo.org/ext/autodoc.html">here</a>.</p>
<p>Hope this would help anyone trying to start with his/her own documentation :)<br />
If you have any suggestions &#8211; let me know.</p>
<p>Take care and make documentation, not war.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2010/02/21/documenting-project-using-sphinx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>pylons translating custom error messages.</title>
		<link>http://www.python-blog.com/2010/02/08/pylons-translating-custom-error-messages/</link>
		<comments>http://www.python-blog.com/2010/02/08/pylons-translating-custom-error-messages/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:02:53 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[lazy translations]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[Pylons]]></category>
		<category><![CDATA[pylons translation issues]]></category>
		<category><![CDATA[python blog]]></category>
		<category><![CDATA[translation problems]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=148</guid>
		<description><![CDATA[I&#8217;d created another simple application in pylons, final step was to translate it from English to Polish.
I used the babel extractor recommended by pylons and that went really smooth.
My application have a language selector available anytime from menu.
I saw that even this switch worked very well for mako templates and string inside controllers,
 it did [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d created another simple application in pylons, final step was to translate it from English to Polish.</p>
<p>I used the babel extractor recommended by pylons and that went really smooth.</p>
<p>My application have a language selector available anytime from menu.<br />
I saw that even this switch worked very well for mako templates and string inside controllers,<br />
 it did not work when displaying my custom messages that i over rid in validators<br />
and also did not work in my own custom validators that inherit from FancyValidator.<br />
So i started to investigate this.</p>
<p>The first problem of not translating custom error messages in the regular formencode validators was easily being fixed by using lazy_ugettex method.</p>
<pre class="brush:python">
def _(s):
    #fix for translation error messages
    return lazy_ugettext(s)
</pre>
<p>This method allowed me to use lazy_ugettext to translate.<br />
So now when in the validators your translating a string using _(&#8216;this string is for translate&#8217;) method it&#8217;s actually wrapper for lazy_ugettext function.<br />
Lazy translation is when you translate a string when it is accessed, not when the _() or other functions are called.</p>
<p>The second problem of translating custom error messages in your own validator was a bigger problem</p>
<p>I was looking for a solution for some time, and found a nice trick. You have to use your own<br />
state_obj with static _() function. As example below for custom validation function.</p>
<pre class="brush:python">
class ValidLoginNames(formencode.validators.FancyValidator):

    messages = {'invalid_name':_('you cannot use %(username)s as login')}

    def validate_python(self, value, state):
        banned_names = ['admin', 'administrator', 'root']
        if value in banned_names:
            raise formencode.Invalid(self.message('invalid_name', state = State_obj, username = value), value, state)

#this is needed to translate the messages using _()
class State_obj(object):
    _ = staticmethod(_)
</pre>
<p>Those two trick now let&#8217;s you translate custom validators without a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2010/02/08/pylons-translating-custom-error-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>alternate &#8220;preaty&#8221; print method.</title>
		<link>http://www.python-blog.com/2010/01/01/alternate-preaty-print-method/</link>
		<comments>http://www.python-blog.com/2010/01/01/alternate-preaty-print-method/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 20:47:29 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[alternate print]]></category>
		<category><![CDATA[debug printing for collections]]></category>
		<category><![CDATA[pprint]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=220</guid>
		<description><![CDATA[I always loved how the print_r() function worked in php. In python print does print everything but when large collections (ie huge dicts) are printed using print  you could get lost in the output. I just discovered a little smarter print function called pprint from module pprint

from pprint import pprint

This is great for debugging [...]]]></description>
			<content:encoded><![CDATA[<p>I always loved how the print_r() function worked in php. In python print does print everything but when large collections (ie huge dicts) are printed using print  you could get lost in the output. I just discovered a little smarter print function called pprint from module pprint</p>
<pre class="brush:python">
from pprint import pprint
</pre>
<p>This is great for debugging something in collections. Pprint prints in a nicer human readable form types of data like : list,dict,tuples.</p>
<pre class="brush:python">
l = [x for x in range(100)]
l.insert(0, l[:])
pprint(l)
l = dict([(x, x) for x in range(100)])

pprint(l)
#this will print this list in more convinient way
{0: 0,
 1: 1,
 2: 2,
 3: 3,
 4: 4,
 5: 5,
 6: 6,
 7: 7,
 8: 8,
 9: 9,
 ...
 98: 98,
 99: 99}
</pre>
<p>There are two interesting arguments in pprint function the:<br />
        width<br />
            Attempted maximum number of columns in the output.<br />
       width=100 will wrap everything that outputs longer than 100 chars.<br />
and<br />
        depth<br />
            The maximum depth to print out nested structures.<br />
ie:</p>
<pre class="brush:python">
pprint.pprint(stuff, depth=3)
['aaaaaaaaaa',
 ('spam', ('eggs', (...))),
 ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'],
 ['cccccccccccccccccccc', 'dddddddddddddddddddd']]
#now as you can see the tuples at index 1 have a depth of more than 3 and #they are being reduced by the pprint. Imagine how this helps with debuggin a
#really complicated structures.
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2010/01/01/alternate-preaty-print-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pydev 1.5.1 &#8211; still getting better.</title>
		<link>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/</link>
		<comments>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 23:02:41 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[1.5.1]]></category>
		<category><![CDATA[decorators]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[eclipse plugin]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[PyDev]]></category>
		<category><![CDATA[pydev 1.5]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=214</guid>
		<description><![CDATA[Few days ago there was again a major update on pydev eclipse plugin.
The version 1.5.1. Comes with new refactoring engine PEPTIC, it&#8217;s way better than any one before.
Complete list below: visit http://pydev.org for download.

Release 1.5.1

Improvements in the AST rewriter
Improvements on the refactoring engine:

No longer using BRM
Merged with the latest PEPTIC
Inline local available
Extract method bug-fixes
Extract local [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago there was again a major update on pydev eclipse plugin.<br />
The version 1.5.1. Comes with new refactoring engine PEPTIC, it&#8217;s way better than any one before.<br />
Complete list below: visit <a href="http://pydev.org" target="_blank">http://pydev.org</a> for download.</p>
<div id="release-1-5-1">
<h1>Release 1.5.1</h1>
<ul>
<li>Improvements in the AST rewriter</li>
<li>Improvements on the refactoring engine:
<ul>
<li>No longer using BRM</li>
<li>Merged with the latest PEPTIC</li>
<li>Inline local available</li>
<li>Extract method bug-fixes</li>
<li>Extract local on multi-line</li>
<li>Generating properties using coding style defined in preferences</li>
<li>Add after current method option added to extract method</li>
<li>A bunch of other corner-case situations were fixed</li>
</ul>
</li>
<li>Bug-fixes:
<ul>
<li>Minor editor improvements</li>
<li>Adding default forced builtins on all platforms (e.g.: time, math, etc) which wouldn&#8217;t be on sys.builtin_module_names on some python installations</li>
<li>Adding &#8216;numpy&#8217; and &#8216;Image&#8217; to the forced builtins always</li>
<li>Ctrl+1: Generate docstring minor fixes</li>
<li>Ctrl+1: Assign to local now follows coding style preferences properly</li>
<li>Exponential with uppercase E working on code-formatting</li>
<li>When a set/get method is found in code-completion for a java class an NPE is no longer thrown</li>
<li>Backspace properly treated in block mode</li>
<li>Setting IRONPYTHONPATH when dealing with Iron Python (projects could not be referenced)</li>
<li>No longer giving spurious &#8217;statement has no effect&#8217; inside of lambda and decorators</li>
<li>Fixed new exec in python 3k</li>
<li>Fixed NPE when breakpoint is related to a resource in a removed project</li>
<li>Fixed import problem on regexp that could lead to a recursion.</li>
<li>No longer giving NPE when debugging with the register view open</li>
<li>List access be treated as __getitem__() in the list &#8212; patch from Tassilo Barth</li>
<li>Fix for invalid auto-self added when typing</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mercurial on nginx with authentication and SSL</title>
		<link>http://www.python-blog.com/2009/11/15/mercurial-on-nginx-with-authentication-and-ssl/</link>
		<comments>http://www.python-blog.com/2009/11/15/mercurial-on-nginx-with-authentication-and-ssl/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 19:59:08 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[certificate generation]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[mercurial ssl]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[push pull]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python blog]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=205</guid>
		<description><![CDATA[Today is a great day ;) i switched my repos from svn to mercurial.
I was still thinking about GIT but there where three key points that made me choose mercurial

 hg serve ( out of the box http server)
 it&#8217;s written in python
 has a very good eclipse plug-in (http://www.vectrace.com/mercurialeclipse/)

Cons: it&#8217;s slower than GIT ( [...]]]></description>
			<content:encoded><![CDATA[<p>Today is a great day ;) i switched my repos from svn to mercurial.<br />
I was still thinking about GIT but there where three key points that made me choose mercurial</p>
<ul>
<li> hg serve ( out of the box http server)</li>
<li> it&#8217;s written in python</li>
<li> has a very good eclipse plug-in (<a href="http://www.vectrace.com/mercurialeclipse/">http://www.vectrace.com/mercurialeclipse/</a>)</li>
</ul>
<p>Cons: it&#8217;s slower than GIT ( but who cares :D )</p>
<p>So after installing mercurial and moving my svn repos with history with <a title="HGSVN home page" href="http://pypi.python.org/pypi/hgsvn" target="_blank">hgsvn</a> ( which can also do push to svn )<br />
I started to setup easy access to the repository using nginx. I&#8217;ll show you how to setup an SSL http based repository to do PUSH/PULL/CLONE what ever.</p>
<p>Firstly we have to make self signed ssl certificates.<br />
I found on of the easiest tutorials available you can find it here: <a href="http://www.akadia.com/services/ssh_test_certificate.html" target="_blank">http://www.akadia.com/services/ssh_test_certificate.html</a></p>
<p>OK when we have the ssl certificates for our server. Put it somewhere on the server so nginx can access it.<br />
We have to setup a new virtual host for nginx that will only do ssl connections<br />
and have basic auth additionally.</p>
<p>Here&#8217;s the example config:</p>
<pre class="brush:plain">server {
    listen          443;
    server_name     hg.yourserver.com;
    ssl    on;
    ssl_certificate    /home/ssl_certs/hg_cert.crt;
    ssl_certificate_key     /home/ssl_certs/hg_cert.key;
    access_log      /var/log/nginx/hg.log;
    auth_basic      "mercurial server";
    auth_basic_user_file    /etc/nginx/.htpasswd;

    location / {
        proxy_pass      http://127.0.0.1:8001;
        #here's where the hg server runs
        include         /etc/nginx/proxy.conf;
    }
}</pre>
<p>Few thing to notice.<br />
.htpasswd file has to be in a format &lt;username&gt;:&lt;cryptPassword&gt; if you don&#8217;t have apache<br />
installed you can use <a href="http://www.python-blog.com/2009/06/23/python-random-password-generator/" target="_blank">my password generator</a> for generating crypt password. This username<br />
and password will be used to do pull/push from console and eclipse.<br />
Another important thing is that when you run hg serve you must specify the -a 127.0.0.1 option which is<br />
for the address the mercurial server runs. Hg serve default is to start at all interfaces<br />
so you have this port open outside and your ssl/passwd protection is for nothing&#8230;</p>
<p>I run my using hg serve &#8211;webdir-conf=/etc/hg/hgweb.conf -d -p 8001 -a 127.0.0.1</p>
<p>The hgweb.conf should be with</p>
<pre class="brush:plain">push_ssl = false
#since nginx is doing the SSL
allow_push = * #NGINX  is doing the auth
style = gitweb</pre>
<p>O and one more thing remember that your repo should be accessible to hg serv.<br />
I made a mistake and run hg serve as www-data and my repo was to my home user,<br />
and i had internal server error when trying to do push to server.</p>
<p>So now you can have your repo via http with SSL and nginx authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/11/15/mercurial-on-nginx-with-authentication-and-ssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python logging &#8211; simpler than ever</title>
		<link>http://www.python-blog.com/2009/11/09/python-logging-simpler-than-ever/</link>
		<comments>http://www.python-blog.com/2009/11/09/python-logging-simpler-than-ever/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:07:04 +0000</pubDate>
		<dc:creator>Łukasz Balcerzak</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[python blog]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=202</guid>
		<description><![CDATA[During the weekend I&#8217;ve created Djalog project hosted at the http://code.google.com/p/djalog/. It is simplest possible logging app aimed to work within Django context (or for prototyping as it is also logging-ready out of the box after import in any scripts). 
I&#8217;ve also put it on the PyPi (http://pypi.python.org/pypi/Djalog) so in order to install it you [...]]]></description>
			<content:encoded><![CDATA[<p>During the weekend I&#8217;ve created Djalog project hosted at the http://code.google.com/p/djalog/. It is simplest possible logging app aimed to work within Django context (or for prototyping as it is also logging-ready out of the box after import in any scripts). </p>
<p>I&#8217;ve also put it on the PyPi (http://pypi.python.org/pypi/Djalog) so in order to install it you would execute:</p>
<pre class="brush:python">
easy_install Djalog
</pre>
<p>and you are ready. If you want to quickly check how it works just type:</p>
<pre class="brush:python">
import djalog
import logging

logging.debug("Log some debug information.")
logging.info("Log some information.")
logging.warn("Log some warning.")
logging.error("Log some error.")
logging.critical("Log some critical information.")

from djalog import configure
configure(LOG_USE_COLORS=True, LOG_SQL=True, LOG_LEVEL=5)

logging.debug("Log some debug information.")
logging.info("Log some information.")
logging.warn("Log some warning.")
logging.error("Log some error.")
logging.critical("Log some critical information.")

# Log sql query
logging.sql("SELECT * FROM users WHERE username = 'admin'")
</pre>
<p>This is beta but it should be changed to &#8220;final&#8221; in two weeks. Remember that you may update projects from CheeseShop using &#8220;-U&#8221; option:</p>
<pre class="brush:python">
easy_install -U Djalog
</pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/11/09/python-logging-simpler-than-ever/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQLAlchemy: give me my Session object!</title>
		<link>http://www.python-blog.com/2009/10/21/sqlalchemy-give-me-my-session-object/</link>
		<comments>http://www.python-blog.com/2009/10/21/sqlalchemy-give-me-my-session-object/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 09:34:44 +0000</pubDate>
		<dc:creator>Łukasz Balcerzak</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[python blog]]></category>
		<category><![CDATA[SqlAlchemy]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=197</guid>
		<description><![CDATA[While I love many things about SQLAlchemy this was something I just missed sooooo much &#8211; defining model&#8217;s methods without having to pass session object.
While using Django ORM for such action it is extra easy as there is no session objects at all (well, there is connection object but it&#8217;s much simpler and less sophisticated).
Assume [...]]]></description>
			<content:encoded><![CDATA[<p>While I love many things about SQLAlchemy this was something I just missed sooooo much &#8211; defining model&#8217;s methods without having to pass session object.<br />
While using Django ORM for such action it is extra easy as there is no session objects at all (well, there is connection object but it&#8217;s much simpler and less sophisticated).<br />
Assume you have BlogEntry and BlogComment mappers and you want to define function at entry model which returns related comments &#8211; I know, it is as simple as it could be, but it&#8217;s only an example.</p>
<pre class="brush:python">
class BlogEntry(Base):
    __tablename__ = 'blog_entry'

    title = Column(String)
    content = Column(Text)
    created_at = Column(DateTime, default=datetime.datetime.now)

    def __repr__(self):
        return self.title

class BlogComment(Base):
    __tablename__ = 'blog_comment'

    content = Column(Text)
    created_at = Column(DateTime, default=datetime.datetime.now)
    entry_id = Column(Integer, ForeignKey('blog_entry.id'))
    entry = relation('BlogEntry',
        primaryjoin='BlogEntry.id==BlogComment.entry_id',
        backref='comment_set')
</pre>
<p>You now can of course get comments using comment_set attribute on blog entry. But sometimes we want start querying for other objects, for some reasons.<br />
With Django ORM, no problem, just define method on the model and start querying &#8211; it just works. With SQLAlchemy on the other hand we need to create query<br />
using Session object. But how does mapper use proper session if you call &#8216;comment_set&#8217;? Well, I&#8217;ve found the answer here: http://www.sqlalchemy.org/docs/05/reference/orm/sessions.html . There is &#8216;Session.object_session&#8217; class method which returns session object binded to an model object.</p>
<p>So now we can simply define method for BlogComment:</p>
<pre class="brush:python">
    def get_related_comments(self):
        session = Session.object_session(self)
        comment_list = session.query(BlogComment)\
            .filter(BlogComment.entry_id==BlogEntry.id)\
            .all()
        return comment_list
</pre>
<p>Just remember that object which is passed to &#8216;Session.object_session&#8217; method has to be binded with some session first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/10/21/sqlalchemy-give-me-my-session-object/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rot47 in python</title>
		<link>http://www.python-blog.com/2009/10/20/rot47-in-python/</link>
		<comments>http://www.python-blog.com/2009/10/20/rot47-in-python/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 20:37:15 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python blog]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=193</guid>
		<description><![CDATA[I needed rot47 in python which is AFAIK not available so i made small function to implement rot47

def rot47(str):
    return ''.join([chr(33+((ord(c)-33+47)\
%(47*2))) if c!=" "else " " for c in str])

There is an rot13 implementation in python just encode a string using &#8216;rot13&#8242; encoding

'string'.encode('rot13')

]]></description>
			<content:encoded><![CDATA[<p>I needed rot47 in python which is AFAIK not available so i made small function to implement rot47</p>
<pre class="brush:python">
def rot47(str):
    return ''.join([chr(33+((ord(c)-33+47)\
%(47*2))) if c!=" "else " " for c in str])
</pre>
<p>There is an rot13 implementation in python just encode a string using &#8216;rot13&#8242; encoding</p>
<pre class="brush:python">
'string'.encode('rot13')
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/10/20/rot47-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lightweight Version Control Browser for Python</title>
		<link>http://www.python-blog.com/2009/10/09/lightweight-version-control-browser-for-python/</link>
		<comments>http://www.python-blog.com/2009/10/09/lightweight-version-control-browser-for-python/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 21:46:47 +0000</pubDate>
		<dc:creator>Łukasz Balcerzak</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[python blog]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=185</guid>
		<description><![CDATA[Finally, I have released my second python project. It is small toolkit for browsing repositories (only svn is supported now) in simple way.
You can find it here: Version Control Browser.
A while ago I started to create django based, software management tracking project. I wanted to implement something similar to the browser from Trac. Long story, [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, I have released my second python project. It is small toolkit for browsing repositories (only svn is supported now) in simple way.<br />
You can find it here: <a href="http://code.google.com/p/python-vcbrowser">Version Control Browser</a>.</p>
<p>A while ago I started to create django based, software management tracking project. I wanted to implement something similar to the browser from <a href="http://trac.edgewall.org/">Trac</a>. Long story, short &#8211; I&#8217;ve reorganized codes and ended up with needs of Django-independant repositories browsing library. There are some modules available right now but most of them focus on mirroring commit/update/pull/push commands &#8211; not on browsing which is much easier and should be more lightweight in my opinion.</p>
<p>If anyone who reads this would like to help me with the project &#8211; let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/10/09/lightweight-version-control-browser-for-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sql alchemy model generator</title>
		<link>http://www.python-blog.com/2009/09/26/sql-alchemy-model-generator/</link>
		<comments>http://www.python-blog.com/2009/09/26/sql-alchemy-model-generator/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 10:53:28 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Pylons]]></category>
		<category><![CDATA[SqlAlchemy]]></category>
		<category><![CDATA[autoload]]></category>
		<category><![CDATA[django-alchemy]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python blog]]></category>
		<category><![CDATA[sql alchemy]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=134</guid>
		<description><![CDATA[Recently i had to create a lot of models using declarative mode with sqlalchemy 0.5.5 It was very time consuming especially for large databases. I started to think about an automated solution.
Sqlalchemy have this auto load feature which fetches info about tables by itself. I wanted to use this somehow to generate a string which [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i had to create a lot of models using declarative mode with sqlalchemy 0.5.5 It was very time consuming especially for large databases. I started to think about an automated solution.</p>
<p>Sqlalchemy have this auto load feature which fetches info about tables by itself. I wanted to use this somehow to generate a string which can be easily  copy/paste to database model definition script. So i started a little project to write auto  model generator for sql alchemy based on auto load feature in sqlalchemy.</p>
<p>The script  is not perfect but it works and save a huge amount of time just codding the models. In fact is was able to setup a 186 table database model in 15minutes with this script.</p>
<p>Well the script helped me a lot and now on when i have to load some new existing database or changes i use it all the time.</p>
<p>The documentation is inside the script i tried to write it so anybody could use it out of the box.</p>
<p>I tested it on 4 schema 200+ tables database and i worked quite good. This script still have to be polished but current functionality is enough for most users.</p>
<p>My script is going to be also a part of django-alchemy project started by my friend Lukasz Balcerzak. You can visit the project site @ <a href="http://code.google.com/p/django-alchemy/">http://code.google.com/p/django-alchemy/</a></p>
<p>I used it with Pylons application and Django with modded sqlalchemy. but it can be basically used in any app which uses sqlalchemy. I did not test it with mysql though,but it should work, just specify mysql as dialect.</p>
<p><span style="font-size:130%"><strong>You can download this script from <a href="http://www.python-blog.com/wp-content/uploads/2009/09/base_model_generator.py">sqlalchemy model generator</a></strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/09/26/sql-alchemy-model-generator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
