File: example.py

package info (click to toggle)
picobox 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248 kB
  • sloc: python: 1,666; makefile: 16
file content (26 lines) | stat: -rw-r--r-- 531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import picobox


def spam():
    return eggs()


def eggs():
    return rice()


@picobox.pass_("secret")
def rice(secret):
    print(secret)


with picobox.push(picobox.Box()) as box:
    box.put("secret", 42)

    # We don't need to propagate a secret down to rice which is good because
    # we kept interface clear (i.e. no changes in spam and eggs signatures).
    spam()

    # The other good thing is despite injection rice can explicitly receive
    # a secret which means its signature wasn't changed either.
    rice(13)