web developer & system programmer

coder . cl

ramblings and thoughts on programming...


unit testing in django

published: 10-05-2011 / updated: 10-05-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

Django is a very flexible Python framework to develop Web Applications. One of its features is the unit testing that it provides. When you start an application, inside a project, it provides an initial file to place unit tests. It is called tests.py. Having only one file to place your tests per application can lead you to have a huge test files. If you follow the Zen of Python, you may know that modularity is mandatory to develop Python applications. You can use some tricks to keep well organized your Django unit tests and you can provide enough parameters to them to build more reliable and robust unit tests.

[ann] pyxser-1.5.2-r2.win32 was released

published: 26-03-2011 / updated: 26-03-2011
posted in: c, development, programming, projects, python, pyxser
by Daniel Molina Wegener

Dear pyxser users, I’m pleased to announce that I have released pyxser-1.5.2r-r2.win32. This is the same release as 1.5.2-r2, but for Win32 platform. It does not add new features or similar stuff, it’s just a compiled binary distribution for Windows machines. You can download this release build for Python 2.7 and Win32 machines on SourceForge. Please follow the following link to download the pyxser-1.5.2-r2.win32 package. It uses the Windows Installer and it’s an executable. You just need to download an official Python 2.7 distribution to use this release.

abstract views in django

published: 18-03-2011 / updated: 18-03-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

As we have seen, decorators in Python are a good approach on functional programming abstraction. On Django you can use decorators to wrap your views, and there are well known decorators which can make your Django applications more stable and reliable. For example you have the @login_required() decorator and the @require_http_methods() decorator, the first one to allow you to create views with previous login required or authenticated user and the second one to restrict the HTTP methods that will be used to access the view.

functional rut validator

published: 11-03-2011 / updated: 11-03-2011
posted in: development, haskell, programming, python, tips
by Daniel Molina Wegener

Functional programming is great, even if you can handle pure functions or not. I have found a well known site with RUT validation routines written in various languages, all of them seem to be very small implementations. I took the Python implementation on this site and I modified it to be a pure functional implementation, just for fun, and to practice a little functional programming.

understanding python decorators

published: 05-03-2011 / updated: 15-06-2012
posted in: development, programming, python, tips
by Daniel Molina Wegener

Python is very nice language. It supports a feature called decorators. Probably its name is not related to the decorator design pattern: “The major one is that the name is not consistent with its use in the GoF book”, as is specified on the PEP318 — the decorator specification on Python — and it is more related to another kind of functional behavior, where it is a function applied to a function and its parameters, similar to Java annotations, so can it wrap your function around another function.

[ann] pyxser-1.5.2r was released

published: 08-01-2011 / updated: 08-01-2011
posted in: development, programming, projects, python, pyxser
by Daniel Molina Wegener

Dear pyxser users, I’m pleased to announce that I’ve released pyxser-1.5.2r. This release adds backport support for Python 2.4 and few algorithm enhancements. As you know this serializer supports cross references and circular references, and have a wide variety of serialization options for your object trasmition and storage tasks. Please feel free to send me your feedback and participate on the pyxser development. You can participate through the SourceForge mailing lists and forums. Also you can report bugs and send me your feedback through the SourceForge web site.

about the zen of python [part 4]

published: 18-12-2010 / updated: 18-12-2010
posted in: development, programming, python, tips
by Daniel Molina Wegener

This is the last post treating The Zen of Python aphorisms. This time most aphorisms are related to general ideas about design and attitude facing the problems to solve in Python. We will find very interesting ideas supporting well done code, instead of quick and dirty or monkey patching code. You prefer that way, rather than supporting ugly code.