Skip to content

Commit 32256e6

Browse files
committed
version 1.20211228.1
1 parent e6c29b4 commit 32256e6

37 files changed

+505
-595
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: b0d1b44aaa6df3fedbf2f70b449fe55f
3+
config: 8acc48e146f3d3c47ffa901083878970
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

apps/_documentation/static/en/_sources/chapter-01.rst.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ details if you come from web2py):
5252
now exclusively on the regular Python import mechanism.
5353
- PY4WEB, like web2py, can serve multiple applications concurrently, as
5454
long as the apps are submodules of the apps module.
55-
- PY4WEB, unlike web2py, is based on bottlepy and in particular uses
56-
the Bottle request object and the Bottle routing mechanism. This is
57-
achieved with `ombott (One More BOTTle) <https://github.com/valq7711/ombott>`__,
58-
which is a fast bottlepy spin-off.
55+
- PY4WEB, unlike web2py, is based on ombott
56+
(a reduced and faster spin-off of Bottle) and in particular uses
57+
a Bottle-compatible request object and routing mechanism.
58+
5959
- PY4WEB, unlike web2py, does not create a new environment at every
6060
request. It introduces the concept of fixtures to explicitly declare
6161
which objects need to be (re)initialized when a new http request arrives

apps/_documentation/static/en/_sources/chapter-05.rst.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ The newly created file will be accessible at
6969
Notice that ``static`` is a special path for py4web and only files under
7070
the ``static`` folder are served.
7171

72-
Important: internally py4web uses the bottle
73-
`static_file <https://bottlepy.org/docs/dev/tutorial.html#static-files>`__
74-
method for serving static files, which means it supports streaming,
75-
partial content, range requests, and if-modified-since. This is all
72+
Important: internally py4web uses the ombott
73+
(One More BOTTle) <https://github.com/valq7711/ombott>`__,
74+
It supports streaming, partial content, range requests,
75+
and if-modified-since. This is all
7676
handled automatically based on the HTTP request headers.
7777

7878
Dynamic Web Pages
@@ -218,7 +218,7 @@ This action can be accessed at:
218218

219219

220220

221-
Notice that the request object is a `Bottle request object <https://bottlepy.org/docs/dev/api.html#the-request-object>`__.
221+
Notice that the request object is equivalent to a `Bottle request object <https://bottlepy.org/docs/dev/api.html#the-request-object>`__.
222222
with one additional attribute:
223223

224224
::
@@ -364,8 +364,7 @@ The scaffold app contains an example of a more complex action:
364364
365365
Notice the following:
366366

367-
- ``request``, ``response``, ``abort`` are defined by Bottle, using
368-
`ombott (One More BOTTle) <https://github.com/valq7711/ombott>`__,
367+
- ``request``, ``response``, ``abort`` are defined by
369368
which is a fast bottlepy spin-off.
370369
- ``redirect`` and ``URL`` are similar to their web2py counterparts
371370
- helpers (``A``, ``DIV``, ``SPAN``, ``IMG``, etc) must be imported

apps/_documentation/static/en/_sources/chapter-10.rst.txt

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,14 +801,48 @@ that match the specified attributes will be searched for text.
801801
>>> print(a)
802802
<div><div><span class="abc">x</span><div><span class="efg">hello</span><span class="abc">z</span></div></div></div>
803803
804-
Import modules from templates
805-
-----------------------------
804+
Using Inject
805+
------------
806806

807807
Normally all the code should be called from the controller program, and only the
808808
necessary data is passed to the template in order to be displayed.
809-
But sometimes it's useful to use a python function as a helper called from a template.
809+
But sometimes it's useful to pass variables or even use a python function as a helper called from a template.
810810

811-
In this case you can use ``Inject``. For example if your helper function is called *sidebar_menu*
811+
In this case you can use the fixture ``Inject`` from py4web.utils.factories.
812+
813+
This is a simple example for injecting a variable:
814+
815+
.. code:: python
816+
817+
from py4web.utils.factories import Inject
818+
819+
my_var = "Example variable to be passed to a Template"
820+
821+
...
822+
823+
@unauthenticated("index", "index.html")
824+
@action.uses(Inject(my_var=my_var))
825+
def index():
826+
827+
...
828+
829+
830+
Then in ``index.html`` you can use the injected variable:
831+
832+
.. code:: html
833+
834+
[[=my_var]]
835+
836+
837+
You can also use ``Inject`` to add variables to the auth.enable line;
838+
in this way auth forms would have access to that variable.
839+
840+
.. code:: python
841+
842+
auth.enable(uses=(session, T, db, Inject(TIMEOFFSET=settings.TIMEOFFSET)))
843+
844+
A more complex usage of Inject is for passing python functions to templates.
845+
For example if your helper function is called *sidebar_menu*
812846
and it's inside the libs/helpers.py module of your app, you could use this in **controllers.py**:
813847

814848
.. code:: python

0 commit comments

Comments
 (0)