#################
# controller
#################
@auth.requires_login()
def groups():
#-------------------------------------------------------------------------------
  # create form
  db.auth_group.role.requires=[IS_NOT_IN_DB
(db,'auth_group.role'),IS_NOT_EMPTY()]
  form=SQLFORM.factory(
      db.auth_group,
      db.auth_membership,
      db.auth_permission,
      )

  # update db
  if form.accepts(request.vars,session):
    user_id=auth.user.id
    group_id=auth.add_group(form.vars.role,form.vars.description)
    membership_id=auth.add_membership(group_id,user_id)
    auth.add_permission(group_id,'create','auth_group',group_id)
    auth.add_permission(group_id,'read','auth_group',group_id)
    auth.add_permission(group_id,'update','auth_group',group_id)
    auth.add_permission(group_id,'delete','auth_group',group_id)
    auth.add_permission(group_id,'select','auth_group',group_id)
    session.flash=DIV(T('Created new group '),'"%s"'%form.vars.role,
        _class='info')
    redirect(URL(r=request,c='default',f='groups'))
  elif form.errors:
    response.flash=DIV(T('Error: did not create new
group'),_class="error")

  # return
  return dict(form=form)

######################
# view
######################
{{
def create_group():
  return DIV(
    form.custom.begin,
    DIV(
      TABLE(
        TR(
          TH(T('Group Name:')),
          TD(form.custom.widget.role),
          ),
        TR(
          TH(form.custom.label['description']),
          TD(form.custom.widget.description),
          ),
        TR(
          TH(form.custom.label['image']),
          TD(form.custom.widget.image),
          ),
        TR(
          TH(form.custom.label['access']),
          TD(form.custom.widget.access),
          ),
        TR(
          TH(form.custom.label['post']),
          TD(form.custom.widget.post,T('Allow members to post
audio')),
          ),
        TR(
          TH(),
          TD(form.custom.submit),
          ),
        _align='center',
        ),
      _class='outer-box',
      ),
    form.custom.end
    )

pass
}}

<h1>Group Entry Form</h1>
{{=create_group()}}
<h1>Errors</h1>
{{=form.errors}}


------------------

this produces the following error:

<Storage {'group_id': 'value not in database!', 'user_id': 'value not
in database!'}>


What am I missing?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to