Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 118

Show
Ignore:
Timestamp:
01/04/05 10:01:38
Author:
cribeiro
Message:

Moved the ExposeItems class out of the lib package init.py. Created a new lib/cptools.py sub-module to hold it another assorted helper functions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/__init__.py

    r117 r118  
    33""" 
    44 
    5 class ExposeItems: 
    6     """ 
    7     Utility class that exposes a getitem-aware object. It does not provide 
    8     index() or default() methods, and it does not expose the individual item 
    9     objects - just the list or dict that contains them. User-specific index() 
    10     and default() methods can be implemented by inheriting from this class. 
    11      
    12     Use case: 
    13      
    14     from cherrypy.lib import ExposeItems 
    15     ... 
    16     cpg.root.foo = ExposeItems(mylist) 
    17     cpg.root.bar = ExposeItems(mydict) 
    18     """ 
    19     exposed = True 
    20     def __init__(self, items): 
    21         self.items = items 
    22     def __getattr__(self, key): 
    23         return self.items[key] 

Hosted by WebFaction

Log in as guest/cpguest to create tickets