OpenQuizz
Une application de gestion des contenus pédagogiques
LocalStack Class Reference
Inheritance diagram for LocalStack:
Collaboration diagram for LocalStack:

Public Member Functions

def __init__ (self)
 
def __release_local__ (self)
 
def __ident_func__ (self)
 
def __ident_func__ (self, value)
 
def __call__ (self)
 
def push (self, obj)
 
def pop (self)
 
def top (self)
 

Detailed Description

This class works similar to a :class:`Local` but keeps a stack
of objects instead.  This is best explained with an example::

    >>> ls = LocalStack()
    >>> ls.push(42)
    >>> ls.top
    42
    >>> ls.push(23)
    >>> ls.top
    23
    >>> ls.pop()
    23
    >>> ls.top
    42

They can be force released by using a :class:`LocalManager` or with
the :func:`release_local` function but the correct way is to pop the
item from the stack after using.  When the stack is empty it will
no longer be bound to the current context (and as such released).

By calling the stack without arguments it returns a proxy that resolves to
the topmost item on the stack.

.. versionadded:: 0.6.1

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Member Function Documentation

◆ __call__()

def __call__ (   self)

◆ __ident_func__() [1/2]

def __ident_func__ (   self)

◆ __ident_func__() [2/2]

def __ident_func__ (   self,
  value 
)

◆ __release_local__()

def __release_local__ (   self)

◆ pop()

def pop (   self)
Removes the topmost item from the stack, will return the
old value or `None` if the stack was already empty.

◆ push()

def push (   self,
  obj 
)
Pushes a new item to the stack

◆ top()

def top (   self)
The topmost item on the stack.  If the stack is empty,
`None` is returned.

The documentation for this class was generated from the following file: