In that case I think you will have to build something on your side... Maybe implement your own IS_IN_DB could be a solution... A hack could be this :
db.ips.reportedby.requires=str(IS_IN_DB()) But I don't think you will be able to define a foreign key... You will have to enforce your integrity check by yourself at the form level with validator... So, change your field definition for string only, no "db.auth_user" and by the way that was wrong model definition I didn't catch at first read... Richard On Thu, Feb 23, 2012 at 2:53 PM, Larry G. Wapnitsky <[email protected]>wrote: > it's only one user that I need to enter into the database at a time, and > only the username. reportedby needs to be text due to another application > that uses the same database. > > > On 2/23/2012 2:51 PM, Richard Vézina wrote: > > Ok, > > So you need to create a foreign key relation... So you need > "requires="... > > db.ips.reportedby.requires=IS_IN_DB(db, 'ips.id', '%(first_name)s > %(last_name)s %(username)s %(whateverfieldname)s') > > If you have only one referenced user you will have to change the type of > reportedby to integer since the id of ips is a int. If you want to > reference many users you will have to add something to you IS_IN_DB > requires : > > db.ips.reportedby.requires=IS_IN_DB(db, 'ips.id', '%(first_name)s > %(last_name)s %(username)s %(whateverfieldname)s', multiple=True) > > And you will have to change also the type of the field for : list:reference > type > > See book chapter 6 whit keyword list:reference > > Richard > > > On Thu, Feb 23, 2012 at 2:43 PM, Larry G. Wapnitsky <[email protected]>wrote: > >> I need to have the username added to another SQL table on submission of >> a form. >> >> This is some of the code: >> >> db.define_table('ips', >> Field('id', 'id'), >> Field('ipaddress','string', length=15, unique=True), >> Field('dateadded', 'datetime', default=request.now), >> Field('reportedby', 'string', db.auth_user, writable=False, >> readable=False), >> Field('updated', 'datetime', default=request.now), >> Field('attacknotes', 'text'), >> Field('b_or_w', 'string', length=1), >> migrate=False) >> >> >> db.ips.ipaddress.requires = [IS_NOT_IN_DB(db, 'ips.ipaddress')] >> db.ips.ipaddress.requires.append(IS_IPV4()) >> >> >> the field 'reportedby' needs to be filled in with the username taken from >> AD for the logged in user. >> >> >> On 2/23/2012 2:37 PM, Richard Vézina wrote: >> >> Ok, but what's is the problem... I don't understand sorry. >> >> Richard >> >> On Thu, Feb 23, 2012 at 2:33 PM, Larry G. Wapnitsky <[email protected]>wrote: >> >>> The issue is not putting the username into the web2py database, but >>> another database that's storing information. >>> >>> On 2/23/2012 2:32 PM, Richard Vézina wrote: >>> >>> I am not sure how you connect to LDAP, but there is utilities to connect >>> LDAP with web2py. You should read about those in the book searching with >>> LDAP as keyword. If you only want to import LDAP user into web2py database >>> table, I suggest you to use the user table of the RBAC. >>> >>> So then you can access those entries with CRUD, but also manage who is >>> allow to access those sensitive informations. >>> >>> Richard >>> >>> On Thu, Feb 23, 2012 at 2:13 PM, Larry Wapnitsky <[email protected]>wrote: >>> >>>> (newbie disclaimer :)) >>>> >>>> I'm logging in to my application via AD/LDAP. I can get the variable >>>> of the username with no issue. What i need to do next is take this >>>> variable and insert it into a field in a CRUD form and have it show in my >>>> database. >>>> >>>> Thanks, >>>> Larry >>>> >>>> >>>> >>> >> >

