Skip to main content

PyRoutes.JS

PyRoutes.JS provide a Javascript routes generation function like Python Routes Mapper.generate method.

Introduction

  • Do you use Python Routes library in Pylons or other applications ?

  • Do you use something like ${h.url('entry_view', entry_id=2)} in your templates ?

So, now do you dream to have Javascript routes generation function ?

PyRoutes.JS is the tool that you need !

If you have this Routes Mapper configuration :

...
map = Mapper()
...
map.connect('entry_view', '/entries/{issue_id:\d*}/', controller='issues', action='view')
map.connect('entry_edit', '/entries/{issue_id:\d*}/edit', controller='issues', action='edit')
...

In your javascript files, you can use PyRoutes.JS like this :

pyroutes.generate('entry_view', entry_id=2); // return '/entries/1/'
pyroutes.generate('entry_edit', entry_id=5); // return '/entries/5/edit/'

Installation

$ pip install pyroutes.js

Pylons integration

In my_app/config/middleware.py file, append :

...
from pylons.middleware import ErrorHandler, StatusCodeRedirect
from pylons.wsgiapp import PylonsApp
from routes.middleware import RoutesMiddleware

...

from pyroutesjs import Middleware as PyRoutesJSMiddleware       # <= append this line

...

from my_app.config.environment import load_environment

...

def make_app(global_conf, full_stack=True, static_files=True, **app_conf):

    ...

    # Append PyRoutes.js middleware
    app = PyRoutesJSMiddleware(app, config['routes.map'])      # <= append this line

    app.config = config
    return app

In your template, append :

<script type="text/javascript" src="${h.url('/js/pyroutes.js')}"></script>

Limitations

  • Currently you can only generate named routes

Source code

Mercurial repository is here : https://bitbucket.org/harobed/pyroutes.js/src

You can clone the code :

$ hg clone http://bitbucket.org/harobed/pyroutes.js

Issue tracker

You can report your bugs here : https://bitbucket.org/harobed/pyroutes.js/issues

News

0.1.0 (not released)

  • Initial version

Metadata

Release files for pyroutes.js 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyroutes.js 0.1.0
File Size Uploaded Provenance
pyroutes.js-0.1.0.tar.gz 4.8 kB Without provenance Details

Release files / pyroutes.js-0.1.0.tar.gz

Download URL pyroutes.js-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4e150036a194e10120d5580346dfbea0aac7340c4743fa34113eb9debbd80f1a
BLAKE2b-256 checksum
How to use checksums
01a3e9612cd1aab143fccd6d00db4163162e9c136a6128a1a2b1574a9a317b1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyroutes.js 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page