Personal tools
You are here: Home Documentation Tutorials Navigating To Transient Objects Tutorial Introduction

Introduction

Why instantiate objects from external data sources?
Thanks to the magic of this database, your web apps can create Python objects that are automatically saved to disk and are available every time your application runs. In particular, every grok.Model and grok.Container object you generate can be written safely to your application's Data.fs file. But sometimes you need to create objects that do not persist in the ZODB, wonderful though it is.
Page 1 of 9.

If you have already read the Grok tutorial, you are familiar with the fact that behind Grok lives a wonderful object database called the Zope Object Database, or the ZODB for short. Thanks to the magic of this database, your web apps can create Python objects that are automatically saved to disk and are available every time your application runs. In particular, every grok.Model and grok.Container object you generate can be written safely to your application's Data.fs file.

But sometimes you need to create objects that do not persist in the ZODB, wonderful though it is. Sometimes these will be objects you design yourself but have no need to save once you are done displaying them, like summary statistics or search results. On other occasions, you will find yourself using libraries or packages written by other people and will need to present the objects they return in your Grok app — whether those objects are LDAP entries, file system directory listings, or rows from a relational database.

For the purpose of this tutorial, we are going to call all such objects transient objects. This highlights the fact that, from the point of view of Grok, they are going to be instantiated on-the-fly as a user visits them. Of course, they might (or might not) persist in some other application, like a file system or LDAP server or relational database! But as far as Grok can tell, they are being created the moment before they are used and then, very often, pass right back out of existence — and out of your application's memory — once Grok is finished composing the response.

To try out the examples in this tutorial, start a Grok project named TransientApp and edit the app.py and other files that you are instructed to create or edit.