[web2py] Re: distinct keyword for SQLFORM.grid

2016-12-21 Thread H. Das
Hi Massimo, I think this still hasn't been added yet. 

I too am doing several inner joins with grid and I'm getting some rows that 
I consider duplicates and would like to get rid of them. The most 
straightforward way to remove these duplicates is perhaps calling select() 
on the Set object with the distinct keyword argument, or perhaps even use 
exclude() on the Rows object. To my knowledge grid does not yet have 
equivalents to distinct and exclude, unfortunately.

Will equivalents to distinct/exclude be added to grid anytime soon? I am 
surprised something so advanced like grid doesn't have this.

Or would you know another way to remove duplicates from grid? 

Please advise.

On Wednesday, April 10, 2013 at 9:14:12 AM UTC-4, Massimo Di Pierro wrote:
>
> Please open a ticket and we can add this.
>
> On Wednesday, 10 April 2013 04:46:14 UTC-5, Calvin wrote:
>>
>> Hi
>>
>> I have been struggling with how one could get just distinct records to 
>> show with SQLFORM.grid if the query passed to it involved more than one 
>> table? Doing an inner join tends to generate a lot of non-unique rows and 
>> hence it would be important to just filter out the unique ones. With 
>> select, there is support for the distinct keyword but this is not the case 
>> with SQLFORM.grid. 
>>
>> Using the groupby keyword is one approach but this can get somewhat 
>> tedious having to specify the fields to group by in advance and hence, I 
>> would like to understand if the omission of support for distinct in 
>> SQLFORM.grid is by design?
>>
>> Many thanks
>> Calvin
>>
>

-- 
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: How to check if expression is Aggregate?

2016-12-21 Thread Jurgis Pralgauskis
> dir(db._adapter)

 ['POOLS', 'REGEX_TABLE_DOT_FIELD', '__class__', '__delattr__', '__dict__',
'__doc__', '__format__', '__getattribute__', '__hash__', '__init__',
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__',
'_add_operators_to_parsed_row', '_add_reference_sets_to_parsed_row',
'_after_connection', '_available_drivers', '_build_cursor',
'_build_handlers_for_execution', '_build_joins_for_select',
'_cached_select', '_clean_cursors', '_colexpand', '_connection_thname_',
'_connection_uname_', '_count', '_cursors_thname_', '_cursors_uname_',
'_delete', '_driver_from_uri', '_drop_table_cleanup', '_expand',
'_expand_for_index', '_find_work_folder', '_geoexpand',
'_get_or_build_free_cursor', '_initialize_', '_insert',
'_load_dependencies', '_parse', '_parse_expand_colnames', '_pid_',
'_regex_select_as_parser', '_register_extract', '_register_regexp',
'_select', '_select_aux', '_select_aux_execute', '_select_wcols',
'_update', 'adapt', 'adapter_args', 'after_connection',
'after_connection_hook', 'alias', 'bulk_insert', 'can_select_for_update',
'check_active_connection', 'close', 'close_all_instances',
'close_connection', 'close_cursor', 'commit', 'commit_on_alter_table',
'commit_prepared', 'common_filter', 'connection', 'connector', 'count',
'create_index', 'create_sequence_and_triggers', 'create_table',
'credential_decoder', 'cursor', 'cursors', 'db', 'db_codec', 'dbengine',
'dbpath', 'delete', 'dialect', 'distributed_transaction_begin', 'driver',
'driver_args', 'driver_name', 'drivers', 'drop', 'drop_index',
'drop_table', 'execute', 'execution_handlers', 'expand', 'expand_all',
'fetchall', 'fetchone', 'filter_sql_command', 'find_driver', 'folder',
'get_table', 'id_query', 'index_expander', 'insert', 'iterparse',
'iterselect', 'lastrowid', 'lock_cursor', 'migrator', 'parse',
'parse_value', 'parser', 'pool_size', 'prepare', 'reconnect',
'release_cursor', 'represent', 'representer', 'rollback',
'rollback_prepared', 'rowslice', 'select', 'set_folder', 'smart_adapt',
'sqlsafe_field', 'sqlsafe_table', 'support_distributed_transaction',
'table_alias', 'tables', 'test_connection', 'truncate', 'types', 'update',
'uploads_in_blob', 'uri', 'web2py_extract', 'web2py_regexp']

On Wed, Dec 21, 2016 at 12:22 AM, Anthony  wrote:

> Not sure what's going on. You'll have to do some digging around. Maybe do
> a dir(db._adapter) to see what the object is.
>
> Anthony
>
> On Tuesday, December 20, 2016 at 4:03:27 PM UTC-5, Jurgis Pralgauskis
> wrote:
>>
>> it just has what  standar app gets:
>>
>> db = DAL(myconf.get('db.uri'),
>>  pool_size=myconf.get('db.pool_size'),
>>  migrate_enabled=myconf.get('db.migrate'),
>>  check_reserved=['all'])
>>
>> @appconfig.ini
>>
>> [db]
>> uri   = sqlite://storage.sqlite
>>
>>
>> On Tue, Dec 20, 2016 at 4:42 PM, Anthony wrote:
>>
>>> How have you defined db? The _adapter attribute of a DAL instance should
>>> be a "SQLiteAdapter" object when using SQLite, not a "SQLite" object.
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, December 20, 2016 at 5:00:02 AM UTC-5, Jurgis Pralgauskis
>>> wrote:

 I have searchform,

 where one can define various fields and mapping to expressions for
 comparison,
 and it automatically constructs select query,

 but if I want to check if expression is aggregate, and direct thesese
 queries to "having"

 but if I try

 if filter.target_expression.op == db._adapter.AGGREGATE:

 I get

 AttributeError: 'SQLite' object has no attribute 'AGGREGATE'




 --
>>> 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/to
>>> pic/web2py/0IvASrrIDkA/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.
>>>
>>
>>
>>
>> --
>> Jurgis Pralgauskis
>> tel: 8-616 77613;
>> Don't worry, be happy and make things better ;)
>> http://galvosukykla.lt
>>
> --
> 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/0IvASrrIDkA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://

[web2py] Re: distinct keyword for SQLFORM.grid

2016-12-21 Thread H. Das
Ok I think I solved my problem by using grid's groupby argument, thanks to this 
post 

 
and this post. 


However a distinct argument for grid would still be great.

On Wednesday, December 21, 2016 at 3:56:13 AM UTC-5, H. Das wrote:
>
> Hi Massimo, I think this still hasn't been added yet. 
>
> I too am doing several inner joins with grid and I'm getting some rows 
> that I consider duplicates and would like to get rid of them. The most 
> straightforward way to remove these duplicates is perhaps calling select() 
> on the Set object with the distinct keyword argument, or perhaps even use 
> exclude() on the Rows object. To my knowledge grid does not yet have 
> equivalents to distinct and exclude, unfortunately.
>
> Will equivalents to distinct/exclude be added to grid anytime soon? I am 
> surprised something so advanced like grid doesn't have this.
>
> Or would you know another way to remove duplicates from grid? 
>
> Please advise.
>
> On Wednesday, April 10, 2013 at 9:14:12 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Please open a ticket and we can add this.
>>
>> On Wednesday, 10 April 2013 04:46:14 UTC-5, Calvin wrote:
>>>
>>> Hi
>>>
>>> I have been struggling with how one could get just distinct records to 
>>> show with SQLFORM.grid if the query passed to it involved more than one 
>>> table? Doing an inner join tends to generate a lot of non-unique rows and 
>>> hence it would be important to just filter out the unique ones. With 
>>> select, there is support for the distinct keyword but this is not the case 
>>> with SQLFORM.grid. 
>>>
>>> Using the groupby keyword is one approach but this can get somewhat 
>>> tedious having to specify the fields to group by in advance and hence, I 
>>> would like to understand if the omission of support for distinct in 
>>> SQLFORM.grid is by design?
>>>
>>> Many thanks
>>> Calvin
>>>
>>

-- 
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] register redirect

2016-12-21 Thread António Ramos
Hello i want to redirect users to a warning page to make sure they
understand taht they need to validate the acount by clicking the link they
receive by email.
The standard flash message is not the solution for my users.

so i did this


def register_w(form):
context={'detail':"Please check your mailbox","error":"Email
confirmation"}
return response.render('templates/RNA.html',context)


def user():
...
auth.settings.register_onaccept= register_w
...


however it does not redirect...

The user first gets this
user/login?_next=/fileit/default/index
but chooses to Sign Up the gets
default/user/register?_next=%2Ffileit%2Fdefault%2Findex
after sign up he gets redirected again to the login page
default/user/login?_next=/fileit/default/index

any help please?
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] IS_IN_DB show fields from related tables (how to )

2016-12-21 Thread icodk
I have 4  tables with relations (see below ) and I want to show a dropdown 
list that shows a string with  one field from each table by using something 
like:
db.customer.price.requires=IS_IN_DB(?)

I tried :

query=((db.price.product== db.product.id)&(db.price.cust_type== 
db.cust_type.id))

db.customer.price.requires = IS_IN_DB(db(query), 
db.shop_price.id,'%(cust_type.name)s %(product.name)s %(price.unit_price)s')


... and it didn't work

db.define_table('customer',

  Field('name'),

  Field('price','refrence price ))


db.define_table('price',

  Field('product', 'reference product',

  Field('cust_type', 'reference cust_type'

  Field('unit_price', 'decimal(8,4)')


db.define_table('product',

  Field('name')


db.define_table('cust_type',

  Field('name')


Is it at all possible ? any better way to do it ?

-- 
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] Can't import plugin module

2016-12-21 Thread Jurgis Pralgauskis
Hi, 

I am trying to make plugin, but ran into 



Version 2.14.6-stable+timestamp.2016.05.09.19.18.48 Traceback 

1.
2.
3.
4.
5.
6.
7.
8.

Traceback (most recent call last):
  File "/home/jurgis/dev/web2py_git/gluon/restricted.py", line 216, in 
restricted
exec(ccode, environment)
  File 
"/home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py:index",
 line 3, in 
  File "/home/jurgis/dev/web2py_git/gluon/custom_import.py", line 104, in 
custom_importer
raise ImportError(e1, import_tb)  # there an import error in the module
ImportError: (ImportError('No module named 
modules.plugin_joins_builder.joins_builder',), )

In file: 
/home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py
 

1.

 at 0x7f70f00e0a30, file 
"/home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py:index",
 line 3>



The code:
https://github.com/dz0/web2py_grand_helpers/blob/master/app/controllers/plugin_joins_builder.py#L3
https://github.com/dz0/web2py_grand_helpers/tree/master/app/modules/plugin_joins_builder

-- 
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't import plugin module

2016-12-21 Thread Anthony
There is no __init__.py file in your /modules folder, nor in the app folder 
(should also be one in the /applications folder).

Anthony

On Wednesday, December 21, 2016 at 8:29:25 AM UTC-5, Jurgis Pralgauskis 
wrote:
>
> Hi, 
>
> I am trying to make plugin, but ran into 
>
>
>
> Version 2.14.6-stable+timestamp.2016.05.09.19.18.48 Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
>
> Traceback (most recent call last):
>   File "/home/jurgis/dev/web2py_git/gluon/restricted.py", line 216, in 
> restricted
> exec(ccode, environment)
>   File 
> "/home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py:index",
>  line 3, in 
>   File "/home/jurgis/dev/web2py_git/gluon/custom_import.py", line 104, in 
> custom_importer
> raise ImportError(e1, import_tb)  # there an import error in the module
> ImportError: (ImportError('No module named 
> modules.plugin_joins_builder.joins_builder',),  0x7f70f0098a70>)
>
> In file: 
> /home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py
>  
>
> 1.
>
>  at 0x7f70f00e0a30, file 
> "/home/jurgis/dev/web2py_git/applications/app/controllers/plugin_joins_builder.py:index",
>  line 3>
>
>
>
> The code:
>
> https://github.com/dz0/web2py_grand_helpers/blob/master/app/controllers/plugin_joins_builder.py#L3
>
> https://github.com/dz0/web2py_grand_helpers/tree/master/app/modules/plugin_joins_builder
>

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

2016-12-21 Thread Anthony

>
> return response.render('templates/RNA.html',context)
>

The above is not a redirect, it is simply returning a value. The 
.register() method doesn't do anything with the return value of the 
onaccept callback. You should instead use the redirect() function to 
redirect to another page that generates the message, or use "raise 
HTTP(200, ...)" to immediately return a response to the current request.

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.


Re: [web2py] Re: How to check if expression is Aggregate?

2016-12-21 Thread Anthony
That's odd. Hard to say what's going on without seeing the code. Maybe 
attach a minimal app that reproduces the problem.

Anthony

On Wednesday, December 21, 2016 at 4:26:19 AM UTC-5, Jurgis Pralgauskis 
wrote:
>
> > dir(db._adapter)
>
>  ['POOLS', 'REGEX_TABLE_DOT_FIELD', '__class__', '__delattr__', 
> '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', 
> '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', 
> '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 
> '__weakref__', '_add_operators_to_parsed_row', 
> '_add_reference_sets_to_parsed_row', '_after_connection', 
> '_available_drivers', '_build_cursor', '_build_handlers_for_execution', 
> '_build_joins_for_select', '_cached_select', '_clean_cursors', 
> '_colexpand', '_connection_thname_', '_connection_uname_', '_count', 
> '_cursors_thname_', '_cursors_uname_', '_delete', '_driver_from_uri', 
> '_drop_table_cleanup', '_expand', '_expand_for_index', '_find_work_folder', 
> '_geoexpand', '_get_or_build_free_cursor', '_initialize_', '_insert', 
> '_load_dependencies', '_parse', '_parse_expand_colnames', '_pid_', 
> '_regex_select_as_parser', '_register_extract', '_register_regexp', 
> '_select', '_select_aux', '_select_aux_execute', '_select_wcols', 
> '_update', 'adapt', 'adapter_args', 'after_connection', 
> 'after_connection_hook', 'alias', 'bulk_insert', 'can_select_for_update', 
> 'check_active_connection', 'close', 'close_all_instances', 
> 'close_connection', 'close_cursor', 'commit', 'commit_on_alter_table', 
> 'commit_prepared', 'common_filter', 'connection', 'connector', 'count', 
> 'create_index', 'create_sequence_and_triggers', 'create_table', 
> 'credential_decoder', 'cursor', 'cursors', 'db', 'db_codec', 'dbengine', 
> 'dbpath', 'delete', 'dialect', 'distributed_transaction_begin', 'driver', 
> 'driver_args', 'driver_name', 'drivers', 'drop', 'drop_index', 
> 'drop_table', 'execute', 'execution_handlers', 'expand', 'expand_all', 
> 'fetchall', 'fetchone', 'filter_sql_command', 'find_driver', 'folder', 
> 'get_table', 'id_query', 'index_expander', 'insert', 'iterparse', 
> 'iterselect', 'lastrowid', 'lock_cursor', 'migrator', 'parse', 
> 'parse_value', 'parser', 'pool_size', 'prepare', 'reconnect', 
> 'release_cursor', 'represent', 'representer', 'rollback', 
> 'rollback_prepared', 'rowslice', 'select', 'set_folder', 'smart_adapt', 
> 'sqlsafe_field', 'sqlsafe_table', 'support_distributed_transaction', 
> 'table_alias', 'tables', 'test_connection', 'truncate', 'types', 'update', 
> 'uploads_in_blob', 'uri', 'web2py_extract', 'web2py_regexp']
>
> On Wed, Dec 21, 2016 at 12:22 AM, Anthony wrote:
>
>> Not sure what's going on. You'll have to do some digging around. Maybe do 
>> a dir(db._adapter) to see what the object is.
>>
>> Anthony
>>
>> On Tuesday, December 20, 2016 at 4:03:27 PM UTC-5, Jurgis Pralgauskis 
>> wrote:
>>>
>>> it just has what  standar app gets:
>>>
>>> db = DAL(myconf.get('db.uri'),
>>>  pool_size=myconf.get('db.pool_size'),
>>>  migrate_enabled=myconf.get('db.migrate'),
>>>  check_reserved=['all'])
>>>
>>> @appconfig.ini
>>>
>>> [db]
>>> uri   = sqlite://storage.sqlite
>>>
>>>
>>> On Tue, Dec 20, 2016 at 4:42 PM, Anthony wrote:
>>>
 How have you defined db? The _adapter attribute of a DAL instance 
 should be a "SQLiteAdapter" object when using SQLite, not a "SQLite" 
 object.

 Anthony


 On Tuesday, December 20, 2016 at 5:00:02 AM UTC-5, Jurgis Pralgauskis 
 wrote:
>
> I have searchform, 
>
> where one can define various fields and mapping to expressions for 
> comparison, 
> and it automatically constructs select query, 
>
> but if I want to check if expression is aggregate, and direct thesese 
> queries to "having"
>
> but if I try 
>
> if filter.target_expression.op == db._adapter.AGGREGATE:
>
> I get 
>
> AttributeError: 'SQLite' object has no attribute 'AGGREGATE'
>
>
>
>
> -- 
 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/0IvASrrIDkA/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.

>>>
>>>
>>>
>>> -- 
>>> Jurgis Pralgauskis
>>> tel: 8-616 77613;
>>> Don't worry, be happy and make things better ;)
>>> http://galvosukykla.lt
>>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - http

[web2py] Re: custom form default value

2016-12-21 Thread Anthony

>
>  id="sample_sample_name" class="text" value={{=row.sample_name}}/>
>

It's always a good idea to check the returned HTML source in the browser. 
In this case, you will see you forgot the quotes around the value -- should 
be:

value="{{=row.sample_name}}"

You're getting:

value=RED CAR WITH ROOF

instead of:

value="RED CAR WITH ROOF"

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: table cells truncation

2016-12-21 Thread Pierre

thanks Anthony

my tables look better now. there was a big mistake in my css. almost 
everything is in order :)

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

2016-12-21 Thread Anthony
On Wednesday, December 21, 2016 at 1:12:26 AM UTC-5, 黄祥 wrote:
>
> learned about cache from the book, but got confused :
>
> 1. when tried to put cache affected for all functions in controller, the 
> cache.action have a strange behaviour
>

First, it doesn't make sense to put cache.action at the top of the 
controller and pass it an empty lambda function -- it must decorate the 
actual function you want to cache so it can cache the content generated by 
that function. The lambda trick works with the auth.requires_login 
decorator because that decorator doesn't actually use the content of the 
decorated function -- it simply does a redirect before ever calling the 
decorated function if the user isn't logged in.
 

> the controllers requires user to login, but it can by passed (not required 
> user logged in),
>

Yes, when you use cache.action, it caches the page in the user's browser 
(in addition to the server), so on subsequent requests, the user will 
simply reload the page from the browser (shouldn't be a problem though, as 
you already delivered that copy to them prior to the caching, which would 
have required login at that time).
 

> 2. when using the cache.action why the key is encrypted, while test using 
> just cache on top of the controllers it shown the function name?
>

cache.action makes the key unique based on the details of the request, 
incorporating a number of items, such as the path, the view, the query 
string, the user agent, and the language. To avoid very long keys, it then 
hashes those items using MD5. If you'd like, you can add a prefix to the 
key (using the "prefix" argument) to help you identify it. 

3. is it neccessary to put the cache in beside on top of the controller, 
> like in dal (select, iterselect, count, is_in_db) ?
>

What do you mean "in beside on top of the controller", and how does that 
relate to the use with the DAL?

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] Column export to txt

2016-12-21 Thread yarecki wr
I have a table defined where I would need to export one column to SMB share 
as a txt file automatically when a new row gets added? How can this be 
achieved? Hope it's clear from the question I'm beggining with web2py and 
python for that matter :)

-- 
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: Issues with changing date format

2016-12-21 Thread David
In doing some additional testing I am able to update the field in the 
database administration page. The ajax calendar renders the date in 
mm/dd/ and then the data is stored as -mm-dd. I am not sure what 
would cause this to work in one place but not the other. 

David


On Tuesday, December 20, 2016 at 4:19:02 PM UTC-5, David wrote:
>
> Hello,
>
> I am trying to change the display of the date format on my SQL forms from 
> -mm-dd to mm/dd/. I have changed the web2py_ajax.html to :
>
> var w2p_ajax_date_format = "{{=T('%m/%d/%Y')}}";
>
> and added
> ield('birthday', 'date', label = 'Birthday', requires = IS_DATE(format = 
> T('%m/%d/%Y')))
>
> to my db model. However, when a SQLFORM is submitted, the date is not 
> stored in the database. I am not sure what would be causing this not to 
> insert. 
>
> David
>
>

-- 
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: Issues with changing date format

2016-12-21 Thread David
I found the issue, I had another vailidator in the controller for testing 
that I had forgotten about. Once this was removed everything worked. 

Sorry for the confusion.

David



On Tuesday, December 20, 2016 at 4:19:02 PM UTC-5, David wrote:
>
> Hello,
>
> I am trying to change the display of the date format on my SQL forms from 
> -mm-dd to mm/dd/. I have changed the web2py_ajax.html to :
>
> var w2p_ajax_date_format = "{{=T('%m/%d/%Y')}}";
>
> and added
> ield('birthday', 'date', label = 'Birthday', requires = IS_DATE(format = 
> T('%m/%d/%Y')))
>
> to my db model. However, when a SQLFORM is submitted, the date is not 
> stored in the database. I am not sure what would be causing this not to 
> insert. 
>
> David
>
>

-- 
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: How to check if expression is Aggregate?

2016-12-21 Thread Jurgis Pralgauskis

> That's odd. Hard to say what's going on without seeing the code. Maybe 
attach a minimal app that reproduces the problem.

https://github.com/dz0/web2py_grand_helpers/blob/master/app/modules/plugin_search_form/search_form.py#L188

you can toggle comment with next line to see the non/working case...

ps.: current.db is set in
https://github.com/dz0/web2py_grand_helpers/blob/master/app/models/plugin_search_form.py

-- 
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: Error background task with Redis

2016-12-21 Thread Jose de Soto
Hi Fabiano,

Maybe to late. Here you have a full app based in python-rq:

https://github.com/josedesoto/web2py-rq-dashboard


On Tuesday, 16 June 2015 19:15:03 UTC+2, Fabiano Faver wrote:
>
> Failed to copy the 2 error. The full traceback of the second error:
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/worker.py", 
> line 558, in perform_job
> rv = job.perform()
>   File 
> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/job.py", line 
> 495, in perform
> self._result = self.func(*self.args, **self.kwargs)
>   File 
> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/job.py", line 
> 206, in func
> return import_attribute(self.func_name)
>   File 
> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/utils.py", 
> line 150, in import_attribute
> module = importlib.import_module(module_name)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in 
> import_module
> __import__(name)
>   File "/home/www-data/web2py/gluon/custom_import.py", line 85, in 
> custom_importer
> modules_prefix, globals, locals, [itemname], level)
> ImportError: No module named modules
>
>
>
>
> Em terça-feira, 16 de junho de 2015 14:03:42 UTC-3, Fabiano Faver escreveu:
>>
>> I have tried to follow this tutorial: 
>> http://www.web2pyslices.com/slice/show/1579/web2py-and-redis-queue
>>
>> Just changed the arguments in the enqueue function to be fixed:
>> def contato():
>> form = SQLFORM.factory(Field("name"), Field("message"))
>> if form.accepts(request):
>> # enqueue the email to be sent!
>>job =  q.enqueue(mail.send,
>>   to="som...@teste.com.br ",  # I CHANGED 
>> THE EMAIL HERE
>>   subject="test contacted you",
>>message="message")
>> # do whatever you want
>>response.flash = "email successfully sent!"
>> return dict(form=form)
>>
>> But it gives me a error. After some time I figured out it was asking the 
>> function name to be a string.
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "/home/www-data/web2py/applications/OPM/controllers/default.py", line 
>> 1772, in 
>>   File "/home/www-data/web2py/gluon/globals.py", line 412, in 
>> self._caller = lambda f: f()
>>   File "/home/www-data/web2py/applications/OPM/controllers/default.py", line 
>> 1750, in contato
>> message="message")
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/queue.py", 
>> line 253, in enqueue
>> job_id=job_id, at_front=at_front)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/queue.py", 
>> line 215, in enqueue_call
>> return self.enqueue_job(job, at_front=at_front)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/queue.py", 
>> line 270, in enqueue_job
>> job.save(pipeline=pipeline)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/job.py", line 
>> 461, in save
>> connection.hmset(key, self.to_dict())
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/job.py", line 
>> 427, in to_dict
>> obj['data'] = self.data
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/rq-0.5.3-py2.7.egg/rq/job.py", line 
>> 227, in data
>> self._data = dumps(job_tuple)
>>   File "/home/www-data/web2py/gluon/storage.py", line 56, in 
>> __getnewargs__ = lambda self: getattr(dict,self).__getnewargs__(self)
>> TypeError: getattr(): attribute name must be string
>>
>>
>> But if i do it I get another error, but this time on Redis side about it 
>> could not import modules.
>>
>>  ImportError: No module named modules
>>
>> Anyone had this problem? Couldn't figured out how to solve it.
>>
>>

-- 
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] how to have field data display without letter "L"

2016-12-21 Thread Alex Glaros
FK field data is expressed with letter "L".  E.g, value is 370, display is 
370L

I have to strip off letter "L" with reg ex:
import re
preParent = db.Role(newSpecificRoleID).object_super_object_FK
thisParent = re.sub("[^0-9]", "", str(preParent))

Is there way to make data appear without the letter "L" in the first place?

thanks

Alex Glaros

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

2016-12-21 Thread 黄祥
thanks anthony, for detail explaination.
1. in controllers usually contain more than 1 function so i think it'll be 
efficient to put it on top of the controllers like i usually do with 
auth.requires_login(), i've tested both no errors occured :
e.g.
#cache.action(time_expire = 300, cache_model = cache.ram, quick = 
'SVLUP')(lambda: None)()
cache.action(time_expire = 300, cache_model = cache.ram, quick = 'SVLUP')

my question is it recommended to put the cache on top of the controllers 
that affect to all the function in that controller?

2. "in beside on top of the controller" is put the cache on top of the 
controllers so that it can affect to all function in that controllers, the 
correlation for the DAL cache is should i pick one or both (DAL cache and 
cache.action) ?
what i've tested so far:
step :
- use DAL (select(), iterselect(), count() and IS_IN_DB() ) query without 
cache and compare it using cache, it make page load faster, but the strange 
things is, it didn't appear in web2py appadmin ccache 
(http://127.0.0.1:8000/test/appadmin/ccache), so i'm not sure is it cache 
or not, but i feel the page load faster. my feeling tell that apps cached, 
but my mind doubt it, since it's not appear in appadmin ccache
- add cache or cache.action on top of the controllers, it appears on web2py 
appadmin ccache, so not sure it affect a lot since i've already put DAL 
cache on the first step

3. in the book it said :
For example, when you show a form to the user, or a list of records, the 
web page should not be cached, as other users may have inserted new records 
on the table you are showing.

ref:
http://web2py.com/books/default/chapter/29/04/the-core?search=cache#cache-action

let say, i have a web app that contain 3 parts : 
- master (e.g. product, customer)
- transaction (e.g. sale order)
- report (e.g. sale order)

so base on the book said, the webapps better not use cache because all of 
the parts (master, transaction, report) is using form (form to input, or 
edit master. form to input transaction. form to generate report and show 
the table query result). 
the problem is when not using cache, the apps respond is slow (function to 
calculate and table record callback), any idea the best way how to 
implement it using web2py way?

thanks and best regards,
stifan

-- 
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 have field data display without letter "L"

2016-12-21 Thread Dave S
On Wednesday, December 21, 2016 at 1:29:14 PM UTC-8, Alex Glaros wrote:
>
> FK field data is expressed with letter "L".  E.g, value is 370, display 
> is 370L
>
> I have to strip off letter "L" with reg ex:
> import re
> preParent = db.Role(newSpecificRoleID).object_super_object_FK
> thisParent = re.sub("[^0-9]", "", str(preParent))
>
> Is there way to make data appear without the letter "L" in the first place?
>
> thanks
>
> Alex Glaros
>


How is that field defined, and how were you displaying it before doing the 
 regex?

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


[web2py] Re: learning cache

2016-12-21 Thread Dave S


On Wednesday, December 21, 2016 at 2:09:53 PM UTC-8, 黄祥 wrote something 
confusing.

Normally, your posts are understandable, but I'm really struggling with 
this thread.  Can you include a code sample or attach a minimal app?  Also, 
don't Python decorators take a function as an argument?  Do they make sense 
having multiple functions as arguments?  They emit a wrapper function that 
is supposed to be applied to the decorated function.

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


[web2py] Re: Column export to txt

2016-12-21 Thread Dave S
On Wednesday, December 21, 2016 at 7:05:57 AM UTC-8, yarecki wr wrote:
>
> I have a table defined where I would need to export one column to SMB 
> share as a txt file automatically when a new row gets added? How can this 
> be achieved? Hope it's clear from the question I'm beggining with web2py 
> and python for that matter :)
>


A starting point for an answer would be:  You query should as the database 
for just that column.  You then convert the Rows object that's returned 
(roughly speaking, an array of dicts  of values that were found in that 
column) into text.  The simplest-to-describe method for that is to loop 
through the Rows object, and write the value of the column (because the 
value is in a dict, you have to use the fieldname to get the value).   

Something like:
openmyfile()
rows=db(mytlable.id > 0).select("bestfieldever");
for row in rows:
   write2myfile(row["bestfieldever"]
closemyfile()


You can turn the Rows object into a list object, and perhaps writing the 
list object works, so you don't have to do the for loop yourself.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#as_dict-and-as_list>

You may also be able to use the CSV export tool:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--one-Table-at-a-time->

Good luck!

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


[web2py] Re: how to have field data display without letter "L"

2016-12-21 Thread Alex Glaros
It's not actually displayed, it's a data element for a json list

json_list.append(dict(title = 
db.SuperObject(a1.member_super_object_FK).object_display_name, id = '"' + 
str(int(a1.member_super_object_FK)) + '"', parent = '"' + str(thisParent) + 
'"', alexLink = 'https://dca.ca.gov', lazy = 'false', kind = 'tasks#task'))

It's a regular FK for a table: 

Field('object_super_object_FK','reference SuperObject', represent = lambda 
value,row: db.SuperObject(value).object_display_name if value else '', 
requires = IS_IN_DB(db, 'SuperObject.id', '%(object_display_name)s', zero = 
T('choose one'))),


-- 
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] Add record button disappears when using groupby argument for SQLFORM.grid()

2016-12-21 Thread H. Das
Hello everyone, the add record button disappears when using groupby 
argument for SQLFORM.grid(). Is this normal behavior? How can I work around 
this without implementing my own add record feature? I'd really like to 
stay within vanilla grid as much as possible.

Please advise.

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

2016-12-21 Thread 黄祥
here is the code i used to learn cache
*models/db0.py*
# -*- coding: utf-8 -*-
db.define_table('test_0', 
Field('name'), 
format = lambda r: '%s' % (r.name) )

db.define_table('test_1', 
Field('test_0', 'reference test_0'), 
Field('name'), 
format = lambda r: '%s' % (r.name) )

*controllers/test.py*
# -*- coding: utf-8 -*-

auth.requires_login()(lambda: None)()

cache.action(time_expire = 300, cache_model = cache.ram, quick = 
'SVLUP')(lambda: None)()
#cache(request.env.path_info, time_expire = 300, cache_model = 
cache.ram)(lambda: None)()

def master_test_1():
grid = SQLFORM.grid(db.test_1)
return locals()

def transaction_test_1():
redirect_url = 'report_form_test_1'
form = SQLFORM.factory(
Field("name", 
  requires = IS_NOT_EMPTY() ), 
Field("test_0", "reference test_0", 
  requires = IS_IN_DB(db, 'test_0.id', db.test_0._format, cache = 
(cache.ram, 3600) ) ) )
if form.process().accepted:
name = form.vars.name
test_0 = form.vars.test_0

db.test_1.insert(name = name, test_0 = test_0)

redirect(URL(redirect_url) )
elif form.errors:
response.flash = T('Form has errors')
return dict(form = form)

def report_form_test_1():
redirect_url = 'report_test_1'
form = SQLFORM.factory(
Field("test_0", "reference test_0", 
  requires = IS_IN_DB(db, 'test_0.id', db.test_0._format, cache = 
(cache.ram, 3600) ) ) )
if form.process().accepted:
test_0 = form.vars.test_0
#response.new_window = URL(redirect_url, args = test_0)
redirect(URL(redirect_url, args = test_0) )
elif form.errors:
response.flash = T('Form has errors')
return dict(form = form)

def report_test_1():
test_0 = request.args(0)
query = (db.test_1.test_0 == test_0)
rows = db(query).iterselect(cache = (cache.ram, 3600), cacheable = True)
view_report_test_1 = dict(rows = rows)
return response.render(view_report_test_1)
#return view_report_test_1

*in the book said :*
Use cache.ram as much as you can but make sure to use a finite set of keys, 
or else the amount of cache used will grow arbitrarily.

*so my question is :*
1 the cache automatically clear after the expire time met or not? if not, 
so we must cleared it manually by using cache.ram.clear() or 
cache.disk.clear(), so that the size of cache didn't grow isn't it?
2 why in admin page clean function didn't clear the cache, it's just clean 
the errors and sessions but the response flash tell cache, sessions and 
errors cleared?

thanks and best regards,
stifan

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

2016-12-21 Thread Anthony
On Wednesday, December 21, 2016 at 5:09:53 PM UTC-5, 黄祥 wrote:
>
> thanks anthony, for detail explaination.
> 1. in controllers usually contain more than 1 function so i think it'll be 
> efficient to put it on top of the controllers like i usually do with 
> auth.requires_login(), i've tested both no errors occured :
> e.g.
> #cache.action(time_expire = 300, cache_model = cache.ram, quick = 
> 'SVLUP')(lambda: None)()
> cache.action(time_expire = 300, cache_model = cache.ram, quick = 'SVLUP')
>
> my question is it recommended to put the cache on top of the controllers 
> that affect to all the function in that controller?
>

Please read my previous explanation -- putting cache.action at the top of 
the controller will not result in the page being stored or served from the 
server cache. It will not generate an error, and (I think) it will properly 
set the headers for client-side caching, but you won't get any server-side 
caching if that's what you want. You will get an entry in the server-side 
cache, but it will simply be None (which is what your lambda function 
returns), and it won't actually be used to serve the page. Do not do this.
 

> 2. "in beside on top of the controller" is put the cache on top of the 
> controllers so that it can affect to all function in that controllers, the 
> correlation for the DAL cache is should i pick one or both (DAL cache and 
> cache.action) ?
>

If you're caching the entire page, there is no need to also cache the DAL 
query. But if the same query is used in multiple places or you are caching 
multiple versions of the page (e.g., based on query string, language, user 
agent, etc.), then caching the query (assuming it doesn't change) could 
also be helpful.

 

> 3. in the book it said :
> For example, when you show a form to the user, or a list of records, the 
> web page should not be cached, as other users may have inserted new records 
> on the table you are showing.
>
> ref:
>
> http://web2py.com/books/default/chapter/29/04/the-core?search=cache#cache-action
>
> let say, i have a web app that contain 3 parts : 
> - master (e.g. product, customer)
> - transaction (e.g. sale order)
> - report (e.g. sale order)
>
> so base on the book said, the webapps better not use cache because all of 
> the parts (master, transaction, report) is using form (form to input, or 
> edit master. form to input transaction. form to generate report and show 
> the table query result). 
> the problem is when not using cache, the apps respond is slow (function to 
> calculate and table record callback), any idea the best way how to 
> implement it using web2py way?
>

Forms include a unique _formkey hidden field, so you shouldn't cache pages 
that include forms. If a page simply includes some data, it's fine to cache 
as long as there is no issue of "freshness" (i.e., if the data are changing 
constantly, caching for a long time will end up serving stale data). 
Whether caching makes sense is up to you -- it's a trade-off between speed 
and freshness.

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

2016-12-21 Thread Anthony

>
> *so my question is :*
> 1 the cache automatically clear after the expire time met or not? if not, 
> so we must cleared it manually by using cache.ram.clear() or 
> cache.disk.clear(), so that the size of cache didn't grow isn't it?
>

Yes, you must clear any keys no longer in use. But if you have a finite set 
of keys, it may be OK to just leave them in the cache (the same set of keys 
will simply keep getting updated).
 

> 2 why in admin page clean function didn't clear the cache, it's just clean 
> the errors and sessions but the response flash tell cache, sessions and 
> errors cleared?
>

The "cleanup" functionality is just meant to clean up the *files *in the 
application (for example, prior to packing it), so it only deletes cache 
*files* (i.e., if you are using disk cache). It is not intended to clear 
cache.ram.

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

2016-12-21 Thread Anthony
On Wednesday, December 21, 2016 at 8:13:02 PM UTC-5, Anthony wrote:
>
> *so my question is :*
>> 1 the cache automatically clear after the expire time met or not? if not, 
>> so we must cleared it manually by using cache.ram.clear() or 
>> cache.disk.clear(), so that the size of cache didn't grow isn't it?
>>
>
> Yes, you must clear any keys no longer in use. But if you have a finite 
> set of keys, it may be OK to just leave them in the cache (the same set of 
> keys will simply keep getting updated).
>

Though note that if you use the Redis cache, it will automatically clear 
cached items after their expiration (which is different behavior from all 
the other caching mechanisms).

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: Add record button disappears when using groupby argument for SQLFORM.grid()

2016-12-21 Thread Anthony
Yes, it is intended behavior, but I think it wouldn't be a bad idea to at 
least allow the option of a create button in this case. See my response 
here regarding the rationale: 
https://groups.google.com/d/msg/web2py/QLN6HzItpS8/mcQfNaOgBwAJ. Feel free 
to open a Github issue.

Anthony

On Wednesday, December 21, 2016 at 7:19:05 PM UTC-5, H. Das wrote:
>
> Hello everyone, the add record button disappears when using groupby 
> argument for SQLFORM.grid(). Is this normal behavior? How can I work around 
> this without implementing my own add record feature? I'd really like to 
> stay within vanilla grid as much as possible.
>
> Please advise.
>

-- 
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 have field data display without letter "L"

2016-12-21 Thread Anthony
I suggest you read this thread: 
https://groups.google.com/forum/#!topic/web2py/Wcq0ZuxJWRE

Though if you are using the str() function, you shouldn't be getting the 
trailing "L".

Anthony

On Wednesday, December 21, 2016 at 4:29:14 PM UTC-5, Alex Glaros wrote:
>
> FK field data is expressed with letter "L".  E.g, value is 370, display 
> is 370L
>
> I have to strip off letter "L" with reg ex:
> import re
> preParent = db.Role(newSpecificRoleID).object_super_object_FK
> thisParent = re.sub("[^0-9]", "", str(preParent))
>
> Is there way to make data appear without the letter "L" in the first place?
>
> thanks
>
> Alex Glaros
>

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

2016-12-21 Thread 黄祥
thanks a lot for detail explaination, anthony

lesson learned about cache for now :
- start from simple first, don't use the cache on top of the controllers, 
use it for each function in controllers that need to be cached (no form in 
that function because of the form hidden field unique id)
- just do the cache for every dal (select(), iterselect(), count() and 
is_in_db() )
- create a schedule for automatically clear cache (e.g. every day)

another things that is not clear about cache :
- about 'finite set of keys', how to do this using web2py way? is it same 
like set the cache expire time?
- is it possible to have prefix in cache = (cache.ram, 3600) ? 
so that i know in appadmin ccache it belongs to which controllers or 
function? 
e.g. cache = (cache.ram, 3600, prefix = '%s/%s' % (request.controller, 
request.function) )

thanks and best regards,
stifan

-- 
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: How to check if expression is Aggregate?

2016-12-21 Thread Anthony
What version of web2py, and are you sure it includes the proper version of 
PyDAL?

What is the object type of db._adapter (a) immediately after db is created 
in db.py and (b) when db is assigned from current.db in the module?

Your traceback shows object type "SQLite", but the adapter is not of that 
type.

Anthony

On Wednesday, December 21, 2016 at 11:57:24 AM UTC-5, Jurgis Pralgauskis 
wrote:
>
>
> > That's odd. Hard to say what's going on without seeing the code. Maybe 
> attach a minimal app that reproduces the problem.
>
>
> https://github.com/dz0/web2py_grand_helpers/blob/master/app/modules/plugin_search_form/search_form.py#L188
>
> you can toggle comment with next line to see the non/working case...
>
> ps.: current.db is set in
>
> https://github.com/dz0/web2py_grand_helpers/blob/master/app/models/plugin_search_form.py
>

-- 
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] portalocker import error

2016-12-21 Thread Avinash Kachhy
Hello

On installing web2py and an application named Sahana Eden and trying to run 
the app, I get an error indicating that portalocker cannot be imported in 
pydal.py.
I see a note that this is fixed on Sept 27. 
What do I need to do it so that I get the update? I had installed web2py 
using the command
git clone --recursive git://github.com/web2py/web2py.git and seems that I 
did not get the commit from late Sept.

web2py™ Version 2.14.6-stable+timestamp.2016.05.09.19.18.48 
Python Python 2.7.12: /usr/bin/python (prefix: /usr) Traceback 

1.
2.
3.
4.
5.
6.
7.

Traceback (most recent call last):
  File "/home/web2py/gluon/restricted.py", line 216, in restricted
exec(ccode, environment)
  File "/home/web2py/applications/eden/models/000_1st_run.py" 
, line 73, 
in 
from gluon import portalocker
ImportError: cannot import name portalocker

Error snapshot [image: help] 

 

(cannot import name portalocker) 




Thanks
Avinash Kachhy 

-- 
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] Linking Auth with another table to store additional info about user

2016-12-21 Thread Andrew Toole
I am quite new to web2py. I am attempting to build an app that will use 
Auth to control log-in and membership for access to various parts of the 
app.

I will have different types of users. Some will just come to get info and 
leave and we don't need to know much about them. Others will be employees 
and will have a bunch of info associated with them that will be used in 
various parts of the app.

My question is how is the best way to link this employee information to the 
users?

E.G.
User 1 is an employee and has "next of kin" and a "charge out rate" (and 
lots more info).

If the current user enters hours worked in a timesheet table, I will need 
to associate the current user with their "charge out rate" (knowing the 
current user is User1 in the other table).

One option is as additional fields in Auth, but my concern is that I am 
adding a lot of fields which will be empty for most users. Is this the best 
approach or is there another approach?

Are there more advanced example applications available somewhere?

Thanks,
Andrew

-- 
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: why you should upgrade to web2py 2.13.4

2016-12-21 Thread Rodrigo attique santana

Hello, I recently upgraded my version of web2py to 2.13, however I am 
having compatibility issues on projects created in version 2.11, which do 
not run in this version. The same is true for projects created in version 
2.13.

Em sábado, 26 de dezembro de 2015 06:22:27 UTC-2, Massimo Di Pierro 
escreveu:
>
> There are many reasons you should upgrade, depending on which version you 
> are using now:
>
> - to help us make sure we did not break backward compatibility. If your 
> existing app does not work with 2.13.4 (and it should) you give us a chance 
> to fix the problem. If no, any potential incompatibility will propagate 
> forward making it more difficult for us to fix it later, and more difficult 
> for you to upgrade.
>
> - to take advantage of new features. For example the awesome JWT feature 
> that allows to create API tokens and use them for authentication without 
> hitting the database.
>
> - there is also an important security bug fix in 2.13.4 related to 
> auth.settings.registration_requires_approval=True. The bug allows a newly 
> registered user to bypass the approval process and approve himself/herself. 
> Under come conditions. This is now fixed.
>
> Massimo
>

-- 
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] How to run web2py on Linux Shared Hosting With No Shell, or SSH access

2016-12-21 Thread Muhammad Hashim Malik
Because PythonAnywhere does not allow PostgreSQL on Free account. Using 
PostgreSQL cost more than $10 a month


Hashim


On Wednesday, 11 February 2015 02:06:13 UTC+5, Massimo Di Pierro wrote:
>
> I do not understand why anybody would use shared hosting in 2015 when you 
> can have PythonAnywere or Google App Engine for free or a dedicated VM on 
> Digital Ocean for $5/mo.
>
> Anyway, the book chapter "Shared hosting with mod_python" must go. 
> mod_python should not be used by anybody anymore.
>
> How to use web2py on shared hosting really depends on what they allow. 
> Probably your best best is running web2py locally under the credentials of 
> the user of the shared account and use htaccess/cpanel to do a port 
> redirection using for example apache mod_proxy. I can give more details if 
> you point me to some documentation from the host company.
>
> Massimo
>
>
>
> On Monday, 9 February 2015 03:04:25 UTC-6, Alexander Morales wrote:
>>
>> I'm waiting for a reply too. 
>> I can't run my web2py on a shared hosting with CPanel.
>>
>> The official tuttorial isn't working...
>>
>> thanks
>> Alexander
>>
>> El sábado, 18 de mayo de 2013, 20:32:33 (UTC-4:30), Neeraj Kumar escribió:
>>>
>>> I am reseller and already have 8+ domains hosted with them. Its really 
>>> painful and time taking to switch, and they offer pretty good space and 
>>> bandwidth(for non web2py, i am still fine with their services, but for 
>>> web2py silicon house is behaving pathetically). They are not offering SSH 
>>> access, asking to take cloud/VPS, but don't want to spend that much of 
>>> money.
>>> (Though i will definitely switch if nothing works).
>>>
>>> Well, in "web2py manual 5th edition" i read section 13.2.10 for "Shared 
>>> hosting with mod_python". That looked promising upon reading, but did not 
>>> work.
>>>
>>> I am basically thinking on 2 lines for solution(3rd obviously is 
>>> changing the hosting provider):
>>> 1) I believe there should be some way out over here, by means of 
>>> ScriptAlias, SetHandler or PythonHandler, etc in .htaccess file
>>> 2) I have access to cPanel, and do see an icon for "cron jobs" and I 
>>> believe i can execute some commands by means of this. But do not know what 
>>> to execute :)
>>>
>>> If anybody has done it in past without modifying apache configuration 
>>> files(..conf/apache.conf, and ..conf/extra/httpd-vhosts.conf), then that 
>>> experience will be of great help.
>>>
>>>
>>> On Friday, May 17, 2013 6:10:57 PM UTC+5:30, yamandu wrote:

 Have you asked your host for SSH access?
 I have used hostgator, I have to ask then to grant me SSH access, and 
 even with this is a pain to make web2py run there.
 If they dont give it anyway, consider change the host, give a try at 
 pythonanywhere.com, you should install web2py with one click.


 2013/5/16 Neeraj Kumar 

> Hi,
>  
> I am trying to deploy Web2Py on my linux shared hosting with 
> siliconhouse.net.
>  
> Python runs on their system, able to run HelloWorld.py
>  
> But when i unzipped the files on my public_html folder(with 755 
> permission on *.py files), instead of running it, it shows me listing of 
> all files including *.py files.
>  
> I am not sure what the problem is? If i click on any *.py files, it 
> shows me 500-Internal Server Error 500.
>  
> I have no shell or SSH access, is there a simple and easy way for me 
> to be able to run web2py on this.
>  
> They are using mod_python, and i can not deploy mod_wsgi. Is there any 
> alternate, or is there something i can do my editable area i.e. inside 
> public_html/..., so that when open my site i should be able to see 
> running 
> web2py application of my choice?
>  
> I shall be highly thankful for any assistance on this.
>  
> Regards,
> Neeraj Kumar
>  
>  
>
> -- 
>  
> --- 
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>



 -- 
 Att.

 Carlos J. Costa
 Cientista da Computação
 Esp. Gestão em Telecom

 EL MELECH NEEMAN!
 אָמֵן



-- 
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] MSSQL connection

2016-12-21 Thread Steve Lyle
Hi guys.
Newbie (of sorts) here.
20+ years in programming including Python but not for a couple of years now.

But now I have the first time opportunity to build my application in web2py 
~ so not a newbie but yes a web2py newbie.

Any quick start guides/guide for dummys style for adapting the default 
application to connect to MSSQL?
You reference will be appreciated.

If I remember from prior python work that even though the module is call 
'..odbc' is doesn't really use odbc does it?!?

Thanks.

-- 
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] Modular application recipes

2016-12-21 Thread Andrea Fae'
Why this line {{=LOAD('default', 'list_items', ajax = True, target 
='showitems')}}

doens't work in the recipe Modular application in the cookbook web2py?
Do you have the same problem?
It's not showing the list of items.

DO you know some easier tutorial og web2py, otherwise the Di Pierro book 
and this cookbook?

-- 
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] Select from auth_user with auth.has_membership condition

2016-12-21 Thread antonella . mauri
Hi,
in my model I have users who have membership to more groups.
I am trying to perform a query of users who DO NOT belong to a group; 
something along these lines:

query = db ((db.auth_user != auth.user.id) & (~(auth.has_membership 
("admin", db.auth_user.id))).select (db.auth_user.first_name, 
db.auth_user.last_name)

The above query does not work, i.e. it retrieves all records except the 
currently logged in user (which is OK) but ignores the "has_membership" 
condition. It gives no errors, though...

I know I can perform the select with only the first condition and then loop 
over the result to remove the users that have membership to group "admin", 
but I wonder if I can have the result in a single query.

Thanks!

-- 
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] Layout design with angular material and web2py

2016-12-21 Thread Biplov Bhandari
Hi All,

I am trying to use angular material with web2py. My layout.html using 
angular material looks like this: http://pastebin.com/Fydxwb8w. The layout 
looks like this when loaded in browser: 

[image: AP4XDAk.png (1823×1041)]

I am trying to create login form. My form style looks like this:

def formstyle_angular_material(form, fields, *args, **kwargs):

def render_row(row_id, label, widget, comment, hidden=False):


input_container = TAG["md-input-container"](_class="md-block")


_class = "form-row row hide" if hidden else "form-row row"


if isinstance(label, LABEL):
label.attributes["_style"] = "color:green"
input_container.append(label)


if isinstance(widget, INPUT):
if "_type" in widget.attributes and \
   widget.attributes["_type"] == "checkbox":
# Checkbox
# Label contained here
widget = TAG["md-checkbox"](label.components[0])
return DIV(widget, _class=_class, _id=row_id)
else:
# Normal Input
# Label contained above
input_container.append(widget)


if hasattr(widget, "element"):
submit = widget.element("input", _type="submit")
if submit:
widget = TAG["md-button"](widget.attributes["_value"],
  _class="md-raised md-primary",
  _type="submit")
return DIV(widget, _class=_class, _id=row_id)


return DIV(input_container, _class=_class, _id=row_id)


parent = TAG[""]()
for row_id, label, widget, comment in fields:
parent.append(render_row(row_id, label, widget, comment))
return parent


The /views/default/user.html looks like this:

{{if request.args(0) == "login":}}
 {{include "auth/_login.html"}}
{{pass}}


{{block page_js}}

jQuery("#web2py_user_form input:visible:enabled:first").focus();
{{if request.args(0)=='register':}}
web2py_validate_entropy(jQuery('#auth_user_password'),100);
{{elif request.args(0)=='change_password':}}
web2py_validate_entropy(jQuery('#no_table_new_password'),100);
{{pass}}

{{end page_js}}



The /views/auth/_login.html looks like this:

{{sidenav_enabled=True}}
{{menu_enabled=False}}
{{extend "layout.html"}}
{{include "angular_module.html"}}
{{include "../static/angular/controllers/AppCtrl.html"}}
{{include "../static/angular/controllers/LoginCtrl.html"}}
{{include "../static/angular/services/menu.service.html"}}
{{block content}}
{{=form}}
{{end}}


The others are controller and services. But this gives me GET 
http://127.0.0.1:8000/favicon.ico 400 (BAD REQUEST) in the browser.

I tried different other combination for views but gives me error in login 
while the index page is loaded ok.

Any thing that I am missing here? Any help is much appreciated.

Many Thanks,
Biplov


-- 
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] How to install GitPython into webp2y app modules directory?

2016-12-21 Thread Manohar Ramarao
Hi,
I need to do operations with git repository from my web app built on 
web2py. I can't add this into python's site-packages. I need to ship it 
along with the web app.

Thanks,
Manohar

-- 
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] Issues with record versioning

2016-12-21 Thread Ricardo Oliveira
Hi,
I'm having a couple of issues with record versioning:
1) I had to directly "force" versioning for tables 
(db.mytable._enable_record_versioning() for each table), although I have:

 auth.define_tables(username=True, signature=True)
 auth.enable_record_versioning(db, 
archive_names='%(tablename)s_archive', current_record='current_record')
 db._common_fields.append(auth.signature)

2) the user & time are not recorded on the modified_on, modified_by columns

Not sure where to go from here.
I would appreciate any help.

Best regards,
Ricardo.

-- 
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: Linking Auth with another table to store additional info about user

2016-12-21 Thread 黄祥
why not create a new table for that and reference it to auth_user table?
*e.g.*
*models/db.py*
db.define_table('employee', 
Field('is_auth', 'boolean'),
* Field('auth_user', 'reference auth_user'), *
Field('first_name'), 
Field('last_name'),
Field('email', 'list:string'),  
Field('occupation'),
Field('address', 'text'), 
Field('notes', 'text'), 
Field('basic_salary', 'integer'), 
format = lambda r: '%s %s' % (r.first_name, r.last_name) )

best regards,
stifan

-- 
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: Linking Auth with another table to store additional info about user

2016-12-21 Thread Anthony
Think about how many users and how much extra space those fields will 
really take in the auth_user table vs. both the complexity and inefficiency 
of having to do joins whenever you need the extra fields if you keep them 
in a separate table. You might also consider keeping some of the extra data 
in a single JSON field if you don't need to search/sort based on the data.

Anthony

On Wednesday, December 21, 2016 at 11:13:09 PM UTC-5, Andrew Toole wrote:
>
> I am quite new to web2py. I am attempting to build an app that will use 
> Auth to control log-in and membership for access to various parts of the 
> app.
>
> I will have different types of users. Some will just come to get info and 
> leave and we don't need to know much about them. Others will be employees 
> and will have a bunch of info associated with them that will be used in 
> various parts of the app.
>
> My question is how is the best way to link this employee information to 
> the users?
>
> E.G.
> User 1 is an employee and has "next of kin" and a "charge out rate" (and 
> lots more info).
>
> If the current user enters hours worked in a timesheet table, I will need 
> to associate the current user with their "charge out rate" (knowing the 
> current user is User1 in the other table).
>
> One option is as additional fields in Auth, but my concern is that I am 
> adding a lot of fields which will be empty for most users. Is this the best 
> approach or is there another approach?
>
> Are there more advanced example applications available somewhere?
>
> Thanks,
> Andrew
>

-- 
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: why you should upgrade to web2py 2.13.4

2016-12-21 Thread Anthony
On Wednesday, December 21, 2016 at 11:13:17 PM UTC-5, Rodrigo attique 
santana wrote:
>
>
> Hello, I recently upgraded my version of web2py to 2.13, however I am 
> having compatibility issues on projects created in version 2.11, which do 
> not run in this version. The same is true for projects created in version 
> 2.13.
>

Do you have a question?

-- 
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: Select from auth_user with auth.has_membership condition

2016-12-21 Thread Anthony
auth.has_membership is not used to construct DAL queries -- it is for 
checking whether a given user actually has a given membership (it returns 
True or False). Also, its second argument should not be a DAL Field object.

You need to construct a query based on the db.auth_membership table.

Anthony

On Wednesday, December 21, 2016 at 11:13:17 PM UTC-5, 
antonella.ma...@yottacle.com wrote:
>
> Hi,
> in my model I have users who have membership to more groups.
> I am trying to perform a query of users who DO NOT belong to a group; 
> something along these lines:
>
> query = db ((db.auth_user != auth.user.id) & (~(auth.has_membership 
> ("admin", db.auth_user.id))).select (db.auth_user.first_name, 
> db.auth_user.last_name)
>
> The above query does not work, i.e. it retrieves all records except the 
> currently logged in user (which is OK) but ignores the "has_membership" 
> condition. It gives no errors, though...
>
> I know I can perform the select with only the first condition and then 
> loop over the result to remove the users that have membership to group 
> "admin", but I wonder if I can have the result in a single query.
>
> Thanks!
>

-- 
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: custom form default value

2016-12-21 Thread Tom Schuerlein
Thank you, I was completely unaware that this syntax was needed.  I will
never get those 2 hrs of my life back, but thanks to you I will sleep well
tonight!!!  You are THE BOSS.

On Wed, Dec 21, 2016 at 5:52 AM, Anthony  wrote:

> > id="sample_sample_name" class="text" value={{=row.sample_name}}/>
>>
>
> It's always a good idea to check the returned HTML source in the browser.
> In this case, you will see you forgot the quotes around the value -- should
> be:
>
> value="{{=row.sample_name}}"
>
> You're getting:
>
> value=RED CAR WITH ROOF
>
> instead of:
>
> value="RED CAR WITH ROOF"
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/IZ0fe7WxYYg/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.


[web2py] Re: Layout design with angular material and web2py

2016-12-21 Thread Biplov Bhandari
Update. I am able to load the auth/_login.html but the form is not 
included. The div id='body' looks like this now:

  

  {{=response.title or app_settings["system_name"]}}

  

  {{block content_form}}
{{include}}
  {{end content_form}}

  


The auth/_login.html looks like this: 

{{sidenav_enabled=False}}
{{menu_enabled=False}}
{{extend "layout.html"}}
{{include "angular_module.html"}}
{{include "../static/angular/controllers/AppCtrl.html"}}
{{include "../static/angular/controllers/LoginCtrl.html"}}
{{include "../static/angular/services/menu.service.html"}}

{{block content_form}}
 {{=form}}
{{end content_form}}



The screenshot of the login page is

[image: GJyT5qh.png (1799×938)]

But as you can see, the form is not loaded. Can anyone help me to include 
the form in the layout from the view? Any help is much appreciated.


Best Regards,
Biplov


-- 
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: Select from auth_user with auth.has_membership condition

2016-12-21 Thread antonella . mauri


On Thursday, December 22, 2016 at 5:13:17 AM UTC+1, antonel...@yottacle.com 
wrote:
>
> Hi,
> in my model I have users who have membership to more groups.
> I am trying to perform a query of users who DO NOT belong to a group; 
> something along these lines:
>
> query = db ((db.auth_user != auth.user.id) & (~(auth.has_membership 
> ("admin", db.auth_user.id))).select (db.auth_user.first_name, 
> db.auth_user.last_name)
>
> The above query does not work, i.e. it retrieves all records except the 
> currently logged in user (which is OK) but ignores the "has_membership" 
> condition. It gives no errors, though...
>
> I know I can perform the select with only the first condition and then 
> loop over the result to remove the users that have membership to group 
> "admin", but I wonder if I can have the result in a single query.
>
> Thanks!
>

== EDIT ==

I have found a way to get what I need:

users = db (
(db.auth_user.id != userid)
).select (db.auth_user.id,
  db.auth_user.first_name,
  db.auth_user.last_name,
  db.auth_user.email,
  distinct = True).exclude (lambda row: not 
auth.has_membership ("admin", row.id))
 
Not sure how efficient it is but it works.

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