Re: [web2py] lgoin_bare WTF???

2018-12-12 Thread Ben Duncan
Yes, I wanted to just use the auth_table.
Everything else is controlled outside of the normal mechs ..

Thanks
*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Wed, Dec 12, 2018 at 4:09 PM Anthony  wrote:

> login_bare() is intended to log in the user without the unnecessary form
> processing of login(). Is there some reason you wouldn't what user_groups
> updated upon login? It is the list of auth groups of which the user is a
> member.
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] lgoin_bare WTF???

2018-12-12 Thread Anthony
login_bare() is intended to log in the user without the unnecessary form 
processing of login(). Is there some reason you wouldn't what user_groups 
updated upon login? It is the list of auth groups of which the user is a member.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: count field with update_or_insert()

2018-12-12 Thread Dave S


On Wednesday, December 12, 2018 at 5:38:29 AM UTC-8, Anthony wrote:
>
> I'm actually taking 2 values from the request as the query (q = mytable.x 
>> == request.vars.X and mytable.y == request.vars.Y)
>> [X is  actually not from the vars, but from the env's].  
>> update_or_insert() takes care of making these more or less unique.  The 
>> downside of that is only knowing the id if the insert takes place, so I can 
>> tell if it was an update but not where.  Doing a second query is possible, 
>> I admit.
>>
>
> If you need to do an update-or-insert but need the ID in case of update, 
> then do not use .update_or_insert -- just write your own logic, as it is 
> quite simple.
>  
>

Ah, well, your answer below is way cooler and then I don't need the ID in 
the calling procedure.
 

> a _before_update hook  gives me the id, but how do I add the num_updates 
>> field?  lambda s, f: f.append(dict('num_updates', 2)) doesn't work 
>> (gives an AttributeError).  The ticket says f is really an OpRow, and 
>> anyway I don't want to stick a dict *into* it.  Python dict's have an 
>> update method to, um, concatenate a dict to a dict; does OpRow have 
>> something like that?  And how can I get the present value?
>>
>
> The second argument passed to _before_update is a Row-like object of the 
> fieldnames/values of the update -- so just do this:
>
> def mytable_before_update(s, f):
>   # f['num_updates'] also works.
>   f.num_updates = db.mytable.num_updates + 1
>
> With a lambda, you can do:
>
> lambda s, f: f.set_value('num_updates', db.mytable.num_updates + 1)
>
> Though the .set_value method is not part of the public API, so may not 
> remain backward compatible.
>
> Note, you do not need the current value of num_updates -- if you use an 
> expression like above, the database will do the addition for you. To see 
> what the generated query looks like, try printing db(db.mytable.id == 
> some_id)._update(num_updates=db.mytable.num_updates + 1).
>
> Anthony
>

Very nice! Thanks for all the help; I am always impressed by the expertise 
here.

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Bug in tools.py

2018-12-12 Thread Ben Duncan
Ok, got it fixed. WAS too busy studying the forest of code to notice my
mistake .
The "or not" threw me

Thanks ...

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Wed, Dec 12, 2018 at 1:08 PM Marcelo Huerta 
wrote:

> Please open your nearest Python interpreter and type at the ">>> " prompt:
>
> help("".strip)
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Bug in tools.py

2018-12-12 Thread Marcelo Huerta
Please open your nearest Python interpreter and type at the ">>> " prompt:

help("".strip)


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] lgoin_bare WTF???

2018-12-12 Thread Ben Duncan
 From the Manual:
Manual Authentication

Some times you want to implement your own logic and do "manual" user login.
This can also be done by calling the function:

1

user = auth.login_bare(username, password)

login_bare returns user if the user exists and the password is valid, else
it returns False. username is the email if the "auth_user" table does not
have a "username" field.
*-*
However, the code in login_bare goes about and does this:
if ((user.registration_key is None or not user.registration_key.strip())
   and  password == user[settings.passfield])):
self.login_user(user)
return user

Which is calling login_user, which is trying to do a self.update_groups()

My understanding of login_bare, is that all it is suppose to do is check
that the user exists in the auth_user file.

Is this not true ?

Thanks ...




*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Bug in tools.py

2018-12-12 Thread Ben Duncan
in tools.py,  function :login_bare there is the command:

if ((user.registration_key is None or not user.registration_key.strip()) and
password == user[settings.passfield]):
self.login_user(user)
return user

strip requires the the import of string.method
Shouldn't there be a "import string" after the def login_bare ?

Thanks.

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Where does it GO?

2018-12-12 Thread Ben Duncan
Ok, thanks ..

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Wed, Dec 12, 2018 at 9:36 AM Christian Varas 
wrote:

> It goes to the console where web2py is running or in the error logs of
> apache or nginx if you are running web2py in one of those.
>
> Cheers.
> Chris.
>
> El mié., 12 dic. 2018 11:39 a. m., Ben Duncan 
> escribió:
>
>> If you put a "print" statement in you application (controller or view)
>> where does the output go?
>>
>> (such as 'print "Testpoint 1")
>>
>> Thanks ..
>>
>> *Ben Duncan*
>> DBA / Chief Software Architect
>> Mississippi State Supreme Court
>> Electronic Filing Division
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Where does it GO?

2018-12-12 Thread Christian Varas
It goes to the console where web2py is running or in the error logs of
apache or nginx if you are running web2py in one of those.

Cheers.
Chris.

El mié., 12 dic. 2018 11:39 a. m., Ben Duncan  escribió:

> If you put a "print" statement in you application (controller or view)
> where does the output go?
>
> (such as 'print "Testpoint 1")
>
> Thanks ..
>
> *Ben Duncan*
> DBA / Chief Software Architect
> Mississippi State Supreme Court
> Electronic Filing Division
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Where does it GO?

2018-12-12 Thread Ben Duncan
If you put a "print" statement in you application (controller or view)
where does the output go?

(such as 'print "Testpoint 1")

Thanks ..

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: login_bare not working

2018-12-12 Thread Anthony
On Tuesday, December 11, 2018 at 1:58:11 PM UTC-5, Ben Duncan wrote:
>
> Your right: should be:
> Controller:
> def user_bare():
> username, password = request.post_vars['username'], 
> request.post_vars['password']
> if not auth.user:
>form = auth.login_bare(username, password)
>

.login_bare does not generate a form -- it is form programmatically logging 
in without the Auth login form. If you need the login form, use 
auth.login() (or just use the standard user() action).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: count field with update_or_insert()

2018-12-12 Thread Anthony

>
> I'm actually taking 2 values from the request as the query (q = mytable.x 
> == request.vars.X and mytable.y == request.vars.Y)
> [X is  actually not from the vars, but from the env's].  
> update_or_insert() takes care of making these more or less unique.  The 
> downside of that is only knowing the id if the insert takes place, so I can 
> tell if it was an update but not where.  Doing a second query is possible, 
> I admit.
>

If you need to do an update-or-insert but need the ID in case of update, 
then do not use .update_or_insert -- just write your own logic, as it is 
quite simple.
 

> a _before_update hook  gives me the id, but how do I add the num_updates 
> field?  lambda s, f: f.append(dict('num_updates', 2)) doesn't work (gives 
> an AttributeError).  The ticket says f is really an OpRow, and anyway I 
> don't want to stick a dict *into* it.  Python dict's have an update 
> method to, um, concatenate a dict to a dict; does OpRow have something 
> like that?  And how can I get the present value?
>

The second argument passed to _before_update is a Row-like object of the 
fieldnames/values of the update -- so just do this:

def mytable_before_update(s, f):
  # f['num_updates'] also works.
  f.num_updates = db.mytable.num_updates + 1

With a lambda, you can do:

lambda s, f: f.set_value('num_updates', db.mytable.num_updates + 1)

Though the .set_value method is not part of the public API, so may not 
remain backward compatible.

Note, you do not need the current value of num_updates -- if you use an 
expression like above, the database will do the addition for you. To see 
what the generated query looks like, try printing db(db.mytable.id == 
some_id)._update(num_updates=db.mytable.num_updates + 1).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: removing / hiding SQLFORM.grid links in the view, edit, add forms?

2018-12-12 Thread Paul Ellis
After reading the sqlhtml.py for a while last night. I decided to use the 
same method.

Before creating the grid:
if request.args(-3) in ('edit', 'view'):




On Wednesday, 12 December 2018 00:10:02 UTC+1, Paul Ellis wrote:
>
> I have a grid with some links. One of the buttons is a placeholder which 
> some Jquery attaches to (useless in a the subforms). How do I stop this 
> button from appearing in the subforms Edit and View.
> I don't really want or need any of the links to appear in the subforms.
>
> grid = SQLFORM.grid(query,
> links = [
> lambda row: 'returns a button',
> lambda row: 'returns another button',
> ]
> )
>
> The only thing I can think of is something like this before the grid and 
> the links = links in the grid:
> if 'view' in request.args:
> links = []
> else:
> links = [lambda, lambda, lambda]
> Is there something already in the SQLFORM.grid which can do this?
>
> ** The links do not appear in the Add form. Just in the Edit and View form.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] removing / hiding SQLFORM.grid links in the view, edit, add forms?

2018-12-12 Thread Paul Ellis
@Sandeep
That will disable the view, edit, create forms completely. I want to use
the forms. I just don't want the extra buttons (links) which I use in the
grid to appear in these forms.

On Wed, Dec 12, 2018 at 6:23 AM sandeep patel 
wrote:

> @Paul,
> You can do this way,
> grid = SQLFORM.grid(query,  editable=False,details=False,create=False,..)
>
> Thanks
> SP
>
>
> On Wed, Dec 12, 2018 at 4:40 AM Paul Ellis  wrote:
>
>> I have a grid with some links. One of the buttons is a placeholder which
>> some Jquery attaches to. How do I stop this button from appearing in the
>> subforms add, view etc.
>> I don't really want or need any of the links to appear in the subforms.
>>
>> grid = SQLFORM.grid(query,
>> links = [
>> lambda row: 'returns a button',
>> lambda row: 'returns another button',
>> ]
>> )
>>
>> The only thing I can think of is something like this before the grid and
>> the links = links in the grid:
>> if 'view' in request.args:
>> links = []
>> else:
>> links = [lambda, lambda, lambda]
>> Is there something already in the SQLFORM.grid which can do this?
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/FcnXZz5dRqo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.