cwvreg.py
changeset 10496 e95b559a06a2
parent 9984 793377697c81
child 10499 d0907690af55
equal deleted inserted replaced
10495:5bd914ebf3ae 10496:e95b559a06a2
    39 - being the access point to all registries
    39 - being the access point to all registries
    40 
    40 
    41 - handling the registration process at startup time, and during automatic
    41 - handling the registration process at startup time, and during automatic
    42   reloading in debug mode.
    42   reloading in debug mode.
    43 
    43 
    44 .. _AppObjectRecording:
       
    45 
    44 
    46 Details of the recording process
    45 Details of the recording process
    47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    46 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    48 
    47 
    49 .. index::
    48 .. index::
    78 Here are the registration methods that you can use in the `registration_callback`
    77 Here are the registration methods that you can use in the `registration_callback`
    79 to register your objects to the `RegistryStore` instance given as argument (usually
    78 to register your objects to the `RegistryStore` instance given as argument (usually
    80 named `vreg`):
    79 named `vreg`):
    81 
    80 
    82 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register_all
    81 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register_all
       
    82    :noindex:
    83 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register_and_replace
    83 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register_and_replace
       
    84    :noindex:
    84 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register
    85 .. automethod:: cubicweb.cwvreg.CWRegistryStore.register
       
    86    :noindex:
    85 .. automethod:: cubicweb.cwvreg.CWRegistryStore.unregister
    87 .. automethod:: cubicweb.cwvreg.CWRegistryStore.unregister
       
    88    :noindex:
    86 
    89 
    87 Examples:
    90 Examples:
    88 
    91 
    89 .. sourcecode:: python
    92 .. sourcecode:: python
    90 
    93 
   120 registered at all without modification to the `registration_callback`
   123 registered at all without modification to the `registration_callback`
   121 implementation. The previous example will register it though, thanks to the call
   124 implementation. The previous example will register it though, thanks to the call
   122 to the `register_all` method.
   125 to the `register_all` method.
   123 
   126 
   124 
   127 
   125 .. _Selection:
       
   126 
   128 
   127 Runtime objects selection
   129 Runtime objects selection
   128 ~~~~~~~~~~~~~~~~~~~~~~~~~
   130 ~~~~~~~~~~~~~~~~~~~~~~~~~
   129 
   131 
   130 Now that we have all application objects loaded, the question is : when
   132 Now that we have all application objects loaded, the question is : when
   169 
   171 
   170 Other primary views specific to other entity types won't be selectable in this
   172 Other primary views specific to other entity types won't be selectable in this
   171 case. Among selectable objects, the `is_instance('Card')` selector will return a higher
   173 case. Among selectable objects, the `is_instance('Card')` selector will return a higher
   172 score since it's more specific, so the correct view will be selected as expected.
   174 score since it's more specific, so the correct view will be selected as expected.
   173 
   175 
   174 .. _SelectionAPI:
       
   175 
   176 
   176 API for objects selections
   177 API for objects selections
   177 ~~~~~~~~~~~~~~~~~~~~~~~~~~
   178 ~~~~~~~~~~~~~~~~~~~~~~~~~~
   178 
   179 
   179 Here is the selection API you'll get on every registry. Some of them, as the
   180 Here is the selection API you'll get on every registry. Some of them, as the
   180 'etypes' registry, containing entity classes, extend it. In those methods,
   181 'etypes' registry, containing entity classes, extend it. In those methods,
   181 `*args, **kwargs` is what we call the **context**. Those arguments are given to
   182 `*args, **kwargs` is what we call the **context**. Those arguments are given to
   182 selectors that will inspect their content and return a score accordingly.
   183 selectors that will inspect their content and return a score accordingly.
   183 
   184 
   184 .. automethod:: cubicweb.vregistry.Registry.select
   185 .. automethod:: cubicweb.vregistry.Registry.select
       
   186    :noindex:
   185 
   187 
   186 .. automethod:: cubicweb.vregistry.Registry.select_or_none
   188 .. automethod:: cubicweb.vregistry.Registry.select_or_none
       
   189    :noindex:
   187 
   190 
   188 .. automethod:: cubicweb.vregistry.Registry.possible_objects
   191 .. automethod:: cubicweb.vregistry.Registry.possible_objects
       
   192    :noindex:
   189 
   193 
   190 .. automethod:: cubicweb.vregistry.Registry.object_by_id
   194 .. automethod:: cubicweb.vregistry.Registry.object_by_id
       
   195    :noindex:
   191 """
   196 """
   192 
   197 
   193 __docformat__ = "restructuredtext en"
   198 __docformat__ = "restructuredtext en"
   194 _ = unicode
   199 _ = unicode
   195 
   200 
   267 
   272 
   268 class InstancesRegistry(CWRegistry):
   273 class InstancesRegistry(CWRegistry):
   269 
   274 
   270     def selected(self, winner, args, kwargs):
   275     def selected(self, winner, args, kwargs):
   271         """overriden to avoid the default 'instanciation' behaviour, ie
   276         """overriden to avoid the default 'instanciation' behaviour, ie
   272         winner(*args, **kwargs)
   277         `winner(*args, **kwargs)`
   273         """
   278         """
   274         return winner
   279         return winner
   275 
   280 
   276 
   281 
   277 class ETypeRegistry(CWRegistry):
   282 class ETypeRegistry(CWRegistry):