MongoDB Aggregation Pipeline and Pagination

One of the most common problems in web development is paginating a set of data. It’s common that the set of data we need to show our users is pretty big and we might want to show only a part of it retrieving the next slices only when requested. Skip/Limit Pagination The most common way to achieve this is usually to count the number of items and split them in pages, each of a fixed set of items. This is usually achieved through the limit, skip and count operators. For the purpose of this post I’ll be relying on a collection containing tickets for a project management tool, each document looks like: {u’_id': ObjectId(‘4eca327260fc00346500000f’), u’_sprint': ObjectId(‘4eca318460fc00346500000b’), u’complexity': u’days’, u’description': u’This […]

MongoDB and UnitOfWork love or hate?

One of the most common source of issues for MongoDB newcomers is the lack of transactions, people have been used to work with transactions for the past 10 years and probably their web frameworks automatically starts, commits and rolls back transactions for them whenever something wrong happens. So we are pretty used to web development environments where the problem of writing only a part of our changes is usually solved out of the box. When people first approach MongoDB I noticed that this behaviour is often took for granted and messed up data might arise from code that crashes while creating or updating entities on the database. No transaction, no party? To showcase the issue, I’ll try to came up […]

DEPOT 0.1.0 new Aliases Feature for Easy Storage switch

DEPOT is a file storage and retrieval framework we created to solve the need of switching different storage systems when deploying in different environments. We wanted a unique and cohesive API┬áthat made possible to keep storing files the same way independently from where they were actually stored. As systems evolve and change during time we also wanted the ability to switch those storages whenever required without breaking past files or changing any code. That lead to various features of DEPOT that specifically pointed this problem, the last of this list is the new Storage Aliases support. If you used a single storage, myfiles, registered as the default one, when you wanted to switch from Local Storage to S3 that was […]

It’s a Pluggable World

One of the new additions in TG2.1.4 has been the support for the so called pluggable applications, this is a really powerful and convenient feature that probably not enough TurboGears users started embracing. For people that never used them, pluggable applications provide a python package that can be installed and “plugged” inside any existing TurboGears application to add new features. Django has been probably the first framework to bring this feature to Python world and TurboGears implementation tries to be as convenient by making pluggable applications identical to plain TurboGears applications and providing a “quickstart-pluggable” command that creates the application skeleton for you. Pluggable applications can be installed using easy_install or pip and they can off course depend on any […]

What’s new about Sprox 0.8

Today Sprox 0.8 got released, it is the first release to add ToscaWidgets2 support. Depending on which version of ToscaWidgets is available inside your environment Sprox will either use TW1 or TW2 to generate its forms. Being mostly a TW2 oriented release it might seem that not a lot changed since the previous version, but a little gem is hidden between all the TW2 changes as Sprox now supports setting default behavior for models themselves using the __sprox__ attribute inside model declaration. class Parent(DeclarativeBase): __tablename__ = ‘parents’   uid = Column(Integer, primary_key=True) data = Column(String(100))   class Child(DeclarativeBase): __tablename__ = ‘children’   class __sprox__(object): dropdown_field_names = {’owner': [’data’]}   uid = Column(Integer, primary_key=True) data = Column(String(100))   owner_id = Column(Integer, […]

TurboGears future performances comparison

Recently I decided to give a quick benchmark for curiosity to the going to be branches of TurboGears2. I quickstarted a simple genshi based application (plain turbogears2 quckstart) and then I created a plain controller method without template, to avoid counting the template generation overhead. The application has been installed in three virtual environments: one with TG2.1.4, one with the development branch which is going to be TG2.2 and one with the development branch which is going to be TG2.3 The following graph reports the resulting requests/second that my pc has been able to serve on each turbogears version. I have to admit that I’m quite happy with the results, the grow is steady and TG2.3 seems to be three […]

Mastering the TurboGears EasyCrudRestController

One of the key features of TurboGears2 is the great CRUD extension. Mastering the CRUD extension can really make the difference between spending hours or just a few minutes on writing a web app prototype or even a full application. The CRUD extension provides two main features, the CrudRestController which is meant to help creating totally custom CRUDs and the EasyCrudRestController which provides a quick and easy way to create CRUD interfaces. I’ll focus on the EasyCrudRestController as it is the easiest and more productive one, moving forward to the CrudRestController is quite straightforward after you feel confident with the Easy one. The target will be to create, in no more than 40 lines of controller code, a full featured […]

TurboGears2 DebugBar

Recently some work has been done to extend the hooks support in TurboGears, to play a little with the new hooks I decided to try creating the famous and envied Django Debug Toolbar. I’m quite happy of the result and most of the features are there. In a few days I’ll be able to place it on a public repository and I’ll release it concurrently with the 2.1.4 release of TurboGears. The code has been heavily inspired by the Pyramid Debug Toolbar and have to thank the Pyramid team for the good job they did at making the Toolbar code clean and simple.

TurboGears2 Performance Improvements

As recently some effort has been involved in improving the performances of TurboGears2, I was curious to see how much things improved. As usually, the test isn’t really reliable in any way and was just for fun. All the graphs report the request/sec the application has been able to perform on my computer with only 1 concurrent client. So higher is better. Here is the comparison between TG2.0 and TG2dev (will be 2.1.4) I also compared various setups with different template engines on TG2dev The comparison happened on an application similar to the quickstarted one. Actually as there is no database involved in this application the template engine impacts a lot and so was a good benchmark for the template […]

ACRcms 0.3.5 released with libacr 0.7

New features introduced are: Assets manager, Upload your videos and images using the Asset manager instead of the RDisk if you want to create slices from them. Assets manager will also create thumbnails for everything and will convert the videos to support HTML5 BlogPost view (an HTML view with a title) Attributes for Pages and Slices Hide Pages from menu with hidden=1 attribute Reorder Pages in menu menu-weight attribute Add metatag description to pages with description attribute Automatic Database migrations, never care about changes to the schema when you upgrade acr again, it will be automatically upgraded by acr itself on first visit Hide edit bars in edit mode to view the slice as a standard visitor Abstraction layer for […]