Re: [web2py] Re: Attribute Error
On Sun, Apr 10, 2011 at 11:07 AM, Anthony wrote: > It works for me. Are you sure you're problem is with {{=n.name}}. The error > message you got looks like a NameError, not an AttributeError. Are you > referring to a variable 'name' somewhere in your view (or controller)? Can > you show your full controller and view code? > > Anthony > On Sunday, April 10, 2011 9:48:26 AM UTC-4, David J wrote: >> >> I am passing a list of employees >> >> so in my view I have >> >> {{ for n in employees:} >> >> {{= n.name }} >> >> {{pass}} Try something like this. In your controller: create your list of employees, ie: employees = [] class Employee: pass john = Employee() # Create an empty employee record # Fill the fields of the record john.name = 'John Doe' john.dept = 'computer lab' john.salary = 1000 employees.append(john) return (employees=employees) In your view, your code should work: {{ for n in employees:}} {{= n.name }} {{pass}} Hope it works for you. Joaquin.
Re: [web2py] Re: Attribute Error
It works for me. Are you sure you're problem is with {{=n.name}}. The error message you got looks like a NameError, not an AttributeError. Are you referring to a variable 'name' somewhere in your view (or controller)? Can you show your full controller and view code? Anthony On Sunday, April 10, 2011 9:48:26 AM UTC-4, David J wrote: > I am passing a list of employees > > so in my view I have > > {{ for n in employees:} > > {{= n.name }} > > {{pass}} > > On 4/10/11 9:10 AM, DenesL wrote: > > > > On Apr 10, 5:53 am, "David J." wrote: > >> In my controller I am defining a class > >> > >> class Employee: > >> pass > >> > >> john = Employee() # Create an empty employee record > >> > >> # Fill the fields of the record > >> john.name = 'John Doe' > >> john.dept = 'computer lab' > >> john.salary = 1000 > >> > >> and in my view > >> > >> I am trying {{=employee.name}} > > How are you setting employee?. > > > >> It throws an attribute exception > >> > >> 'p23 S'("name \'name\' is not defined",)' > >> > >> I am using trunk version; Perhaps I am doing something wrong. > >> > >> Thanks. > >
Re: [web2py] Re: Attribute Error
I am passing a list of employees so in my view I have {{ for n in employees:} {{= n.name }} {{pass}} On 4/10/11 9:10 AM, DenesL wrote: On Apr 10, 5:53 am, "David J." wrote: In my controller I am defining a class class Employee: pass john = Employee() # Create an empty employee record # Fill the fields of the record john.name = 'John Doe' john.dept = 'computer lab' john.salary = 1000 and in my view I am trying {{=employee.name}} How are you setting employee?. It throws an attribute exception 'p23 S'("name \'name\' is not defined",)' I am using trunk version; Perhaps I am doing something wrong. Thanks.