Script API
In the TechMaju platform, various Python modules and commands are available for use in in-app scripting. These tools are essential for customizing and automating functionalities within your TechMaju applications without the need to create a fully-featured application.
However, some commands are restricted in this context and more complex features should be implemented within dedicated applications using Python modules. Below is a detailed list of available modules and commands categorized by their functionalities.
Formatting
|
Function |
Description |
Example |
|---|---|---|
|
|
Translate a string |
|
|
|
Format a value based on its datatype |
|
|
|
Format as default date format |
|
|
|
Returns date as "1st September 2019" |
|
Session
|
Attribute/Function |
Description |
Example |
|---|---|---|
|
|
Form/request parameters |
|
|
|
Request object |
|
|
|
Response object |
|
|
|
Current user |
|
|
|
CSRF token of the current session |
|
|
|
Current user |
|
|
|
Returns fullname of the current user |
|
|
|
Gets the user display image |
|
|
|
Fullname of the current user |
|
Documents (ORM)
|
Function |
Description |
Example |
|---|---|---|
|
|
Get metadata object |
|
|
|
Create a new Document record |
|
|
|
Get Document |
|
|
|
Get the last Document of a particular DocType |
|
|
|
Get Document (or cached) |
|
|
|
Get mapped document |
|
|
|
Rename document |
|
|
|
Delete document |
|
|
|
Get system default settings |
|
Database
|
Function |
Description |
Example |
|---|---|---|
|
|
Get list of records filtered by current user's permissions |
|
|
|
Get list of all records |
|
|
|
Run a SELECT query |
|
|
|
Get a value from a record |
|
|
|
Get value from a single type document |
|
|
|
Get default value |
|
|
|
Sanitize value for database queries |
|
|
|
Set a value |
|
|
|
Checks for existence of a document |
|
|
|
Allow explicit commits in server scripts |
Note: Does not work in DocType Event server scripts. |
|
|
Allow rollback changes via server scripts |
Note: Does not work in DocType Event server scripts. |
Query Builder
|
Function |
Description |
Example |
|---|---|---|
|
|
Query builder API |
|
Utilities
|
Function |
Description |
Example |
|---|---|---|
|
|
Executes a Script Function |
|
|
|
Run a server script |
|
|
|
Show a modal on the server side |
|
|
|
Methods in |
|
|
|
Render a Jinja template |
|
|
|
Get URL of the current site |
|
|
|
Returns mimetypes.guess_type |
|
|
|
Encode HTML as text (markdown) |
|
|
|
True if in developer mode |
|
|
|
Generate error log with traceback |
|
API
|
Function |
Description |
Example |
|---|---|---|
|
|
Make a GET request |
|
|
|
Make a POST request |
|
|
|
Make a PUT request |
|
|
|
Make a PATCH request |
|
|
|
Make a DELETE request |
|
|
Function |
Description |
Example |
|---|---|---|
|
|
Send an email |
|