Saturday, September 22, 2007

LaTeX and Arial font

I'm doing a boring university assignment: a console minesweeper and another game, both written in plain C, without even ncurses (as it will be tested on Windows platform, there is no point on using that anyway). But this isn't about the assignment.

We are also required to write a report about the problem, the details of the chosen implementation, user manual, you know, all the non-programming work that is supposed to be related with every "real world program". Except that doing this with a toy program seems overkill...

Anyway, this isn't about if I should make the reports or not. I must. Otherwise, I'll get a 1.0 (Here qualifications go from 1.0 to 7.0).

This is about the university requiring me to use Arial font in such report. And I don't use Word or OpenOffice Writer. I use LaTeX. So, how I tell LaTeX to use Arial when typesetting my document?

Google answers really fast: use the helvet package. Yeah, that's Helvetica, not Arial. But they are similar, according to that web page.

After a bit of researching, I learned that Arial is (almost) a copy of Helvetica, and not the other way around. And that it is everywhere just because it was cheaper when MS looked for a font for Windows 3.1. At the same time, it seems that Apple choose Helvetica anyway, because its users were more sensible to the differences between these fonts.

So, I should put \usepackage{helvet} \renewcommand{\familydefault}{\sfdefault} in the preamble of the report and go back to write it right now, instead of procrastinating reading the web or writing here. Oh, but they are also asking for special headers in the report...

Thursday, September 13, 2007

Django on Jython: Links

Fortunately, I'm far from being the only guy trying to run Django on Jython. Cam, Frank, Marty and Tristan King are working on it too. So, here goes a summary of our progress and goals as far as I know:On related news: H. Eriksson is working on CherryPy + Jython. He already got the classic "hello world" running.

Sunday, September 9, 2007

Django on Jython: syncdb works, going for the admin.



This week I had less time for my Django plus Jython hacking, but I managed to progress a bit:

  • jython manage.py syncdb works for models of the auth, sites and admin apps.

  • The admin index works. So do the object listing pages. Adding and editing fails, tought.

  • The debugging info page works. It's a good thing to have when you get one crash after the other :).




The hardest thing has been getting the test suite running. I haven't made much progress there.

I will make a proper report of code changes as soon as I can. I should fill some Jython bugs too.

Sunday, September 2, 2007

Django on Jython: What I've done until now



Now that Jython has released it's 2.2 version and has some progress on 2.3 features, I decided to try Django on it. As you can see on thte screenshot above, I got the development server running. And there is some progress on getting database syncing to work:

lsoto@colinux:~/src/hellodjango$ createdb hellodjango
CREATE DATABASE
lsoto@colinux:~/src/hellodjango$ CLASSPATH=/usr/share/java/postgresql.jar ~/src/jython/trunk/jython/jython.sh manage.py syncdb
Creating table auth_permission
Creating table auth_user
Creating table auth_message
Creating table auth_group
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username: admin
E-mail address: admin
Error: That e-mail address is invalid.
E-mail address: admin@admin.com
Warning: Problem with getpass. Passwords may be echoed.
Password: 123
Warning: Problem with getpass. Passwords may be echoed.
Password (again): 123
Traceback (innermost last):
File "manage.py", line 11, in ?
[...]
File "/home/lsoto/src/django.svn.trunk/django/db/backends/postgresql_zxjdbc/base.py", line 86, in execute
Error: ERROR: la columna «is_staff» es de tipo boolean pero la expresión es de tipo integer [SQLCode: 0], [SQLState: 42804]

So here are the steps I've done until now:

  1. Get the development (SVN) source of both project. As Django requires python >= 2.3, I didn't tried Jython 2.2. I'm using mercurial to maintain my "branch", so I made a mercurial mirror of django svn repository and another mercurial repository for my changes

  2. Build Jython using ant

  3. Add Django directory to Jython path (copying the registry file to dist/ and editing the python.path line).
  4. Add some modules from Jython's CPythonLib/ to dist/Lib directory: optparse.py, gettext.py, locale.py and getpass.py

  5. Cook a simple script to run jython from the shell

  6. Apply these two patches to jython. The later is not really a fix, but it allowed me to forget that bug for a while.

  7. Modify django source where needed:

    1. Replace __builtins__ with __builtin__ (changeset)

    2. Make a new backend: postgresql_zxjdbc

    3. Avoid using colors on the tty if running on java (changeset).

    4. Don't assume that iterables have an __iter__ attribute (two changesets)

    5. Workaround Jython problem when trying to insert non-string keys on some dicts (changesets here, here and here)

    6. Make a special case for on robustapply for Jython's reflected functions (changeset)

    7. Support non-descriptor methods on django.dispatch.saferef.BoundMethodWeakRef (changeset)

    8. Workaround Jython's isclass() bug (changeset)

    9. Support zxJDBC's autocommit attribute (on other backends it's a method) (changeset)

    10. Avoid filesystem permissions checks if running on jython
    11. (changeset)

All the changes concerning Django are on my mercurial repository, so you can easily get a patched source tree using mercurial:

$ hg clone https://hg.leosoto.com/django.jythonport

Pending short-term goals:

  • syncdb should work

  • The test suite should run