There's more...

While you can do basically anything with the record element, there are shortcut elements that make it more convenient for the developer to create certain kinds of records. These include menu item, template, or act window. Refer to Chapter 10, Backend Views, and Chapter 16, CMS Website Development, for information about these.

A field element can also contain the function element, which calls a function defined on a model to provide a field's value. Refer to the Invoking functions from XML files recipe for an application in which we simply call a function to directly write to the database, circumventing the loading mechanism.

The preceding list misses entries for 0 and 1, because these are not very useful when loading the data. They are entered, as follows, for the sake of completeness:

  • (0, False, {'key': value}): This creates a new record of the referenced model, with its fields filled from the dictionary at position three. The second element of the tuple is ignored. As these records don't have an XML ID and are evaluated every time the module is updated, leading to double entries, it's better to avoid this. Instead, create the record in its own record element, and link it as explained in How it works section of this recipe.
  • (1, id, {'key': value}): This can be used to write on an existing linked record. For the same reasons that we mentioned earlier, you should avoid this syntax in your XML files.

These syntaxes are the same as the ones we explained in the Creating new records and Updating values of records recipes in Chapter 6, Basic Server-side Development.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset