Today, somebody asked me if Relatorio could generate sheets (aka tabs) dynamically. We had never done so and I did not know if it would work. It turns out it works nicely out of the box. The trick is to create a sheet with a <relatorio://for each="xxx"> link, then the sheet(s) you want repeated, then an empty sheet with only a <relatorio:///for> link.
Unfortunately, the name of the sheets created this way cannot be set dynamically so far. Instead, the first sheet so create will have the name of the repeated sheet and subsequent sheets will be named automatically by OpenOffice: TableXX
If anybody want to try it for himself, I've added a demo of sheet looping to the examples directory of Relatorio...
Here is a post I have started to write a long time ago but always postponed its completion...
Reading Elixir's mailing list and some comments about Elixir on various blogs, I came to realize that many people don't get what the real goal of Elixir is. To be honest, I didn't realize it myself until a couple months ago.
Sure, it abstracts some of the little details, but this has never been a goal in itself and is only a consequence of the goal. The initial goal was only to provide a declarative syntax. This goal is now also filled by the SQLAlchemy built-in declarative extension.
But what differentiate Elixir from declarative is its ability to generate columns (and other structures) and thus save people from repetitive declarations, both by providing built-in constructs for common patterns as well as providing a way to define their own patterns. For example, if you declare a many-to-one relation between a source entity and a target entity, you nearly always want to add a column in the source entity table with a foreign key constraint to the primary key column of the target entity table. When using pure SQLAlchemy, you have to declare the relationship and the column separately as in:
class Address(Base):
__tablename__ = 'addresses'
id = Column(Integer, primary_key=True)
email_address = Column(String, nullable=False)
user_id = Column(Integer, ForeignKey('users.id'))
user = relation(User, backref=backref('addresses', order_by=id))
while in Elixir, this is done in one step, as in:
class Address(Entity):
email_address = Field(String, required=True)
user = ManyToOne('User')
So, yes, Elixir generates columns for you, but it is not (and never was) meant to hide them from you. It is just meant to save you the trouble to explicitly declare them over and over again. In short, Elixir is a sort of templating system for SQLAlchemy, but to best benefit from Elixir, you should know what it generates for you, and thus you should understand how "raw SQLAlchemy" works.
Ok, now that I said that I hear people coming with the complaint that in our documentation we don't explain clearly nor prominently what gets generated for all constructs. You would be right. I wonder why nobody ever complained about this... For what it's worth, I consider those issues bugs and I am committed to fix them in time. Of course, I would gladly accept patches adding such documentation.
As to better clarify my "vision" of Elixir's future, here are the "abstract" goals I have for Elixir:
- Implement more useful patterns,
- provide ways to customize all the provided patterns the exact way you want them,
- and do not get in the way when you do not want to use them at all.
The only limitation Elixir should add is the inherent declarative limitation, which is that you can't map the same class to different tables/selectables.
Incidentally, these are roughly the release criteria for Elixir 1.0, whenever that will happen.
Creating a collection manager with Elixir in January issue of Python Magazine
Written on 2009-01-27 14:38.After being in the pipeline for a while, my article about Elixir was published in the January issue of Python Magazine. To my surprise, it even made the cover. Maybe, the editors meant it as a little present for my birthday (which is today), who knows... ;-)
Within the article, I build a simple collection manager using Elixir, SQLAlchemy, CherryPy and Genshi. This is the first time I write an article for a technical magazine, and I would really love to hear what people think about it.
Update: As I have been given access to the PDF version of the issue, I noticed the "Useful/Related Links" of my article are not the ones I put there (and are completely unrelated -- I wonder where they come from?). For what it's worth here are the links that should have been included:
- Source code for the program built within the article - http://www.openhex.com/products/elixir/pymag
- Data Mapper Pattern - http://www.martinfowler.com/eaaCatalog/dataMapper.html
- Active Record Pattern - http://www.martinfowler.com/eaaCatalog/activeRecord.html
- REST - http://en.wikipedia.org/wiki/Representational_State_Transfer
Now I understand why there was not any hit on the page holding the application source code...
Update: The version they distribute now has been corrected.
Thanks to someone who let us know by email, we just realized the comment form on our blog has been broken for the last 2 months for people who were not using the "follow-up by email" feature. This is fixed now. Sorry for the inconvenience.
Due to the recent surge of comment spam on Nicolas's blog (160+ in 10 days), I've now implemented the most basic captcha I could think of for posting comments in our blogs. FWIW, I used a text input, instead of the simpler alternatives: a checkbox or a dropdown so that it is unlikely to be bypassed "unintentionally" by random content.
I wonder how long it'll take to get some spam again. I hope it will take a while as I think that even this utterly basic system should keep the spam bots away until a spammer investigate this site in particular, and I guess this shouldn't happen anytime soon (given that we only host our own blogs).
- 1
