Fix missing imports in examples
This commit is contained in:
parent
6d5c671895
commit
f73963dd0a
|
@ -179,6 +179,8 @@ annotations. The following function definitions have identical
|
|||
effects, except for name binding side-effects (which will be described
|
||||
below)::
|
||||
|
||||
from overloading import when
|
||||
|
||||
@overload
|
||||
def flatten(ob: basestring):
|
||||
yield ob
|
||||
|
@ -325,10 +327,11 @@ System (CLOS), or the corresponding "advice" types in AspectJ.
|
|||
Like ``@when``, all of these decorators must be passed the function to
|
||||
be overloaded, and can optionally accept a predicate as well::
|
||||
|
||||
from overloading import before, after
|
||||
|
||||
def begin_transaction(db):
|
||||
print "Beginning the actual transaction"
|
||||
|
||||
|
||||
@before(begin_transaction)
|
||||
def check_single_access(db: SingletonDB):
|
||||
if db.inuse:
|
||||
|
@ -383,6 +386,8 @@ continue the invocation process. "Around" methods are usually used
|
|||
to transform input arguments or return values, or to wrap specific
|
||||
cases with special error handling or try/finally conditions, e.g.::
|
||||
|
||||
from overloading import around
|
||||
|
||||
@around(commit_transaction)
|
||||
def lock_while_committing(__proceed__, db: SingletonDB):
|
||||
with db.global_lock:
|
||||
|
|
Loading…
Reference in New Issue