[web2py] Re: About session variable

2017-01-21 Thread Dave S
On Saturday, January 21, 2017 at 11:11:23 PM UTC-8, Dave S wrote:
>
>
>
> On Friday, January 20, 2017 at 9:14:00 AM UTC-8, Anthony wrote:
>>
>> See http://stackoverflow.com/a/41769011/440323.
>>
>> On Friday, January 20, 2017 at 6:09:31 AM UTC-5, Bishal Saha wrote:
>>>
>>> I have stored a dictionary in the session variable and now I want to 
>>> store the values of the dictionary in my MySQL database in another server. 
>>> Will I be able to do it ? And if yes dn how ?
>>>
>>
> If the dict keys don't  match the table schema, an error is returned, no?
>
> Yep, it's a ticketing offense.

/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: About session variable

2017-01-21 Thread Dave S


On Friday, January 20, 2017 at 9:14:00 AM UTC-8, Anthony wrote:
>
> See http://stackoverflow.com/a/41769011/440323.
>
> On Friday, January 20, 2017 at 6:09:31 AM UTC-5, Bishal Saha wrote:
>>
>> I have stored a dictionary in the session variable and now I want to 
>> store the values of the dictionary in my MySQL database in another server. 
>> Will I be able to do it ? And if yes dn how ?
>>
>
If the dict keys don't  match the table schema, an error is returned, no?

/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: Conditional validation

2017-01-21 Thread Anthony
On Friday, January 20, 2017 at 11:22:14 AM UTC-5, Andrea Fae' wrote:
>
> Hello guys, I need to have a dependent field in a table.
> If the field "is_active" = True then I cannot insert in the field "date" 
> nothing.
> If the field "is_atvie" = False then I can or not insert something in the 
> field "date".
> How to do in the definition of table? Or it's better to use "onvalidation" 
> function?
>

You can handle validation involving multiple fields via onvalidation. You 
can also conditionally specify whether the field is writable based on 
request.post_vars.

Field('mydate', 'date', requires=IS_EMPTY_OR(IS_DATE()),
  writable=request.post_vars.is_active == True)

In the UI, you can also conditionally hide the date field (though you 
should still handle the validation/writable status on the server) -- see 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Conditional-fields.

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

2017-01-21 Thread Andrea Fae'
Where can I find conditional validation documentation?

Il giorno venerdì 20 gennaio 2017 17:22:14 UTC+1, Andrea Fae' ha scritto:
>
> Hello guys, I need to have a dependent field in a table.
> If the field "is_active" = True then I cannot insert in the field "date" 
> nothing.
> If the field "is_atvie" = False then I can or not insert something in the 
> field "date".
> How to do in the definition of table? Or it's better to use "onvalidation" 
> function?
> 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] Re: Arbitrary args/kwargs with service?

2017-01-21 Thread Anthony


> I created an issue here: https://github.com/web2py/web2py/issues/1561
>
> I can probably do a pull request, but wanted to see if anyone knows of a 
> reason why the existing service functionality restricts the passed 
> arguments, instead of just passing them all to the service function, as 
> request.restful does.
>

I'm not aware of any reason for the current restriction.

This brings to mind another possible workaround -- you can monkey patch 
universal_caller in gluon.tools.

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

2017-01-21 Thread Bishal Saha
Cant we use grid to update few rows ?

-- 
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: Advice on structuring my app

2017-01-21 Thread Val K
Hi, here is my solution:
There are some abstract *actions *like view/edit/delete/upload/download and 
so on
There are the *roles *that define combinations of the actions - it's the 
table that has 'value' bit field  - each bit corresponds to the action
There are the *groups *and two  symmetric relation tables: *user_group_role 
, object_group_role *, object means anything on which could be performed 
the actions
Now, the set of allowed actions on the object for the user  could be 
calculated:  
 - find `intersection` (common) groups of *user *and *object *(inner join 
on group)
* - *logical sum up  role.value (bitwise aggregate OR)  for 
*user_group_role *and for *object_group_role **= user_sum_role, 
object_sum_role  *
*allowed_actions_set* = *user_sum_role *AND *object_sum_role   *(bitwise 
AND)  

for example:  user has membership in orgA with role 'super', but orgA has 
only 'read' role on the *object - * 'super'  will be trimmed to 'read'... 
but if user also has membership under 'super' in another group which has 
'super' against the object too, role_action_set won't be trimmed  

On Tuesday, January 17, 2017 at 7:59:27 PM UTC+3, Leonel Câmara wrote:
>
> I'm in the process of turning an application that was used by a single 
> organization into one that will be used by many, I'm using regular Auth and 
> auth groups to manage which users can do what according to what groups they 
> have memberships on.  
>   
> The first problem I'm facing is that the users that belong to a given 
> auth_group will now only belong to that group in a given organization, 
> which I guess would also be a problem with regular auth functions. 
>
> Another problem is that I want the organizations to be able to share some 
> of their data with another organization.  
>   
> So, right now, I'm considering what would be the best architecture for the 
> application.  
>   
> One idea would be to store the organization the user is currently browsing 
> with (no reason to limit that one user can only belong to one organization) 
> in session, then I would have to check in each controller if the user has 
> the right group and organization for what he wants to do, this would 
> pollute my code somehow.  
>   
> Another idea is for each organization to become a group, then what I use 
> groups for right now will be permissions, this is probably the best route. 
> This would still leave the problem of making the user see the right data 
> depending on which organization he is currently browsing with.   
>   
> Any advice on how to do this as cleanly as possible in terms of code?
>

-- 
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] Store dates in UTC format across all tables

2017-01-21 Thread Gaurav Vichare
I want to store created_on and modified_on values of all tables in UTC 
format. Audit fields are added using 
db._common_fields.append(auth.signature) and  in auth.signature default 
value for created_on and modified_on is request.now, I want to change it to 
request.utcnow. So I tried following but its now working, it is still 
storing server time, not in UTC. 

auth.signature.created_on.default = request.utcnow
auth.signature.modified_on.default = request.utcnow
db._common_fields.append(auth.signature)


I am able to change default value to utc by explicitly defining it for each 
table like this

db.table_name.field_name.created_on.default =  request.utcnow
db.table_name.field_name.modified_on.default =  request.utcnow

But I don't want to repeat same thing for all tables.
So how can I override default values of modified_on and created_on with 
minimum lines of code?
My next task is to show record creation date/time according to user's 
timezone.

Thank You
- Gaurav Vichare

-- 
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_NOT_ID_DB for mutliple fields

2017-01-21 Thread Yebach
Hello

I have to make a validator on my SQLFORM that checks 4 fields

my table is


db.define_table('workers_skills',
Field('ws_organisation', type ='integer'),
Field('ws_worker', 'reference workers', label = T('Worker')),
Field('ws_skill', 'reference skills', label = T('Skill')),
Field('ws_priority', type ='integer', label = T('Priority')),
Field ('ws_status', type= 'integer',  label = T('Status'), 
widget = SQLFORM.widgets.options.widget, default = 1),
migrate = settings.migrate)


The check is on fields ws_organisation, ws_worker, ws_skill and ws_priority

So a worker cannot have the same ws_priority value for two different 
skills. 

this are the validators already set

db.workers_skills.ws_priority.requires = [IS_NOT_EMPTY(error_message=T('Missing 
priority level')),
  IS_INT_IN_RANGE(1, 
10,error_message=T('Priority cannot be 0 or larger then 10!'))


db.workers_skills.ws_worker.requires = IS_IN_DB(
db((db.workers.w_organisation == org) & 
(db.workers.w_status < 100)),
db.workers.id, '%(w_nick_name)s - 
%(w_last_name)s %(w_first_name)s', zero=T('Select worker'))

#preprečmo da bi ble podvojene vrednosti isti delavc isti skill pa da je 
dropdown mani sk_name glede na organizacijo
db.workers_skills.ws_skill.requires = IS_IN_DB(db((db.skills.sk_organisation == 
org) &
  (db.skills.sk_status < 100)), 
db.skills.id, '%(sk_name)s',
   zero=T('Select skill'),
   
_and=IS_NOT_IN_DB(db(db.workers_skills.ws_worker == request.vars.ws_worker),
 
'workers_skills.ws_skill'))


What would be the most elegant way to solve this?

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.