This version of the page http://maxischenko.in.ua/blog/ (0.0.0.0) stored by archive.org.ua. It represents a snapshot of the page as of 2008-01-04. The original page over time could change.
Max Ischenko’ blog

Using django.newforms with Pylons

November 26th, 2007

Django recently got a nifty newforms library while Pylons still hesitates what is “the best” way to deal with forms.

What if Django’s newforms library were available to Pylons project? It is.

It actually is quite easy to get it up and running. Basically, you just tweak code snippets from the documentation for Pylons. The only caveat is that it depends on 'DJANGO_SETTINGS_MODULE environment variable — not true, see below.

I have built a simple pylonsnewforms-1.0rel1.tar.gz project which demostrates the concept. Here are bulk of the changes I made from stock paster create --template=pylons.

1. A Mako page template

<form action=\"${h.url_for('djform')}\" method=\"post\">
    <table>
      ${c.form.as_table()}
    </table>
    ${h.submit(u'Submit')}
</form>

2. A controller

class DjangotestController(BaseController):
	
    def index(self):
        if request.method == 'POST':
            c.form = ContactForm(request.POST)
            if c.form.is_valid():
                c.submitted_data = c.form.cleaned_data
        else:
            # init form with pre-populated data
            data = {'subject': 'hello',
                   'cc_myself': True}
            c.form = ContactForm(data)
        return render('/djforms.mako')

3. config/environment.py

    from django.conf import settings
    settings.configure()

This does django configuration explicitly, thanks readers for the tip.

That’s it. Simple, eh?

One thing left out is form_for_model django’s function which generates form for you using model metadata. I am sure this is doable for SQLAlchemy models; this is what FormAlchemy and TurboGears’ FastData efforts were trying to achieve.
I am interested in your opinion so pls comment here or in the pylons-dicuss mailing list.


I switch to a Russian-language blog

October 10th, 2007

I realized that I should continue blogging in Russian since most of my potential audience are Russian-speaking. Therefore this blog will be eventually archived and new posts appearing on http://maxischenko.in.ua/ frontpage will be in Russian. Here is new RSS feed.

(Blog design is shamelessly stolen from Russel Beattie blog though I plan to customize it eventually. Sorry for this, Russ).


Accidential business: seizing the opportunity

July 28th, 2007

As my blog states, I earn living by providing software development outsourcing services (in Python). That’s been the case since early 2005 when I quit my regular job in Ukrainian software company. About that time (spring 2005) I launched developers.org.ua site, mainly as a blog and companion site for ua-devtalk google group.

The site went on under radar with a few casual visitors for about a year, until I launched two new services on it: salary survey/database tool and local companies’ discussion forum. The services turned out to be hits and the site started gaining popularity in local audience.

I still didn’t pay much attention to it even though some small advertising money started flowing in. After all, most of my earnings were from software development services and the site was just a hobby project, albeit a nice one.

The problem is, the site started to demand more and more of my attention and in March 2007 I realized I need to do something about it. In April, after some wishful thinking and planning, I came up with figures and projections that could make the site a viable business in and by itself. And went on executing the plan.

Here is what I have a few months later:

This chart represents site’s earning in advertising dollars for last 10 or so months. Note the spike in recent months, when I decided to “go serious” and exploit site’s possibilities to the fullest. Actually, July is the first month ever when site earned me more than my outsourcing business (though the other reason for this is that I barely have time now for any client work). This is simply amazing for me.

I still haven’t decided what I want to do with the site in a 6-12 months but if the trend will continue like this it will be a nice problem to have.

The funny thing is - I never planned anything like this. It was almost an accident. The only thing I did was paying attention to reality and my decision to try to exploit it. Magic happens, sometimes. And I try not to be over-excited as no one can predict what tomorrow will be like.


EuroPython is over

July 16th, 2007

EuroPython 2007 is over and I was glad to be there.

My EuroPython impressions (in Russian) are here: EuroPython 2007 notes (in Russian). If you do not speak Russian pls see automatic Google translation (the quality is very rough though).


EuroPython, day 1

July 10th, 2007

First day of EuroPython 2007 is through.

The best talk I attended was by Simon Willison’s concerning OpenID and the best talk I missed seems to be Optimizing MySQL. Pylons was mentioned quite a few times. Besides my talk, there were a talk about running Zope on Paste, a KSS talk used Pylons to build a sample demo app for the framework, OpenID mentioned Pylons as one of “supporting” tools.

I did ok with my Pylons talk, if you missed it here are the slides: http://maxischenko.in.ua/slides/pylons-casestudy/.

Organization is excellent; there are free drinks and Wi-Fi access everywhere. Vilnius is a very nice city from what I’ve seen (see Tim’s photos on Flickr). And every person I met seem to speak three languages: Lithuanian, English and Russian.