<s> from zope . interface import implements <EOL> from twisted . python . components import registerAdapter , Adapter <EOL> from nevow import inevow <EOL> from nevow import loaders <EOL> from nevow import rend <EOL> from nevow import tags as T <EOL> class Person : <EOL> def __init__ ( self , firstName , lastName , nickname ) : <EOL> self . firstName = firstName <EOL> self . lastName = lastName <EOL> self . nickname = nickname <EOL> class Bookmark : <EOL> def __init__ ( self , name , url ) : <EOL> self . name = name <EOL> self . url = url <EOL> class PersonView ( Adapter ) : <EOL> """<STR_LIT>""" <EOL> implements ( inevow . IRenderer ) <EOL> def rend ( self , data ) : <EOL> attrs = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> return T . div ( _class = "<STR_LIT>" ) [ <EOL> T . p [ '<STR_LIT>' ] , <EOL> T . dl [ <EOL> [ ( T . dt [ attr ] , T . dd [ getattr ( self . original , attr ) ] ) <EOL> for attr in attrs ] <EOL> ] <EOL> ] <EOL> class BookmarkView ( Adapter ) : <EOL> """<STR_LIT>""" <EOL> implements ( inevow . IRenderer ) <EOL> def rend ( self , data ) : <EOL> attrs = [ '<STR_LIT:name>' , '<STR_LIT:url>' ] <EOL> return T . div ( _class = "<STR_LIT>" ) [ <EOL> T . p [ '<STR_LIT>' ] , <EOL> T . dl [ <EOL> [ ( T . dt [ attr ] , T . dd [ getattr ( self . original , attr ) ] ) <EOL> for attr in attrs ] <EOL> ] <EOL> ] <EOL> registerAdapter ( PersonView , Person , inevow . IRenderer ) <EOL> registerAdapter ( BookmarkView , Bookmark , inevow . IRenderer ) <EOL> objs = [ <EOL> Person ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> Person ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> Bookmark ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> Person ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> Bookmark ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> Bookmark ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> class Page ( rend . Page ) : <EOL> addSlash = True <EOL> def render_item ( self , ctx , data ) : <EOL> return inevow . IRenderer ( data ) <EOL> docFactory = loaders . stan ( <EOL> T . html [ <EOL> T . body [ <EOL> T . ul ( data = objs , render = rend . sequence ) [ <EOL> T . li ( pattern = '<STR_LIT>' ) [ render_item ] <EOL> ] , <EOL> ] , <EOL> ] <EOL> ) </s>
