Skip to content

Commit

Permalink
Add docs and fix the decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
s-cork committed Aug 11, 2023
1 parent 7ca9ce4 commit 5100913
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client_code/routing/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __new__(cls, **properties):
form_class = fn()
return form_class.__new__(form_class, **properties)

return route_wrapper(Lazy)
route_wrapper(Lazy)
return fn

return wrapper
16 changes: 16 additions & 0 deletions docs/guides/modules/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,22 @@ Decorators
If the ``before_unload`` method is added it will be called whenever the form currently in the ``content_panel`` is about to be removed.
If any truthy value is returned then unloading will be prevented. See `Form Unloading <#form-unloading>`__.

.. function:: routing.lazy_route(url_pattern, url_keys=[], title=None, full_width_row=False, template=None)

.. code:: python
from anvil_extras import routing
@routing.lazy_route('article', url_keys=['id', routing.ANY], title="Article-{id} | RoutingExample")
def article_route():
from ..ArticleForm import ArticleForm
return ArticleForm
This decorator allows you to lazyily load Forms. When using ``@routing.route`` all Forms that are routes must be imported before the app starts.
This is fine for most small applications, but as your application grows you may find that executing all the code for all the Forms is slow.
The ``lazy_route`` decorator should decorate a function that imports the Form and returns it.


.. function:: routing.redirect(path, priority=0, condition=None)

The redirect decorator can decorate a function that will intercept the current navigtation, depending on its ``path``, ``priority`` and ``condition`` arguments.
Expand Down

0 comments on commit 5100913

Please sign in to comment.