Search Results: "tg"

26 May 2007

Chris Lamb: Pro Prolog is pro.

A lot of computer problems (and some puzzles) simply involve backtracking over the solution space and checking constraints, yet these can be fairly clunky to describe in imperative languages. Compounding this, the high cost of method calls in most VM and dynamic languages make any reasonably sane-looking implementation (read: recursive) rather slow. A much better idea is to use a language that makes this really easy, like Prolog: I have a Compiler Design exam in less than a weeks time, and a common question involves being given a number of definitions of compilers in terms of their source and target languages, along with the language the compiler itself is implemented in. The task is simply to work out whether it is possible to translate from a specified language to another. This is just two stanzas in Prolog:
can_translate(Src, Tgt, [L])   :- t_diagram(Src, Tgt, _, L).
can_translate(Src, Tgt, [H T]) :- t_diagram(Src, Via, _, H),
   can_translate(Via, Tgt, T).
Compilers can be then just be defined with
t_diagram(source, target, implemented in, name).
and querying the translation pipeline is done with
?- can_translate(source, target, Result)
(Modifying it so that it works with cycles isn’t very tricky, either.)

24 May 2007

Nico Golde: creating (dynamic) function call graphs

I am currently writing a general purpose shared library for acpi (more on that soon).
I was interested in having a function call graph especially to see if the interface looks somehow clean and to include it in the documentation of the library. Of course I wanted to do it with open source tools. There are several tools for static call graphs but if you want dynamic call graphs you have to use additional features of your compiler to generate a graph based on code during runtime.

The first variant I tried was using egypt a small perl script to generate a dot file. Dot (today included into graphviz? is a tool originally developed at AT&T to generate hierarchical or layered drawings of directed graphs.

So what is needed?
First install software (here on a Debian systen, egypt is not included in Debian):
$ aptitude install graphviz graphicsmagick (+ download egypt from the homepage)

Compile your software using gcc with the option -dr to dump an RTL file of the source.
Most of gcc's work is done in an intermediate representation of your code, called register transfer language (RTL). This pretty much describes the instructions in plain text and is inspired by LISP lists.
Ok, here we go:
$ gcc -dr list.c libacpi.c test.c
This generates three RTL files, for every source file one. Depending on the gcc version the names may vary, here the names are libacpi.c.00.expand list.c.00.expand and test.c.00.expand.

Now use egypt to create a dot file (I don't want one for test.c now):
$ egypt libacpi.c.00.expand list.c.00.expand dot -Gsize=100,100 -Grankdir=LR -Tps -o graph.ps
Egypt will create dot-output and by piping it to dot with -Tps -o graph.ps you get the resulting graph as a ps file. -Grankdir is used to generate a graph which runs from the left to the right, default is up-down which looks a bit strange.

Now convert the ps file into a png:
$ gm convert graph.ps graph.png
The result looks like this (looks cool huh? :-)):



The second variant I tested is a bit different and in my opinion the resulting graph looks a bit better.
The gcc commandline switch -finstrument-functions allows easy creations of call-graphs for C/C++ (script languages used but I haven't tried).
You need to compile every file with the -finstrument-functions switch. Then gcc places a call to the functions __cyg_profile_func_enter upon entering a function and __cyg_profile_func_exit on leaving a function.

Compile your sources with -g and -finstrumental-functions:
$ gcc -g -finstrumental-functions list.c libacpi.c test.c -o test
Now you need to get some source code by Sebastian Krahmer (SuSE):
$ wget http://www.suse.de/~krahmer/instrumental/instrumental.tgz && tar xvfz instrumental.tgz && cd instrumental
Compile a shared object file:
$ cc -fPIC -c instrumental.c && ld -Bshareable instrumental.o -o inst.so
This generates a shared object file you can preload with LD_PRELOAD
$ LD_PRELOAD=./inst.so test
.....

Now you will find a log.inst.dot.<pid> and log.inst.ascii.<pid> in /tmp (path can be modified in instrumental.c).
The first file is a dot file you can now create a ps and a png file with but you need to attach a closing bracket at the end of the file since the package is not
able to intercept exit() or aborts. echo ' ' >> log.inst.dot.<pid>
$ dot -Gsize=15,20 -Grankdir=LR -Tps -o graph.ps log.inst.dot.<pid> && gm convert graph.ps graph.png
The result looks like:


PDF file which scales a bit better

The other file represents the call graph in ascii:
~ [1000 1000 1000] -- main (0x8049ea4)
~ [1000 1000 1000] -- check_acpi_support (0x8048984)
~ [1000 1000 1000] -- get_acpi_version (0x8048782)
~ [1000 1000 1000] -- get_acpi_content (0x80486b4)
~ [1000 1000 1000] -- scan_acpi_value (0x8048837)
~ [1000 1000 1000] -- init_acpi_batt (0x80489d6)
~ [1000 1000 1000] -- dir_list (0x804a447)
~ [1000 1000 1000] -- new_list (0x804a23c)
~ [1000 1000 1000] -- append_node (0x804a309)
~ [1000 1000 1000] -- append_node (0x804a309)
~ [1000 1000 1000] -- read_acpi_battinfo (0x80497d3)
~ [1000 1000 1000] -- get_acpi_content (0x80486b4)
....

So both methods work but the first seems to be more useful if you want a graph for a specific file, not a specific program since you get an RTL file for each source file and you don't need all to create the dot file. The second method however looks better but has the limitation that you actually need to run the program (but that's dynamic and not static) and you can't (correct me if I miss something) create graphs for single files.

Have fun creating graphs for your favorite software and have a look into Sebastian Krahmers paper http://www.suse.de/~krahmer/instrumental/instrumental.pdf and http://www.ibm.com/developerworks/library/l-graphvis/. He also created a graph for openssh http://www.suse.de/~krahmer/ossh4.6.pdf.

21 May 2007

Alexander Schmehl: Playing with the package file

For Meikes thesis, we needed a csv-File from the Debian-Package file, so I wrote a small script to do that. You can get it from my repository (or via websvn). (Not yet perfect, but worked well enough for us; patches welcome.) If you just need the csv to copy the data in a database (like she did), don't try to guess, how long a textfield (e.g. for depends or the long description) should be; we tried and failed several times (Sure... 2000 characters should be enough for a long description.). We finally used the following database (We used PostgreSQL, should work similar on other database systems): CREATE TABLE packages ( package character varying (75) NOT NULL, source character varying (75), priority character varying(10) NOT NULL, section character varying(20) NOT NULL, installedsize integer NOT NULL, maintainer character varying(150) NOT NULL, architecture character varying(4) NOT NULL, version character varying(40) NOT NULL, depends character varying(5000), conflicts character varying(5000), recommends character varying(5000), suggests character varying(5000), enhances character varying(500), predepends character varying(500), provides character varying(500), replaces character varying(500), buildessential character varying(3), essential character varying(3), filename character varying(200) NOT NULL, md5sum character(33) NOT NULL, origin character varying(100), sha1 character(41) NOT NULL, sha256 character(65) NOT NULL, size integer NOT NULL, tag character varying(1000), task character varying(400), description text NOT NULL, longdescription character varying(30000), CONSTRAINT pk PRIMARY KEY (package) );. Now that you've created a table, you need to fill it. Easiest method is to use the COPY statement, as follows: copy packages (package, source, priority, section, installedsize, maintainer, version, depends, conflicts, recommends, suggests, enhances, predepends, replaces, buildessential, essential, filename, md5sum, origin, sha1, sha256, size, tag, task, description, longdescription) FROM '/path/to/your/csv-file' DELIMETER ';' CSV;. You should now have a nice database to play with :) Some examples... Which are the packages with the longest longdescription?
debian_packages=> select package, length(longdescription) as length from packages order by length desc limit 5;
        package           length
------------------------+--------
 texlive-latex-extra       25337
 texlive-fonts-extra        5719
 emacs-goodies-el           4502
 xbase-clients              4403
 postgresql-contrib-7.4     4223
(5 rows)
Or... Which maintainer have the most packages?
debian_packages=> select maintainer, count(*) as anzahl  from packages group by maintainer order by anzahl desc limit 5;
                            maintainer                              anzahl
------------------------------------------------------------------+--------
 Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>            465
 Debian QA Group <packages@qa.debian.org>                              458
 Debian X Strike Force <debian-x@lists.debian.org>                     274
 Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>      261
 Daniel Baumann <daniel@debian.org>                                    255
(5 rows)
Or... Is there a package, whose sha256-sum contains Meikes birthday?
debian_packages=> select package, sha256 from packages where sha256 like '%261081%';
           package                                           sha256
------------------------------+-------------------------------------------------------------------
 libobject-realize-later-perl   5188126108146fc0b1328473125687fb388bd8d87f460e335952dbb1b66aa3d1
(1 row)
And another goodie (We needed to alter the database several times, to make this package fit into it): Which is the package with the longest name?
debian_packages=> select package, length(package) from packages order by length(package) desc limit 1;
                         package                           length
---------------------------------------------------------+--------
 libmaypole-plugin-authentication-usersessioncookie-perl       55
(1 row)
A lot of fun... and a lot of interesting facts to be discovered...

17 May 2007

MJ Ray: Contracts for people to work on Free Software: unearthing a lawyerbomb

Marc Fargas commented about the work-grabbing contract clauses --

"From clause 2 I understand the $ COMPANY has access to later version **used in the $ COMPANY ** ""of such software in use at $ COMPANY ."", not any later version, just those used while being in $ COMPANY as they may be depending on such code."
So, is this (all versions of (such software in use at $ COMPANY )) or ((all versions of such software in use) at $ COMPANY )? Whoo, a lawyerbomb - it's unknowable unless it's reached court.

16 May 2007

MJ Ray: Contracts for people to work on Free Software

This is a reply to Andrew McMillan Contracts for people to work on Open Source Software, posted on my blog because of yet another stupid eyetest. It looks like there might be a loophole: Clause 2 maybe gives $ COMPANY rights to access the source code of later versions, just because $ EMPLOYEE used one version at $ COMPANY . I don't think it's fair for $ COMPANY ownership to be the default instead of joint ownership. I didn't spot anything obviously missing. I'd like to see $ COMPANY changed so that the workers are owners rather than merely employees, but that's probably not on offer ;-) However, that's part of how TTLLP side-steps the question - it's a partnership, not a employer-employee situation where the employer's owners try to own the fruits of the worker-employees' labour in addition to the company's assets.

14 May 2007

Jordi Mallach: Data disaster on pusa

pusa, a server I administer at uni, suffered a massive data accident on Wednesday. When I went to see why it didn't come up from a reboot on Friday, I found out the initrd hadn't been able to mount /. Weird... Luckily, the two new disks were already installed in the host and waiting for me to finish the migration to the RAID1 and the new Linux-VServer setup, but unfortunately I've been way too busy and it was too late for some of our data. A fsck of /dev/hda1 resulted on large portions of the data going to /lost+found. Discovering this made me feel like a great fool after not having dd'd the device before doing this (a dry-run of fsck had not reported anything useful). I found out some of the lost data in random directories, but in general lots were missing, and others made no sense:
/oldpusa/etc: gzip compressed data, was "libpng.txt", from Unix, last modified: Wed Dec 20 00:58:51 2006, max compression
I hoped for my PostgreSQL stuff being intact, so after dd'ing /dev/hda5, I fsck'd the image. The result was an empty filesystem, and a lost+found full of stuff. I can't find a directory with stuff that resembles postgresql data at all. I did find a directory with a PG_VERSION file in it, but the rest of the files in it (around 100) had numeric names and little more. If anyone thinks I might be able to rebuild my /var/lib/postgresql from this, I'll be infinitely grateful. Anyway, I haven't written to the corrupted after I fucked up the root partition. I'm very interested in knowing what could cause corruption on all partitions, making them unmountable, but still recognisable by fsck, even if the result is not good at all. Maybe a corrupted partition table? If so, what does the Dear Lazyweb recommend me to try out? I suspect the first portion of all partitions were damaged, but maybe just that. Some partition table shift , which makes the filesystems lose the first superblock (trying other superblocks didn't work either)? Suggestions is very welcome by comment or email, and detail on what tools and how to use to try out things, better. My backup of PostgreSQL is not so recent, and recovering some SmartList data would also be great. As for the mandatory where are your backups , the answer is basically we had no resources to store them until very recently, and when we finally got the disks I've had no time until now to set it up entirely, so some bits (db, lists, web) were still not running off the new drives. The luckiest people have been the MUD owners, who have had no data loss at all, as they were living entirely on /dev/md0. Losing MUD data probably means getting angry calls at 4AM or so. :)

12 May 2007

Enrico Zini: tg-i18n-quirks

Turbogears i18n quirks Collecting strings from .kid files tg-admin i18n collect won't collect strings from your .kid files: you need the toolbox web interface for that. Indentation problems in .kid files The toolbox web interface chokes on intentation errors on your .kid files. To see the name of the .kid file that causes the error, look at the tg-admin toolbox output in the terminal for lines like Working on app/Foo/templates/bar.kid. What happens is that the .kid files are converted to python files, and if there are indentation glitches they end up in the python files, and python will complain. Once you see from the tg-admin toolbox standard error what is the .kid file with the problem, edit it and try to make sure that all closing tags are at the exact indentation level as their coresponding opening tags. Even a single space would matter. Bad i18n bug in TurboKid versions earlier than 1.0.1 faide on #turbogears also says:
It is of outmost importance that you use TurboKid 1.0.1 because it is the first version that corrects a BIG bug regarding i18n filters ... The version below had a bug where the filters kept being added at each page load in such a way that after a few hundreds of pages you could have page loading times as long as 5 minutes!
If one has a previous version of TurboKid, one (and only one) of these is needed: So, in short, all i18n users should upgrade to TurboGears 1.0.2.2 or patch TurboKid using http://trac.turbogears.org/ticket/1301.

Enrico Zini: tg-more-singleselectfield-quirks

Turbogears quirks when testing controllers that use SingleSelectField Suppose you have a User that can be a member of a Company. In SQLObject you model it somehow like this:
    class Company(SQLObject):
        name = UnicodeCol(length=16, alternateID=True, alternateMethodName="by_name")
        display_name = UnicodeCol(length=255)
    class User(InheritableSQLObject):
        company = ForeignKey("Company", notNull=False, cascade='null')
Then you want to make a form that allows to choose what is the company of a user:
def companies():
    return [ [ -1, 'None' ] ] + [ [c.id, c.display_name] for c in Company.select() ]
class NewUserFields(WidgetsList):
    """Fields for editing general settings"""
    user_name = TextField(label="User name")
    companyID = SingleSelectField(label="Company", options=companies)
Ok. Now you want to run tests:
  1. nosetests imports the controller to see if there's any initialisation code.
  2. The NewUserFields class is created.
  3. The SingleSelectField is created.
  4. The SingleSelectField constructor tries to guess the validator and peeks at the first option.
  5. This calls companies.
  6. companies accesses the database.
  7. The testing database has not yet been created because nosetests imported the module before giving the test code a chance to setup the test database.
  8. Bang.
The solution is to add an explicit validator to disable this guessing code that is a source of so many troubles:
class NewUserFields(WidgetsList):
    """Fields for editing general settings"""
    user_name = TextField(label="User name")
    companyID = SingleSelectField(label="Company", options=companies, validator=v.Int(not_empty=True))

Russell Coker: career risks

Paul Graham makes some interesting observations about taking risks to achieve career benefits. One thing he doesn’t mention is that the risks have to match your life situation. If you are 21, living with your parents, and single (typical for a CS graduate) then you should take the riskiest options in terms of your career (apart from working in Iraq of course). If you don’t have much money then you don’t have much to lose. If you live with your parents then you still have accommodation and food even if you have no money. If you have no dependents (SO or children) then there’s nothing compelling you to earn a certain income. When you get older you may get a mortgage, a SO, and/or children. Also you won’t live with your parents forever. Most career risks that you might want to take aren’t possible if you leave them too late. Finally if you do something risky such as starting your own company and it doesn’t work out then it’s still going to look good on your CV. If you already have a lot of experience in the industry then the CV improvement may not be worth the time and effort invested in an unsuccessful company. When I was 22 I (along with two business partners) started an Internet cafe. It went reasonably well (by the standards of small businesses), it lasted for a few years before cheap net access at home killed most of the business. At the time the cafe had to close the ISP side of the business was doing reasonably well and one of my partners bought the operating ISP business. This buy-out caused me to approximately break even out of the entire business which is a lot better than most small businesses do. When I was 26 I moved to London (I have dual nationality, UK and Australian). The experience I had gained from running my own business allowed me to immediately get contract work for large ISPs in Europe. Most of the risks in my career were ones that I took while living with my parents. At the time I didn’t think through the issues of mortgages etc, my thinking was mostly along the lines of “it could work, I’m bored, so why not?”. ;) Update: While in the process of writing this blog post I forwarded the URL of a dating service for scientists (sciconnect.com) to some friends. The main page has pictures of single people wearing lab coats and using laptops which I found amusing. I have no idea whether it’s a good service or not, but the pictures on the main page made it worth a look. It seems that I accidentally pasted the wrong URL into my blog post so people who were looking for the Paul Graham article ended up at the dating service instead. But I guess if you are the type of person who reads my blog and who is interested in a link to Paul Graham’s blog and you happen to be single then a dating service for scientists might be of some interest. Thanks to MJ Ray for pointing out my error.

8 May 2007

MJ Ray: Travelling to Debconf7

I've booked my travel to Debconf7. Here are some tips for anyone making the trip over land from England: There are cheap megatrains and megabuses from central Edinburgh to/from Manchester (train, weekdays) and Sheffield Meadowhall (bus, everyday) which give useful connections to points further south, avoiding London. Caledonian Sleeper Bargain Berths are now bookable, but Fridays go quickly (and seem to have gone for 15th). Similarly, there seem to be no cheap tickets left on the train up the Welsh border to Manchester for most useful dates. Find your "magic towns" for train tickets: stations where you can break long journeys to save money. They're often stations with more than one fast train operator, so these are usually old railway towns. For example, mine are Crewe and Derby from Somerset. Sometimes you don't even need to get off the train, but if you do change trains, you might be gambling on delays on the way to that town (if using timed tickets and so on), so allow enough time! Debconf's arrivals day (Saturday 16 June) is the European Day of Action Against Airport Expansion so arriving over land is a damn good idea, even without the CO2 reasons. (Debconf's last day is Pride Scotia - is all the silly scheduling deliberate?) Anyway, I think I'll have a bit of time in Manchester and Derby - anyone got tips on where to eat or what to see?

Gerfried Fuchs: Birthdaywhisper

Some small impressions of Sunday that made it the happiest of my life: spent the day with a very special person—good indian food for lunch—Spiderman 3 in the afternoon which I enjoyed quite a bit—meeting up with friends in the Metalab, have a nice chat and quick dinner—moved over to B72 for the concert of Grossstadtgeflüster which was absolutely great—received a "Sudoku for Dummies" book from Berk with whom I did Sudokus at lunch at work until he let the company—received a pink-fluffy handbag with matching riveted belt and a mini tartan skirt—received a Mermaid mousepad from Alex—received a Grossstadtgeflüster patch from Raphael.
Hope you don't take the list of some presents as belittling the others. It's just that these meant something special to me, not that I didn't enjoy the others. Some friends were still a bit puzzled about the tickets I bought—they tried to give me the money for it. They weren't aware of the try to at least thank them with them for that they were and are there for me in bad times, giving me support and strength when I need it. And I can say that most of them enjoyed it, even though I was distracted quite a bit... And be sure, this is what you get when you let me do some birthday arrangements on my own. ;)

7 May 2007

Enrico Zini: tg-override-sqlobject

Quirks when overriding SQLObject setters Let's suppose you have a User that is, optionally, a member of a Company. In SQLObject you model it somehow like this:
    class Company(SQLObject):
        name = UnicodeCol(length=16, alternateID=True, alternateMethodName="by_name")
        display_name = UnicodeCol(length=255)
    class User(InheritableSQLObject):
        company = ForeignKey("Company", notNull=False, cascade='null')
Then you want to implement a user settings interface that uses a Select box to choose the company of the user. For the Select widget to properly handle the validator for your data, you need to put a number in the first option. As my first option, I want to have the "None" entry, so I decided to use -1 to mean "None". Now, to make it all blend nicely, I overrode the company setter to accept -1 and silently convert it to a None:
    class User(InheritableSQLObject):
        company = ForeignKey("Company", notNull=False, cascade='null')
        def _set_company(self, id):
            "Set the company id, using None if -1 is given"
            if id == -1: id = None
            self._SO_set_company(id)
In the controller, after parsing and validating all the various keyword arguments, I do something like this:
            user.set(**kw)
Now, the overridden method didn't get called. After some investigation, and with the help of NandoFlorestan on IRC, we figured out the following things:
  1. That method needs to be rewritten as _set_companyID:
            def _set_companyID(self, id):
                "Set the company id, using None if -1 is given"
                if id == -1: id = None
                self._SO_set_companyID(id)
    
  2. Methods overridden in that way are alsop called by user.set(**kw), but not by the User(**kw) constructor, so using, for example, a similar override to transparently encrypt passwords would give you plaintext passwords for new users and encrypted passwords after they changed it.

3 May 2007

Gerfried Fuchs: Chumbawamba

Kind reminder right at the start: the Grossstadtgeflüster concert on my birthday is going to happen coming sunday—if you want to celebrate with me or just enjoy nice electro pop, get your tickets now. But this entry is meant to be about another band that I love quite well, Chumbawamba. You most propably have heard some of their songs somewhere, Tubthumping was aired quite well. But I guess many people don't know much about their political background, which makes them even more interesting. Like their Enough is Enough (Kick It Over) which they wrote at the time when the austrian government was put together not by the main voted party but by the second and third, where the second is a rather right winged party, to make people start thinking again. Or their Pass It Along which they put online in a rather genious mp3 remix containing some quite interesting quotes and point of views from some of the "important" people in music business.
Hopefully you'll like their songs (including the other non-album tracks they put online for download) and agree with me that they are worth the support.

MJ Ray: Crackers: Evil Mambots and a com_extcalendar exploit

A couple of hours of today went on dealing with the effects of a big spam attack on a managed server. One user had installed the Joomla ExtCal component on their web site, while another reported that email was running slowly. The attacker was exploiting com_extcalendar/admin_events.php to send spam and trying to send 9000 emails meant they hit the maximum permitted sending rate quite quickly. As soon as I spotted it, I shut down outgoing mail, killed the sending process, disabled the exploited site and component, cleaned the spam from the queue and restarted mail. I'm searching the rest of the server for any other com_extcalendar installations and then I should contact the other exploited servers I've seen during this attack. It looks like there's an entire class of evil "Mambots" out there, using exploitable Mambo and Joomla sites to crawl in search of others. I don't think the exploited site's owner will be billed for the clean-up, because I can't find a security advisory for this. Neither the mambo site (whose site search doesn't work for me) nor the joomla site seems clear about security alerts. I didn't find a third-party advisory that was clearly about this (but there were a few maybe-relevant ones). The homepage at Mambo last released in 2005 and doesn't mention this in its release notes, while the homepage listed by Joomla 404s (and I don't enjoy using the Joomla site because, as it says,
"we are aware, and regret, that our website does not comply with many WCAG/508 requirements"
). If you are using com_extcalendar on your site, check whether it's safe, or replace it with a better calendar.

30 April 2007

Enrico Zini: tg-quirk

Turbogears form quirk I had a great idea:
@validate(model_form)
@error_handler()
@expose(template='kid:myproject.templates.new')
def new(self, id, tg_errors=None, **kw):
    """Create new records in model"""
    if tg_errors:
        # Ask until there is still something missing
        return dict(record = defaults, form = model_form)
    else:
        # We have everything: save it
        i = Item(**kw)
        flash("Item was successfully created.")
        raise redirect("../show/%d" % i.id)
It was perfect: one simple method, simple error handling, nice helpful messages all around. Except, check boxes and select fields would not get the default values while all other fields would. After two hours searching and cursing and tracing things into widget code, I found this bit in InputWidget.adjust_value:
# there are some input fields that when nothing is checked/selected
# instead of sending a nice name="" are totally missing from
# input_values, this little workaround let's us manage them nicely
# without interfering with other types of fields, we need this to
# keep track of their empty status otherwise if the form is going to be
# redisplayed for some errors they end up to use their defaults values
# instead of being empty since FE doesn't validate a failing Schema.
# posterity note: this is also why we need if_missing=None in
# validators.Schema, see ticket #696.
So, what is happening here is that since check boxes and option fields don't have a nice behaviour when unselected, turbogears has to work around it. So in order to detect the difference between "I selected 'None'" and "I didn't select anything", it reasons that if the input has been validated, then the user has made some selections, so it defaults to "The user selected 'None'". If the input has not been validated, then we're showing the form for the first time, then a missing value means "Use the default provided". Since I was doing the validation all the time, this meant that Checkboxes and Select fields would never use the default values. Hence, if you use those fields then you necessarily need two different controller methods, one to present the form and one to save it:
@expose(template='kid:myproject.templates.new')
def new(self, id, **kw):
    """Create new records in model"""
    return dict(record = defaults(), form = model_form)
@validate(model_form)
@error_handler(new)
@expose()
def savenew(self, id, **kw):
    """Create new records in model"""
    i = Item(**kw)
    flash("Item was successfully created.")
    raise redirect("../show/%d"%i.id)
If someone else stumbles on the same problem, I hope they'll find this post and they won't have to spend another two awful hours tracking it down again.

27 April 2007

Miriam Ruiz: Building a cross-compiler

When I first started to build my own cross-compiler and my own toolchain, I didn’t think that it was so delicate. It took me almost two weeks to have it working, always fighting quite cryptical errors that could be solved with very unevident switches. Lots of thanks go to Simon Richter and Rob Landley for their help, among many others. I wouldn’t have done it without them. What you need: Steps: Links: You can download my script for building the compiler if you want. Feedback is welcome.

Enrico Zini: tg-file-download

File downloads with TurboGears In TurboGears, I had to implement a file download method, but the file required access controls so it was put in a directory not exported by Apache. In #turbogears I've been pointed at: http://cherrypy.org/wiki/FileDownload and this is everything put together:
from cherrypy.lib.cptools import serveFile
# In cherrypy 3 it should be:
#from cherrypy.lib.static import serve_file
@expose()
def get(self, *args, **kw):
    """Access the file pointed by the given path"""
    pathname = check_auth_and_compute_pathname()
    return serveFile(pathname)
Then I needed to export some CSV:
@expose()
def getcsv(self, *args, **kw):
    """Get the data in CSV format"""
    rows = compute_data_rows()
    headers = compute_headers(rows)
    filename = compute_file_name()
    cherrypy.response.headers['Content-Type'] = "application/x-download"
    cherrypy.response.headers['Content-Disposition'] = 'attachment; filename="'+filename+'"'
    csvdata = StringIO.StringIO()
    writer = csv.writer(csvdata)
    writer.writerow(headers)
    writer.writerows(rows)
    return csvdata.getvalue()
In my case it's not an issue as I can only compute the headers after I computed all the data, but I still have to find out how to serve the CSV file while I'm generating it, instead of storing it all into a big string and returning the big string.

20 April 2007

Gustavo Franco: Lenny and my work on new tasks.

I've started Lenny related work on my tasksel branch, hopefully joeyh will merge some of that, until now the new stuff is:

* Add lamp-server task.
Linux + Apache + Mysql + PHP, Python and Perl (LAMP^3). In other words this th web-server task + mysql-server and phpmyadmin. Keep in mind that our database-server for Etch installs PostgreSQL so you can install lamp-server + database-server and go with a full LAMP stack and both mysql and pgsql.

* Add lightweight-web-server task.
lighttpd with php4 and php5 support, perl and python are side effects due to fastcgi.

* Reintroduce backup-server task.
Bacula and related tools, basically.

* Add ltsp-server task.
This experimental task doesn't install a complete ltsp system yet, you need to run ltsp-build-client manually. Actual work for a fresh install is being done into ltsp-client-builder udeb.

My goal for Lenny is if you select both desktop environment and ltsp server you will end with a system ready to provide GNOME (KDE or Xfce) for thin or fat clients on the LAN. We just need the task ready, polish ltsp-client-builder, and solve some pending stuff in other packages: I think I've sorted out the nfs-kernel-server export issue (thanks Steinar!), we're still missing dhcp and tftp configuration or the possibility to 'preseed' it (wishlist bugs opened) to have all this working out of the box. Once in place you will be able to impress your friends spreading Debian on the LAN using a usb keychain or live cd.

Get ready for some more server related work, but I'll keep up with the desktop stuff also. :-)

19 April 2007

Michal &#268;iha&#345;: Gammu test version 1.10.3

I just released new version of Gammu, you can download it from download server. There is quite a lot of changes: As I can now build full featured Gammu binary for Windows, the download size increased a lot. If you thing it is too big, I can start to produce two sets of binaries.

16 April 2007

Peter Makholm: Java on Linux/PPC

One step nearer removing OS X form my iBook. Now I got java running so I can log on to my net banking account. The following works on my Debian Etch (-ish):
  1. Download IBM’s java-package from http://www-128.ibm.com/developerworks/java/jdk/linux/download.html (registration required) - you need the 32bit iSeries/pSeries version in tgz format
  2. Make sure that the package includes …/jre/bin/libjavaplugin_oji.so (somehow I got a package which didn’t have the file)
  3. install java-package
  4. run make-jpkg <tgz file>. If it complain about “no matching plugin was found” look in /usr/share/doc/java-package/SUPPORTED and rename you tgz file to something supporte of almost the correct version.
  5. Install the resulting package and restart firefox (whatever it is named today)
I downloaded a file called ibm-java2-jre-5.0-4.0-linux-ppc.tgz and renamed it to ibm-java2-jre-50-linux-ppc.tgz and it seems to work.

Next.

Previous.