There's more...

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

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 Using the noupdate and forcecreate flags recipe for an application where we simply call a function to directly write to the database, circumventing the loading mechanism.

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

  • (0, False, {'key': value}) 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 those 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 in general, create the record in its own record element, and link it as explained earlier.
  • (1, id, {'key': value}) can be used to write on an existing linked record. For the same reasons as mentioned earlier, you should avoid this syntax in your XML files.

These syntaxes are the same as the one 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
3.17.167.114