Can I help or do something to track it down?

On jún. 28, 20:52, szimszon <szims...@gmail.com> wrote:
> The virtualfields class is not a common python class?
>
> On jún. 28, 09:35, szimszon <szims...@gmail.com> wrote:
>
> > That's weired why is this working:
>
> > class web_sites_extra():
> >   def servername( self ):
> >     return self.web_sites.txt.split()
>
> > and this not:
>
> > class web_sites_extra():
> >   def servername( self ):
> >     r=self.web_sites.txt.split()
> >     return self.web_sites.txt.split()
>
> > or this:
>
> > class web_sites_extra():
> >   def servername( self ):
> >     r="something"
> >     return self.web_sites.txt.split()
>
> > On jún. 28, 09:13, szimszon <szims...@gmail.com> wrote:
>
> > > After the
>
> > >http://www.thadeusb.com/weblog/2009/12/31/web2py_virtualfields_as_an_...
>
> > > webpage I made something like:
> > > --- cut ---
> > > db.define_table( 'web_sites',
> > >                                                                 Field( 
> > > 'web_id', db.web,
> > >                                                                           
> > >               label = T( 'Web config' ),
> > >                                                                           
> > >               requires = IS_IN_DB( db, 'web.id', '%(name)s' ) ),
> > >                                                                 Field( 
> > > 'name', 'string',
> > >                                                                           
> > >               label = T( 'Name' ),
> > >                                                                           
> > >               requires = [IS_NOT_EMPTY()] ),
> > >                                                                 Field( 
> > > 'txt', 'text',
> > >                                                                           
> > >               label = T( 'Config file' ),
> > >                                                                           
> > >               requires = [IS_NOT_EMPTY()] ),
> > >                                                                 Field( 
> > > 'weight', 'integer',
> > >                                                                           
> > >               label = T( 'Weight' ),
> > >                                                                           
> > >               requires = [IS_NOT_EMPTY()] ),
> > >                                                                 Field( 
> > > 'active', 'boolean',
> > >                                                                           
> > >               label = T( 'Active' ),
> > >                                                                           
> > >               default = True,
> > >                                                                           
> > >               ),
> > >                                                                 Field( 
> > > 'modified', 'boolean',
> > >                                                                           
> > >               label = T( 'Modified' ),
> > >                                                                           
> > >               default = True,
> > >                                                                           
> > >               writable = False,
> > >                                                                           
> > >               readable = False,
> > >                                                                           
> > >               ),
> > >  )
>
> > > # computing ServerNames and ServerAliases
> > > ##########################################
> > > class web_sites_extra():
> > >         def servername( self ):
> > >                 def lzy(  ):
> > >                         x = 'sfjha'
> > >                         return x
> > >         return lzy
>
> > > db.web_sites.virtualfields.append( web_sites_extra() )
> > > --- cut ---
>
> > > In the view:
> > > --- cut ---
> > > {{=selected_rows[0].servername()}}
>
> > > But I got:
>
> > >   File "gluon/sql.py", line 665, in __getattr__
> > >     return dict.__getitem__(self,key)
> > > KeyError: 'servername'
>
> > > If I only change:
>
> > > class web_sites_extra():
> > >         def servername( self ):
> > >                 def lzy(  ):
> > >                         x = 'sfjha'
> > >                         return x
> > >         return lzy
>
> > > to:
>
> > > class web_sites_extra():
> > >         def lzy( self ):
> > >                         x = 'sfjha'
> > >                         return x
> > >         def servername( self ):
> > >                 return self.lzy
>
> > > it works.

Reply via email to