Archive for the 'Exoweb' Category

Using Django admin’s search in your own views

Friday, December 8th, 2006

In liu of a real fulltext search engine for Django, you may just want to use the same simple search engine that Django’s admin uses. Unfortunately it’s not readily reusable, so you’ll have to pull it out of the ChangeList.getqueryset in django.contrib.admin.views.main.


  def django_admin_keyword_search(model, keywords):
      """Search according to fields defined in Admin’s search_fields"""
      if not keywords: return []
      fields = model._meta.admin.search_fields

      qs = QuerySet(model)
      for keyword in keywords:
          or_queries = [ Q(**{‘%s__icontains’ % field: keyword}) for field in fields ]
          other_qs = QuerySet(model)
          if qs._select_related:
              other_qs = other_qs.select_related()
          other_qs = other_qs.filter(reduce(operator.or_, or_queries))
          qs = qs & other_qs

      return qs
 

Alternate syntax for Django urlpatterns

Sunday, December 3rd, 2006

Django’s urlpatterns variable has traditionally expected callbacks to be specified as strings, and extra arguments (commonly used with generic views) to be passed as a separate dict, for example:


  info_dict = {
    ‘queryset’: Entry.objects.all(),
    ‘date_field’: ‘pub_date’,
  }

  urlpatterns = patterns(‘django.views.generic.date_based’,
    (r‘^(?P<year>\d{4})/$’,   ‘archive_year’,   info_dict),
  )
 

(more…)

Speaking in code

Tuesday, November 28th, 2006

Once upon a time there was a guy called Donald Knuth. Besides being the author of our discipline’s most prominent work, the Art of Computer Programming, he also invented Literate Programming, of which he says:

I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature. Hence, my title: “Literate Programming.”

Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.

The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means. He or she strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other.

(more…)

Wii – can you dig it?

Monday, November 20th, 2006

Seth Godin in his latest post writes about the Wii again, and he still doesn’t like its name:

It still has a dumb name, though.

Seth’s right that good names have to be both findable on the Internet and evoke the right feelings in people, but I think he’s dead wrong that “Wii” is a bad name:

  1. It is already very findable. Nintendo made sure they got wii.com, and wii.nintendo.com is the first hit for a “wii” search on Google these days.

  2. It is evokative in the right way. It sounds like the kind-of cute sound someone would make while playing a game, thus it could probably be considered onomatopoetic for “fun”. Secondly, it’s got the obvious connotation to “we”, meaning a group of people, friends.

  3. It is differentiating. Seth got the target audience wrong at first: it’s not teenage male players. They’re broadening the market, making games that are fun to play for casual gamers, NOT the hardcore gamers. “Wii” as a name is in stark contrast to the techie and macho “Play Station 3″ and “XBox”, further increasing the feeling that this is a different type of game console for a different type of people. It makes PS3 and XBox sound like complex and boring tech toys, not like something fun you’d like to play with. Strike ‘em where they ain’t, Nintendo :)

The Internet is broken in China

Saturday, November 11th, 2006

For a while now I’ve been aware of this situation, but thinking it would pass I didn’t do anything. Well, it hasn’t, so I thought I’d start sharing what I see.

Beijing Telecom has broken the Internet

At various places, one or more of the DNS servers you get from, e.g., wifi hotspots, will be configured to always resolve any domain name lookup. That means typos like www.doesnotexist11.com will resolve.

What do they resolve to? They resolve to IP addresses for websites of advertisers. It’s most likely a pay-per-referrer business model.

(more…)

EuroPython 2006 post-mortem

Saturday, July 15th, 2006

This was ours (Exoweb’s) first EuroPython, and our first to CERN and Geneva as well.

Geneva and CERN were wonderful. Geneva was charming and beautiful, CERN and its projects were mindblowing. A picture is worth a thousand words, so see the photo album of the Geneva and CERN visit. There’s also flickr photo pool for EuroPython 2006.

Between sampling a meter of beer we managed to go to many interesting talks and meet many like-minded people. It seems companies are often struggling with the same issues, one recurring one is how to organize and manage a distributed software development company practicing agile methodologies. Both the Programmers of Vilnius and Canonical held talks about this.

I also participated in the first day of the PyPI Sprint with Richard and Johannes. The Python Package Index—PyPI, also known as the Cheese Shop—is a very important project with a lot of potential. A comprehensive, well organized, easy-to-use package library is essential for Python’s future. The Cheese Shop and Python Eggs should be what CPAN is to Perl, and Ruby Gems is to Ruby. More on this later.

Richard’s been working hard at it, but he needs more help, so if you’ve got free time, please contact him. PyPI is implemented in a minimal home-grown Python framework using ZPT/ TAL/ TALES. It’s okay, but it would’ve been nicer in Django :)

Norway photos on flickr

Sunday, July 2nd, 2006

I’ve added two new photo sets on flickr:

Exoweb at EuroPython 2006

Saturday, July 1st, 2006

Although it’s relaxing and nice to visit relatives in Norway, I’m starting to look forward to EuroPython 2006 next week in Geneva, Switzerland.

Exoweb is going with three people: Ken Wong, Gzregorz Jakacki, and me.

Are you going as well? Drop us a line. Would be fun to meet up and chat, especially if it’s about Python, Django, Dojo, or Postgres. :)

Where everyone is the same…

Saturday, July 1st, 2006

Sipping a US$ 13 beer I cannot help but feel Norwegian again, even if the beer is a Kilkenny.

There are of course many contrasts between Norway, my home country, and Beijing, where I spent the last 8 years of my life.

Norway is very rich in natural resources—espically in oil, which has seen some growth recently—has a small population, and a “Robin Hood” social democracy.

The entire population is one big affluent middle class; nobody’s rich, nobody’s poor. With overtime pay the cleaning staff of my school made more money than the head of education in my county, even if they were both working about the same number of hours. This is perhaps as close to the communist ideal as you can find in a materialistic world, making Norway the 2nd highest GDP per capita in the world, and the 1st in terms of human development accoring to the UN.

And when the oil prices crash? Well, Norway’s saving its money in a petroleum fund, currently at US$ 245 billion.

This lack of income disparity has one very apparent effect: services become very expensive. Combined with a weak dollar and yen it’s perhaps no wonder Oslo surpassed Tokyo as the most expensive city in the world.  Swedes are taking over a lot of the service jobs as they know the language, the pay is better, and the working hours less than back home; as much as 2 hours less per day for, e.g., nurses.

Here’s a quick a dirty chart of the costs of some items in Norway and Beijing, all converted to US$ for easy comparison:

Item Oslo Beijing Multiple
10 min cab ride US$ 32.00 US$ 1.50 21.3✕
0.5l Kilkenny US$ 12.16 US$ 4.50 2.7✕
stone wall at home US$ 5,000.00 US$ 375.00 13.0✕

Huge taxes on gas and cars combined with high wages explains the big difference in cab fares. Kilkenny is an import in both countries, and only the service is really different, meaning less difference overall; electronics are even closer in price. Installing a stone wall involves a lot of service: some digging, transportation, installation, and cleanup, thus the big price difference; there’s certainly no lack of raw material (stone) in Norway.

So if you want to see what it’s like when the world is completely flat—when globalization has had its way and equalized all wage disparities—head to Norway. Be sure to bring enough plastic money, though.

RFC: debian-lanserver Custom Debian Distribution

Sunday, March 26th, 2006

For many years I’ve been in companies that, sometimes thanks to my stubbornness, were using Debian GNU/Linux as the general office server. As the number of services and the integration requirements (we don’t want 10 disjoint user databases) of these services have grown, this has become quite painful; Debian provides little help with such integration. Here is a list of sample requirements:

  • Firewall with NAT
  • DHCP server connected to DNS server
  • Windows file sharing (Samba)
  • Apple file sharing (Netatalk)
  • Linux file sharing
  • SMTP server with authentication, spam and virus checking
  • IMAP server
  • VPN server
  • Intranet services such as Wiki and Issue tracking
  • Shared accounts across Linux machines
  • Shared calendaring and mail folders a la Exchange (if feasible)

All of these services should be operating from one common user database, pre-configured to work together, and continue to work flawlessly as Debian packages are updated. It should fit the requirements of small and medium-sized enterprises/ businesses (SME/ SMB) as much as possible.

A couple of years ago, I became aware of the e-smith server, aka Mitel SME Server (information also on contribs.org) that does a great job at the above, but it is a derived Red Hat 7.3 distribution, old and relatively useless by now. Looking around I could find one other request for a SME server equivalent for Debian, but Alex Polite had not gotten any replies when I asked him. If anyone know of anyone doing such undertaking, please let me know.

Assuming there is no project underway to make it such a LAN server, I would like to start gathering requirements for such a server, to be implemented as a Custom Debian Distribution (a meta package), allowing anyone with a stock Debian distribution to be able to easily configure all the above services, while still enjoying the ease-of-upgrading and wide base of packages available for Debian. (See an earlier post about not reinventing the wheel for more benefits of this approach.)

If you’ve got requirements, general thoughts, information, or want to participate, please reply.

[ See discussion about this on debian-custom. ]


tracker