@@ -193,12 +193,16 @@ def __init__(self, client):
193193 # we want config to be exposed
194194 self .config = client .db .config
195195
196+ def __getitem__ (self , item ):
197+ self ._client .db .getclass (item )
198+ return HTMLClass (self ._client , item )
199+
196200 def __getattr__ (self , attr ):
197201 try :
198- self . _client . db . getclass ( attr )
202+ return self [ attr ]
199203 except KeyError :
200204 raise AttributeError , attr
201- return HTMLClass ( self . _client , attr )
205+
202206 def classes (self ):
203207 l = self ._client .db .classes .keys ()
204208 l .sort ()
@@ -857,27 +861,27 @@ def plain(self, escape=0):
857861 value = cgi .escape (value )
858862 return value
859863
860- def field (self ):
864+ def field (self , showid = 0 , size = None ):
861865 ''' Render a form edit field for the property
862866 '''
863867 linkcl = self ._db .getclass (self ._prop .classname )
864868 if linkcl .getprops ().has_key ('order' ):
865869 sort_on = 'order'
866870 else :
867871 sort_on = linkcl .labelprop ()
868- options = linkcl .filter (None , {}, [ sort_on ], [])
872+ options = linkcl .filter (None , {}, ( '+' , sort_on ), ( None , None ))
869873 # TODO: make this a field display, not a menu one!
870- l = ['<select name="%s">' % property ]
874+ l = ['<select name="%s">' % self . _name ]
871875 k = linkcl .labelprop (1 )
872- if value is None :
876+ if self . _value is None :
873877 s = 'selected '
874878 else :
875879 s = ''
876880 l .append (_ ('<option %svalue="-1">- no selection -</option>' )% s )
877881 for optionid in options :
878882 option = linkcl .get (optionid , k )
879883 s = ''
880- if optionid == value :
884+ if optionid == self . _value :
881885 s = 'selected '
882886 if showid :
883887 lab = '%s%s: %s' % (self ._prop .classname , optionid , option )
@@ -999,6 +1003,8 @@ def field(self, size=30, showid=0):
9991003 if value :
10001004 value .sort (sortfunc )
10011005 # map the id to the label property
1006+ if not linkcl .getkey ():
1007+ showid = 1
10021008 if not showid :
10031009 k = linkcl .labelprop (1 )
10041010 value = [linkcl .get (v , k ) for v in value ]
0 commit comments