Search Results: "turbo"

13 May 2009

Martin Michlmayr: Update on QNAP TS-119/TS-219 kernel support

I mentioned a few weeks ago that initial kernel support for the QNAP TS-119 and TS-219 Turbo NAS got accepted for 2.6.30 but that there were some issues left. Here's an update: The SATA and flash fixes are already in our 2.6.29 kernel.

31 March 2009

Martin Michlmayr: Kernel support for QNAP TS-119 and TS-219 Turbo NAS in 2.6.30

My patch for initial kernel support for the QNAP TS-119 and TS-219 Turbo NAS got accepted and will be in 2.6.30. I can run Debian on a USB disk without any problems but there are some issues left (some severe, some cosmetic): Unfortunately, I've no idea how to resolve these issues. However, the QNAP TS-119 and TS-219 have started shipping so hopefully someone else will investigate these issues.

19 March 2009

Russell Coker: The Cost of Car Crashes

An article from 1999 suggested that car crashes caused a financial loss in OECD countries equivalent of 2% of their entire economies [1]. An article from the Sydney Morning Herald in 2001 gave a conservative estimate of the cost of a road fatality at $1.5 million [2], it also notes that due to different analysis methods American transport economists derived a figure of $5.5 million. $1.5 million in 2001 adjusted for CPI would be close to $2 million now. Currently that $2M cost is an externality of the car industry. Most of it is paid by the government, IE we all pay for it through our taxes. This means that there is little financial incentive for drivers and car companies to make the roads safer. Many of the attempts to legislate road safety fail due to the legal system being unable to manage the rapidly changing range of vehicles on the market. The insurance companies have very detailed analysis of the relative safety of vehicles, so it seems that the only sensible way of enforcing safe driving is through economic measures implemented via insurance. I believe that for every person who is killed or seriously injured on the road a fine of $2M should be levied. Every driver should be compelled to have insurance to cover such fines (driving without insurance should be illegal). Then the government could cease being involved in regulating what types of car someone can drive. If someone who is less than 25 years old can get insurance for a turbo-charged car then it probably means that a statistical analysis suggests that the combination of driver and vehicle is likely to be reasonably safe (EG there are many turbo-charged cars on the market that are not particularly fast). Now this will increase the car insurance costs for everyone, but it will decrease the amount of general tax money that is spent on issues related to road fatalities, which would allow the income tax rates to be decreased. This means that any tax-payer who has a good driving record and who drives a type of car that tends not to be crashed could expect to save money overall. Any tax-payer who doesn t drive a car would save even more money. But the main point of this idea is to increase road safety by forcing bad cars and drivers off the road. Currently defective cars are only removed from the road if police notice something unsafe about them and cite them for being unroadworthy - this only happens if it s a problem which can be observed from outside the vehicle (EG worn tires or broken lights). In some states elderly drivers have no requirement for periodic health checks to determine their ability to drive, I know of one case of a woman who was certified as legally blind, ordered a white cane, and then drove home afterwards! I m sure that insurance companies would implement whatever tests are necessary to reduce the risk of being hit by multiple $2M fines from a single crash.

12 March 2009

Martin Michlmayr: Debian support for QNAP TS-119 and TS-219 Turbo NAS coming

TS-219 on top of TS-209 I received a sample of QNAP's new TS-219 Turbo NAS today. The TS-119 and TS-219 devices are an upgrade to QNAP's TS-109 and TS-209 devices and were announced earlier this month at CeBIT. The new TS-219 uses the same robust case as the TS-209 but offers much more performance: The numbers I've seen about the Kirkwood CPU suggest that the TS-219 will indeed give a very significant performance boost. So far, the TS-219 looks very nice. My only complaint is that QNAP didn't export the second Ethernet port the Kirkwood chip offers, but I suspect this is because they wanted to stay as close to the original design of the TS-209 as possible. In any case, the TS-219 is a nice machine and I look forward to porting Debian to it. As a first step, this means getting the mainline kernel to run on the device and adding a kernel for Kirkwood to the archive (the latter is needed for a number of other devices based on Kirkwood anyway). Hopefully, the remaining porting work and integration into the Debian installer should be fairly straightforward given that the TS-209 is already supported in Debian. I'm sure I'll find out as I dig into the details... I'll give periodic updates of my progress. In the meantime, I've created an image gallery of the TS-219.

7 January 2009

Aigars Mahinovs: Rails on Python?

Matt, if you want to have something Pythonic that is as comprehensive as Rails is, look at TurboGears. Look at version 2.0 that is currently is in beta. The documentation is incomplete, but it is rather usable already. It is built around Pylons providing a neat pre-configured package of everything you need to develop a good website. And if you don t like parts of it, you can replace parts of it with other things or even write your own parts. Other people prefer Django, but it is too monolithic, non-modular and heavy to me.

13 November 2008

Martin Michlmayr: Debian installer improvements for NAS devices in lenny RC1

There have been a number of improvements to the Debian installer on Network Attached Storage (NAS) devices in the last few months and they are available to users now that RC1 has been released. We have added support for Marvell's Orion platform. Orion is a system on a chip (SoC) that integrates an ARM CPU, Ethernet, SATA, USB, and other functionality in one chip. The majority of NAS devices that have come out within the last two years are based on Orion chips, so it's exciting to have support for this significant platform in Debian. Specifically, we support the following devices based on Orion: QNAP Turbo Station (TS-109, TS-209, TS-409), HP Media Vault mv2120, and Buffalo Kurobox Pro (with more to come later). Here are some other newsworthy improvements and changes: Finally, the armel port is recommended for new installations now. Debian lenny has two different and incompatible ARM ports: the old ABI port (arm) and the new EABI port (armel). Debian lenny is the last release with support for the arm port and future releases will only support the armel port. It's therefore recommended to use armel for new installations of lenny.

7 November 2008

Martin Michlmayr: Please test debian-installer rc1 images on ARM and MIPS

debian-installer rc1 is going to be officially announced next week. However, the netboot images are already available. I'm now looking for people who are interested in testing these installer images on ARM and MIPS based machines. If you have a spare ARM or MIPS machine or want to reinstall your machine for some reason (for example to move from arm to armel), please see my messages on debian-arm and debian-mips for more information. I've used this opportunity to update all my installation instructions to lenny. See here for Debian on Linksys NSLU2, Thecus N2100, QNAP Turbo Station, HP mv2120 and Cobalt.

26 October 2008

Ondřej Čertík: Google Mentor Summit II

On Saturday morning I met Steve McIntyre and Dirk Eddelbuettel, Steve took us by car to Google. Well, it was overwhelming.

For example we met there two other Debian developers, Jeff Bailey and Daniel Burrows. There are developers from all the famous projects, like git, Wine, Turbogears, Jython, ... There are still people I wanted to meet but didn't manage yesterday, need to fix that today. My plan is to get SymPy running on top of Jython, or at least do some more progress to take the advantage, that Philip Jenvey from Jython is here. Also I wanted to fix some RC bugs in Debian when Steve is here, to make some progress on my NM finally. We'll see how it goes.

There was also an excellent presentation from people behind Android. One thing I was curious if it's going to run native C applications, like Python and it seems it will happen eventually, all the sources are out there, so someone just needs to push it forward. Another very cool thing they did that I was always looking for is Gerrit for reviewing patches (see review.source.android.com for example how it looks like) -- basically a fork of Guido's codereview, but it has many nice features, like automatically applying the patch to the git repository as a new topic branch and one can then easily pull it, as well as review it over the web interface. When I get back to Prague I am going to install this for SymPy.

25 October 2008

Adrian von Bidder: Trying new technology

Since it's apparently en vogue to change one's way these days, I'm now learning Python (by looking at TurboGears and related technologies), using Emacs as my main editor (so far I was using mostly Perl and vim.) But while indenting with vim was often correct but occasionally annoying, I've found the much-touted autoindenting with Emacs disappointing. Yes, indent-region is cool, and if I hit tab on a line it indents it correctly, and using C-J instead of hitting enter also gives the right result. But why do I have to do all this? When I hit enter I want to have the new line at the correct indenting. When I start a line with “</” in a HTML file I want emacs to automatically run indent-for-tab-command on the closing “>” of this tag (or better yet immediately autocomplete the tag, since in XML there is only one tag to close, right?) (Oh, and btw: I've not found much about Python to dislike to date. So while my Emacs use might be just an episode, I might stick with Python as default scripting language for future projects for a while now. I thought about switching to git from hg as well in this “trying new things” effort but I think I'll leave this for later, since I've not had hg annoy me much so far.)

21 July 2008

Martin Michlmayr: Daily installer image available for QNAP TS-109, TS-209 and TS-409

Daily installer images are now available for the QNAP TS-109, TS-209 and TS-409. This means that complete installations of Debian testing are possible now. You can consider the daily image as a beta release of RC1 of the debian-installer for Debian lenny. It should only be used by experienced users and only if you can make a serial console in case something goes wrong. As the name suggests, the daily images change on a daily basis and they install Debian testing which also changes on a daily basis (although testing should be fairly stable since we're close to the freeze of testing in preparation for the release of Debian lenny). If you install Debian with these installer images, please send an installation report to debian-boot send an email to me so I can let you know in case there are any important news you should be aware of. There is a web site now with complete installation instructions and other information about Debian on QNAP Turbo Station. If you have any questions or suggestions, please let me know.

30 June 2008

Russell Coker: The History of MS

Jeff Bailey writes about the last 26 years of Microsoft [1]. He gives Microsoft credit for “saving us from the TRS 80″, however CP/M-86 was also an option for the OS on the IBM PC [2]. If MS hadn’t produced MS-DOS for a lower price then CP/M would have been used (in those days CP/M and MS-DOS had the same features and essentially the same design). He notes the use of the Terminate and Stay Resident (TSR) [3] programs. As far as I recall the TSR operation was undocumented and was discovered by disassembling DOS (something that the modern MS EULAs forbid). Intel designed the 8086 and 80286 CPUs to permit code written for an 8086 to run unchanged in “protected mode” on an 80286 (as noted in the Wikipedia page about the 80286 [4]). Basically all that you needed to do to write a DOS program with the potential of being run directly in protected mode (or easily ported) was to allocate memory by requesting it from the OS (not just assuming that every address above your heap was available to write on) and by addressing memory only by the segment register returned from the OS when allocating memory (IE not assuming that incrementing a segment register is equivalent to adding 16 to the offset). There were some programs written in such a manner which could run on both DOS and text-mode OS/2 (both 1.x and 2.x), I believe that such programs were linked differently. The term Fat Binary [5] is often used to refer to an executable which has binary code for multiple CPUs (EG PPC and M68K CPUs on the Macintosh), I believe that a similar concept was used for DOS / OS/2 programs but the main code of the application was shared. Also compilers which produce object code which doesn’t do nasty things could have their object code linked to run in protected mode. Some people produced a set of libraries that allowed linking Borland Turbo Pascal code to run as OS/2 16bit text-mode applications. The fact that OS/2 (the protected-mode preemptively multi-tasking DOS) didn’t succeed in the market was largely due to MS. I never used Windows/386 (a version of Windows 2.x) but used Windows 3.0 a lot. Windows 3.0 ran in three modes, “Real Mode” (8086), “Standard Mode” (80286), and “Enhanced Mode” (80386). Real Mode was used for 8086 and 8088 CPUs, for 80286 systems if you needed to run one DOS program (there was no memory for running more than one), and for creating or adjusting the swap-file size for an 80386 system (if your 80386 system didn’t have enough swap you had to shut everything down, start Real Mode, adjust the swap file, and then start it again in Enhanced Mode). Standard Mode was the best mode for running Windows programs (apart from the badly written ones which only ran on Real Mode), but due to the bad practices implemented by almost everyone who wrote DOS programs MS didn’t even try to run DOS programs in 286 protected mode and thus Standard Mode didn’t support DOS programs. Enhanced Mode allowed multitasking DOS programs but as hardly anyone had an 80386 class system at that time it didn’t get much use. It was just before the release of Windows 3.1 that I decided to never again use Windows unless I was paid to do so. I was at a MS presentation about Windows 3.1 and after the marketing stuff they had a technical Q/A session. The questions were generally about how to work around bugs in MS software (mainly Windows 3.0) and the MS people had a very detailed list of work-arounds. Someone asked “why don’t you just fix those bugs” and we were told “it’s easier to teach you how to work around them than to fix them“. I left the presentation before it finished, went straight home and deleted Windows from my computer. I am not going to use software written by people with such a poor attitude if given a choice. After that I ran the DOS multi-tasker DesqView [6] until OS/2 2.0 was released. Desqview allowed multitasking well written DOS programs in real mode, Quarterdeck was the first company to discover that almost 64K of address space could be used above the 1MB boundary from real-mode on a 80286 (a significant benefit when you were limited to 640K of RAM), as well as multitasking less well behaved DOS programs with more memory use on an 80386 or better CPU. OS/2 [7] 2.x was described as “A Better DOS than DOS, a Better Windows than Windows”. That claim seemed accurate to me. I could run DOS VM86 sessions under OS/2 which could do things that even Desqview couldn’t manage (such as having a non-graphical DOS session with 716K of base memory in one window and a graphical DOS session in another). I could also run combinations of Windows programs that could not run under MS Windows (such as badly written windows programs that needed Real Mode as well as programs that needed the amount of memory that only Standard or Enhanced mode could provide). Back to Bill Gates, I recently read a blog post Eight Years of Wrongness [5] which described how Steve Ballmer has failed MS stockholders by his poor management. It seems that he paid more attention to fighting Linux, implementing Digital Restrictions Management (DRM), and generally trying to avoid compatibility with other software than to actually making money. While this could be seen as a tribute to Bill Gates (Steve Ballmer couldn’t do the job as well), I think that Bill would have made the same mistakes for the same reasons. MS has always had a history of treating it’s customers as the enemy. Jeff suggests that we should learn from MS that the freedom to tinker is important as is access to our data. These are good points but another important point is that we need to develop software that does what users want and acts primarily in the best interests of the users. Overall I think that free software is quite well written in regard to acting on behalf of the users. The issue we have is in determining who the “user” is, whether it’s a developer, sys-admin, or someone who wants to just play games and do some word-processing.

25 June 2008

Russell Coker: Car vs Public Transport to Save Money

I’ve just been considering when it’s best to drive and when it’s best to take public transport to save money. My old car (1999 VW Passat) uses 12.8L/100km which at $1.65 per liter means 21.1 cents per km on fuel. A new set of tires costs $900 and assuming that they last 20,000km will cost 4.5 cents per km. A routine service every 10,000Km will cost about $300 so that’s another 3 cents per km. While it’s difficult to estimate the cost per kilometer of replacing parts that wear out, it seems reasonable to assume that over 100,000Km of driving at least $20,000 will be spent on parts and the labor required to install them, this adds another 20 cents per km. The total then would be 48.6 cents per km. The tax deduction for my car is 70 cents per km of business use, so if my estimates are correct then the tax deductions exceed the marginal costs of running a vehicle (the costs of registration, insurance, and asset depreciation however make the car significantly more expensive than that - see my previous post about the costs of owning a small car for more details [1]). So for business use the marginal cost after tax deductions are counted is probably about 14 cents per km. Now a 2 hour ride on Melbourne’s public transport costs $2.76 (if you buy a 10 trip ticket). For business use that’s probably the equivalent cost to 20Km of driving. The route I take when driving to the city center is about 8Km, that gets me to the nearest edge of the CBD (Central Business District) and doesn’t count the amount of driving needed to find a place to park. This means the absolute minimum distance I would drive when going to the CBD would be 16Km. The distance I would drive on a return trip to the furthest part of the CBD would be almost exactly 20km. So on a short visit to the central city area I might save money by using my car if it’s a business trip and I tax-deduct the distance driven. A daily ticket for the public transport is equivalent to two 2 hour tickets (if you have a 10 trip ticket then if you use it outside the two hour period it becomes a daily ticket and uses a second credit). If I could park my car for an out of pocket expense of less than $2.76 (while I can tax-deduct private parking it’s so horribly expensive that it would cost at least $5 after deductions are counted) then I could possibly save money by driving. There were some 4 hour public parking spots that cost $2. So it seems that for a basic trip to the CBD it’s more expensive to use a car than to take a tram when car expenses are tax deductible. For personal use a 5.7km journey would cost as much as a 2 hour ticket for public transport and a 11.4km journey would cost as much as a daily ticket. The fact that public transport is the economical way to travel for such short distances is quite surprising. In the past I had thought of using a tram ticket as an immediate cost while considering a short car drive as costing almost nothing (probably because the expense comes days later for petrol and years later for servicing the car). Also while there is a lot of media attention recently about petrol prices, it seems that for me at least petrol is still less than half the marginal cost of running a car. Cars are being advertised on the basis of how little fuel they use to save money, but cars that require less service might actually save more money. There are many cars that use less fuel than a VW Passat, and also many cars that are less expensive to repair. It seems that perhaps the imported turbo-Diesel cars which are becoming popular due to their fuel use may actually be more expensive than locally manufactured small cars which have cheap parts. Update: Changed “Km” to “km” as suggested by Lars Wirzenius.

17 June 2008

Enrico Zini: Passing values to turbogears widgets at display time (the general case)

Passing values to turbogears widgets at display time (the general case) Last time I dug this up I was not clear enough in documenting my findings, so I had to find them again. Here is the second attempt. In Turbogears, in order to pass parameters to arbitrary widgets in a compound widget, the syntax is:
form.display(PARAMNAME=dict(WIDGETNAME=VALUE))
And if you have more complex nested widgets and would like to know what goes on, this monkey patch is good for inspecting the params lookup functions:
import turbogears.widgets.forms
old_rpbp = turbogears.widgets.forms.retrieve_params_by_path
def inspect_rpbp(params, path):
    print "RPBP", repr(params), repr(path)
    res = old_rpbp(params, path)
    print "RPBP RES", res
    return res
turbogears.widgets.forms.retrieve_params_by_path = inspect_rpbp
The code for the lookup itself is, as the name suggests, in the retrieve_params_by_path function in the file widgets/forms.py in the Turbogears source code.

26 March 2008

Joey Hess: my anti-platform: followup

A year ago I posted an anti-platform with some things I wanted to work on over the next year or three. This is a followup to see what, if anything, has been accomplished. constantly usable testing CUT generated some discussion in the project, but I've done nothing toward it myself. The only real progress in this area over the last year has been increasing improvements in the testing security team, and the release team, both of which I'm not currently active in. deprecating www.debian.org This continues to happen organically, for example, Debian Weekly News stopped and http://wiki.debian.org/DeveloperNews took its place. Aside from pointing out that this is happening, I haven't done much to push it. double the archive sync frequency again Sadly, this has not happened yet. automated whole system testing HP donated a test machine, which I set up to run emulated tests of installations of i386, amd64, s390, mips, and mipsel. (Arm and armel should be added soon.) I don't always manage to keep all the tests working at all times by myself, but they have been valuable. developer (virtual) machines My test machine spits out disk images for 5 architectures that have debian pre-installed on them, but due to hosting issues I have not been able to share those images with others yet. find the next nslu2 I was pretty sure this would be OpenMoko's Neo phone, but I have only briefly had access to one, and it's not clear it will be easy enough to get the hardware to make it worthwhile to target it. Meanwhile, tbm has found a more nslu2-like next nslu2, the QNAP Turbostation NAS device, and there's work underway to fully support it from d-i onwards. Others have also worked on running Debian on various related AP hardware, including the ASUS WL-500g and Linksys WRTSL54GS, using OpenWRT to boot Debian. There's instructions and downloads on a wiki page. It would be good to get this fully supported without the hacks.

16 December 2007

Matthew Palmer: Camping: CGIs on steroids

There's no way around it: I'm a bit of a Rails fanboy. While it's got it's glitches, it's certainly made the part of my life that involves writing web applications a hell of a lot easier, and introduced me to the wonder that is the Ruby programming language. However, there are plenty of times when Rails just isn't a good fit. It's not particularly simple to deploy, it's quite heavy, and it does have a definite learning curve. So, when I need to write something simple, I've just used Ruby's built-in CGI support. But I will do so no longer. For I have found Camping. The name doesn't make a whole lot of sense, and until you come to grips with Why The Lucky Stiff's weird sense of humour, the docs will probably make you think that acid trip you took several years ago has just kicked in again. However, the purpose of Camping is pretty easy to understand: it allows you to make simple (CGI level) web "applications" using Rails-like (or more properly, MVC) concepts, which are fairly easy to write and deploy. If you're familiar with Rails (or probably most of the other Rails-clones that have sprung up in other languages) then Camping will probably smell at least faintly familiar. You have routes, which map URLs to controller actions, which retrieve models and feed them to a view which sends results back as HTML. From that perspective, Camping is easy to learn -- it's core concepts can piggyback on existing knowledge, and you can get started very quickly. Using your Rails-fu, however, will only get you so far. For one thing, the API is similar-but-different enough that while your first couple of simple experiments will probably Just Work, getting more complex things done will either fall under the "different" or "difficult" headings. That isn't meant to be a slight on Camping, though -- if you want to do horribly complex things, then you're heading into territory best served by Rails anyway. But there is a bit of a middle ground where the utter simplicity of Camping is stretched a little, but it's still more appropriate to write a Camping app than a Rails app, and it's important to remember that you're not using full-blown framework when you thump up against something that's beyond-trivial in Rails, but is not quite so simple in Camping. Camping is a microframework -- it says so right there on the front page. Why's intention is that Camping will always be provided in less than 4kB of code. So you're never going to get, for instance, the broad range of HTML helpers that Rails' ActionView provides to make writing HTML templates so easy, or the Prototype JavaScript framework shipped with the main code. If you don't want to blow a steam pipe, then, when starting out with Camping, you need to think "this is a lot easier than hand-writing CGIs" instead of "this is a lot harder than writing a Rails app". There are a few things that are undeniably a pest in Camping, though. The docs are a little incomplete and hard to follow (even when you account for Why's "unique" style of writing), and some of the coding tricks that are employed in making the framework can make debugging a bit tricky. They're not showstoppers, but it's worth knowing about them in advance so you don't go nuts when you're first using the framework. If you're not the sort of person who needs small, self-contained web scripts, then I'd say you'll probably never get much benefit out of Camping. On the other hand, if you're still writing your CGIs against the "bare(ish) metal", then I would strongly encourage you to take a look at Camping, to make your life just that little bit more delightful.

23 November 2007

Aigars Mahinovs: TurboGears widget errors

I am making a small project with TurboGears and I am just loving the widgets and the identity framework. There are some rough spots, like the documentation, but luckily for the most pars you can just launch an ipython interpreter and use tab completion to look at what functions are available. But then I got this error:
Traceback (most recent call last):
File "./start-foo.py", line 23, in
from foo.controllers import Root
File “…Foo/foo/controllers.py”, line 22, in
action=”save_settings”
File “/var/lib/python-support/python2.5/turbogears/widgets/meta.py”, line 169, in widget_init
validator = generate_schema(self.validator, widgets)
File “/var/lib/python-support/python2.5/turbogears/widgets/meta.py”, line 277, in generate_schema
if widget.is_named:
AttributeError: type object ‘SettingsFields’ has no attribute ‘is_named’

And I could not find any help on this. Luckily I found Lucas manual and by comparing the code I found that in this part of the code:
settings_form = widgets.TableForm(
fields=SettingsFields,
action="save_settings"
)
Instead of passing the whole SettingsFields class, an instance of it needs to be passed ( as in “fields=SettingsFields(),” ). Cann’t wait to see all the goodies they are making now in TG 2.0, but considering my experience, I will wait until they update the documentation for it before diving in.

6 September 2007

Bernd Zeimetz: mod_wsgi 1.0

mod_wsgi 1.0 Yesterday the official 1.0 version of mod_wsgi was released and uploaded to unstable (the binary package you want to install is called libapache2-mod-wsgi, in case you were wondering), so I think it's a good time to blog about it. Mod_wsgi is an Apache module which can host any Python application which supports the WSGI interface (the reference is also available as package). Major applications and frameworks which are known to work well with mod_wsgi include CherryPy, Django, Karrigell, Pylons, TurboGears, web.py, MoinMoin, PyBlosxom and Trac. In fact every application which provides a WSGI compatible interface should be able to be hosted with mod_wsgi. The module is very simple to use, is very well configurable, documented, has a very active and responsive upstream author and is suitable for use in hosting high performance production web sites, as well as your average personal site. There are two common ways of operation: If you're running python web applications which provide a WSGI interface: go and give mod_wsgi a try! ~~DISCUSSION~~

29 June 2007

Enrico Zini: tg-linktoself

Linking to self in turbogears I want to put in my master.kid some icons that allow to change the current language for the session. First, all user-accessible methods need to handle a 'language' parameter:
@expose(template="myapp.templates.foobar")
def index(self, someparam, **kw):
    if 'language' in kw: turbogears.i18n.set_session_locale(kw['language'])
Then, we need a way to edit the current URL so that we can generate modified links to self that preserve the existing path_info and query parameters. In your main controller, add:
def linkself(**kw):
    params =  
    params.update(cherrypy.request.params)
    params.update(kw)
    url = cherrypy.request.browser_url.split('?', 1)[0]
    return url + '?' + '&'.join(['='.join(x) for x in params.iteritems()])
def add_custom_stdvars(vars):
    return vars.update( "linkself": linkself )
turbogears.view.variable_providers.append(add_custom_stdvars)
(see the turbogears stdvars documentation and the cherrypy request documentation (cherrypy 2 documentation at the bottom of the page)) And finally, in master.kid:
<div id="footer">
  <div id="langselector">
    <span class="language">
      <a href="$ tg.linkself(language='it_IT') ">
        <img src="$ tg.url('/static/images/it.png') "/>
      </a>
    </span>
    <span class="language">
      <a href="$ tg.linkself(language='C') ">
        <img src="$ tg.url('/static/images/en.png') "/>
      </a>
    </span>
  </div><!-- langselector -->
</div><!-- footer -->

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))

Next.

Previous.