Gramex 1.87 release notes

Gramex 1.87 supports FormHandler argument typing, distributed user stores, flexible deletions, and more.

FormHandler argument type

FormHandler filter values are converted from strings to the column type, where possible. To explicitly set the type, use argstype:

url:
  flags:
    pattern: /people
    handler: FormHandler
    kwargs:
      url: people.csv
      argstype:
        age: { type: int }
        weight: { type: float }
        is_married: { type: bool }
        date_of_birth: { type: pd.to_datetime }
        date_of_death: { type: pd.to_datetime(_val) if _val else None }

argstype is a dictionary of column names and their types. The type can be:

Note: argstype values can also include an {expanding: true} to treat values as lists. This is used in FormHandler queries to prevent SQL injection in the IN operator.

Reference

Distributed user stores

User information (including attributes) is stored in a user store that is configured as follows:

storelocations:
  user:
    url: sqlite:///$GRAMEXDATA/auth.user.db
    table: user
    columns:
      key: { type: TEXT, primary_key: true }
      value: { type: TEXT }

If you use Gramex on multiple servers, change this to a remote database with the same syntax as FormHandler. For example, add this in your gramex.yaml:

storelocations:
  user:
    url: postgresql://$USER:$PASS@server/db
    # url: mysql+pymysql://$USER:$PASS@server/db
    # ...
    table: user

Reference

Flexible Delete

FormHandler DELETE required a primary key to be specified via kwargs.id.

This is no longer required. DELETE now works exactly like GET, except that it deletes rows instead of filtering them.

Similarly, gramex.data.delete() now works like gramex.data.filter(). For example:

# Fetches data based on a filter
rows = gramex.data.filter('sqlite:///sales.db', table='sales', where={'city': 'Olso'})
# Returns the number of rows deleted. Same as len(rows)
count = gramex.data.delete('sqlite:///sales.db', table='sales', where={'city': 'Olso'})

MS SQL ordering

If we use OFFSET or LIMIT with MS SQL, we must specify an ORDER BY clause. Otherwise, it raises: MSSQL requires an order_by when using an OFFSET or a non-simple LIMIT.

Gramex now does this automatically. If the query is not sorted, Gramex sorts by the first column in the table. #626

Old Admin App deprecated

The first version of the Admin app (imported from $GRAMEXAPPS/admin/gramex.yaml) was deprecated in Gramex 1.33.

This version of Gramex removes it.

Bug fixes

Backward compatibility & security

Gramex 1.87 is backward compatible with previous releases unless the release notes say otherwise. Automated builds test this.

Every Gramex release is tested for security vulnerabilities using the following tools.

  1. Bandit tests for back-end Python vulnerabilities. See Bandit results
  2. npm-audit tests for front-end JavaScript vulnerabilities. See npm-audit results
  3. Snyk for front-end and back-end vulnerabilities. See Synk results
  4. ClamAV for anti-virus scans. See ClamAV results
  5. Trivy for container scans. See Trivy results

Statistics

The Gramex code base has:

How to install

See the Gramex installation and upgrade instructions.