I’m back in the ubuntuusers team and currently helping out amix on todoist.
Archive for July, 2007
New Jinja Parser
Uha. One day of programming and Jinja got a new parser :D 129 out of 131 tests pass, and nearly all of the old semantics still work. I changed some things so far that probably make more sense. Syntax changes from 1.1 to 1.2:
- call and endcall are keywords now. I wanted to do that in 1.3, not 1.2 but because it’s easy to change it’s a good thing to do the change now.
- tuples are tuples now, not lists. That will make strings formatting easier too — it really was a bad idea to uniform lists and tuples. This change shouldn’t cause many problems because the namespace is more or less read only. So there are no concatenation issues that will appear because a list and tuple are mixed together.
- __getslice__ is currently not supported. Parsing the python slice rules is not that simple and for the moment slice objects are easier. So foo[1:2] results in get_attribute(foo, slice(1, 2, None)). I will add some more unittests to check if this breaks stuff.
- foo|escape + bar|escape is possible now.
The code is not in trunk by now because there are still some things to fix (string escaping, streaming system) and i don’t know if the change has any side effects on bigger code. If someone wants to try out the new parser tough you can check it out from here: new-parser.
Backward incompatible changes: the lexer tokenstream, the lexer tokenize method (not the tokeniter one which is public) and the parse functions because the new parser looks different and has different nodes from different modules (no compiler.ast any more). I hope that there are few hardcore users that analyse the Jinja ast but if there are some, you probably have to change some code.
Pocoo and Jinja Update
First of all: Pocoo gets some love recently. EnTeQuAk joined the team and is working on finishing the changes I haven’t finished (conversion to werkzeug and splitting up the packages). That’s great news, but don’t expect checkins the next nine days, he’s on holiday currently.
The other news affects Jinja. The plan was to introduce a new module system for the next Jinja version so that the loaders reload better and that you can use macros without including a module into the current namespace. So {% include foo = “foo.html” %} {{ foo.macro() }} should work.
This however was postponed for a simple reason. The compiler package Jinja is using internally is deprecated because with Python 2.5 the AST is a core Python feature and automatically in sync with the parser Python uses itself. But because maintaining a version for python2.5/2.6, python3 and python2.4 and lower is too much work Jinja will get a hand-written parser for the current syntax.
I expect that this will Jinja also a lot more lightweight because some of the trickeries I do with the AST will become redundant. So that will become the next thing to do.
OMG! Access Denied
it was on digg and probably some more blogs. An GRUB that starts up ubuntu is featured in issue #4 of the Marvel Comic Mighty Avengers. Together with a cool “access denied” bar which obviously has not the same resolution as the GRUB ;)

Well. That’s not the original comic, but the text makes IMHO more sense :-)
the original one is here.
Pygments is soooo big…
…that it appears two times on the django powered pages mosaic. 7;13 and 1;18.
Music you *have* to listen to
Sacrificed Sons, Ocatavarium and Stream Of Consciousness by Dream Theater.
Curse on Jinja
Since yesterday curse-gaming is now curse and running on Jinja. Awesome :) They are using a loader that loads the template bytecode from memcached servers. Thanks to Bryan McLemore that loader is part of Jinja since some time.
Lodgeit Vim Script
Currently I constantly go to paste.pocoo.org to paste stuff i copied from my vim there. Why not just paste directly from within vim? So I wrote a small vim plugin (requires python) that pastes to lodgeit: lodgeit.vim.
Oh. And from the werkzeug plaintext view you can paste directly into the lodgeit now too :-)
Update: Improved version online. It now converts to utf-8 automatically and allows to download pastes directly into vim via :Lodgeit URL. If you have done your change you can push it back to the server via :Lodgeit.
The last two weeks…
Alright. No posts for quite a long time. But just because the blog was pretty dead that doesn’t mean that nothing is happening. In fact I’m working hard on a couple of things I cannot announce yet. Unfortunately my notebook harddisk once again broke which is somewhat annoying. Looks like this summer is more expensive then all the summers before :) Guess my next notebook will be a macbook pro.
Oh. And in the new python documentation (which btw needs your help) you can now comment on keywords on pages too:

Fun with Ruby Syntax
Smilies:
smilies = :-? /:-/ :-D
That’s nonsense code, smilies just gets /:-/ assigned. Fun nevertheless. Why that works? The first thing is a symbol literal, then there is a ternary operator, first result expression is a regular expression literal, the second is the negative version of the “D” constant. Because the symbol is true the second return expression is never evaluated and nobody complains about the missing constant D.