Mercurial > hg > pyloader
comparison README.txt @ 7:79676a48f6d8
begin porting and modernizing instructions from wsgiblob to pyloader
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Tue, 24 May 2011 19:12:09 -0700 |
| parents | 6fa6d987b3af |
| children | 4d3ea44fd813 |
comparison
equal
deleted
inserted
replaced
| 6:886009132409 | 7:79676a48f6d8 |
|---|---|
| 1 pyloader | 1 pyloader |
| 2 =========== | 2 =========== |
| 3 | 3 |
| 4 Load python attributes from a string | 4 Load python attributes from strings |
| 5 | |
| 6 JSON Format | |
| 7 ----------- | |
| 8 | |
| 9 pyloader uses a JSON-serializable format for the canonical | |
| 10 (serializable) form of python objects:: | |
| 11 | |
| 12 {'foo': # (arbitrary) object name, | |
| 13 {'args': ['positional', 'arguments'], | |
| 14 'kwargs': {'keyword': 'arguments}, | |
| 15 'path': 'dotted.or.file.path:ObjectName'}, | |
| 16 'bar': ... } # etc | |
| 17 | |
| 18 Objects are instantiated like:: | |
| 19 | |
| 20 ObjectName(*args, **kwargs) | |
| 21 | |
| 22 In the case that the object is not to be instantiated (e.g. a | |
| 23 standalone function, ``args`` and ``kwargs`` will either not be | |
| 24 present or will be None (``null`` in JSON). | |
| 25 | |
| 26 | |
| 27 INI Format | |
| 28 ---------- | |
| 29 | |
| 30 pyloader also features an INI format which is translated to the JSON | |
| 31 Format but adds a few convenience features. A simple object is | |
| 32 expressed as:: | |
| 33 | |
| 34 [foo:dotted.or.file.path:ObjectName] | |
| 35 . = positional, arguments | |
| 36 keyword = arguments | |
| 37 | |
| 38 ``.`` expresses positional arguments which is a comma-separated | |
| 39 list. The remaining (key, value) pairs become keyword arguments. The | |
| 40 section name contains the object name (e.g. ``foo``) followed by a | |
| 41 ``:`` followed by a loading path. Like JSON, a dotted path or a file | |
| 42 path may be used. In addition, other (pluggable) loading paths are | |
| 43 available: | |
| 44 | |
| 45 - override loader: [TODO] | |
| 46 | |
| 47 In addition, .ini files may include other .ini files. This allows for | |
| 48 encapsulation of intent of specific .ini files. | |
| 49 | |
| 5 | 50 |
| 6 ---- | 51 ---- |
| 7 | 52 |
| 8 Jeff Hammel | 53 Jeff Hammel |
| 9 http://k0s.org/ | 54 http://k0s.org/ |
