Re: [web2py] Name error, but only if I run it in view..

2010-11-24 Thread Ole Martin Maeland
Hi,

That will not work. I just read the output from dict - companies - that is a
query on db.newcomp. So only keys in dict will be the database names - id,
uuid, address. It works for id and uuid, but not for name and address. state
that it is not defined, but it's in the db, it's in the db model. so it's
something else...

but I have no idea..

regards
Ole Martin

def list_companies():
form=crud.create(db.newcomp)
companies=db(db.newcomp.id0).select(orderby=db.newcomp.id)
return dict(companies=companies,form=form)



2010/11/19 Kenneth Lundström kenneth.t.lundst...@gmail.com

  {{for company in companies:}}
  tr
  td{{=uuid}}/td
  td{{=address}}/td
  /tr
 {{pass}}

 Shouldn´t this be like

 td{{=company.uuid}}/td
 td{{=company.address}}/td

 or maybe

 td{{=companies[company].uuid}}/td
 td{{=campanies[company].address}}/td


 Kenneth




-- 
Hilsen
Ole Martin
Mob: 95227471


[web2py] Name error, but only if I run it in view..

2010-11-19 Thread Ole Martin Maeland
Hi,

If anyone have a answer - pls. reply:


*My model:*

db.define_table('newcomp',
Field('uuid', length=64, default=uuid.uuid1()),
Field('name'),
Field('address'))

db.newcomp.uuid.writable=False

when I run this directly from the controller, or in db admin tool is works
fine. When I run it from view I get a name error.

*Here is the view model:*

{{response.files.append(URL(r=request,c='static',f='jquery.dataTables.min.js'))}}
{{response.files.append(URL(r=request,c='static',f='demo_table.css'))}}
{{extend 'layout.html'}}

script
$(document).ready(function() {
   jQuery('.smarttable').dataTable();
});
/script

h1List Companies/h1
[a href=#nil onclick=jQuery('.form').slideToggle();new company/a]
div class=form hidden
br /
{{=form}}
/div

br /br /
table class=smarttable
thead
   tr
  thName/ththcompany/th
   /tr
/thead
tbody
{{for company in companies:}}
tr
   td{{=uuid}}/td
   td{{=address}}/td
/tr
{{pass}}
/tbody
/table

___

this works fine if I use {{=uuid}} and / or {{=id}}. If I add the address or
name field I get this:

Traceback (most recent call last):
  File C:\web2py\web2py\gluon\restricted.py, line 188, in restricted
exec ccode in environment
  File C:\web2py\web2py\applications\tq/views\default/list_newcomp.html,
line 77, in module
NameError: name 'address' is not defined






-- 
Hilsen
Ole Martin
Mob: 95227471


Re: [web2py] Name error, but only if I run it in view..

2010-11-19 Thread Kenneth Lundström

 {{for company in companies:}}
 tr
 td{{=uuid}}/td
 td{{=address}}/td
 /tr
{{pass}}

Shouldn´t this be like

td{{=company.uuid}}/td
td{{=company.address}}/td

or maybe

td{{=companies[company].uuid}}/td
td{{=campanies[company].address}}/td


Kenneth