[web2py] validate_and_insert() doesn't work for compute field

2016-10-02 Thread Yang
Hello, 

It seems that validate_and_insert() doesn't work for compute field. For 
example,

db.define_table('test',
  Field('x', 'float'),
  Field('y', 'float', compute=lambda r: r['x'] * 2))

db.test.validate_and_insert(x=1) gives 
db.test.insert(x=1) gives 

Is this expected? Thank you in advance.

-- 
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] Under Scheduler request.is_scheduler is None rather than True - Why?

2016-10-02 Thread Brian M
Is there a reason why when something is run under the scheduler 
request.is_scheduler = None rather than True? When you access 
request.is_scheduler from outside of the scheduler you get False as one 
would expect. The current None value seems strange/non-intuitive.
#this won't work
if request.is_scheduler:
   #do special scheduler stuff

#To really know if you're running under the scheduler you must use this 
which makes no sense
if request.is_scheduler == None:
   #do special scheduler stuff
 

This has been the case for a while and is still happening with the latest 
git trunk



-- 
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: Partial flush of request

2016-10-02 Thread luis . valladares
The second sounds good to me, but i dont know really where to store it, my 
front end is REST and has no database connected to it, all the info i get 
its from microservices, so i need some sort of variable or environment 
space where to store the token when i receive it and retrieve it in the 
case of an error, there is anything like that in web2py?

El domingo, 2 de octubre de 2016, 11:59:13 (UTC-4), Anthony escribió:
>
> On Sunday, October 2, 2016 at 7:52:04 AM UTC-4, Luis Valladares wrote:
>>
>> Because my application has a microservice architecture, this means there 
>> is another app storing the token in the database and the only thing my 
>> web2py front end does is make a http request to that microservice and 
>> format the received data, but if during that formatting some exception is 
>> raised I lost all the content (in this case the token) that I want to send 
>> in request.cookies, this mean the user still have the old token when the 
>> microservice already have changed that token in their database.
>>
>
> You could either wrap your web2py code in a try/except to ensure you catch 
> any errors directly, or use routes_onerror in routes.py to route any errors 
> to a separate error handling app/controller (in the latter case, you'll 
> need to make sure the relevant token data have been saved somewhere the 
> error handler can access).
>
> 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] Scheduler - response.render no longer working

2016-10-02 Thread Brian M
OK, so I've had multiple scheduled tasks running for years that use 
response.render('path/to/template.html', dict(var= 'something')) to help 
build email bodies and it has been working perfectly. Now when I try to 
upgrade to the latest web2py trunk (was on 2.13.4 - yeah I'm a bit behind) 
all that has stopped working.  Below is the error I'm getting
File "C:\FMSC Webapps\web2py_master\gluon\globals.py", line 437, in render
self._view_environment.update(self._vars)
AttributeError: 'NoneType' object has no attribute 'update'

Why isn't this working anymore? Has some backwards compatibility breaking 
change been made to the scheduler environment? Any advice would be much 
appreciated.

-Brian

PS. I've 
seen 
https://groups.google.com/forum/#!searchin/web2py/response.render$20scheduler|sort:relevance/web2py/UsUvODL07zs/HrcCsxQcCQAJ
 
which would seem related but I'm unable to get it working by just adding 
from gluon.template import render

-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter

Thanks again Marlysson!


Okay, I've tried a few configurations  (a lot actually) and came up with 
this which doesn't work (but it doesn't crash either - it breaks the view 
by showing no calendar entries)  
  
It's probably too influenced by my python formatting and flow*! Regardless, 
I can't figure out what I should be passing to  'element'* anyway (see 
?)



$(document).ready(function() {

var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();

$('#calendar').fullCalendar({
eventRender: eventRenderCallback,

function eventRenderCallback(event, element){
if (event.type == "TRAINING"){
element.classList.add('training');
}else if (event.type == "MEETING"){
element.classList.add('meeting');
}else if (event.type == 'PROJECT_WORK'){
element.classList.add('project_work');
}
}

editable: false,
events: [
{{for row in rows:}}
event = {  type: '{{row.task.task_type.lower()}}',
  title: '{{=row.task.task_status}} 
{{=row.task.task_type}}  {{=row.person.fullname.replace("'","\\'")}} ',
 allDay: false,
  start: new Date('{{=row.task.start_time.strftime('%B 
%d, %Y %H:%M:%S')}}'),
url: '{{=URL('view_task',args=row.task.id)}}'
  },
 eventRenderCallback(event, ???)
   {{pass}}
]
});
 });





  
*Should I even be wrapping up the attributes of each event (in the rows 
loop) assigning them to a variable 'event' and passing that to 
eventRenderCallback? *


I am really in the dark here!

Peter

 

-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Marlysson Silva
First , in css , the classes are defined with "." before name them , then 
it's so : .trainning , .project_work 

With this answer : 
http://stackoverflow.com/questions/31322105/full-calendar-rails-adding-custom-css-classes-to-events/33894043#33894043
 


It's possible to use a custom function in javascript to handle events of 
calendar, by example:

To create classes:

.meeting{ 
background-color: green;
 border-color: black;
 color: #fff;
}

.training{
 background-color: green;
 border-color: black;
 color: #fff;

}

.project_work{
background-color: blue;
 border-color: black;
 color: #fff;
}

with classes created you should capture type of event via javascript:

$('#calendar').fullCalendar({
...
eventRender: eventRenderCallback,
...});
function eventRenderCallback(event, element){

if (event.type == "TRAINING"){

element.classList.add('training');

}else if (event.type == "MEETING"){

element.classList.add('meeting');

}else if (event.type == 'PROJECT_WORK'){

element.classList.add('project_work');

}
}


How you already have classes created , on event javascript get each event 
of calendar and will make verification of type ( here use variable of event 
that represent the type his ) and add class respective.

Anyway just call me , I think that I added a lot of things.

Em domingo, 2 de outubro de 2016 16:50:09 UTC-3, Peter escreveu:
>
>
> Thanks Marlysson,
>
>
>
> Assuming   row.task.task_typecan be  one of   [ 'TRAINING' , 
> 'MEETING'  , 'PROJECT_WORK'']
>
> I want the event background to be RED GREEN or BLUE respectively.
>
>
> Do I add code something like this to the CSS file 
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass TRAINING {
> background-color: red;
> border-color: black;
> color: #fff;
>  }
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass MEETING {
>  background-color: green;
>  border-color: black;
>  color: #fff;
>  }
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass PROJECT_WORK {
>  background-color: blue;
>  border-color: black;
>  color: #fff;
>  }
>
>
>  
> then how to I call it from the calendar view included (see original post)?
>
>
> Peter
>
>
>

-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Marlysson Silva
First , in css , the classes are defined with "." before name them , then 
it's so : .trainning , .project_work 

With this answer 
: 
http://stackoverflow.com/questions/31322105/full-calendar-rails-adding-custom-css-classes-to-events/33894043#33894043

It's possible to use a custom function in javascript to handle events of 
calendar, by example:

To create classes:

.meeting{ 
background-color: green;
 border-color: black;
 color: #fff;
}

.training{
 background-color: green;
 border-color: black;
 color: #fff;

}

.project_work{
background-color: blue;
 border-color: black;
 color: #fff;
}

with classes created you should capture type of event via javascript:

$('#calendar').fullCalendar({
...
eventRender: eventRenderCallback,
...});
function eventRenderCallback(event, element){

if (event.type == "TRAINING"){

element.addClass('training');

}else if (event.type == "MEETING"){

element.addClass('meeting');

}else if (event.type == 'PROJECT_WORK'){

element.addClass('project_work');

}
}


How you already have classes created , on event javascript get each event 
of calendar and will make verification of type ( here use variable of event 
that represent the type his ) and add class respective.

Anyway just call me , I think that I added a lot of things.


Em domingo, 2 de outubro de 2016 16:50:09 UTC-3, Peter escreveu:
>
>
> Thanks Marlysson,
>
>
>
> Assuming   row.task.task_typecan be  one of   [ 'TRAINING' , 
> 'MEETING'  , 'PROJECT_WORK'']
>
> I want the event background to be RED GREEN or BLUE respectively.
>
>
> Do I add code something like this to the CSS file 
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass TRAINING {
> background-color: red;
> border-color: black;
> color: #fff;
>  }
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass MEETING {
>  background-color: green;
>  border-color: black;
>  color: #fff;
>  }
>
>  .myclass,
>  .fc-agenda .myclass .fc-event-time,
>  .myclass PROJECT_WORK {
>  background-color: blue;
>  border-color: black;
>  color: #fff;
>  }
>
>
>  
> then how to I call it from the calendar view included (see original post)?
>
>
> Peter
>
>
>

-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter

Thanks Marlysson,



Assuming   row.task_typecan be  one of   [ 'TRAINING' , 'MEETING'  , 
'PROJECT_WORK'']

I want to the event background to be RED GREEN or BLUE respectively.


Do I add code something like this to the CSS file 

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass TRAINING {
background-color: black;
border-color: black;
color: red;
 }

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass MEETING {
 background-color: black;
 border-color: black;
 color: green;
 }

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass PROJECT_WORK {
 background-color: black;
 border-color: black;
 color: blue;
 }


 
then how to I call it from the calendar view included (see original post)?


Peter


-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Marlysson Silva
You need that each type event change with a type backgroud specific?

You should to create styles to each type and to use by javascript or jquery 
handle events and change background of element wished .. What do you need 
do?

Em domingo, 2 de outubro de 2016 12:28:12 UTC-3, Peter escreveu:
>
>
>
> Would anyone haver time to explain briefly how to utilise this CSS code.
>
> /* Global Event Styles
> */
>
> .fc-event,
> .fc-agenda .fc-event-time,
> .fc-event a {
>border-style: solid; 
>border-color: #36c; /* default BORDER color (probably the same as 
> background-color) */
>background-color: #36c; /* default BACKGROUND color */
>color: #fff;/* default TEXT color */
>}
>
>/* Use the 'className' CalEvent property and the following
> * example CSS to change event color on a per-event basis:
> *
> * .myclass,
> * .fc-agenda .myclass .fc-event-time,
> * .myclass a {
> * background-color: black;
> * border-color: black;
> * color: red;
> * }
> */
>
>
>
> I know some python & html but know little about CSS so I need to take a 
> course or two...
>
> In the mean time I would appreciate any help with this...
>
> The calendar view has this code
>
> $('#calendar').fullCalendar({
> editable: false,
> events: [
> {{for row in rows:}}
> {  .myclass, .fc-agenda .myclass .fc-event-time, .myclass a { 
> background-color: black; border-color: black; color: red;  }
> title: '{{=row.task.task_status}} {{=row.task.task_type}}  
> {{=row.person.fullname.replace("'","\\'")}} ',
> allDay: false,
> start: new Date('{{=row.task.start_time.strftime('%B %d, %Y 
> %H:%M:%S')}}'),
> url: '{{=URL('view_task',args=row.task.id)}}'
> },
> {{pass}}
> ]
> });
>
>
> This works to display the calendar events but they all have the same 
> background colour of blue
>
> How do I implement the CSS so each event background colour changes 
> depending on {{=row.task.task_type}}
>
>
> Many thanks,
>  
> Peter
>

-- 
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: Partial flush of request

2016-10-02 Thread Anthony
On Sunday, October 2, 2016 at 7:52:04 AM UTC-4, Luis Valladares wrote:
>
> Because my application has a microservice architecture, this means there 
> is another app storing the token in the database and the only thing my 
> web2py front end does is make a http request to that microservice and 
> format the received data, but if during that formatting some exception is 
> raised I lost all the content (in this case the token) that I want to send 
> in request.cookies, this mean the user still have the old token when the 
> microservice already have changed that token in their database.
>

You could either wrap your web2py code in a try/except to ensure you catch 
any errors directly, or use routes_onerror in routes.py to route any errors 
to a separate error handling app/controller (in the latter case, you'll 
need to make sure the relevant token data have been saved somewhere the 
error handler can access).

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] Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter


Would anyone haver time to explain briefly how to utilise this CSS code.

/* Global Event Styles
*/

.fc-event,
.fc-agenda .fc-event-time,
.fc-event a {
   border-style: solid; 
   border-color: #36c; /* default BORDER color (probably the same as 
background-color) */
   background-color: #36c; /* default BACKGROUND color */
   color: #fff;/* default TEXT color */
   }
   
   /* Use the 'className' CalEvent property and the following
* example CSS to change event color on a per-event basis:
*
* .myclass,
* .fc-agenda .myclass .fc-event-time,
* .myclass a {
* background-color: black;
* border-color: black;
* color: red;
* }
*/



I know some python & html but know little about CSS so I need to take a 
course or two...

In the mean time I would appreciate any help with this...

The calendar view has this code

$('#calendar').fullCalendar({
editable: false,
events: [
{{for row in rows:}}
{  .myclass, .fc-agenda .myclass .fc-event-time, .myclass a { 
background-color: black; border-color: black; color: red;  }
title: '{{=row.task.task_status}} {{=row.task.task_type}}  
{{=row.person.fullname.replace("'","\\'")}} ',
allDay: false,
start: new Date('{{=row.task.start_time.strftime('%B %d, %Y 
%H:%M:%S')}}'),
url: '{{=URL('view_task',args=row.task.id)}}'
},
{{pass}}
]
});


This works to display the calendar events but they all have the same 
background colour of blue

How do I implement the CSS so each event background colour changes 
depending on {{=row.task.task_type}}


Many thanks,
 
Peter

-- 
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: Partial flush of request

2016-10-02 Thread Luis Valladares
Because my application has a microservice architecture, this means there is
another app storing the token in the database and the only thing my web2py
front end does is make a http request to that microservice and format the
received data, but if during that formatting some exception is raised I
lost all the content (in this case the token) that I want to send in
request.cookies, this mean the user still have the old token when the
microservice already have changed that token in their database.

El sáb., oct. 1, 2016 9:40 PM, Anthony  escribió:

> On Saturday, October 1, 2016 at 4:19:59 PM UTC-4, Luis Valladares wrote:
>
> They expire, when I generate a new token I store it in the database and
> send to the user browser, each time the token is expired I generate a new
> one, overwrite the token in the database (and because this the other token
> is lost) and sent to the user.
>
>
> I'm not sure I understand. Every HTTP request is wrapped in a database
> transaction, so if an error occurs during a request, any database
> operations that had been made prior to the error will be rolled back before
> returning the error response. So, how is it that your token overwriting is
> not being rolled back upon error?
>
>
> 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/Dx52cLv-8-Y/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.