Gramex 1.30 Release Notes

Log viewer

Gramex features a built-in log viewer application. This is a mini-application that is embedded with Gramex.

Log viewer

This currently shows the

Users can select any period over which to view this data, and filter for specific users, statuses, etc.

Deploying the application just required adding this configuration:

import:
  logviewer:
    path: $GRAMEXAPPS/logviewer/gramex.yaml # Source of the app
    YAMLURL: $YAMLURL/log/ # Location to mount at
    namespace: [url, schedule] # Avoid name space conflicts
    auth: ... # Restrict access as required

Proxy APIs

ProxyHandler, which was introduced in v1.29 that lets you access REST APIs from the browser. We can connect to most web applications:

This has 2 advantages:

  1. Access data live. We treat the apps like live databases and query them directly.
  2. Build client-side applications easily. This avoids the need to write Python code – which may be complicated by the need to log in.

For example, a simple configuration exposes the Google Translation API to Gramex apps:

Translate “How are you” to Hindi

OAuth2 login

ProxyHandler is more powerful with the OAuth2 handler - which is new in v1.30. This lets users log into all the above applications, and allows ProxyHandler to access the logged in user’s data.

This also lets us build secure applications where Gramex does not store data, but shows users their own data, like:

Multiple logins

Users can now into multiple auth engines at the same time. For example, you can log in with both DBAuth and LDAP. This lets you link users’ DBAuth login to an LDAP login ID dynamically.

This is enabled by user attributes. All auth handlers let you define which session key to store the user attributes in.

This defaults to user. But you can set it to ldap for the LDAP auth handler, and have handler.session.user hold the DBAuth info, and handler.session.ldap hold the LDAP info.

If you want to save this information somewhere, or perform any post-login action, the best place to do that is login actions.

SMS notification

Gramex is now integrated with Amazon’s SNS. This lets us send an SMS message at fairly low rates.

You can test it out here.

The code to do this is simple too. Once configured, just run:

notifier.send(
    to='+919741552552',
    subject='This is from Gramex',
)

Here is the output:

SMS received

This lets you send mobile alerts if there’s any unusual business scenario, like:

You can also send mobile alerts as summaries. For example:

This also paves the way for more features, like:

Config reload

Earlier, if gramex.yaml changed, Gramex would reload the entire application. Re-launching ChromeCapture, PhantomJS, and every single one of your handlers, schedulers, etc.

Now Gramex is faster. It reloads a handler or scheduler only if its configuration has changed.

Gramex can also be dynamically reconfigured. – creating new URLs on the fly. This can be used to:

NOTE: Since these URLs are constructed dynamically, it makes the application more complex that it is worth. Use with caution.

Documentation

The Guide now features a Search feature with full-text search. This is handy if you want to understand:

The deployment guide has a new section on shared deployment that lists common problems when deploying multiple applications to the same instance - like on uat.gramener.com. The biggest problem is that the app runs locally, but not on the server. And it’s simple to fix.

Others

Bugs

Stats

Upgrade

To upgrade Gramex, run:

pip uninstall gramex
pip install --verbose https://github.com/gramener/gramex/archive/master.zip

This downloads Chromium and other front-end dependencies. That may take time.