=====================
This is a somewhat-functional attempt to bring a more intuitive and less spaghettified syntax to Django's URLConf. It implements a declarative class-based syntax:
# urls.py (née 'URLConf')
from django.conf.urls import patterns
from url_namespaces import (Namespace, View, Redirect, \
ReverseRedirect, KeywordReverseRedirect)
class MyOtherURLs(Namespace):
""" URL namespaces are classes,
the URLs they contain are properties
of those classes. """
class Meta:
namespace = 'testapp:views'
app_name = 'testapp'
view_prefix = ''
rss = View(
r'^(?P<blog>[\w\-]+)/rss/?$',
'testapp.views.blogrss',
arg='yo', other_arg='dogg')
index = View(
r'^(?P<blog>[\w\-]+)/$',
'testapp.views.blogpage')
entry = View(
r'^(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$',
'testapp.views.blogentrypage')
class MyURLs(Namespace):
""" Namespaces can be nested """
class Meta:
namespace = 'testapp'
app_name = 'testapp'
view_prefix = ''
pages = MyOtherURLs(r'^/pages/')
elsewhere = Redirect(
r'^/yodogg?',
"http://www.yodogg.com/")
root = ReverseRedirect(
r'^/?',
'testapp:index', blog="test")
entry_redirect = ReverseRedirect(
r'^blog/(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$',
'testapp:entry', blog="%(blog)s", entry="%(entry)s")
entry_redirect_again = KeywordReverseRedirect(
r'^blog/(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$',
'testapp:entry')
# These classes generate standard URL patterns
# and use url(), reverse(), RegexURLResolver;
# the project aims for compatibility with Django's
# URLConf structures.
urlpatterns = patterns('',
MyURLs(r'^/?').connect('testapp'))
Djano-URL-Namespaces implements a host of combinator objects, representing intuitive ideas e.g. `View`, `Redirect`, `Namespace` &c,
which can be modularly rearranged without the worries incumbent in getting ones' hands dirty with the rather fragile Django-native
URLConf syntax.
At the time of writing the project is in a state of somewhat indeterminate disrepair; namespaces don't nest quite right, there's a lot of sketchy code commented out and not enough docstrings, etc. If this is the sort of thing that floats your boat, know that I never turn away an entertaining pull-request, indeed!
Metadata
Release files for django-url-namespaces 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-url-namespaces-0.1.0.tar.gz | 8.9 kB | Without provenance | Details for django-url-namespaces-0.1.0.tar.gz |
Release files / django-url-namespaces-0.1.0.tar.gz
| Download URL | django-url-namespaces-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b8e6dd2b00570466e597fad9badd2cf464ff7f9c498e2250832f500cf34308f
|
|
BLAKE2b-256 checksum How to use checksums |
33ffd170d5ae6ae4c42c99e9c3645b8d70090b15e7bfc3652b4793b445afbc13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-url-namespaces 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.