[web2py] Re: crud newbie question regarding update

2010-01-29 Thread weheh
OK, I see the problem. The .id link created by crud.select points to
the default controller. I need it to point to admin. What's the method
for informing crud to do that? Obviously, I can do a redirect, but
that seems kludgy. Why wouldn't crud.select automatically set the
controller to be the same controller that issued the select?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update [ALMOST THERE]

2010-01-29 Thread weheh


On Jan 29, 1:40 pm, weheh richard_gor...@verizon.net wrote:
 OK, I see the problem. The .id link created by crud.select points to
 the default controller. I need it to point to admin. What's the method
 for informing crud to do that? Obviously, I can do a redirect, but
 that seems kludgy. Why wouldn't crud.select automatically set the
 controller to be the same controller that issued the select?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update [ALMOST THERE]

2010-01-29 Thread weheh
OK, I see the problem. The .id link created by crud.select points to
the default controller. I need it to point to admin. What's the
method
for informing crud to do that? Obviously, I can do a redirect, but
that seems kludgy. Why wouldn't crud.select automatically set the
controller to be the same controller that issued the select?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread mdipierro
form = crud.update(db.person, request.args(0), ...)

this will do an update if you have http://.../action/[id] and a create
if http://.../action


On Jan 28, 1:53 am, weheh richard_gor...@verizon.net wrote:
 changing subject line

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread weheh
Massimo, I don't see how that could possibly work if there's no
request.args(0)? In fact, I tried it and got an invalid function
error. Wouldn't I first have to test not len(request.args(0)) and if
True then create else update? This seems obvious, but it seems that
crud is so compact that it might already be testing that condition,
no?

On Jan 28, 10:02 am, mdipierro mdipie...@cs.depaul.edu wrote:
 form = crud.update(db.person, request.args(0), ...)

 this will do an update if you havehttp://.../action/[id] and a create
 ifhttp://.../action

 On Jan 28, 1:53 am, weheh richard_gor...@verizon.net wrote:



  changing subject line- Hide quoted text -

 - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread mdipierro
request.args[0] fails if there is no request.args. request.args(i)
never fails returns None instead.
If you pass None as second argument to crud.update it behaves as
crud.create. ;-)

On Jan 28, 2:33 pm, weheh richard_gor...@verizon.net wrote:
 Massimo, I don't see how that could possibly work if there's no
 request.args(0)? In fact, I tried it and got an invalid function
 error. Wouldn't I first have to test not len(request.args(0)) and if
 True then create else update? This seems obvious, but it seems that
 crud is so compact that it might already be testing that condition,
 no?

 On Jan 28, 10:02 am, mdipierro mdipie...@cs.depaul.edu wrote:

  form = crud.update(db.person, request.args(0), ...)

  this will do an update if you havehttp://.../action/[id] and a create
  ifhttp://.../action

  On Jan 28, 1:53 am, weheh richard_gor...@verizon.net wrote:

   changing subject line- Hide quoted text -

  - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread weheh
Hi Massimo, I'm sorry, but I don't understand how to do this. I tried
the following:

#controller
def junk():
  form = crud.update(db.content,request.args(2),next=request.url)
  rows=crud.select(...)
  return dict(form=form,rows=rows)

Record creation works OK. But when I click on a rows record id,
expecting the form to populate and then update when I submit, I get an
invalid function error.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread mdipierro
what is the url that gives you invalid record? What is in request.url?
with args(2) and not args(0)?

On Jan 28, 7:20 pm, weheh richard_gor...@verizon.net wrote:
 Hi Massimo, I'm sorry, but I don't understand how to do this. I tried
 the following:

 #controller
 def junk():
   form = crud.update(db.content,request.args(2),next=request.url)
   rows=crud.select(...)
   return dict(form=form,rows=rows)

 Record creation works OK. But when I click on a rows record id,
 expecting the form to populate and then update when I submit, I get an
 invalid function error.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread weheh
http://127.0.0.1:8000/spin/default/junk/read/content/4

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread weheh
The URL is automatically generated by the crud.select and is attached
to the record id. Here's the URL:

http://127.0.0.1:8000/spin/default/marketing/read/content/4

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud newbie question regarding update

2010-01-28 Thread weheh
Oh, Massimo, one other thing. The crud.select is returning the
auth.user.id, whereas I would like to get auth.user.email in the rows
listing. How would I go about doing that? My db.content table has a
field named email:

Field('user',db.auth_user,requires=IS_IN_DB(db,'auth_user.id','%(email)
s'))

But I still only get the auth.user.id value for field user.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.