Thanks Julio,
I changed some things around but still have not got it working. Here
is my code:
now I have a problem with "id"
model:
db.define_table("prodj",
SQLField("timestamp",'datetime',default=now),
SQLField("uuid",length=128,writable=False,default=str(uuid.uuid4
())),
SQLField("active",'boolean',default=True),
SQLField("name"))
db.define_table('discuss',
SQLField('uuid',length=128,writable=False,default=str
(uuid.uuid4())),
SQLField('score','integer',default=1),
SQLField('timestamp','datetime',default=now),
SQLField('author_name',db.auth_user),
SQLField('author_alias'),
SQLField('author_email'),
SQLField('parente','integer',default=0),
SQLField('prodj',db.prodj),
SQLField('body','text'),
SQLField('flagged','boolean',default=False))
controller:
@auth.requires_login()
def show():
"shows a wiki prodj"
#try:
prodj=int(request.args[0])
#prodj=db(db.prodj.id==request.args[0]).select()[0]
#except: redirect(URL(r=request,f='index'))
if session.authorized:
form=SQLFORM(db.discuss,fields=['body'],labels={'body':''})
form.vars.author=session.authorized
form.vars.author_alias=session.alias
form.vars.prodj=prodj
if form.accepts(request.vars,formname='0'):
response.flash='discuss posted'
else: form=None
#try:
#item=db(db.prodj.id==prodj).select()[0]
item=db(db.prodj.id==request.args[0]).select()[0]
discuss=db(db.discuss.id==prodj.id).select
(orderby=~db.discuss.score)
#except: redirect(URL(r=request,f='index'))
items=[]
tree={}
forms={}
for c in discuss:
if not tree.has_key(c.parente): tree[c.parente]=[c]
else: tree[c.parente].append(c)
if session.authorized:
f=SQLFORM(db.discuss,fields=['body'],labels={'body':''})
f.vars.author=session.authorized
f.vars.author_alias=session.alias
f.vars.prodj=prodj
f.vars.parente=c.id
if f.accepts(request.vars,formname=str(c.id)):
session.flash='discuss posted'
redirect(URL(r=request,args=request.args))
forms[c.id]=f
return dict
(prodj=prodj,item=item,form=form,tree=tree,forms=forms,parent=0)
traceback:
WARNING 2009-04-14 09:41:43,703 cache.py] no cache.disk
ERROR 2009-04-14 09:41:43,983 main.py] Traceback (most recent call
last):
File "c:\apps\web2py\gluon\restricted.py", line 98, in restricted
exec ccode in environment
File "c:\apps\web2py\applications\fabmonger/controllers/default.py",
line 246, in <module>
File "c:\apps\web2py\gluon\globals.py", line 75, in <lambda>
self._caller = lambda f: f()
File "c:\apps\web2py\gluon\tools.py", line 989, in f
return action(*a, **b)
File "c:\apps\web2py\applications\fabmonger/controllers/default.py",
line 94, in show
discuss=db(db.discuss.id==prodj.id).select
(orderby=~db.discuss.score)
AttributeError: 'int' object has no attribute 'id'
INFO 2009-04-14 09:41:44,046 dev_appserver.py] "GET /fabmonger/
default/show/2 HTTP/1.1" 200 -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---