Hard to say without seeing models for db.application and db.version
but this may be what you're looking for:

def downloadApp():
    query = db(db.userSoftware.user_id==auth.user_id) & \
              db(db.userSoftware.application_id == request.args(0)
    existing = db(query).count()
    if not existing:
 
db.userSoftware.insert(user_id=auth.user_id,application_id=request.args(0))
    return response.download(request,db)


On Mar 21, 2:53 am, Matthew McNaughton <mamcnaugh...@gmail.com> wrote:
> Ok, so I'm trying to create a Download function that keeps track of the
> files that the user downloads and updates a database table.
>
> The database model is:
> ------------------------------------------------
> db.define_table('userSoftware',
>     Field('user_id', db.auth_user),
>     Field('application_id', db.application),
>     Field('version_id', db.version),
>     Field('Release_Date', db.version))
> -----------------------------------------------
>
> I'm trying to write a Download function that will update the above table
> with the a new row if it is a new file that the user is downloading. My
> current download function is below:
> -------------------------------
> def downloadApp():
>     if((db(db.userSoftware.user_id == auth.id).count())==0) :
>         db().update(db.userSoftware.user_id = auth.user_id)
>     else:
> #        db().update(db.userSoftware.user_id = auth.user_id)
>
>     return response.download(request,db)
> -------------------------------
>
> The reason I haven't been able to get much farther than this is because
> I get the following traceback error:
> -------------------------------
> Traceback (most recent call last):
>   File "/home/matthewm/Downloads/web2py/gluon/restricted.py", line 171, in 
> restricted
>     ccode = compile(code.replace('\r\n', '\n'), layer, 'exec')
>   File 
> "/home/matthewm/Downloads/web2py/applications/Amso/controllers/default.py", 
> line 43
>     db().update(db.userSoftware.user_id = auth.user_id)
> SyntaxError: keyword can't be an expression
>
> I'm not really what the syntax error is complaining about.
> Also what are the different arguments that are request.args? Massimo mentioned
> that request.args[0] was the filename. What are the others?
>
> Thank you again for all the assistance.
>
> On Sat, 2010-03-20 at 10:42 -0700, mdipierro wrote:
> > You can put them in db.py after auth=..., or in a registration
> > controller or simply in the user() action. As long as they are
> > executed before the registration form runs.
>
> > Massimo
>
> > On Mar 20, 12:30 pm, Matthew McNaughton <mamcnaugh...@gmail.com>
> > wrote:
> > > DO the commands in 1) go into the db.py after auth=Auth(globals(),db) or
> > > in a new controller that is created for user registration?
>
> > > On Sat, 2010-03-20 at 08:03 -0700, mdipierro wrote:
> > > > Good questions:
>
> > > > 1)
>
> > > > if not db(db.auth_group.role=='users').count():
> > > >      db.auth_group.insert(role='users')
> > > > auth.settings.register_onaccept=lambda form:
> > > > auth.add_membership(auth.id_group('users'),form.vars.id)
>
> > > > 2)
> > > > Not sure what you mean by file renaming. Can you explain more?
> > > > To keep track of downloads create your own download function
>
> > > > def download():
> > > >     ### log the download, filename is in request.args(0) and user in
> > > > auth.user_id
> > > >     return response.download(request,db)
>
> > > > On Mar 20, 2:11 am, Matthew McNaughton <mamcnaugh...@gmail.com> wrote:
> > > > > Greetings all,
> > > > > I've read the access control section in book a couple times over, and 
> > > > > I
> > > > > still can't completely figure out authorization. I want to do the
> > > > > following:
> > > > > I want to add all newly registered users to a specific group called
> > > > > "users", which I have already created in auth_groups
>
> > > > > I have another group called "admin" which can add records to the 
> > > > > various
> > > > > databases. The only way to begin this user is use the web2py
> > > > > administrator login. Where do I put the access privileges for this
> > > > > group?
>
> > > > > A related question. If I have certain files that the user can upload 
> > > > > and
> > > > > download. How do i manage the file renaming in the mysql db? Also, how
> > > > > do I keep track of the files that a user download from the server.
>
> > > > > I apologize for the newb questions. Thank you again for all the help 
> > > > > so
> > > > > far.
>
>

-- 
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.

Reply via email to