Fixing broken inline genshi tags on TG2.1

Turbogears 2.1 got a little issue with genshi templates being rendered as xml instead of xhtml. This causes the most various strange problems with tags nesting being closed in random points as the browser likes. This is caused by an improvement to the mechanism used to decide with rendering format to use that it is now based on the response content type. If your applications returns Content-Type text/xml or text/plain your templates will be rendered as xml or as plain text. But what happens with your application returns text/html which is the default case? Indeed in this case the application asks to your configuration file what to do, and as in your configuration file by default there isn’t any templating.genshi.method […]

Workaround for empty helpers in Turbogears 2.1

Last release of TG2.1 has a subtle bug due to the changes helpers management to support in pylons 1.0, this makes the “h” object appear as an empty dict instead of your application helpers module. The bug is already tracked on http://trac.turbogears.org/ticket/2488 and as the fix is quite easy it will be probably fixed soon. In the mean time you can work around it by monkey patching the pylons.templating.pylons_globals (I do it in lib/app_globals.py but any place is fine). import tg.render, pylons def patched_pylons_globals(): x = tg.render.my_pylons_globals() if x[’h’] == {}: conf = pylons.config._current_obj() x[’h’] = conf[’package’].lib.helpers return x pylons.templating.pylons_globals = patched_pylons_globals This will make your helpers work again in TG2.1. Please pay attention that this code is specific for […]

Lowering Tg2 memory usage by running multiple instances of an app inside same WSGI daemon process

I was recently trying to deploy one app multiple times inside the same WSGIProcessGroup and WSGIApplicationGroup %{GLOBAL} to reduce memory usage. This works quite well except for all the SQLAlchemy sessions which end being attached to the engine of the last wsgi script started. The best solution that I have been able to get so far is to create a proxy interface to the application engine. This way each wsgi script gets binded to the same engine, but the engine itself keeps track of all the available real engines and responds to the script requests sending them to the right real engine. class MultiSiteEngine(object): def __init__(self): self.engines = {}   def __getattr__(self, name): if name == ‘engines': return object.__getattribute__(self, name) […]

ACR got support for user permissions

ACR opensource Turbogears2 CMS got support for user permissions to allow users to edit only some pages and create children only in some sections. This should permit to separate work between multiple people in ACR based sites. ACR also got support for blog/news slice template. This permits to create blogs in ACR with just two clicks instead of having to declare the ACR slicegroup youself. As usual you can download ACR from http://repo.axant.it/hg/acr by using mercurial

Remember me in Turbogears2

One of the problems with TG2 is that the current version doesn’t support a “standard” way to remember the user after he closes the browser. We have been able to find a quick and dirty solution that we like to share here. Keep in mind that this solution only works with recent versions of repoze.who, this works with TG2.0.3, but might not work with previous releases of TG2. Inside the login.html we set a cookie for the remember_me option to pass it to the controller and then inside the post_login we change the cookie. Supposing you have a #remember_me checkbox inside your login.html you can add this to set the cookie: function set_remember_cookie() { is_checked = jQuery(’#remember_me:checked’).length; if (is_checked) document.cookie […]

Turbogears authentication over mongodb users database

As we saw that there isn’t a lot of documentation around about how to perform authentication in turbogears over mongodb we decided to create a simple code snippet and public it here to help people trying to obtain the same thing. This is mainly a proof of concept and is quick and dirty way to obtain it. You will probably have something like ming as your model, instead of directly accessing mongo. This code also validates password over the clear text one, you will probably have hashed passwords in your database, so remember to change validate_password method as required To make it work you will have to place this code inside your config.app_cfg, it also expects you to have you […]

ACR gets Slice Templates

ACR is a flexible and quite powerfull CMS library, but users have to learn Slices and Slicegroups to be able to insert more advanced content like photo galleries, videos and a news section. To simplify this process we created “Slice Templates”. Slice Templates are actually a set of common ways to use slices to insert more advanced content. The first two slice templates implemented are: Youtube Videos which make easy to insert a youtube video inside an ACR Page. Photo Gallery which makes easy to insert a photo gallery with cool effects inside an ACR Page. Next template to come will be a news section, for now you can upgrade your libACR and start using the templates feature or take […]

Turbogears Glossom finally live

We started to collaborate with the Glossom project more than an year ago, the first version was a Ruby on Rails prototype and has served well thousand of users for about an year. When the Glossom team decided to rewrite the software to move from a prototype to a more complete software we studied which frameworks were available and finally decided for Turbogears2. Turbogears is a quite complete and really flexible framework, we used it since version 1.0 for about 3 years and the more we used it the more we loved it. It might have its problems but differently from other solutions when the framework has a limit it is really easy to bypass the framework and implement your […]

Rehearsing new ACR look and feel

As some turbogears projects are starting to use ACR as their CMS library we received the first few requests by real users and the most prominent one is to have a better administrative section. Currently administration section is implemented by using the great tgext.admin and sprox, even if those are really good to quickly implement a CRUD section they might not couple very well when a more interactive and advanced user experience is required. So a transition phase that will end with a totally new administration section for ACR has been started, currently the system implements a new user interface still using the same backend as before to handle the operations, but on the long time the backend itself will […]