-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declarative url_for construction #77
Comments
Given these constraints:
|
Since blueprint routes are referred to as |
This was referenced Nov 21, 2017
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
coaster.sqlalchemy.UrlForMixin
has made view construction much simpler by allowing for usage in the form of{{ ob.url_for() }}
instead of the longer{{ url_for('ob_view', name=ob.name) }}
syntax.However, the models now require a
url_for
method which is aware of each view that applies to the model. Since models are lower level than views in our hierarchy (models < forms < workflows < views) and lower levels are by intent not supposed to be aware of higher levels, this has been a bad compromise.UrlForMixin
should provide ais_url_for
classmethod that can be used to decorate views, to indicate that this view applies to it. Sample use:Like
load_model
,is_url_for
will need assistance knowing what parts of the post are required to construct the URL, but in reverse, including sub-attributes likeself.parent.name
. To support this, it accepts keyword arguments after the "action" name, where the value of each argument is a string naming the attribute to extract from self, or a tuple containing a recursive set of attributes (like('parent', 'name')
). As a shortcut, a dotted string may be provided, which is broken down into a tuple at decorator-load time.The text was updated successfully, but these errors were encountered: