[web2py] Microsoft SQL Server Migrate Trying to Create New Table instead of Editing Old One

2013-09-28 Thread PN
Version: Using web2py 2.6.4

Steps:

1. I used web2py DAL to create a table in ms sql. This ran in production 
for a while.

2. I downloaded the web2py app to my development machine, and added a 
column to the table in DAL.

3. When I try to go to the table in web2py admin (database administration) 
with migrate=True, I get an error message " ('42S01', "[42S01] [Microsoft][ODBC SQL Server 
Driver][SQL Server]There is already an object named 'BIG_Mapping' in the 
database. (2714) (SQLExecDirectW)")

4. The error message shows that web2py is issuing a CREATE command, not the 
ALTER command (in the error log)

Any suggestions on further troubleshooting? I can alter the table manually 
but wanted to test migrations through DAL so I understand them for future 
reference.

-- 
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/groups/opt_out.


[web2py] Re: Microsoft SQL Server Migrate Trying to Create New Table instead of Editing Old One

2013-10-04 Thread PN
So, in theory, will the following process fix the issue?

1. Start web2py with old DAL definitions and migrate = True. This should 
create the .table files as the old structure
2. Then change the DAL to reflect the new database structure, migrate still 
= True
3. Restart web2py and my tables should get migrated?

On Sunday, September 29, 2013 7:45:32 AM UTC-4, Niphlod wrote:
>
> probably your .table files weren't in sync with your model. web2py issues 
> a CREATE statement only if the corresponding .table file is not found into 
> the databases/ folder (implicating that that table doesn't exist on the 
> backend)
>
> On Sunday, September 29, 2013 2:06:50 AM UTC+2, PN wrote:
>>
>> Version: Using web2py 2.6.4
>>
>> Steps:
>> 
>> 1. I used web2py DAL to create a table in ms sql. This ran in production 
>> for a while.
>>
>> 2. I downloaded the web2py app to my development machine, and added a 
>> column to the table in DAL.
>>
>> 3. When I try to go to the table in web2py admin (database 
>> administration) with migrate=True, I get an error message "> 'pyodbc.ProgrammingError'> ('42S01', "[42S01] [Microsoft][ODBC SQL Server 
>> Driver][SQL Server]There is already an object named 'BIG_Mapping' in the 
>> database. (2714) (SQLExecDirectW)")
>>
>> 4. The error message shows that web2py is issuing a CREATE command, not 
>> the ALTER command (in the error log)
>>
>> Any suggestions on further troubleshooting? I can alter the table 
>> manually but wanted to test migrations through DAL so I understand them for 
>> future reference.
>>
>

-- 
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/groups/opt_out.


[web2py] Re: Microsoft SQL Server Migrate Trying to Create New Table instead of Editing Old One

2014-01-08 Thread PN
For future reference, verifying that this can be fixed using the 
fake_migrate feature (
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Fixing-broken-migrations
)

Summary of steps:
1. Set your model in define_table to the old model that matches existing 
database
2. Set fake_migrate to True in define_table(..., migrate=True, 
fake_migrate=True)
3. Run your app - this will create the migrate files
4. Remove the fake_migrate argument from define_table
5. Run your app again, this will do a migrate with an ALTER instead of a 
CREATE

On Thursday, October 3, 2013 3:45:17 PM UTC-4, PN wrote:
>
> So, in theory, will the following process fix the issue?
>
> 1. Start web2py with old DAL definitions and migrate = True. This should 
> create the .table files as the old structure
> 2. Then change the DAL to reflect the new database structure, migrate 
> still = True
> 3. Restart web2py and my tables should get migrated?
>
> On Sunday, September 29, 2013 7:45:32 AM UTC-4, Niphlod wrote:
>>
>> probably your .table files weren't in sync with your model. web2py issues 
>> a CREATE statement only if the corresponding .table file is not found into 
>> the databases/ folder (implicating that that table doesn't exist on the 
>> backend)
>>
>> On Sunday, September 29, 2013 2:06:50 AM UTC+2, PN wrote:
>>>
>>> Version: Using web2py 2.6.4
>>>
>>> Steps:
>>> 
>>> 1. I used web2py DAL to create a table in ms sql. This ran in production 
>>> for a while.
>>>
>>> 2. I downloaded the web2py app to my development machine, and added a 
>>> column to the table in DAL.
>>>
>>> 3. When I try to go to the table in web2py admin (database 
>>> administration) with migrate=True, I get an error message ">> 'pyodbc.ProgrammingError'> ('42S01', "[42S01] [Microsoft][ODBC SQL Server 
>>> Driver][SQL Server]There is already an object named 'BIG_Mapping' in the 
>>> database. (2714) (SQLExecDirectW)")
>>>
>>> 4. The error message shows that web2py is issuing a CREATE command, not 
>>> the ALTER command (in the error log)
>>>
>>> Any suggestions on further troubleshooting? I can alter the table 
>>> manually but wanted to test migrations through DAL so I understand them for 
>>> future reference.
>>>
>>

-- 
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/groups/opt_out.


[web2py] DAL has not attribute db when field is a reference to another table

2014-03-06 Thread PN
When I use a query which uses a reference type field, I get the 
error:  'DAL' object has no attribute 
'db' 
In my code below, db.Units.site_id is a reference field. The error only 
happens when I use this field and not on other fields of the table.

The relevant traceback seems to be:

  File "C:/web2py/applications/mgmt/controllers/programs.py" 
, line 
170, in nyserda
units = db(db.Units.site_id == 1)._select()
  File "C:\web2py\gluon\dal.py", line 10359, in _select
return adapter._select(self.query,fields,attributes)
  File "C:\web2py\gluon\dal.py", line 1774, in _select
sql_w = ' WHERE ' + self.expand(query) if query else ''
  File "C:\web2py\gluon\dal.py", line 1541, in expand
out = op(first, second, **optional_args)
  File "C:\web2py\gluon\dal.py", line 1438, in EQ
self.expand(second, first.type))
  File "C:\web2py\gluon\dal.py", line 1552, in expand
return str(self.represent(expression,field_type))
  File "C:\web2py\gluon\dal.py", line 3519, in represent
return BaseAdapter.represent(self, obj, fieldtype)
  File "C:\web2py\gluon\dal.py", line 2018, in represent
ftype = self.db[p[0]][p[2]].type
  File "C:\web2py\gluon\dal.py", line 8322, in __getitem__
return self.__getattr__(str(key))
  File "C:\web2py\gluon\dal.py", line 8329, in __getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'db'


The issues seems to be in line 2018 of dal.py
I looked through the code on github but the change happened a while ago, so 
not sure if it is just something I am doing wrong or the code is buggy. The 
code snippet is from the represent function (highlighted in yellow). Any 
suggestions?

elif field_is_type('reference'): # reference
# check for tablename first
referenced = fieldtype[9:].strip()
if referenced in self.db.tables:
return str(long(obj))
p = referenced.partition('.')
if p[2] != '':
try:
*ftype = self.db[p[0]][p[2]].type*
return self.represent(obj, ftype)
except (ValueError, KeyError):
return repr(obj)
elif isinstance(obj, (Row, Reference)):
return str(obj['id'])
return str(long(obj))

-- 
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: DAL has not attribute db when field is a reference to another table

2014-03-06 Thread PN
On further digging, I see that this set of lines - around 2018 in dal.py 
were changed from a much simpler version that did not use self.db. However, 
I still don't see why the code throws a self.db error on line 2018, instead 
of in, say a few lines about it when the code again references self.db (if 
referenced in self.db.tables:)


On Friday, March 7, 2014 12:31:09 AM UTC-5, PN wrote:
>
> When I use a query which uses a reference type field, I get the 
> error:  'DAL' object has no attribute 
> 'db' 
> In my code below, db.Units.site_id is a reference field. The error only 
> happens when I use this field and not on other fields of the table.
>
> The relevant traceback seems to be:
>
>   File "C:/web2py/applications/mgmt/controllers/programs.py" 
> <http://127.0.0.1:8000/admin/default/edit/mgmt/controllers/programs.py>, line 
> 170, in nyserda
> units = db(db.Units.site_id == 1)._select()
>   File "C:\web2py\gluon\dal.py", line 10359, in _select
> return adapter._select(self.query,fields,attributes)
>   File "C:\web2py\gluon\dal.py", line 1774, in _select
> sql_w = ' WHERE ' + self.expand(query) if query else ''
>   File "C:\web2py\gluon\dal.py", line 1541, in expand
> out = op(first, second, **optional_args)
>   File "C:\web2py\gluon\dal.py", line 1438, in EQ
> self.expand(second, first.type))
>   File "C:\web2py\gluon\dal.py", line 1552, in expand
> return str(self.represent(expression,field_type))
>   File "C:\web2py\gluon\dal.py", line 3519, in represent
> return BaseAdapter.represent(self, obj, fieldtype)
>   File "C:\web2py\gluon\dal.py", line 2018, in represent
> ftype = self.db[p[0]][p[2]].type
>   File "C:\web2py\gluon\dal.py", line 8322, in __getitem__
> return self.__getattr__(str(key))
>   File "C:\web2py\gluon\dal.py", line 8329, in __getattr__
> return ogetattr(self, key)
> AttributeError: 'DAL' object has no attribute 'db'
>
>
> The issues seems to be in line 2018 of dal.py
> I looked through the code on github but the change happened a while ago, 
> so not sure if it is just something I am doing wrong or the code is buggy. 
> The code snippet is from the represent function (highlighted in yellow). 
> Any suggestions?
>
> elif field_is_type('reference'): # reference
> # check for tablename first
> referenced = fieldtype[9:].strip()
> if referenced in self.db.tables:
> return str(long(obj))
> p = referenced.partition('.')
> if p[2] != '':
> try:
> *ftype = self.db[p[0]][p[2]].type*
> return self.represent(obj, ftype)
> except (ValueError, KeyError):
> return repr(obj)
> elif isinstance(obj, (Row, Reference)):
> return str(obj['id'])
> return str(long(obj))
>
>

-- 
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: DAL has not attribute db when field is a reference to another table

2014-03-06 Thread PN
Problem found and fixed - it was in my own code. I was using the wrong 
format to reference another table, changed it to match what is specified in 
the web2py book and all is well.

-- 
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: Scheduler: plugin cs_plugin_monitor updated to 2.0.1

2014-11-02 Thread pn
Looks really impressive! Will check out the code tomorrow. Are you looking 
for any help besides code-review/comments?

On Sunday, November 2, 2014 8:49:51 AM UTC-5, Niphlod wrote:
>
> Followers of the relevant repo 
>  should be yet aware that 
> there was something going on with the monitor
> And now, it's ready for show-time:
> - new revamped interface
> - new graphs 
> - monitoring jobs (group of tasks) included
>
> Beware: it only works with web2py trunk, and it's still to be considered 
> as experimental.
> I'll be glad to hear your comments about it, and as always, your 
> comments/code-analysis/etc are highly appreciated.
>
> A few images are attached.
>
>
>

-- 
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: 2 factor auth doesn't seem to take effect.

2014-12-09 Thread pn
I contributed this originally, will take a look today. Should be an easy 
fix.

On Monday, December 8, 2014 9:27:35 PM UTC-5, Massimo Di Pierro wrote:
>
> Honestly I have not used this much myself recently. Please open a ticket 
> about this problem. It may be broken.
>  v
>
> On Friday, 5 December 2014 11:34:29 UTC-6, Andrew wrote:
>>
>> Following the information in the web2py book I have attempted to enable 2 
>> factor authentication. It does not seem to be working though.
>>
>> I have set up a group with the role of "web2py Two-Step Authentication" 
>> I assign users to this with
>>
>> auth.settings.create_user_groups = False
>> auth.settings.everybody_group_id = 3
>>
>>
>> However after the failed login attempts nothing happens. I am even free 
>> to login as normal. 
>> I am using a custom auth table with the following:
>>
>>
>> db.define_table(auth.settings.table_user_name,
>> Field('first_name', requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=3, 
>> maxsize=15)]),
>> Field('last_name', requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=3, 
>> maxsize=15)]),
>> Field('email'),
>> Field('username', unique=True),
>> Field('password', 'password', length=512,
>>   readable=False, label='Password'),
>> Field('current_ip', default=request.client, readable=False, writable=
>> False),
>> Field('registration_key', length=512,
>>   writable=False, readable=False),
>> Field('reset_password_key', length=512,
>>   writable=False, readable=False),
>> Field('registration_id', length=512, writable=False, readable=False))
>>
>> auth.settings.create_user_groups = False
>> auth.settings.everybody_group_id = 3
>> auth.settings.actions_disabled=['change_password',
>> 'request_reset_password']
>> auth.settings.formstyle = 'bootstrap'
>> auth.settings.remember_me_form = False
>> auth.define_tables()  
>> auth.settings.register_captcha = Recaptcha(request, '', '', use_ssl=True, 
>> options="theme : 'clean'")
>> auth.settings.login_onaccept.append(lambda form: db.auth_user(auth.
>> user_id).update_record(current_ip = request.client))
>>
>>
>>
>> I am using web2py version: 2.9.11-stable+timestamp.2014.09.15.23.35.11
>>
>> Any advice is greatly appreciated
>>
>> Thank You :D
>>
>

-- 
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: 2 factor auth doesn't seem to take effect.

2014-12-09 Thread pn
I just tested and it works fine except it seems that the documentation in 
the book is incorrect.

You must add this line to db.py (or in whatever file you define the auth 
and set auth.settings);

auth.settings.two_factor_authentication_group = 'web2py Two-Step 
Authentication'

Other things to note:

   - You must have a group with this name in auth_group
   - You must add user to this group
   - You must have email setup in order to receive the two factor 
   authentication code

I'll submit a fix to the documentation in the book.

On Tuesday, December 9, 2014 1:50:33 PM UTC-5, pn wrote:
>
> I contributed this originally, will take a look today. Should be an easy 
> fix.
>
> On Monday, December 8, 2014 9:27:35 PM UTC-5, Massimo Di Pierro wrote:
>>
>> Honestly I have not used this much myself recently. Please open a ticket 
>> about this problem. It may be broken.
>>  v
>>
>> On Friday, 5 December 2014 11:34:29 UTC-6, Andrew wrote:
>>>
>>> Following the information in the web2py book I have attempted to enable 
>>> 2 factor authentication. It does not seem to be working though.
>>>
>>> I have set up a group with the role of "web2py Two-Step Authentication" 
>>> I assign users to this with
>>>
>>> auth.settings.create_user_groups = False
>>> auth.settings.everybody_group_id = 3
>>>
>>>
>>> However after the failed login attempts nothing happens. I am even free 
>>> to login as normal. 
>>> I am using a custom auth table with the following:
>>>
>>>
>>> db.define_table(auth.settings.table_user_name,
>>> Field('first_name', requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=3, 
>>> maxsize=15)]),
>>> Field('last_name', requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=3, 
>>> maxsize=15)]),
>>> Field('email'),
>>> Field('username', unique=True),
>>> Field('password', 'password', length=512,
>>>   readable=False, label='Password'),
>>> Field('current_ip', default=request.client, readable=False, writable
>>> =False),
>>> Field('registration_key', length=512,
>>>   writable=False, readable=False),
>>> Field('reset_password_key', length=512,
>>>   writable=False, readable=False),
>>> Field('registration_id', length=512, writable=False, readable=False
>>> ))
>>>
>>> auth.settings.create_user_groups = False
>>> auth.settings.everybody_group_id = 3
>>> auth.settings.actions_disabled=['change_password',
>>> 'request_reset_password']
>>> auth.settings.formstyle = 'bootstrap'
>>> auth.settings.remember_me_form = False
>>> auth.define_tables()  
>>> auth.settings.register_captcha = Recaptcha(request, '', '', use_ssl=True
>>> , options="theme : 'clean'")
>>> auth.settings.login_onaccept.append(lambda form: db.auth_user(auth.
>>> user_id).update_record(current_ip = request.client))
>>>
>>>
>>>
>>> I am using web2py version: 2.9.11-stable+timestamp.2014.09.15.23.35.11
>>>
>>> Any advice is greatly appreciated
>>>
>>> Thank You :D
>>>
>>

-- 
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: My first web project

2014-12-10 Thread PN
User registration and authentication -- use the auth functionality that 
comes with web2py by default (see the chapter on Access Control). Create a 
group called 'Instructor' and if someone is a member of that they get 
additional functionality (like viewing other users' grades). Use the 
built-in form functionality to create questionnaires. The Forms and 
Validators chapters can help you here. Once forms are submitted you can 
process the answers and store results in another table. Store the scores in 
a db table that has a field that references auth_user so each score is 
associated with a user. You can display this table to the instructor using 
SQLFORM.grid (in the Forms and Validators chapter). The grid comes with 
functionality that can sort and paginate.

On Monday, December 8, 2014 7:14:47 PM UTC-5, Adrian Aurel Chiriac wrote:
>
> Hello!
>
> I'm taking my introduction to programming class (Python) and for my final 
> project I'm experimenting with web2py.
> I'm trying to create a webpage/app for testing purposes.
> The user signs in and is given a test. After he responds to all the 
> questions he submits, gets graded and the score is saved. The passing score 
> is 80%, each question having a certain amount of points out of 100.
> This project needs to be capable to test about 1,000 students at once. 
> Also needs to rank them and make the scores accessible to instructor.
> It's not very complicated but I would like to get some advice. 
>
> They only teach Python fundamentals in class so I've been reading the 
> web2py book.
>
> Can anyone give some advice or a diagram on how should I build it and what 
> the project should contain?
>
>
>
>
>
>
> English is my second language and I apologize for all the grammar and 
> language mistakes. 
>
>

-- 
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: Boots trap user graph

2014-03-20 Thread PN
The solution will depend on what user activity you are trying to log/graph. 
You can use Google Analytics (the code is built into web2py, but there are 
tons of help pages available) to track usage report. There are many useful 
standard reports (how often, what location, what device, etc.) and if you 
want to record custom fields like usernames, you can do that also.

On Wednesday, March 19, 2014 4:24:35 AM UTC-4, Anubhav Singh wrote:
>
> hi guys,
>is there any easy script for create a user log graph . if yes 
> please help me because i have little knowledge of j-query . while i was 
> searching on google there are all result come with j-query and also with 
> very difficult  script .. help me please ... thanks 2 all
>

-- 
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: Pulling data every 30s for a ticker with web2py

2014-03-20 Thread PN
You can also use web2py components (see the chapter titled 'Components and 
Plugins' in the web2py book). Basically first make a normal web2py page 
that reads the remote API every time the page is loaded, and displays the 
results. Then, load this page as a component into another page, and specify 
the 'timeout' parameter of the component so that it reloads every 30 
seconds. You will not have to do any of the ajax/js yourself this way.

On Sunday, March 16, 2014 1:48:11 PM UTC-4, Martin wrote:
>
> Hi all,
> Please could anyone help me out, I need to pull some data from some API 
> (ex: https//xxx/aaa/ etc.) every 30s and then display the result in a ti
> cker
> How do I do this with Web2py + JavaScript ? I am new to web2py.
>
> Thank you.
>

-- 
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: 2.9.5-stable Version throws ticket when /admin accessed - dead in water

2014-03-21 Thread PN
Any luck? Posting the details of the ticket error output will help debug 
the problem.

On Friday, March 21, 2014 12:06:11 AM UTC-4, weheh wrote:
>
> Gaah! I just restored the older version of web2py from which I upgraded 
> (ashamed to say it's 2.3.2) and now I'm getting the same error. So 
> apparently, something got corrupted along the way. Note to self: don't 
> attempt upgrades just before a major release.
>

-- 
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: list reference with ondelete=set null breaking when delete parent

2014-03-21 Thread PN
Your desired behavior is that when a color is deleted it should be set to 
null in tshirts, so you need to put the ondelete attribute in the color 
field in the color table instead of on the colors field in the tshirt table.

db.define_table('color',
   Field('color', 'string', ondelete="SET NULL"))


db.define_table('tshirt',
   Field('name', 'string'),
   Field('colors', 'list:reference color'))


On Thursday, March 20, 2014 2:15:56 PM UTC-4, André Kablu wrote:
>
> I have 2 tables, using sqlite:
>
> db.define_table('color',
>Field('color', 'string'))
>
>
> db.define_table('tshirt',
>Field('name', 'string'),
>Field('colors', 'list:reference color', 
> ondelete="SET NULL"))
>
>
> When I delete a color, all tshirts that have this color will break with 
> the error message:
> "using a recursive select but encountered a broken reference"
>
>
> So the delete() is not putting NULL on the reference...
>
> This is a bug right? Not the correct behavior...
>
> I was using list:reference b/c it seems much easier than building 3 
> tables... but now I am not sure if it is good to be used once it is not 
> "automatic"...
>
>
>
>
>
>

-- 
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: Can the DAL produce pivot table query (for use with Google Charts Plugin)?

2014-03-21 Thread PN
I don't think the DAL provides that by default. You have the option of 
writing your own pivot function (it's not very complicated, that's the way 
I went) or you can use a library like pandas if your production server lets 
you install numpy/scipy/pandas. Pandas will give you a lot more data 
manipulation functionality but it involves learning yet another tool.

On Monday, March 17, 2014 2:48:21 PM UTC-4, Michael Beller wrote:
>
> I'm trying to create a query that produces a pivot table.  I have a 
> Project and Project Status table.  Each Project has a Status reference 
> field to a Project Status and a Manager reference field to an Auth User.
>
> db.define_table('t_project_status',
> Field('f_name', requires=IS_NOT_EMPTY(), label=T('Name')),
> auth.signature)
>
> db.define_table('t_project',
> Field('f_name', requires=IS_NOT_EMPTY(), label=T('Name')),
> Field('f_description', 'text', readable=False, label=T('Description')),
> Field('f_manager', 'reference auth_user', label=T('Manager')),
> Field('f_status', 'reference t_project_status', label=T('Status')),
> auth.signature)
>
> I would like a table that produces a row for every Manager and a column 
> for every Status (which I can then display as a Bar Chart using Google 
> Charts).
>
> This query comes close to at least producing a normalized list, i.e., one 
> row for each combination of Manager/Status in the Project table (but not an 
> entry for a Status that doesn't exist for a particular Manager, I can't 
> figure out how to add a 2nd constraint to the 'left' clause):
>
> joinquery = ((db.t_project.f_status == db.t_project_status.id) &
> (db.t_project.f_manager == db.auth_user.id))
>
> data = db(joinquery).select(
> db.auth_user.last_name,
> db.t_project.f_status,
> db.t_project_status.f_name,
> db.t_project_status.id.count(),
> groupby=(db.auth_user.id|db.t_project_status.id),
> orderby=(db.auth_user.last_name|db.t_project_status.id),
> left=db.auth_user.on(db.t_project.f_manager == db.auth_user.id),
> )
>
> I've started to look at itertools.groupby but was trying to find a DAL 
> solution to create the pivot table.
>
> I'm then using this code to create a table for Google Charts using the 
> Google Charts Plugin but will need to modify once I get the pivot table 
> working:
>
> datalist = []
> datalist.append(['Manager','Status','Count'])
> for row in data:
> datalist.append([row.auth_user.last_name or 'None', 
> row.t_project.f_status or 'None', int(row[db.t_project_status.id.count()])])
>
>

-- 
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: list reference with ondelete=set null breaking when delete parent

2014-03-21 Thread PN
You're right, the update is defined on the field like you have. I have used 
'NO ACTION' on a reference field with no issues. However never tried it 
'SET NULL' on a List:reference. I spoke too soon.

On Friday, March 21, 2014 1:21:34 PM UTC-4, André Kablu wrote:
>
> I think you are mistaken... 
> ondelete is for use with upload and reference fields...
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-constructor
>
>
>
>
> On Fri, Mar 21, 2014 at 1:54 PM, PN 
> > wrote:
>
>> Your desired behavior is that when a color is deleted it should be set to 
>> null in tshirts, so you need to put the ondelete attribute in the color 
>> field in the color table instead of on the colors field in the tshirt table.
>>
>> db.define_table('color',
>>Field('color', 'string', ondelete="SET NULL"))
>>
>>
>> db.define_table('tshirt',
>>Field('name', 'string'),
>>Field('colors', 'list:reference color'))
>>
>>
>> On Thursday, March 20, 2014 2:15:56 PM UTC-4, André Kablu wrote:
>>>
>>> I have 2 tables, using sqlite:
>>>
>>> db.define_table('color',
>>>Field('color', 'string'))
>>>
>>>
>>> db.define_table('tshirt',
>>>Field('name', 'string'),
>>>Field('colors', 'list:reference color', 
>>> ondelete="SET NULL"))
>>>
>>>
>>> When I delete a color, all tshirts that have this color will break with 
>>> the error message:
>>> "using a recursive select but encountered a broken reference"
>>>
>>>
>>> So the delete() is not putting NULL on the reference...
>>>
>>> This is a bug right? Not the correct behavior...
>>>
>>> I was using list:reference b/c it seems much easier than building 3 
>>> tables... but now I am not sure if it is good to be used once it is not 
>>> "automatic"...
>>>
>>>
>>>
>>>
>>>
>>>  -- 
>> 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/TycU_Q-ywYI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@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: Is anyone working on a two-step login for auth? (Sometimes called two factor authentication)

2014-04-24 Thread PN
I just implemented two-factor authentication in an app that I am working 
on. Unfortunately it required changing the login() method of the 
gluon/tools.py file directly, there was no mechanism that would allow a 
secondary login requirements. Is this still useful? If someone is more 
experienced in web2py authentication and can point me in the right 
direction, I can try to make a patch for it.

If there is interest, I can clean out the customer/private information from 
the code and upload a version somewhere.

On Wednesday, May 1, 2013 4:36:43 PM UTC-4, Cliff Kachinske wrote:
>
> If so, can you share the code?
>
> If not, I will put it on my todo list, but there are a lot of things in 
> front of it.
>
> Thanks,
> Cliff Kachinske
>
>
>

-- 
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: Is anyone working on a two-step login for auth? (Sometimes called two factor authentication)

2014-09-02 Thread PN
Update. The code is part of web2py starting at version 2.9.6

On Wednesday, May 14, 2014 2:18:59 PM UTC-4, pallav wrote:
>
> Another update - submitted the fixed code as a pull request. This fixes 
> the issue that was causing unit tests to fail. Waiting to hear back from 
> the team.
>
> On Tuesday, April 29, 2014 4:57:49 AM UTC-4, thehuman trashcan wrote:
>>
>> Thanks for working on this! I think it is important and look forward to 
>> implementing it.
>>
>> All the best
>>
>> On Monday, 28 April 2014 04:10:07 UTC+2, pallav wrote:
>>>
>>> For anyone wondering on the status, my code causes the unit tests for 
>>> web services to break. I plan on looking into it over the next couple of 
>>> days.
>>>
>>> On Sunday, April 27, 2014 2:31:37 AM UTC-4, pallav wrote:

 Submitted the pull requests.

 Source: https://github.com/web2py/web2py/pull/431
 Documentation: https://github.com/mdipierro/web2py-book/pull/202

 The two-step verification in this pull can be activated on a per-user 
 basis by adding the user to a group named 'web2py Two-Step 
 Authentication'. 
 This string is hard-coded in the code. If a user logs in successfully with 
 their username and password, and they are a part of this group, then the 
 two-step functionality is enabled. The server sends an email to the user's 
 registered email address with a random code. The user has 4 tries to enter 
 this code before they are logged out and must enter username/password 
 again.

 Possible future enhancements:

- Add some ability to customize. Let people create their own 
two-step auth methods (like the extended_login functionality)
- Add TOTP based two-factor authentication instead of sending email 
(there is already a MOTP plugin for web2py that can be used as base)


 On Wednesday, May 1, 2013 4:36:43 PM UTC-4, Cliff Kachinske wrote:
>
> If so, can you share the code?
>
> If not, I will put it on my todo list, but there are a lot of things 
> in front of it.
>
> Thanks,
> Cliff Kachinske
>
>
>

-- 
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: using plugin_jqmobile prevents uploading a file

2014-09-14 Thread pn
It is probably because you cannot upload files when ajax is enabled in 
jquery-mobile forms. There are more details at the following links on how 
to correctly structure a file upload form in jquery mobile.

Quote from their docs (http://demos.jquerymobile.com/1.4.4/forms/   -- near 
the bottom of the page)

File Inputs + Ajax

Using a multipart form with a file input is not supported by Ajax. In this 
case you should decorate the parent form with data-ajax="false" to ensure 
the form is submitted properly to the server.

On Sunday, September 14, 2014 3:13:55 PM UTC-4, mweissen wrote:
>
> I have a very simple model
>
> db.define_table('ding',
> Field('beschreibung'),
> Field('bild','upload')
> )
>
>
> a simple function
>
> def snap():
> form=SQLFORM(db.ding, None, deletable=True, upload=URL('download'))
> if form.process().accepted:
> response.flash="Fertig"
> elif form.errors:
> response.flash="Fehler"
> return dict(form=form)
>
>
> ​and a view
>
> {{#extend 'layout.html'}}
> {{extend 'plugin_jqmobile/layout.html'}}
> SNAP
> {{=form}}​
>
>
> ​With layout.html ​everything is fine, but with plugin_jqmobile the upload 
> finishes after a second with no error message but also with no new uploaded 
> file in the database.
>
> Any ideas?
> Regards Martin
>
>
> 

-- 
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] Running a long task with task scheduler multiple times in the same browser

2014-09-21 Thread pn
Did you test in a production environment (example behind an apache/other server 
calling web2py via wsgi as described in the deployment recipes chapter) or just 
using the built-in web2py server on your dev machine?

The difference is that apache will certainly be able to handle multiple 
simultaneous requests, even long running ones until it runs out of allocated 
resources. Not sure if the built-in rocket server can do that or if it only 
handles one request at a time.

If you are unable to run multiple requests even behind a production server, 
then check if the processes are locking each other (trying to get locks on the 
same file, locked because they are updating/reading the same database tables 
and keeping locks on them, etc)

-- 
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: Version 2.9.6 indeed breaks backward compat for some users

2014-09-22 Thread PN
Seems like a related issue still exists in web2py 2.9.11 for Microsoft SQL 
Server.

list:integer type fields get mapped to 'text' type fields in MS SQL. The 
text type fields cannot use functions like 'LOWER', only varchar type 
fields can. So now queries like field.contains() will not work 
because the DB throws an error "Argument data type text is invalid for 
argument 1 of lower function. (8116)".

Changing the type of the field in the database would fix the issue, but 
that requires droppping and recreating the table. Not something done 
trivially.

Recommended workarounds?

On Friday, September 12, 2014 11:07:42 PM UTC-4, Massimo Di Pierro wrote:
>
> done
>
> On Thursday, 11 September 2014 23:34:43 UTC-5, Joe Barnhart wrote:
>>
>> Just set case_sensitive=False and it will work exactly the way you want 
>> regardless of the convention chosen.  I now set the case on my queries 
>> since it seems prudent to do so.  After all, I may change from Postgres to 
>> MySql or something and I don't want to be surprised.
>>
>> -- Joe
>>
>>
>> On Thursday, September 11, 2014 7:46:17 PM UTC-7, Leonel Câmara wrote:
>>>
>>> Nothing is exactly broken, but autocomplete uses "like" in its queries 
>>> when it's not running on gae, so, once this is decided, we need to either 
>>> set it case_sensitive=False or make it use ilike (so it has the same 
>>> behaviour on gae and other adapters)
>>>
>>

-- 
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: Upgrading an old version - will my app work?

2014-09-28 Thread pn
The bad news: You will need to test to be sure it works, and there may be 
some work required for the upgrade.
The good news: Most likely, you will only need to make minor changes and 
will be happy with the features offered by the newer versions.

The biggest change you will have to deal with were introduced around 
version 2.6 -- "For pre 2.6 applications to work with web2py >=2.6, you 
must copy static/js/web2py.js, controllers/appadmin.py, and 
views/appadmin.html from the welcome app to your own apps (all of them)."

See the following link for details:
http://www.web2py.com/init/default/changelog


On Sunday, September 28, 2014 1:44:31 PM UTC-4, Marko Poutiainen wrote:
>
> I made a simple application with web2py 
> version 2.4.6-stable+timestamp.2013.04.06.17.37.38 and thought about 
> upgrading to the latest one because someone else wants to use the same 
> application on their server. No point in installing an old version, IMO, so 
> I'll update our version first. Do I run into problems, i.e. has the 
> framework changed so that it's not backwards compatible to that version?
>
> And should the upgrade from the admin interface work? There's a warning 
> that it's still experimental.
>

-- 
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: mssql legacy tables reference

2014-09-28 Thread pn
Can you provide some clarification on what behavior are you expecting but 
not seeing when you create the reference? For example, are you able to 
create entries in the 'Partneri' table that refer keys not in the 'Mjesta' 
table? A quick workaround would be to put in a 'requires' lambda into the 
field definition in the Partneri table. This way you can define your own 
custom rules.

On Saturday, September 27, 2014 2:51:31 AM UTC-4, Alen Cerovic wrote:
>
> tried
> 'reference Mjesta' - no error but also nothing happens
> 'reference PostanskiBroj' - Query Not Supported: 'DAL' object has no 
> attribute 'PostanskiBroj'
>
> I did not dive in source code but is it difficult to make references 
> between legacy tables reliable. From my perspective it is very important 
> as many web projects does not start from scratch.
>
> Dana subota, 27. rujna 2014. 08:01:22 UTC+2, korisnik Massimo Di Pierro 
> napisao je:
>
>> 'reference Mjesta.PostanskiBroj'* should be *'reference PostanskiBroj'
>>
>>
>> *but I would not swear by references for legacy keyed tables.*
>> On Thursday, 25 September 2014 11:58:21 UTC-5, Alen Cerovic wrote:
>>>
>>> Hi,
>>>
>>> I am totaly new to web2py, actually started yesterday :)
>>> I am trying to work with legacy mssql database and having problems in 
>>> referencing two legacy keyed tables
>>>
>>> db.define_table('Mjesta',
>>> Field ('PostanskiBroj'
>>> ,'integer',notnull=True,unique=True),
>>> Field ('Naziv'),
>>> primarykey=['PostanskiBroj'],
>>> migrate=False)
>>>
>>> db.define_table('Partneri',
>>> Field ('Sifra',
>>> 'integer'),
>>> Field ('Naziv'),
>>> Field 
>>> ('Mjesto','reference 
>>> Mjesta.PostanskiBroj'),
>>> primarykey=['Sifra'],
>>> migrate=False)
>>>
>>> no errors but field Partneri.Mjesto does not reference 
>>> Mjesta.PostanskiBroj
>>>
>>> What am I doing wrong?
>>>
>>>

-- 
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: web2py usage monitor with slow web2py vs fast web2py

2014-09-30 Thread PN
Are the SLOW version and FAST version different web2py applications (i.e. 
the code under web2py/applications/project_name is different)? If so, the 
difference in speed is likely coming from what processes each app is 
running on call.

Some places to look at -- try to identify which page is the slowest in the 
slow app, then use {{=response.toolbar()}} in the view, it will show you a 
toolbar that shows database stats and how long and how many queries ran. 
This will give you an idea. Usually slowness is from database lookups 
(either a big data lookup, or many small lookups adding up). If db is not 
the issue, look up 'profiling' for your IDE, it will let you see how much 
time is being spent in various python processes.

On Tuesday, September 30, 2014 5:34:31 PM UTC-4, Cory wrote:
>
>
> Hey, does anyone know why my usage is the way it is? for instance, in the 
> picture below (slow version) everything is in increments with a  gap in 
> between each spike. This happens while under both heavy load and idle. My 
> web2py is so slow its unusable. When I use web2py with a different project 
> it does not display my usage in the same way (without consistent gaps 
> between each spike, see fast version) and is very fast. Any ideas what 
> could cause this? 
>
> *SLOW version*
>
>
> 
>
> *FAST version*
>
> 
>
>
> 
>  
> 
>
>
>  
>

-- 
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] Nested Role Based Access Control

2015-09-30 Thread PN
Currently web2py's RBAC functionality does not accommodate nested groups. 
Any interest in adding this to the standard web2py access control module?


*Example Use-Case*

Suppose we are creating an inventory management application that lets you 
view addresses for buildings within your portfolio of buildings. Now a 
customer wants to divide their buildings into sub-regions, give permission 
to some users over sub-regions, and some users over all the sub-regions.

1. A table named Buildings represents buildings and their addresses. 

2. An auth_group entry for the top-level customer ("Wayne Industries"), and 
another entry for each of the sub-regions ("Gotham City", "Gotham Suburbs")

3. Users are assigned groups using the auth_membership table. Users who 
should have access to all the buildings get put into the "Wayne Industries" 
group. Users who should only see a sub-region get put into one of the City 
or Suburbs groups.


*Problem*

Suppose we want to show a user a grid of buildings based on what group they 
belong to. Users in Gotham City should only see sites that are part of that 
sub-region, but users in Wayne Industries should see buildings that are 
part of all 3 groups.

In the current setup, we would have to create two auth_permission entry for 
each building. One for the Wayne Industries group, and another for either 
of the sub-groups so users in the top-level group and the sub-group can see 
that building. This is fine if the list of buildings or groups is not 
dynamic. But if we are allowing users to add sub-groups and buildings, then 
every time a building is created, we need to know that the building should 
also be added to the top-level group. Various ways exist but keeping things 
in sync become hard.


*The proposed alternative*

1. We assign buildings to sub-regions by creating an auth_permission entry 
for the sub-region and the building ({Group: "Gotham City", Table: 
"Buildings", Name: "EDIT", Record_ID: }, etc.)

2. We assign the Wayne Industries group ADMIN permssion over the Gotham 
City and Gotham Suburbs group

3. We build a access control tree that allows queries over the nested 
groups. We can do this using a library like NetworkX that makes building 
and searching a graph/tree structure easier. We also add a parameter to the 
auth.accessible_query that decides whether to return only records owned by 
groups this user is a member of, or also return records owned by any 
(sub)groups the users' current groups have admin permission over. We can 
add a cache time property that allows storing this tree in memory to reduce 
db hits.

Does this sound like good design/useful feature to add? Much of this has 
already been built for our current application but we were looking to do 
something more standardized, putting it into web2py would allow us to get 
feedback on the implementation and how generalized/fast/secure it is.

-- 
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: Nested Role Based Access Control

2015-09-30 Thread PN
No graph database needed the way we implemented it. We use a regular db and 
generate the graph in-memory. 

The current simple implementation is to query auth_permissions where 
table_name = 'auth_group' so we only get entries that are relevant to 
group-group ownerships. The graph is kept in memory and updated 
periodically. This avoid recursive queries into the database as all entries 
are retrieved in one call. This structure is shared between *all* users, so 
not pulled at every login. We refresh the structure periodically (every 60 
seconds in our case). Disadvantage is what happens if there are so many 
group-group permissions that they don't fit in memory. Also, a periodic 
refresh is not as accurate as an event based refresh (only refresh when a 
group-group entry is created/modified/deleted in permissions)

I see your point about the alternate architecture - one that implements a 
layer on top of RBAC and creates the appropriate auth_permission entries 
for each group/sub-group. In this situation, if you create a building under 
a sub-group, you would create two entries in auth_permission, one for the 
sub-group and one for the top-level group. This is good when you want to 
just retrieve all buildings that a user has access to, not as useful when 
you want to create a hierarchical view for the user (for example, a 
drill-down list of sub-groups kinda like windows shows files and folders - 
you see a list of all files in the top level folder, and a list of 
subfolders that you can click to view files within that subfolder). Using a 
layer on top of the RBAC would mean we have to do recursive queries anyway 
to show the top-level view (i.e. show me all buildings that are owned by 
the top-level group AND not owned by any of the sub-groups). Not sure if 
I'm explaining it clearly. It seems like a generic use-case so I was hoping 
there was a standard design pattern we could follow. Maybe by having a 
different permission name when the group owns a building directly, vs when 
a group has access to a building through a sub-group?

I'm happy to work on the n+1 query problem on RBAC, is there a reference 
thread somewhere that I can use as a jumping off point?

On Wednesday, September 30, 2015 at 3:46:12 PM UTC-4, Niphlod wrote:
>
> This has been discussed before and trashed as soon as a graph database is 
> needed to store and retrieve efficiently data.
> Of course, recursive queries are a no-go.
> There's a reason why Active Directory through Kerberos sends out the 
> flattened list of group membership when trying to authenticate.
> And a reason why even with that trick it's fading away. We don't need to 
> copy behaviour from a well known architecture which has already proven its 
> limits. 
> Checking membership recursively at login-time is FAR FAR FAR worse than 
> just managing group membership on another layer, on top of RBAC which isn't 
> limiting from the "turing" perspective. 
>
> PS: web2py suffers of the n+1 query problem EVEN for not nested groups. I 
> assume it was done to support noSQL database. I realized it reviewing the 
> code in order to allow JWT authentication. IMHO the eventual "refactoring 
> hours" spent on RBAC should be spent there instead of nested groups 
> functionality 
>

-- 
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: How to demonstrate LOAD() working properly?

2015-10-02 Thread pn
Hi, the link you posted shows a blank page. I think you may have 
copy-pasted from inside an email that requires you to have been logged in, 
try visiting the link and copy-pasting from the browser URL. Or maybe 
provide the example of your app by uploading it to github/bitbucket.

On Friday, October 2, 2015 at 7:05:24 PM UTC-4, Tom Campbell wrote:
>
> I am working on a simplified single-page app demo. I think I have it 
> working, but I'm not sure because I need to demonstrate that only part of 
> the page is reloading. Most of the code is shown in this post:
>
>
> https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.en.Pryf_O7ZHDs.O/m=m_i,t/am=PiM-ZGD_3_uDWGcIoF3ySIW999_vLil2_-Hx_3sQQbJXAP8A-H8A_wEvRF9I/rt=h/d=1/t=zcms/rs=AHGWq9CcTajC8VF4OQk0ZBX1nqhzCmoSzQ
>
> Despite using LOAD() and seeing the correct XHR requests being made in the 
> Javascript console, reloads seem to occur exactly as often as if I didn't 
> use LOAD().
>
> What is the best way to demonstrate that LOAD() is only loading partial 
> pages on demand, and that the static portion is not being reloaded?
>

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