doc/book/en/development/vreg/appobject.rst
branchstable
changeset 5147 70181998897f
parent 5143 43afbdd5c8b4
equal deleted inserted replaced
5146:fe56baf63ecb 5147:70181998897f
     1 
     1 XXX todo:
     2 
     2 * configure members for doc generated for appojbect class,
     3 The `AppObject` class
     3 * configure module's member into the module
     4 ~~~~~~~~~~~~~~~~~~~~~
     4 * put doc below somewhere else
     5 
       
     6 In general:
       
     7 
       
     8 * we do not inherit directly from this class but from a more specific
       
     9   class such as `AnyEntity`, `EntityView`, `AnyRsetView`,
       
    10   `Action`...
       
    11 
       
    12 * to be recordable, a subclass has to define its own register (attribute
       
    13   `__registry__`) and its identifier (attribute `id`). Usually we do not have
       
    14   to take care of the register, only the identifier `id`.
       
    15 
       
    16 We can find a certain number of attributes and methods defined in this class
       
    17 and common to all the application objects.
       
    18 
       
    19 At recording time, the following attributes are dynamically added to
       
    20 the *subclasses*:
       
    21 
       
    22 * `vreg`, the `vregistry` of the instance
       
    23 * `schema`, the instance schema
       
    24 * `config`, the instance configuration
       
    25 
       
    26 We also find on instances, the following attributes:
       
    27 
       
    28 * ._cw`, `Request` instance
       
    29 * `rset`, the *result set* associated to the object if necessary
       
    30 
     5 
    31 :URL handling:
     6 :URL handling:
    32   * `build_url(*args, **kwargs)`, returns an absolute URL based on the
     7   * `build_url(*args, **kwargs)`, returns an absolute URL based on the
    33     given arguments. The *controller* supposed to handle the response,
     8     given arguments. The *controller* supposed to handle the response,
    34     can be specified through the first positional parameter (the
     9     can be specified through the first positional parameter (the
    50 
    25 
    51 :And more...:
    26 :And more...:
    52 
    27 
    53   * `tal_render(template, variables)`, renders a precompiled page template with
    28   * `tal_render(template, variables)`, renders a precompiled page template with
    54     variables in the given dictionary as context
    29     variables in the given dictionary as context
    55 
       
    56 .. note::
       
    57   When we inherit from `AppObject` (even not directly), you *always* have to use
       
    58   **super()** to get the methods and attributes of the superclasses, and not
       
    59   use the class identifier.
       
    60 
       
    61   For example, instead of writting: ::
       
    62 
       
    63       class Truc(PrimaryView):
       
    64           def f(self, arg1):
       
    65               PrimaryView.f(self, arg1)
       
    66 
       
    67   You must write: ::
       
    68 
       
    69       class Truc(PrimaryView):
       
    70           def f(self, arg1):
       
    71               super(Truc, self).f(arg1)