Python API

Any Rapido Python function receives context as parameter.

The context provides the following properties:

This property gives access to the Rapido application object.


Returns the Rapido application’s access control list object (see below).
Returns the existing block ids.
Returns the existing index ids.
Returns the application URL.


create_record(self, id=None)
Creates and return a new record. If id is not provided, a default one is generated. If id already exists, it is replaced with another one (like ...-1, ...-2).
delete_record(self, id=None, record=None, ondelete=True)
Delete the record (which can be passed as object or id). If ondelete is truthy, the on_delete function will be called (if it exists) before deleting the record.
get_block(self, block_id)
Returns a block.
get_record(self, id)
Returns the record corresponding to the id, or None if it does not exist.
log(self, message)
Logs a message in the server log. If the app is in debug mode, logs the same message in the browser’s javascript console. Messages can be strings or any other serializable object.
Returns all the records as a list.
Returns all the records as a Python generator.
search(self, query, sort_index=None, reverse=False)
Performs a search and returns records as a list.
_search(self, query, sort_index=None, reverse=False)
Performs a search and returns records as a Python generator.

context.request and context.parent_request

context.request is the actual request to Rapido, like:

When a block is embedded in a Plone page, context.request was issued by the user’s browser, it was issued by Diazo.

To get the request issued by the user’s browser, we use context.parent_request.

Both of them are HTTP requests objects, see the reference documentation.


  • Reading submitted values:
val1 = context.request.get('field_1')  # returns None if key doesn't exist
val1 = context.request['field_2']  # fail if key doesn't exist
  • Reading the BODY:


Return the Plone portal object.

It is equivalent to:


The most common task we will perform through the portal object is to get its contents:

folder = context.portal['my-folder']


It returns the current Plone content.

The most common tasks we will perform on the content are:

  • reading/writing its attributes (read/write):
the_tile = context.content.title
context.content.title = "I prefer another title"
  • getting its URL:

To manipulate the content, refer to the Plone API documentation about contents.


Depending on its content type, the content object might have very different methods and properties.


It returns the current Rapido record if any.

See Record for more information.


It gives access to the full Plone API.


There is no need to import the API, as shown in all the Plone API examples:

from plone import api  # WRONG

because the API is already available in the Rapido context:

catalog = context.api.portal.get().portal_catalog

This API mainly allows:

  • to search contents; for example:

    folders = context.api.content.find(portal_type="Folder")
    # be careful, the find() method returns Brain objects, not real objects
    # so only indexed attributes are available.
    desc = folders[0].Description # OK
    folders[0].objectIds() # WRONG!
    folder = folders[0].getObject()
    folder.objectIds() # OK!
  • to manipulate contents (create / delete / move / publish / etc.), example:

    new_page = context.api.content.create(
        title='My Content',
    context.api.content.transition(obj=new_page, transition='publish')
  • to access or manage the users and groups information, and send emails. Example:

    current_user = context.api.user.get_current()

For more detailed examples, refer to the Plone API documentation.


context.rapido is a function able to obtain another Rapido application in our current script.

It takes as mandatory parameter the id of the Rapido application. Example:

purchase_app = context.rapido('purchase')
new_purchase_order = purchase_app.create_record()

It might also accept a content parameter to provide a specific content context to the app (if not provided, it will take the current content). Example:

stat_app = context.rapido('stats',



For security reason, it is not allowed to import a Python module in a Rapido Python file.

Rapido provides some safe modules through context.modules:

If we need to add extra modules to context.modules, we can do it by adding in our own add-on something like:

import re
from rapido.core import app = re

In this example, we allow to access from our Rapido Python files.



Returns the record URL.
Returns the record identifier.


display(self, edit=False)
Render the record using its associated block (if any).
get(self, name, default=None)
Returns the value of the item (and defaults to default if the item does not exist).
Returns all the stored items.
Re-index the record.
save(self, request=None, block=None, block_id=None, creation=False)

Update the record with the provided items and index it.

request can be an actual HTTP request or a dictionnary.

If a block is mentionned, formulas (on_save, computed elements, etc.) will be executed.

If no block (and request is a dict), we just save the items values.

set_block(self, block_id)
Assign a block to the record. The block will be then used to render the record or to save it.

Python dictionary-like interface

The record’s items can be accessed and manipulated like dictionary items:

myrecord['fruit'] = "banana"
for key in myrecord:[key])
if 'vegetable' in myrecord:
    del myrecord['fruit']


When setting an item value, the record is not reindexed.

Access control list


The application access control list can be obtain by


Returns the current user id. Equivalent to:
Returns the groups the current user belongs to. Equivalent to:
has_access_right(self, access_right)
Returns True if the current user has the specified access right (Rapido access rights are reader, author, editor, manager)
has_role(self, role_id)
Returns True if the current user has the specified role.
Returns the existing roles.