Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
that works even better than what I found. Thanks, Anthony! On 2/23/2012 3:48 PM, Anthony wrote: db.define_table('ips', Field('id', 'id'), Field('ipaddress','string', length=15, unique=True), Field('dateadded', 'datetime', default=request.now), Field('reporte

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
It was difficult to understand what he wants to do... Richard On Thu, Feb 23, 2012 at 3:48 PM, Anthony wrote: > db.define_table('ips', >> Field('id', 'id'), >> Field('ipaddress','string', length=15, unique=True), >> Field('dateadded', 'datetime', default=request.now), >> Field('

Re: [web2py] inserting username into database

2012-02-23 Thread Anthony
> > db.define_table('ips', > Field('id', 'id'), > Field('ipaddress','string', length=15, unique=True), > Field('dateadded', 'datetime', default=request.now), > Field('reportedby', 'string', writable=False, readable=False, > default=auth.user.username > if auth.user else 'some_oth

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
Happy you solve your big problem Richard On Thu, Feb 23, 2012 at 3:37 PM, Larry G. Wapnitsky wrote: > found this: > > yes you can do this: > > db.mytable.myfield.default='best' > db.mytable.myfield.writable=False # user cannot change it > db.mytable.myfield.readable=False # user does not see it

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
found this: yes you can do this: db.mytable.myfield.default='best' db.mytable.myfield.writable=False # user cannot change it db.mytable.myfield.readable=False # user does not see it before form=crud.create(db.mytable) via http://osdir.com/ml/web2py/2010-08/msg01892.html working for me. On 2

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
Because you don't use the proper type for the field to allow web2py to work properly... An other solution : remove "db.auth_user, writable=False, readable=False" from this line : Field('reportedby', 'string', db.auth_user, writable=False, readable=False), Then you will be able to put what ev

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
two tables does not simplify things. why can i not just enter that variable into a crud submission? On 2/23/2012 3:24 PM, Richard Vézina wrote: Sorry, my english is terrilble sometimes... I just thought about an other solution : You could have two ips table one that interact with web2py and

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
Sorry, my english is terrilble sometimes... I just thought about an other solution : You could have two ips table one that interact with web2py and an other for your other program that access ips table. Then you will have to trigger data synchronisation between the 2 tables. Richard On Thu, Feb

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
I apologize, but there is a bit of a language barrier here. What you've written is very confusing to me On 2/23/2012 3:14 PM, Richard Vézina wrote: How your other system call you ips table? Directly at backend level? If so you can't just use the proper field type to make work web2py correctly

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
How your other system call you ips table? Directly at backend level? If so you can't just use the proper field type to make work web2py correctly and use plainfully you will have to master much more web2py and how it works to make it works the way you need it to work. If the orther program that us

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
I'm pretty lost in everything you've described. I've been working with web2py for 2+ days and am slowly getting the hang of it. If you could dumb it down a bit, that would be helpful. FYI - I can print the username using auth.user_id.username anyplace else in a web page. I just need to subm

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
I am pretty not sure about the hack, but you can try... It is pretty dirty... And you will not be able to use represent except if you transform back you id from string to int. Why you don't just write a simple function that you other ressource will call to get the ids under string format like this

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
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 ch

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
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 "requir

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
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

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
You maybe have to redefine the auth_user models to append new fields... If you add username field web2py will use the values stored there as login automatically. But for that you have to redefine the user table. Then you can use CRUD as well... Richard On Thu, Feb 23, 2012 at 2:37 PM, Richard

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
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', 'stri

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
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 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: > >

Re: [web2py] inserting username into database

2012-02-23 Thread Larry G. Wapnitsky
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 search

Re: [web2py] inserting username into database

2012-02-23 Thread Richard Vézina
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 acces