Well there's not error message right now - but if I move these two lines:

auth = Auth(db)
auth.define_tables(username=True)

 back to the beginning of the file (after the from ...) then I get this:

Traceback (most recent call last):
  File "/Applications/web2py.app/Contents/MacOS/gluon/restricted.py", line 
219, in restricted
    exec(ccode, environment)
  File 
"/Applications/web2py.app/Contents/MacOS/applications/Images/models/db.py", 
line 9, in <module>
    auth = Auth(db)
NameError: name 'db' is not defined

In what would appear to my (very) untrained eye - if I leave them at the 
end of the file then there is no error ... but no authentication either.


On Wednesday, April 22, 2020 at 4:30:31 PM UTC-4, Jim S wrote:
>
> Jon
>
> Can you post the traceback that you're receiving?
>
> -Jim
>
> On Wednesday, April 22, 2020 at 3:08:14 PM UTC-5, Jon Paris wrote:
>>
>> In the section on basic Authentication in the documents (
>> http://web2py.com/books/default/chapter/29/03/overview#An-image-blog) it 
>> says to include in the model the following:
>>
>> from gluon.tools import Auth
>> auth = Auth(db)
>> auth.define_tables(username=True)
>>
>> And to add this to the default controller.
>>
>> def user():
>>     return dict(form=auth())
>>
>> But _where_?  
>>
>> The def user(); part was already in the base controller.
>>
>> So I just added the "from ..." to the start of the file where it already 
>> had:
>> from gluon.contrib.appconfig import AppConfig
>>
>> That cause the app to fail with a message that db did not exist.
>>
>> So I moved the two action lines down to the end following the table 
>> definition. No error that way but no authentication occurs either.
>>
>> So where is the stuff supposed to go so that it is actioned? 
>>
>>
>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/535b6e39-a1a8-48bb-944a-f836b9d6e835%40googlegroups.com.

Reply via email to