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('reportedby', 'string', writable=False, readable=False,
default=auth.user.username if auth.user else 'some_other_default')


Anthony


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('reportedby', 'string', writable=False, readable=False, 
>> default=auth.user.username
>> if auth.user else 'some_other_default')
>>
>
> Anthony
>


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_other_default')
>

Anthony 


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
>
> before form=crud.create(db.mytable)
>
>
> via http://osdir.com/ml/web2py/2010-08/msg01892.html
>
> working for me.
>
>
> 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 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 23, 2012 at 3:16 PM, Larry G. Wapnitsky wrote:
>
>>  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
>> 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 use the ips table access the data in ips by
>> passing query to web2py then you can change your field type to integer and
>> let web2py do it works.
>>
>>  Richard
>>
>> On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky wrote:
>>
>>>  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 submit that variable to the database when my
>>> form is properly filled out.  Nothing more, nothing less.  I know this can
>>> be done using hidden form objects in regular HTML, but I don't see how to
>>> do that with CRUD.
>>>
>>>
>>> On 2/23/2012 3:02 PM, Richard Vézina wrote:
>>>
>>> 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 :
>>>
>>>  def id_to_string(id):
>>> return str(id)
>>>
>>>
>>>  Richard
>>>
>>> On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 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 
 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  > 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),

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/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 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 23, 2012 at 3:16 PM, Larry G. Wapnitsky > wrote:


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 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 use the ips table access the data in
ips by passing query to web2py then you can change your field
type to integer and let web2py do it works.

Richard

On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky
mailto:la...@kvetsch.com>> wrote:

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 submit that
variable to the database when my form is properly filled
out.  Nothing more, nothing less.  I know this can be done
using hidden form objects in regular HTML, but I don't see
how to do that with CRUD.


On 2/23/2012 3:02 PM, Richard Vézina wrote:

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 :

def id_to_string(id):
return str(id)


Richard

On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina
mailto:ml.richard.vez...@gmail.com>> wrote:

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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> wrote:

I need to have the username added to another
SQL table on submission of a form.

This is some of the code:


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 ever you want into that field... But you
will have to ensure by yourself (manually) that you put the proper user
reference from db.auth_user to link you record in both table. Web2py will
not be able to know that there is a relation between those two tables. But
you will be able to make SQL request and code your own request with some
help of web2py.

Hope it helps.

Richard


On Thu, Feb 23, 2012 at 3:24 PM, Larry G. Wapnitsky wrote:

>  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 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 23, 2012 at 3:16 PM, Larry G. Wapnitsky wrote:
>
>>  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
>> 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 use the ips table access the data in ips by
>> passing query to web2py then you can change your field type to integer and
>> let web2py do it works.
>>
>>  Richard
>>
>> On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky wrote:
>>
>>>  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 submit that variable to the database when my
>>> form is properly filled out.  Nothing more, nothing less.  I know this can
>>> be done using hidden form objects in regular HTML, but I don't see how to
>>> do that with CRUD.
>>>
>>>
>>> On 2/23/2012 3:02 PM, Richard Vézina wrote:
>>>
>>> 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 :
>>>
>>>  def id_to_string(id):
>>> return str(id)
>>>
>>>
>>>  Richard
>>>
>>> On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 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 
 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  > wrote:
>
>>  I need to have the username added to another SQL table

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 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 23, 2012 at 3:16 PM, Larry G. Wapnitsky > wrote:


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 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 use the ips table access the data in
ips by passing query to web2py then you can change your field
type to integer and let web2py do it works.

Richard

On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky
mailto:la...@kvetsch.com>> wrote:

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 submit that
variable to the database when my form is properly filled
out.  Nothing more, nothing less.  I know this can be done
using hidden form objects in regular HTML, but I don't see
how to do that with CRUD.


On 2/23/2012 3:02 PM, Richard Vézina wrote:

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 :

def id_to_string(id):
return str(id)


Richard

On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina
mailto:ml.richard.vez...@gmail.com>> wrote:

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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> 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),

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 23, 2012 at 3:16 PM, Larry G. Wapnitsky wrote:

>  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 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 use the ips table access the data in ips by
> passing query to web2py then you can change your field type to integer and
> let web2py do it works.
>
>  Richard
>
> On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky wrote:
>
>>  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 submit that variable to the database when my
>> form is properly filled out.  Nothing more, nothing less.  I know this can
>> be done using hidden form objects in regular HTML, but I don't see how to
>> do that with CRUD.
>>
>>
>> On 2/23/2012 3:02 PM, Richard Vézina wrote:
>>
>> 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 :
>>
>>  def id_to_string(id):
>> return str(id)
>>
>>
>>  Richard
>>
>> On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> 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 
>>> 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 
 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  > wrote:
>

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 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 use the ips table access the data in ips by 
passing query to web2py then you can change your field type to integer 
and let web2py do it works.


Richard

On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky > wrote:


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 submit that variable
to the database when my form is properly filled out.  Nothing
more, nothing less.  I know this can be done using hidden form
objects in regular HTML, but I don't see how to do that with CRUD.


On 2/23/2012 3:02 PM, Richard Vézina wrote:

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 :

def id_to_string(id):
return str(id)


Richard

On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina
mailto:ml.richard.vez...@gmail.com>> wrote:

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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> 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 

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 use the ips table access the data in ips by
passing query to web2py then you can change your field type to integer and
let web2py do it works.

Richard

On Thu, Feb 23, 2012 at 3:07 PM, Larry G. Wapnitsky wrote:

>  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 submit that variable to the database when my
> form is properly filled out.  Nothing more, nothing less.  I know this can
> be done using hidden form objects in regular HTML, but I don't see how to
> do that with CRUD.
>
>
> On 2/23/2012 3:02 PM, Richard Vézina wrote:
>
> 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 :
>
>  def id_to_string(id):
> return str(id)
>
>
>  Richard
>
> On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> 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 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 
>>> 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 
 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
>
>>

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 submit that variable to the database when 
my form is properly filled out.  Nothing more, nothing less.  I know 
this can be done using hidden form objects in regular HTML, but I don't 
see how to do that with CRUD.


On 2/23/2012 3:02 PM, Richard Vézina wrote:
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 :


def id_to_string(id):
return str(id)


Richard

On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina 
mailto:ml.richard.vez...@gmail.com>> wrote:


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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> wrote:

(

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 :

def id_to_string(id):
return str(id)


Richard

On Thu, Feb 23, 2012 at 2:58 PM, Richard Vézina  wrote:

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

>>>
>>
>


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



>>>
>>
>


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 "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 > 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
mailto:la...@kvetsch.com>> 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
mailto:la...@kvetsch.com>> 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









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


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


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', '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 > 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
mailto:la...@kvetsch.com>> 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







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


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





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