[web2py] Re: How do I do transaction in web2py?

2014-05-12 Thread Dragan Matic
All database operations in your controllers which are executed through DAL 
are executed in a transaction. 
So every time you do a database operation in your controller it starts a 
new transaction which is automatically commited if there were no errors. If 
it encounters any error then the transaction is rolled back. 

If you still want to control your transactions (e.g. if you wish to have 
more transaction in a single controller call) you can do it through 
db.commit() and db.rollback(). 

Take a look at this: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=transaction#commit-and-rollback

On Monday, May 12, 2014 2:34:00 AM UTC+2, Xiaojian Huang wrote:
>
> I want to insert records into two tables A  and B. I will insert into A 
> first then B.
>
> and I like to rollback A when inserting into B failed. Is there any way to 
> do this?
>
> 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] web2py conference - online talks

2014-05-12 Thread António Ramos
Amber was only focused in showing how easy it is to create a better
experience for the user using Angular than simple javascript.
Also a lot less code for us, developers.

It was just a simple demo. Of course that if the app was real and to be
used by many, she could/should worry about keeping data in sync.
And angular could fetch ajax data just like web2py components.I see no
diference here. Its only a matter of taste.

I could as well say that using only web2py,if i have 1000 users and
everytime i need to hide a row in a table i need an http call, my server
will die soon with all requests.. and for this angular is a perfect fit.




2014-05-12 3:28 GMT+01:00 weheh :

> +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to Amber
> for a talk well given!
>
> I've been studying AngularJS a little and haven't written any code, yet,
> but my web Spidey sense is giving off alarms. I think Amber's talk
> underscores a potential danger of client-side MVC. First, correct me if I'm
> wrong, but there's nothing in AngularJS that you can't already do in web2y
> using components. The difference is that Angular does it client side
> without needing to make an http call, so it potentially runs faster. And
> AngularJS seems to have a more compact way of doing things we do in jQuery
> with _onclick="blah blah blah" and other such
> ajax("url",["target"],":eval"); or web2py_component(...) stuff.
>
> The danger highlighted by Amber's example is that Angular makes it much
> easier to create a client-side model that gets out of synch with its
> server-side web2py model. And keeping them in synch violates DRY
> principles, requiring the http calls that you would have had to do anyway
> if you did a web2py-component-only approach.
>
> For instance, if Amber's talk had been about a collaborative recipe app
> and someone was updating the recipe database serverside while somebody else
> was perusing the db clientside, then it would be easy for the clientside
> user to get an out of date recipe and stay ignorant of that fact for a very
> long time. That's because the local copy of the data is fetched only once
> when the recipe is first clicked, assuming I understood her app correctly.
> Further exiting and entering the recipe would not do an http call, whereas
> the web2py component approach would naturally force an http call, thereby
> keeping the user in synch.
>
> AngularJS seems to offer nifty, high-performance clientside business logic
> ability. But unless structured carefully, it's not clear that it'll save
> http calls without endangering synch between client and server. And it
> could introduce even more complexity in terms of debugging and verbosity in
> terms of supporting two MVCs for the same app. The thought of that makes me
> wince.
>
> Anybody else have an opinion about this?
>
> --
> 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.
>

-- 
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: next_run_time is initially set to time-date of scheduling

2014-05-12 Thread Tom Clerckx
Hi,

When  adding a new task via queue_task, the next_run_time is initially set 
to the time the task is added to the queue. Is there a specific reason for 
this and is there a way to set the first_run_time correctly immediately 
when adding a new task to the queue?
I would expect that the first_run_time would be initialized to the 
start_time of the task.

The problem is that if I show the queue in a grid, from a user perspective, 
the initial next_run_time of a created task seems to be in the past which 
may create confusion.

Only after the time the task has actually ran for the first time, the 
next_run_time field is properly updated.


My web2py version.
Version

2.8.2-stable+timestamp.2013.11.28.13.54.07
(Running on Rocket 1.2.6, Python 2.7.5)

Best regards, 
Tom.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Scheduler: next_run_time is initially set to time-date of scheduling

2014-05-12 Thread Niphlod
Given that it's a field that is used just for internal usage, the default 
is "now", and it's used later on for:
- repeating tasks
- pop out from the queue the tasks in the correct order
- mark a task as expired

Given the second point, the current default fits the bill, and BTW, users 
should never see next_run_time if start_time is greater . 

On Monday, May 12, 2014 12:30:43 PM UTC+2, Tom Clerckx wrote:
>
> Hi,
>
> When  adding a new task via queue_task, the next_run_time is initially set 
> to the time the task is added to the queue. Is there a specific reason for 
> this and is there a way to set the first_run_time correctly immediately 
> when adding a new task to the queue?
> I would expect that the first_run_time would be initialized to the 
> start_time of the task.
>
> The problem is that if I show the queue in a grid, from a user 
> perspective, the initial next_run_time of a created task seems to be in the 
> past which may create confusion.
>
> Only after the time the task has actually ran for the first time, the 
> next_run_time field is properly updated.
>
>
> My web2py version.
> Version
>
> 2.8.2-stable+timestamp.2013.11.28.13.54.07
> (Running on Rocket 1.2.6, Python 2.7.5)
>
> Best regards, 
> Tom.
>

-- 
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] best way to load more db tables via ajax

2014-05-12 Thread Trevor Overman
What would be the most effective way to load, for example, 25 more database 
tables via an ajax function on clicking, for example again, a more button?
What I am trying to do is load the first 25 tables and have this list 
concatenated for the next 25 in the sorted list. 
The problem I'm running across is keeping the sorting intact. I know this 
could be done by selecting the whole database, but I'm wanting to avoid 
that. 

def example():
table_list = db(db.example).select(limitby=(0, 25))
return dict(table_list=table_list)


Thanks for the help! 


-- 
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: SQLFORM URL duplicate validation

2014-05-12 Thread Anthony
For those interested, solutions here: 
http://stackoverflow.com/questions/23601275/web2py-sqlform-url-duplicate-validation


On Monday, May 12, 2014 12:53:55 AM UTC-4, Sihui Huang wrote:
>
> I want to forbid users being able to submit duplicate urls into the 
> database.
>
> Right now my approach is:
> db.url.URL.requires=[IS_URL(error_message='URL Error'),
>  IS_NOT_IN_DB(db, 'url.URL',error_message='Dupilcated 
> URL')]
>
> It covers the case for with "http" and without "http". 
> For example, if www.123.com is already in database, then user could not 
> submit http://www.123.com.
> But this approach does NOT cover the case with "https", i.e. the user 
> still could submit https://www.123.com.
>
> Is there anyway to prevent such duplication?
>
> I think eliminating the "http"/"https" ,if any, in urls before calling 
> SQLFORM().process(). In such way, the urls in database are all without 
> "http"/"https". But I don't know how to edit user input before calling 
> SQLFORM().process().
>
> Right now my code is 
> url_form=SQLFORM(db.url).process()
>
> Any ideas?
>
> 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.


Re: [web2py] web2py conference - online talks

2014-05-12 Thread weheh
@Ramos: of course, I understand that Amber's script was necessarily 
limited, but it did highlight an important gotcha with this kind of 
scripting when used with web2py. And if all I wanted to do was hide a table 
entry on click, I wouldn't want to pay the penalty of loading AngularJS to 
do that. $(".target").hide() works fine. So I'm still looking for the angle 
where AngularJS fits (no pun intended, but happy to make the pun anyway). 
;-)

On Monday, May 12, 2014 6:15:37 PM UTC+8, Ramos wrote:
>
> Amber was only focused in showing how easy it is to create a better 
> experience for the user using Angular than simple javascript.
> Also a lot less code for us, developers.
>
> It was just a simple demo. Of course that if the app was real and to be 
> used by many, she could/should worry about keeping data in sync.
> And angular could fetch ajax data just like web2py components.I see no 
> diference here. Its only a matter of taste.
>
> I could as well say that using only web2py,if i have 1000 users and 
> everytime i need to hide a row in a table i need an http call, my server 
> will die soon with all requests.. and for this angular is a perfect fit.
>
>
>
>
> 2014-05-12 3:28 GMT+01:00 weheh >:
>
>> +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to 
>> Amber for a talk well given!
>>
>> I've been studying AngularJS a little and haven't written any code, yet, 
>> but my web Spidey sense is giving off alarms. I think Amber's talk 
>> underscores a potential danger of client-side MVC. First, correct me if I'm 
>> wrong, but there's nothing in AngularJS that you can't already do in web2y 
>> using components. The difference is that Angular does it client side 
>> without needing to make an http call, so it potentially runs faster. And 
>> AngularJS seems to have a more compact way of doing things we do in jQuery 
>> with _onclick="blah blah blah" and other such 
>> ajax("url",["target"],":eval"); or web2py_component(...) stuff.
>>
>> The danger highlighted by Amber's example is that Angular makes it much 
>> easier to create a client-side model that gets out of synch with its 
>> server-side web2py model. And keeping them in synch violates DRY 
>> principles, requiring the http calls that you would have had to do anyway 
>> if you did a web2py-component-only approach.
>>
>> For instance, if Amber's talk had been about a collaborative recipe app 
>> and someone was updating the recipe database serverside while somebody else 
>> was perusing the db clientside, then it would be easy for the clientside 
>> user to get an out of date recipe and stay ignorant of that fact for a very 
>> long time. That's because the local copy of the data is fetched only once 
>> when the recipe is first clicked, assuming I understood her app correctly. 
>> Further exiting and entering the recipe would not do an http call, whereas 
>> the web2py component approach would naturally force an http call, thereby 
>> keeping the user in synch.
>>
>> AngularJS seems to offer nifty, high-performance clientside business 
>> logic ability. But unless structured carefully, it's not clear that it'll 
>> save http calls without endangering synch between client and server. And it 
>> could introduce even more complexity in terms of debugging and verbosity in 
>> terms of supporting two MVCs for the same app. The thought of that makes me 
>> wince.
>>
>> Anybody else have an opinion about this?
>>
>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] web2py conference - online talks

2014-05-12 Thread António Ramos
I was not talking about hiding on click. I was thinking about filtering
with a live search box above the table.
Angular Filters and directives are awesome and once you know them you cant
stop thinking about them.

I´m here to learn so feel free to pun me...

:P


2014-05-12 16:25 GMT+01:00 weheh :

> @Ramos: of course, I understand that Amber's script was necessarily
> limited, but it did highlight an important gotcha with this kind of
> scripting when used with web2py. And if all I wanted to do was hide a table
> entry on click, I wouldn't want to pay the penalty of loading AngularJS to
> do that. $(".target").hide() works fine. So I'm still looking for the angle
> where AngularJS fits (no pun intended, but happy to make the pun anyway).
> ;-)
>
>
> On Monday, May 12, 2014 6:15:37 PM UTC+8, Ramos wrote:
>
>> Amber was only focused in showing how easy it is to create a better
>> experience for the user using Angular than simple javascript.
>> Also a lot less code for us, developers.
>>
>> It was just a simple demo. Of course that if the app was real and to be
>> used by many, she could/should worry about keeping data in sync.
>> And angular could fetch ajax data just like web2py components.I see no
>> diference here. Its only a matter of taste.
>>
>> I could as well say that using only web2py,if i have 1000 users and
>> everytime i need to hide a row in a table i need an http call, my server
>> will die soon with all requests.. and for this angular is a perfect fit.
>>
>>
>>
>>
>> 2014-05-12 3:28 GMT+01:00 weheh :
>>
>>> +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to
>>> Amber for a talk well given!
>>>
>>> I've been studying AngularJS a little and haven't written any code, yet,
>>> but my web Spidey sense is giving off alarms. I think Amber's talk
>>> underscores a potential danger of client-side MVC. First, correct me if I'm
>>> wrong, but there's nothing in AngularJS that you can't already do in web2y
>>> using components. The difference is that Angular does it client side
>>> without needing to make an http call, so it potentially runs faster. And
>>> AngularJS seems to have a more compact way of doing things we do in jQuery
>>> with _onclick="blah blah blah" and other such 
>>> ajax("url",["target"],":eval");
>>> or web2py_component(...) stuff.
>>>
>>> The danger highlighted by Amber's example is that Angular makes it much
>>> easier to create a client-side model that gets out of synch with its
>>> server-side web2py model. And keeping them in synch violates DRY
>>> principles, requiring the http calls that you would have had to do anyway
>>> if you did a web2py-component-only approach.
>>>
>>> For instance, if Amber's talk had been about a collaborative recipe app
>>> and someone was updating the recipe database serverside while somebody else
>>> was perusing the db clientside, then it would be easy for the clientside
>>> user to get an out of date recipe and stay ignorant of that fact for a very
>>> long time. That's because the local copy of the data is fetched only once
>>> when the recipe is first clicked, assuming I understood her app correctly.
>>> Further exiting and entering the recipe would not do an http call, whereas
>>> the web2py component approach would naturally force an http call, thereby
>>> keeping the user in synch.
>>>
>>> AngularJS seems to offer nifty, high-performance clientside business
>>> logic ability. But unless structured carefully, it's not clear that it'll
>>> save http calls without endangering synch between client and server. And it
>>> could introduce even more complexity in terms of debugging and verbosity in
>>> terms of supporting two MVCs for the same app. The thought of that makes me
>>> wince.
>>>
>>> Anybody else have an opinion about this?
>>>
>>> --
>>> 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+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: [web2py] web2py conference - online talks

2014-05-12 Thread weheh
Filtering and sorting can definitely save on http calls. Is there anything 
else you can think of where it's applicable without creating a synch issue 
in highly collaborative apps?

On Monday, May 12, 2014 11:37:07 PM UTC+8, Ramos wrote:
>
> I was not talking about hiding on click. I was thinking about filtering 
> with a live search box above the table.
> Angular Filters and directives are awesome and once you know them you cant 
> stop thinking about them.
>
> I´m here to learn so feel free to pun me...
>
> :P
>
>
> 2014-05-12 16:25 GMT+01:00 weheh >:
>
>> @Ramos: of course, I understand that Amber's script was necessarily 
>> limited, but it did highlight an important gotcha with this kind of 
>> scripting when used with web2py. And if all I wanted to do was hide a table 
>> entry on click, I wouldn't want to pay the penalty of loading AngularJS to 
>> do that. $(".target").hide() works fine. So I'm still looking for the angle 
>> where AngularJS fits (no pun intended, but happy to make the pun anyway). 
>> ;-)
>>
>>
>> On Monday, May 12, 2014 6:15:37 PM UTC+8, Ramos wrote:
>>
>>> Amber was only focused in showing how easy it is to create a better 
>>> experience for the user using Angular than simple javascript.
>>> Also a lot less code for us, developers.
>>>
>>> It was just a simple demo. Of course that if the app was real and to be 
>>> used by many, she could/should worry about keeping data in sync.
>>> And angular could fetch ajax data just like web2py components.I see no 
>>> diference here. Its only a matter of taste.
>>>
>>> I could as well say that using only web2py,if i have 1000 users and 
>>> everytime i need to hide a row in a table i need an http call, my server 
>>> will die soon with all requests.. and for this angular is a perfect fit.
>>>
>>>
>>>
>>>
>>> 2014-05-12 3:28 GMT+01:00 weheh :
>>>
 +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to 
 Amber for a talk well given!

 I've been studying AngularJS a little and haven't written any code, 
 yet, but my web Spidey sense is giving off alarms. I think Amber's talk 
 underscores a potential danger of client-side MVC. First, correct me if 
 I'm 
 wrong, but there's nothing in AngularJS that you can't already do in web2y 
 using components. The difference is that Angular does it client side 
 without needing to make an http call, so it potentially runs faster. And 
 AngularJS seems to have a more compact way of doing things we do in jQuery 
 with _onclick="blah blah blah" and other such 
 ajax("url",["target"],":eval"); 
 or web2py_component(...) stuff.

 The danger highlighted by Amber's example is that Angular makes it much 
 easier to create a client-side model that gets out of synch with its 
 server-side web2py model. And keeping them in synch violates DRY 
 principles, requiring the http calls that you would have had to do anyway 
 if you did a web2py-component-only approach.

 For instance, if Amber's talk had been about a collaborative recipe app 
 and someone was updating the recipe database serverside while somebody 
 else 
 was perusing the db clientside, then it would be easy for the clientside 
 user to get an out of date recipe and stay ignorant of that fact for a 
 very 
 long time. That's because the local copy of the data is fetched only once 
 when the recipe is first clicked, assuming I understood her app correctly. 
 Further exiting and entering the recipe would not do an http call, whereas 
 the web2py component approach would naturally force an http call, thereby 
 keeping the user in synch.

 AngularJS seems to offer nifty, high-performance clientside business 
 logic ability. But unless structured carefully, it's not clear that it'll 
 save http calls without endangering synch between client and server. And 
 it 
 could introduce even more complexity in terms of debugging and verbosity 
 in 
 terms of supporting two MVCs for the same app. The thought of that makes 
 me 
 wince.

 Anybody else have an opinion about this?

 -- 
 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+un...@googlegroups.com.

 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to t

[web2py] Re: What is a clear procedure to style web2py css files using Bootstrap theme generators/choosers?

2014-05-12 Thread JoeCodeswell
Dear LightDot,

Thanks SO MUCH for the CLEAR explanations.

I'll mark this ANSWER as the BEST. However, the explanation, I think, also 
includes your other post and Ari's post as well.

Thanks again to you BOTH and to this GREAT Community.

Love and peace,

Joe

On Friday, May 9, 2014 4:58:22 PM UTC-7, LightDot wrote:
>
> As far as Bootswatch 2 themes are concerned, the original, stock 
> bootstrap-responsive.min.css must be loaded if you wish your page to be 
> "responsive". Bootswatch 2 themes do not provide this functionality. So, 
> regardless of the Bootswatch 2 theme used, they can all co-exist with the 
> same, stock bootstrap-responsive.min.css.
>
> What bootstrap-responsive.min.css does is explained in the old Bootstrap 2 
> docs, for example here: 
> http://getbootstrap.com/2.3.2/scaffolding.html#responsive and you can 
> just try how your page looks with or without it. Just to be clear - you 
> don't have to use the responsive features or even load the 
> bootstrap-responsive.min.css, it's optional.
>
> Regards
>
> On Friday, May 9, 2014 5:24:23 PM UTC+2, JoeCodeswell wrote:
>>
>> Dear LightDot and Ari,
>>
>> Thanks for the responses. The situation is getting clearer in my mind.
>>
>> I have some follow-on questions for LightDot. You said:
>>
>> Details such as whether you need to replace just bootstrap.min.css (and 
>>> keep the original bootstrap-responsive.min.css) or replace the 
>>> bootstrap.min.css and remove bootstrap-responsive.min.css altogether, are 
>>> going to be stated in the documentation of the theme / project you're 
>>> switching to.
>>
>>
>> I am sure you know WAY more about the history of Bootstrap and its 
>> documentation than I do. I went to http://bootswatch.com/2/ and looked 
>> at the Cerulean Preview, which seems to me to be the "the documentation of 
>> the theme". I did a firefox page search for "responsive". Result: "Phrase 
>> not found".
>>
>> Here are my questions, LightDot. Thanks in advance for educating me.
>>
>> Does every Bootstrap2 theme have a *correspondingly 
>> developed*bootstrap-responsive.min.css? I assume the answer to this is NO.
>>
>> Will every Bootstrap2 theme work with a *separately 
>> developed*bootstrap-responsive.min.css?
>>
>> Will the web2py default bootstrap-responsive.min.css "work" with any 
>> Bootstrap2 theme's bootstrap.min.css? If, YES, generally what will the 
>> result look like, when the bootstrap-responsive.min.css is in control?
>>
>> Thanks again, LightDot and Ari.
>>
>> Love and peace,
>>
>> Joe
>>
>> On Wednesday, May 7, 2014 11:57:54 AM UTC-7, ari northage-orr wrote:
>>>
>>> LightDot is correct, this is due to the fact that web2py comes with 
 bootstrap 2. I had the exact same issue as you, I was trying to use a 
 theme 
 from Bootswatch and it ended up breaking the navbar and messing up the 
 placement of things on my page. Googling themes for bootstrap 2 and using 
 one of those fixed the issue completely. 

>>>

-- 
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] web2py conference - online talks

2014-05-12 Thread António Ramos
I´m just in favor of angular to improve and modernize user experience.
In this matter router-ui seems very interesting also.
Also ng animate for animations.

I dont understand how you relate directly data out of sync with angular and
not with web2py.
If new data on server, just publish it to the clients so all update it.Its
a web2py problem not angular.


Regards
António


2014-05-12 16:59 GMT+01:00 weheh :

> Filtering and sorting can definitely save on http calls. Is there anything
> else you can think of where it's applicable without creating a synch issue
> in highly collaborative apps?
>
>
> On Monday, May 12, 2014 11:37:07 PM UTC+8, Ramos wrote:
>
>> I was not talking about hiding on click. I was thinking about filtering
>> with a live search box above the table.
>> Angular Filters and directives are awesome and once you know them you
>> cant stop thinking about them.
>>
>> I´m here to learn so feel free to pun me...
>>
>> :P
>>
>>
>> 2014-05-12 16:25 GMT+01:00 weheh :
>>
>> @Ramos: of course, I understand that Amber's script was necessarily
>>> limited, but it did highlight an important gotcha with this kind of
>>> scripting when used with web2py. And if all I wanted to do was hide a table
>>> entry on click, I wouldn't want to pay the penalty of loading AngularJS to
>>> do that. $(".target").hide() works fine. So I'm still looking for the angle
>>> where AngularJS fits (no pun intended, but happy to make the pun anyway).
>>> ;-)
>>>
>>>
>>> On Monday, May 12, 2014 6:15:37 PM UTC+8, Ramos wrote:
>>>
 Amber was only focused in showing how easy it is to create a better
 experience for the user using Angular than simple javascript.
 Also a lot less code for us, developers.

 It was just a simple demo. Of course that if the app was real and to be
 used by many, she could/should worry about keeping data in sync.
 And angular could fetch ajax data just like web2py components.I see no
 diference here. Its only a matter of taste.

 I could as well say that using only web2py,if i have 1000 users and
 everytime i need to hide a row in a table i need an http call, my server
 will die soon with all requests.. and for this angular is a perfect fit.




 2014-05-12 3:28 GMT+01:00 weheh :

> +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to
> Amber for a talk well given!
>
> I've been studying AngularJS a little and haven't written any code,
> yet, but my web Spidey sense is giving off alarms. I think Amber's talk
> underscores a potential danger of client-side MVC. First, correct me if 
> I'm
> wrong, but there's nothing in AngularJS that you can't already do in web2y
> using components. The difference is that Angular does it client side
> without needing to make an http call, so it potentially runs faster. And
> AngularJS seems to have a more compact way of doing things we do in jQuery
> with _onclick="blah blah blah" and other such 
> ajax("url",["target"],":eval");
> or web2py_component(...) stuff.
>
> The danger highlighted by Amber's example is that Angular makes it
> much easier to create a client-side model that gets out of synch with its
> server-side web2py model. And keeping them in synch violates DRY
> principles, requiring the http calls that you would have had to do anyway
> if you did a web2py-component-only approach.
>
> For instance, if Amber's talk had been about a collaborative recipe
> app and someone was updating the recipe database serverside while somebody
> else was perusing the db clientside, then it would be easy for the
> clientside user to get an out of date recipe and stay ignorant of that 
> fact
> for a very long time. That's because the local copy of the data is fetched
> only once when the recipe is first clicked, assuming I understood her app
> correctly. Further exiting and entering the recipe would not do an http
> call, whereas the web2py component approach would naturally force an http
> call, thereby keeping the user in synch.
>
> AngularJS seems to offer nifty, high-performance clientside business
> logic ability. But unless structured carefully, it's not clear that it'll
> save http calls without endangering synch between client and server. And 
> it
> could introduce even more complexity in terms of debugging and verbosity 
> in
> terms of supporting two MVCs for the same app. The thought of that makes 
> me
> wince.
>
> Anybody else have an opinion about this?
>
> --
> 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 unsub

[web2py] Re: color cells based on value in SQLFORM

2014-05-12 Thread LoveWeb2py
Thank you for your reply, Michael & Anthony.

Michael: I really like this idea. What would my model look like?

I setup db.define_table('status',
 Field('id','integer'),
 Field('normal','string'),
 Field('warning','string'),
 migrate=False)

Would I have to populate the fields or can we just use the field names... I 
want to make it to where the referenced table allows me to choose a color 
for the selected column of interest (or cell). 
So if my column looked like this:
Item | status
server | 1

The server cell would be green.Could I do this?



On Saturday, May 10, 2014 1:26:51 PM UTC-4, Michael Beller wrote:
>
> I learned this method from one of Massimo's lecture video's:
>
> At the top of your model file:
> # function to allow models to set status style
> def show_status(status,row=None):
> return SPAN(status.f_name.replace(' ','_'),_class=status.f_name) ifstatus 
> else status
>
> After your table definition (could be in your controller but I set the 
> represent after my table definition in my model file so it is consistent 
> across all locations in my app):
> db.table_name.status_field_name.represent = show_status
>
> Note that in my models db.table_name.status_field_name is a reference 
> field to a status table (so you select from a drop down list to select a 
> status) and the name of the status in the status table is f_name.
>
> In your CSS (I have one CSS static file for my application for application 
> specific styles that I include in layout.html):
> /* Status styles */
> .Not.Started {background-color: yellow; padding:5px;}
> .In.Progress {background-color: green; color:white; padding:5px;}
> .Completed {background-color: red; color:white; padding:5px;}
> .Deferred {background-color: blue; color:white; padding:5px;}
>
> I think this is nicer than embedding an if statement with hardcoded styles 
> in your code.
>
>
> On Friday, May 9, 2014 4:22:45 PM UTC-4, LoveWeb2py wrote:
>>
>> Hello,
>>
>> I have a spreadsheet of items and I want to track their inventory based 
>> on color (similar to an excel spreadsheet).
>>
>> I have two columns for example: Item, Item_Status
>> The item could be a desk, chair, etc... and for status I have 1 2 or 3.
>>
>> If the status is 1 I would like to make the cell color of the desk green, 
>> 2 yellow, 3 red.
>>
>> so far I have 
>>
>> def represent_colored(value):
>>if value == 1:
>>return SPAN(value,_style="background-color:green',)
>> elif value == 2:
>>return SPAN(value,_style="background-color:yellow',)
>> elif value == 3:
>>return SPAN(value,_style="background-color:red',)
>> else:
>>return SPAN(value,_style="background-color:orange',)
>>
>> def inventory():
>>db.inventory.items.represent = lambda value, row: 
>> represent_colored(value)
>>grid=SQLFORM.grid(db.inventory, paginate=20)
>>return dict(grid=grid)
>>
>> This works so far, but it only changes the background color of the text 
>> in the status column and I want to change the column of the actual item. I 
>> also would like to change the entire cell  instead of just the 
>> background behind the text.
>> Also, I plan on branching the inventory out to multiple columns and I 
>> have two questions:
>>
>> 1) How could I change the entire cell color?
>> 2) Is making multiple "status" columns the most efficient and pythonic 
>> way to accomplish this.
>>
>> You guys are the best!
>>
>>
>> Wil
>>
>>
>

-- 
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] web2py conference - online talks

2014-05-12 Thread Michele Comitini
How is angular.js compared to ractive.js inside web2py's ecosystem?
What is your opinion?

2014-05-12 18:25 GMT+02:00 António Ramos :
>
> I´m just in favor of angular to improve and modernize user experience.
> In this matter router-ui seems very interesting also.
> Also ng animate for animations.
>
> I dont understand how you relate directly data out of sync with angular and
> not with web2py.
> If new data on server, just publish it to the clients so all update it.Its a
> web2py problem not angular.
>
>
> Regards
> António
>
>
> 2014-05-12 16:59 GMT+01:00 weheh :
>
>> Filtering and sorting can definitely save on http calls. Is there anything
>> else you can think of where it's applicable without creating a synch issue
>> in highly collaborative apps?
>>
>>
>> On Monday, May 12, 2014 11:37:07 PM UTC+8, Ramos wrote:
>>>
>>> I was not talking about hiding on click. I was thinking about filtering
>>> with a live search box above the table.
>>> Angular Filters and directives are awesome and once you know them you
>>> cant stop thinking about them.
>>>
>>> I´m here to learn so feel free to pun me...
>>>
>>> :P
>>>
>>>
>>> 2014-05-12 16:25 GMT+01:00 weheh :
>>>
 @Ramos: of course, I understand that Amber's script was necessarily
 limited, but it did highlight an important gotcha with this kind of
 scripting when used with web2py. And if all I wanted to do was hide a table
 entry on click, I wouldn't want to pay the penalty of loading AngularJS to
 do that. $(".target").hide() works fine. So I'm still looking for the angle
 where AngularJS fits (no pun intended, but happy to make the pun anyway).
 ;-)


 On Monday, May 12, 2014 6:15:37 PM UTC+8, Ramos wrote:
>
> Amber was only focused in showing how easy it is to create a better
> experience for the user using Angular than simple javascript.
> Also a lot less code for us, developers.
>
> It was just a simple demo. Of course that if the app was real and to be
> used by many, she could/should worry about keeping data in sync.
> And angular could fetch ajax data just like web2py components.I see no
> diference here. Its only a matter of taste.
>
> I could as well say that using only web2py,if i have 1000 users and
> everytime i need to hide a row in a table i need an http call, my server
> will die soon with all requests.. and for this angular is a perfect fit.
>
>
>
>
> 2014-05-12 3:28 GMT+01:00 weheh :
>>
>> +1 regarding the AngulaJS talk with web2py by Amber Doctor. Kudos to
>> Amber for a talk well given!
>>
>> I've been studying AngularJS a little and haven't written any code,
>> yet, but my web Spidey sense is giving off alarms. I think Amber's talk
>> underscores a potential danger of client-side MVC. First, correct me if 
>> I'm
>> wrong, but there's nothing in AngularJS that you can't already do in 
>> web2y
>> using components. The difference is that Angular does it client side 
>> without
>> needing to make an http call, so it potentially runs faster. And 
>> AngularJS
>> seems to have a more compact way of doing things we do in jQuery with
>> _onclick="blah blah blah" and other such ajax("url",["target"],":eval"); 
>> or
>> web2py_component(...) stuff.
>>
>> The danger highlighted by Amber's example is that Angular makes it
>> much easier to create a client-side model that gets out of synch with its
>> server-side web2py model. And keeping them in synch violates DRY 
>> principles,
>> requiring the http calls that you would have had to do anyway if you did 
>> a
>> web2py-component-only approach.
>>
>> For instance, if Amber's talk had been about a collaborative recipe
>> app and someone was updating the recipe database serverside while 
>> somebody
>> else was perusing the db clientside, then it would be easy for the
>> clientside user to get an out of date recipe and stay ignorant of that 
>> fact
>> for a very long time. That's because the local copy of the data is 
>> fetched
>> only once when the recipe is first clicked, assuming I understood her app
>> correctly. Further exiting and entering the recipe would not do an http
>> call, whereas the web2py component approach would naturally force an http
>> call, thereby keeping the user in synch.
>>
>> AngularJS seems to offer nifty, high-performance clientside business
>> logic ability. But unless structured carefully, it's not clear that it'll
>> save http calls without endangering synch between client and server. And 
>> it
>> could introduce even more complexity in terms of debugging and verbosity 
>> in
>> terms of supporting two MVCs for the same app. The thought of that makes 
>> me
>> wince.
>>
>> Anybody else have an opinion about this?
>>
>> --
>> Resources:
>> - htt

[web2py] ipython notebook and web2py

2014-05-12 Thread Johann Spies
Thanks to Anthony for his talk about the hard way to learn Web2py.

Anthony I have been thinking of writing to you to ask about how you got to
know the inner workings of Web2py and you have answered about everything in
your talk at the conference - of which I saw the video today.

I did not know about ipython notebook before I saw your presentation so I
tried it out but it complained a little bit:

%run /home/js/web2py/web2py.py -M -S alterit

WARNING:web2py:import IPython error; use default python shell
Python 2.7.6 (default, Mar 22 2014, 15:40:47)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.9.5-trunk+timestamp.2014.04.15.10.26.52
Database drivers available: SQLite(sqlite3), MySQL(pymysql),
MySQL(MySQLdb), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc),
Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib)

In :


I have a further question - maybe because I do not have the time to study
the source code of ipython notebook as you would probably do :)

How did you define the %w2p  macro or magic command?

And

Your "render" function with which you could show the form - how did you do
it?

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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] disable checkbox on selectable grid.

2014-05-12 Thread TSmith
Using SQLFORM.grid, I can set editable equal to a lambda function and cause 
edit buttons to only appear for certain rows  
for example:  editable= lambda row :  row.locked == 0,

If I use a selectable function to add one check box per row, is there a 
similar function so I could only have checkboxes enabled for certain 
records?
 
 

-- 
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: Appadmin error - 'Column "auth membership"."id" not found (SQL TABLE)'

2014-05-12 Thread Dave S


On Sunday, May 11, 2014 8:05:15 AM UTC-7, Stefan van den Eertwegh wrote:
>
> Hi all,
>
> I have a web2py project and a sqlite database and every table  shows this 
> error: 'Column "auth membership"."id" not found (SQL TABLE)'
> Ofcourse every table its own error.
>
> Does anyone know the solution?
>

Not me, but a question does occur to me:

How were the tables in your database created?  From within web2py, or 
imported from somewhere else?

/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: list:reference

2014-05-12 Thread Dave S


On Sunday, May 11, 2014 11:06:01 PM UTC-7, Jesse Ferguson wrote:
>
> I FIgured it out, I was missing the field name when trying to add values i 
> was doing row.update(data)   instead of   row.update(posts=data)
>

Glad you got it working.  Now I can search for this post when I get puzzled.

/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: best way to load more db tables via ajax

2014-05-12 Thread Dave S


On Monday, May 12, 2014 5:49:23 AM UTC-7, Trevor Overman wrote:
>
> What would be the most effective way to load, for example, 25 more 
> database tables via an ajax function on clicking, for example again, a more 
> button?
> What I am trying to do is load the first 25 tables and have this list 
> concatenated for the next 25 in the sorted list. 
> The problem I'm running across is keeping the sorting intact. I know this 
> could be done by selecting the whole database, but I'm wanting to avoid 
> that. 
>
> def example():
> table_list = db(db.example).select(limitby=(0, 25))
> return dict(table_list=table_list)
>
>
> Thanks for the help! 
>


Pardon me, but I think you means "rows" rather than "tables"(db.example 
is a table, innit, but the select is picking out rows)

Doesn't SQLTABLE or SQLFORM do something similar?  I haven't played around 
much with letting the user click-to-sort, but you should be able to get 
some ideas from inspecting the widget code.

/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: web2py conference - online talks

2014-05-12 Thread Anthony
I promised the code and slides from my talk -- available here: 
https://groups.google.com/d/msg/web2py/1_CsiqCzrS4/E0mXwAiwWRYJ.

Anthony

On Monday, May 5, 2014 11:55:28 AM UTC-4, Massimo Di Pierro wrote:
>
> Please find below the links to the video of the first web2py conference. 
> Videos are not broken into talks. 
> There is no audio for the first 2minutes but no talk either, only service 
> announcements.
>
>
> *Part #1 (from start to lunch break)*
>
> https://colflash.cdm.depaul.edu/colflashweb/COLFlashPlayer.aspx?ID=183272
>
> 10:00-10:10! Conference Opening
>
> 10:10-10:20! “What's New with the PSF” by Brian Curtin
>
> 10:20-11:00! “History of web2py” by Massimo Di Pierro
>
> 11:00-11:40! "Learn web2py the Really Hard Way" by Anthony Bastardi 
> 11:40-12:20! "Stereodose" by Mark Li
>
> 12:20-12:30! "Planet Host" by Jason Burosh
>
> *Part #2 (from tutorial to coffee break)*
>
> https://colflash.cdm.depaul.edu/colflashweb/COLFlashPlayer.aspx?ID=183273
>
> 13:00:13:40! "hands-on web2py tutorial" by Clifford Williams
>
> 13:40-14:20! "Angular and web2py" by Amber Doctor
>
> 14:20-14:40 ! "Stitching together the tree of life with web2py" by Richard 
> Ree 1
>
> 4:40-15:00! "ShipElf: Automated Fulfillment with Web2Py" by Peter 
> Szczepanski 
>
> 15:00-15:20! "MyIRE - What is Open Source Science?" by Mark Graves 
>
> 15:20-15:40! "Introduction to Mongodb" by Marco Chou
>
> *Part #3 (from coffee break to end)*
>
> https://colflash.cdm.depaul.edu/colflashweb/COLFlashPlayer.aspx?ID=183274
>
> 16:00-16:20! "Introduction to OpenShift" by Craig Brott
>
> 16:20-16:40! "Introduction to Hypermedia API" by Bryan Barnard 
>
> 16:40-17:00! "web2py and the Semantic web" by Chris Baron 
>
> 17:00-17-20! "Teaching an old dog new tricks" by Don O'Hara 
>
> 17:20-17:30! Conference Closing
>

-- 
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: color cells based on value in SQLFORM

2014-05-12 Thread Michael Beller
I wouldn't recommend using field names, that would not be very flexible. 
 Here's an option:

db.define.table('status',
Field('name'),
Field('highlight_color'))

db.define.table('inventory',
Field('item'),
Field('status', 'reference status'))

Then just populate the status table with your list of statuses and its 
associated highlight color.  Then in your controller and view, create a 
query for the status colors and a corresponding loop in your view to build 
the list of status styles.  Something like this may work ...

{{for x in status_list:}}
{{=x.name.replace(' ','_')}} {background-color: {{=x.color}}; 
padding:5px;}
{{pass}}

to produce this ...

.Not.Started {background-color: yellow; padding:5px;}
.In.Progress {background-color: green; color:white; padding:5px;}
.Completed {background-color: red; color:white; padding:5px;}
.Deferred {background-color: blue; color:white; padding:5px;}



On Monday, May 12, 2014 1:44:29 PM UTC-4, LoveWeb2py wrote:
>
> Thank you for your reply, Michael & Anthony.
>
> Michael: I really like this idea. What would my model look like?
>
> I setup db.define_table('status',
>  Field('id','integer'),
>  Field('normal','string'),
>  Field('warning','string'),
>  migrate=False)
>
> Would I have to populate the fields or can we just use the field names... 
> I want to make it to where the referenced table allows me to choose a color 
> for the selected column of interest (or cell). 
> So if my column looked like this:
> Item | status
> server | 1
>
> The server cell would be green.Could I do this?
>
>
>
> On Saturday, May 10, 2014 1:26:51 PM UTC-4, Michael Beller wrote:
>>
>> I learned this method from one of Massimo's lecture video's:
>>
>> At the top of your model file:
>> # function to allow models to set status style
>> def show_status(status,row=None):
>> return SPAN(status.f_name.replace(' ','_'),_class=status.f_name) 
>> ifstatus 
>> else status
>>
>> After your table definition (could be in your controller but I set the 
>> represent after my table definition in my model file so it is consistent 
>> across all locations in my app):
>> db.table_name.status_field_name.represent = show_status
>>
>> Note that in my models db.table_name.status_field_name is a reference 
>> field to a status table (so you select from a drop down list to select a 
>> status) and the name of the status in the status table is f_name.
>>
>> In your CSS (I have one CSS static file for my application for 
>> application specific styles that I include in layout.html):
>> /* Status styles */
>> .Not.Started {background-color: yellow; padding:5px;}
>> .In.Progress {background-color: green; color:white; padding:5px;}
>> .Completed {background-color: red; color:white; padding:5px;}
>> .Deferred {background-color: blue; color:white; padding:5px;}
>>
>> I think this is nicer than embedding an if statement with 
>> hardcoded styles in your code.
>>
>>
>> On Friday, May 9, 2014 4:22:45 PM UTC-4, LoveWeb2py wrote:
>>>
>>> Hello,
>>>
>>> I have a spreadsheet of items and I want to track their inventory based 
>>> on color (similar to an excel spreadsheet).
>>>
>>> I have two columns for example: Item, Item_Status
>>> The item could be a desk, chair, etc... and for status I have 1 2 or 3.
>>>
>>> If the status is 1 I would like to make the cell color of the desk 
>>> green, 2 yellow, 3 red.
>>>
>>> so far I have 
>>>
>>> def represent_colored(value):
>>>if value == 1:
>>>return SPAN(value,_style="background-color:green',)
>>> elif value == 2:
>>>return SPAN(value,_style="background-color:yellow',)
>>> elif value == 3:
>>>return SPAN(value,_style="background-color:red',)
>>> else:
>>>return SPAN(value,_style="background-color:orange',)
>>>
>>> def inventory():
>>>db.inventory.items.represent = lambda value, row: 
>>> represent_colored(value)
>>>grid=SQLFORM.grid(db.inventory, paginate=20)
>>>return dict(grid=grid)
>>>
>>> This works so far, but it only changes the background color of the text 
>>> in the status column and I want to change the column of the actual item. I 
>>> also would like to change the entire cell  instead of just the 
>>> background behind the text.
>>> Also, I plan on branching the inventory out to multiple columns and I 
>>> have two questions:
>>>
>>> 1) How could I change the entire cell color?
>>> 2) Is making multiple "status" columns the most efficient and pythonic 
>>> way to accomplish this.
>>>
>>> You guys are the best!
>>>
>>>
>>> Wil
>>>
>>>
>>

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

[web2py] Re: list:reference

2014-05-12 Thread Michael Beller
I haven't used 'list:reference' before, what are the advantages or use 
cases for your approach rather than add a reference field such as 
Field('daily', 'reference daily') on the post table?

On Monday, May 12, 2014 2:06:01 AM UTC-4, Jesse Ferguson wrote:
>
> I FIgured it out, I was missing the field name when trying to add values i 
> was doing row.update(data)   instead of   row.update(posts=data)
>

-- 
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: best way to load more db tables via ajax

2014-05-12 Thread Michael Beller
The recipe on pagination in the book may provide some ideas:

http://web2py.com/books/default/chapter/29/14/other-recipes?search=pagination#Pagination

You could then put your list that you're trying to concatenate in an 
ajax load.

On Monday, May 12, 2014 8:49:23 AM UTC-4, Trevor Overman wrote:
>
> What would be the most effective way to load, for example, 25 more 
> database tables via an ajax function on clicking, for example again, a more 
> button?
> What I am trying to do is load the first 25 tables and have this list 
> concatenated for the next 25 in the sorted list. 
> The problem I'm running across is keeping the sorting intact. I know this 
> could be done by selecting the whole database, but I'm wanting to avoid 
> that. 
>
> def example():
> table_list = db(db.example).select(limitby=(0, 25))
> return dict(table_list=table_list)
>
>
> Thanks for the help! 
>
>
>

-- 
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: color cells based on value in SQLFORM

2014-05-12 Thread Anthony
Keep in mind, this method will execute a separate database select for every 
row in the table in order to retrieve the status highlight_color. Also, the 
CSS rule will not color the background of the entire cell, just the status 
text (plus padding).

Anthony

On Monday, May 12, 2014 7:33:06 PM UTC-4, Michael Beller wrote:
>
> I wouldn't recommend using field names, that would not be very flexible. 
>  Here's an option:
>
> db.define.table('status',
> Field('name'),
> Field('highlight_color'))
>
> db.define.table('inventory',
> Field('item'),
> Field('status', 'reference status'))
>
> Then just populate the status table with your list of statuses and its 
> associated highlight color.  Then in your controller and view, create a 
> query for the status colors and a corresponding loop in your view to build 
> the list of status styles.  Something like this may work ...
>
> {{for x in status_list:}}
> {{=x.name.replace(' ','_')}} {background-color: {{=x.highlight_color
> }}; padding:5px;}
> {{pass}}
>
> to produce this ...
>
> .Not.Started {background-color: yellow; padding:5px;}
> .In.Progress {background-color: green; color:white; padding:5px;}
> .Completed {background-color: red; color:white; padding:5px;}
> .Deferred {background-color: blue; color:white; padding:5px;}
>
>
>
> On Monday, May 12, 2014 1:44:29 PM UTC-4, LoveWeb2py wrote:
>>
>> Thank you for your reply, Michael & Anthony.
>>
>> Michael: I really like this idea. What would my model look like?
>>
>> I setup db.define_table('status',
>>  Field('id','integer'),
>>  Field('normal','string'),
>>  Field('warning','string'),
>>  migrate=False)
>>
>> Would I have to populate the fields or can we just use the field names... 
>> I want to make it to where the referenced table allows me to choose a color 
>> for the selected column of interest (or cell). 
>> So if my column looked like this:
>> Item | status
>> server | 1
>>
>> The server cell would be green.Could I do this?
>>
>>
>>
>> On Saturday, May 10, 2014 1:26:51 PM UTC-4, Michael Beller wrote:
>>>
>>> I learned this method from one of Massimo's lecture video's:
>>>
>>> At the top of your model file:
>>> # function to allow models to set status style
>>> def show_status(status,row=None):
>>> return SPAN(status.f_name.replace(' ','_'),_class=status.f_name) 
>>> ifstatus 
>>> else status
>>>
>>> After your table definition (could be in your controller but I set the 
>>> represent after my table definition in my model file so it is consistent 
>>> across all locations in my app):
>>> db.table_name.status_field_name.represent = show_status
>>>
>>> Note that in my models db.table_name.status_field_name is a reference 
>>> field to a status table (so you select from a drop down list to select a 
>>> status) and the name of the status in the status table is f_name.
>>>
>>> In your CSS (I have one CSS static file for my application for 
>>> application specific styles that I include in layout.html):
>>> /* Status styles */
>>> .Not.Started {background-color: yellow; padding:5px;}
>>> .In.Progress {background-color: green; color:white; padding:5px;}
>>> .Completed {background-color: red; color:white; padding:5px;}
>>> .Deferred {background-color: blue; color:white; padding:5px;}
>>>
>>> I think this is nicer than embedding an if statement with 
>>> hardcoded styles in your code.
>>>
>>>
>>> On Friday, May 9, 2014 4:22:45 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I have a spreadsheet of items and I want to track their inventory based 
 on color (similar to an excel spreadsheet).

 I have two columns for example: Item, Item_Status
 The item could be a desk, chair, etc... and for status I have 1 2 or 3.

 If the status is 1 I would like to make the cell color of the desk 
 green, 2 yellow, 3 red.

 so far I have 

 def represent_colored(value):
if value == 1:
return SPAN(value,_style="background-color:green',)
 elif value == 2:
return SPAN(value,_style="background-color:yellow',)
 elif value == 3:
return SPAN(value,_style="background-color:red',)
 else:
return SPAN(value,_style="background-color:orange',)

 def inventory():
db.inventory.items.represent = lambda value, row: 
 represent_colored(value)
grid=SQLFORM.grid(db.inventory, paginate=20)
return dict(grid=grid)

 This works so far, but it only changes the background color of the text 
 in the status column and I want to change the column of the actual item. I 
 also would like to change the entire cell  instead of just the 
 background behind the text.
 Also, I plan on branching the inventory out to multiple columns and I 
 have two questions:

 1) How could I change the entire cell color?
 2) Is making multiple "status" columns the most efficient and pythonic 
 way to accomplish this.

 You guys are the best!


>

[web2py] Re: list:reference

2014-05-12 Thread Jesse Ferguson
ok so it actually doesnt work which is really strange. it works on 
console however when i do it in a scheduled task it jacks up the database 
somehow, i think I may be inserting the references incorrectly... I will 
investigate this tonight and try to give everyone an answer 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: list:reference

2014-05-12 Thread Jesse Ferguson
https://groups.google.com/forum/#!searchin/web2py/list$3Areference/web2py/pXBj0EhX3iA/vamglS5txQsJ

seems this may be a bug in web2py... Does anyone know if this bugfix is 
still only in trunk or if it has been put into stable?

-- 
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: ipython notebook and web2py

2014-05-12 Thread Johann Spies
Thank you very much Anthony!

Again, I received much more than I expected.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

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