Changes between Initial Version and Version 1 of ObjectReferences


Ignore:
Timestamp:
09/23/2008 01:25:35 AM (9 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ObjectReferences

    v1 v1  
     1{{{ 
     2#!rst 
     3Object references 
     4================= 
     5 
     6Object references are textual references to Python objects. There are 
     7especially used in the :wiki:`ApplicationConfiguration` files to indicate what 
     8Python objects to use. 
     9 
     10The general form of an object reference is: ``<schema> <path>:<object_name>``. 
     11Given such an object reference, the ``load_object()`` method of 
     12:apidoc:`nagare.admin.util#util.load_object` returns a tuple where the 
     13first item is the Python object, and the second item is the 
     14`distribution <http://peak.telecommunity.com/DevCenter/PkgResources#distribution-objects>`_ 
     15where this object is located, if found. 
     16 
     17The available ``schemas`` are: 
     18 
     19  - ``python <module_path>:<object_name>`` -- a reference to an object in a 
     20    Python module. The Python module is searched using ``sys.path``. This 
     21    schema is used by default if no schema is given. 
     22 
     23    .. code-block:: pycon 
     24     
     25       >>> from nagare.admin import util 
     26       >>> util.load_object('python xml.sax.xmlreader:XMLReader') 
     27       (<class xml.sax.xmlreader.XMLReader at 0x851f17c>, None) 
     28       >>> util.load_object('xml.sax.xmlreader:XMLReader') 
     29       (<class xml.sax.xmlreader.XMLReader at 0x851f17c>, None) 
     30 
     31  - ``file <filename>:<object_name>`` -- a reference to an object in a Python 
     32    file. 
     33 
     34    .. code-block:: pycon 
     35 
     36       >>> from nagare.admin import util 
     37       >>> util.load_object('file /usr/lib/python2.5/xml/sax/xmlreader.py:XMLReader') 
     38       (<class xmlreader.XMLReader at 0x851f62c>, None) 
     39 
     40  - ``app <application_name>`` -- a reference to a registered Nagare application 
     41    entry point. 
     42      
     43    .. code-block:: pycon 
     44     
     45       >>> from nagare.admin import util 
     46       >>> util.load_object('app admin') 
     47       (<nagare.admin.admin_app.WSGIApp object at 0x8b5148c>, nagare 0.1.0 (/home/apr/projects/nagare/dev/src/nagare/core)) 
     48 
     49  - ``egg <distribution_name>:<application_name>`` -- a reference to a specific 
     50    registered Nagare application entry point of a distribution. 
     51   
     52    .. code-block:: pycon 
     53     
     54       >>> from nagare.admin import util 
     55       >>> util.load_object('egg nagare.examples:wiki') 
     56       (<class 'nagare.examples.wiki.wiki9.Wiki'>, nagare.examples 0.1.0 (/home/apr/projects/nagare/dev/src/nagare/examples)) 
     57 
     58.. wikiname: ObjectReferences 
     59}}}