[web2py] Re: restful service + auth on same application/ different controllers = gives Not authorized message

2017-11-20 Thread Val K
As I see Leo uses requestS module, don't confuse with web2py request object. 
Yes  it's no good idea to use 'session' as name

-- 
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: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 10:05:47 PM UTC-8, Maurice Waka wrote:
>
> You mean a screen shot of before input, and after the input? 
>

I mean the top lines of 

(posted at 8:50 my time (Los Angeles area, UTC-8) )
It's a for-loop as embedded in your view file.

/dps


> On 21 Nov 2017 8:59 AM, "Dave S"  wrote:
>
>>
>>
>> On Monday, November 20, 2017 at 9:49:41 PM UTC-8, Maurice Waka wrote:
>>>
>>> That's the first input message I typed. The return message in the white 
>>> bubble should also be the same as the one in the bubble blue. Am just 
>>> testing to see that I pick the right input from my modules. 
>>>
>>>
>> In that view sample (the 4 lines of web2py '{{...}}' stuff, where does 
>> quizes come from?  In your controller, you are returning quiz=quiz.
>>
>> /dps
>>
>>  
>>
>>> On 21 Nov 2017 8:22 AM, "Dave S"  wrote:
>>>
>>>
>>>
>>> On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:

 [...]  But what is the blue bubble above the Send button?  It says 
 "God is love" ... are you putting the result in the wrong place?

 I see the sololearn  example page puts my input into blue bubbles that 
>>> are right-justified, like the "God is love" bubble in your picture.
>>>
>>> /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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/dN9KfQULX54/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
Let me start a new app and build from there. Then I'll let you know. There
could be something I insert somewhere that I don't know.
Regards

On 21 Nov 2017 9:05 AM, "Maurice Waka"  wrote:

> You mean a screen shot of before input, and after the input?
>
> On 21 Nov 2017 8:59 AM, "Dave S"  wrote:
>
>>
>>
>> On Monday, November 20, 2017 at 9:49:41 PM UTC-8, Maurice Waka wrote:
>>>
>>> That's the first input message I typed. The return message in the white
>>> bubble should also be the same as the one in the bubble blue. Am just
>>> testing to see that I pick the right input from my modules.
>>>
>>>
>> In that view sample (the 4 lines of web2py '{{...}}' stuff, where does
>> quizes come from?  In your controller, you are returning quiz=quiz.
>>
>> /dps
>>
>>
>>
>>> On 21 Nov 2017 8:22 AM, "Dave S"  wrote:
>>>
>>>
>>>
>>> On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:

 [...]  But what is the blue bubble above the Send button?  It says
 "God is love" ... are you putting the result in the wrong place?

 I see the sololearn  example page puts my input into blue bubbles that
>>> are right-justified, like the "God is love" bubble in your picture.
>>>
>>> /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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/web2py/dN9KfQULX54/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.


Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
You mean a screen shot of before input, and after the input?

On 21 Nov 2017 8:59 AM, "Dave S"  wrote:

>
>
> On Monday, November 20, 2017 at 9:49:41 PM UTC-8, Maurice Waka wrote:
>>
>> That's the first input message I typed. The return message in the white
>> bubble should also be the same as the one in the bubble blue. Am just
>> testing to see that I pick the right input from my modules.
>>
>>
> In that view sample (the 4 lines of web2py '{{...}}' stuff, where does
> quizes come from?  In your controller, you are returning quiz=quiz.
>
> /dps
>
>
>
>> On 21 Nov 2017 8:22 AM, "Dave S"  wrote:
>>
>>
>>
>> On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:
>>>
>>> [...]  But what is the blue bubble above the Send button?  It says "God
>>> is love" ... are you putting the result in the wrong place?
>>>
>>> I see the sololearn  example page puts my input into blue bubbles that
>> are right-justified, like the "God is love" bubble in your picture.
>>
>> /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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/dN9KfQULX54/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.


Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 9:49:41 PM UTC-8, Maurice Waka wrote:
>
> That's the first input message I typed. The return message in the white 
> bubble should also be the same as the one in the bubble blue. Am just 
> testing to see that I pick the right input from my modules. 
>
>
In that view sample (the 4 lines of web2py '{{...}}' stuff, where does 
quizes come from?  In your controller, you are returning quiz=quiz.

/dps

 

> On 21 Nov 2017 8:22 AM, "Dave S"  wrote:
>
>
>
> On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:
>>
>> [...]  But what is the blue bubble above the Send button?  It says "God 
>> is love" ... are you putting the result in the wrong place?
>>
>> I see the sololearn  example page puts my input into blue bubbles that 
> are right-justified, like the "God is love" bubble in your picture.
>
> /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: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 9:22:43 PM UTC-8, Dave S wrote:
>
>
>
> On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:
>>
>> [...]  But what is the blue bubble above the Send button?  It says "God 
>> is love" ... are you putting the result in the wrong place?
>>
>> I see the sololearn  example page puts my input into blue bubbles that 
> are right-justified, like the "God is love" bubble in your picture.
>
>
A mildly amusing example.  Somewhat off-topic, here's a clip of me 
interacting with it ... that is, a clip of the html obtained by the Inspect 
Element tool.  (Yeah, a screen shot probably would have been easier, but 
this is more in the proper spirit, or something.)

Enter code here...Do you prefer questions?

I haven't 
been taught how to respond to that yet.

I can't 
respond to "no response"

I haven't 
been taught how to respond to that yet.



[it -- the output --  seems to be missing my send of "commands" here]

{
"random": "var rand = (Math.floor(Math.random() * 10)); 
incoming(rand);",
"commands": "var objstr = JSON.stringify(commands); objstr = 
JSON.stringify(commands, null, 4); incoming(objstr)"
}


random


6


commands


hi


Hello There!


responses("Question 
authority", "I do not question myself")


Question authority


i do not question 
myself


responses("are you for real?", "I am as real as you can 
imagine"


SyntaxError: 
missing ) after argument list


responses("are you for real?", "I am as real as you can 
imagine!")


Are you for real?


i am as real as you 
can imagine!




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


Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
That's the first input message I typed. The return message in the white
bubble should also be the same as the one in the bubble blue. Am just
testing to see that I pick the right input from my modules.

On 21 Nov 2017 8:22 AM, "Dave S"  wrote:



On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:
>
> [...]  But what is the blue bubble above the Send button?  It says "God
> is love" ... are you putting the result in the wrong place?
>
> I see the sololearn  example page puts my input into blue bubbles that are
right-justified, like the "God is love" bubble in your picture.

/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 a topic in the
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/web2py/dN9KfQULX54/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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


[web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 8:15:55 PM UTC-8, Dave S wrote:
>
> [...]  But what is the blue bubble above the Send button?  It says "God 
> is love" ... are you putting the result in the wrong place?
>
> I see the sololearn  example page puts my input into blue bubbles that are 
right-justified, like the "God is love" bubble in your picture.

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


Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 8:50:51 PM UTC-8, Maurice Waka wrote:
>
> HI this is my code:
>

Do you really have a lot of stuff *outside* of the  tags?  Or 
are you showing us several separate files?  I'm not sure how to tie this 
all together.

/dps

 

> {{for q in quizes:}}
> {{quiz = q.message}}
> {{pass}}
>
> 
> 
> Chat Bot
> 
> Original
> 
> 
>  placeholder="Type a message..." />
>  onclick="ajax('{{=URL('view_searches')}}',['message'],'target');" 
> >SEND
> 
> 
> 
>
> 
> * {
>margin: 0px; 
>user-select: none;
>-webkit-user-select: none;
>-moz-user-select: none;
> }
> body {
> margin: 0px;
> height:400px;
> bottom:0;
> }
> #user {
> width: 100vw;
> position: fixed;
> left: 0px;
> bottom: 0px;
> display: block;
> background-color: #EEE;
> white-space: nowrap;
> height:105px;
> }
> #msgbox {
>width: calc(80% - 12px);
>min-height: 25px;
>max-height: 35px;
>padding: 5px;
>outline: none;
>border: solid 1px #AAA;
>display: inline-block;
>vertical-align: center;
>float: left;
>background-color: #FFF;
>border-radius: 25px;
>resize: none;
>margin: 0px;
>word-wrap:break-all;
> }
> #send {
>width: 20vw;
>height: 35px;
>display: inline-block
>outline: none;
>border: none;
>color: #FFF;
>background-color: #00F;
>float: left;
>border-radius: 25px;
>padding: 0px;
>cursor: pointer;
>margin: 0px;
> }
> #send:active {
>background-color: #00A; 
>outline: none;
> }
> #header {
>display: flex; 
>justify-content: left;
>align-items: center;
>width: calc(100% - 30px);
>height: 20px;
>padding: 15px;
>color: #FFF;
>font-size: 200%;
>font-weight: bolder;
>background-color: #00F;
>position: fixed;
>font-family: arial;
> }
> #messages {
>display: block;
>width: 100vw;
>height: calc(100% - 87px);
>background-color: #EEE;
>position: fixed;
>top: 50px;
>left: 0px;
>overflow: auto;
>overflow-x: hidden;
>overflow-y: auto;
> }
> .left {
>text-align: left; 
>/*
>display: block;
>*/
> }
> .right {
>text-align: right; 
>/*
>display: block;
>*/
> }
> .incoming {
>background-color: #FFF;
>color: #000;
>border: solid 1px #AAA;
> }
> .outgoing {
>background-color: #00F;
>color: #FFF;
> }
> .section {
>display: block; 
>width: calc(100% - 30px);
>padding-left: 15px;
>padding-right: 15px;
>margin-top: 7.5px;
>margin-bottom: 7.5px;
> }
> .message {
>display: inline-flex;
>justify-content: left;
>align-items: center;
>border-radius: 25px; 
>padding: 10px;
>font-size: 10pt;
> }
> input:first {
>color: #F00; 
> }
> .incoming:active {
>background-color: #EEE; 
> }
> .outgoing:active {
>background-color: #00A; 
> }
> * {
>outline: none; 
>tap-highlight: none;
>-webkit-tap-highlight: none;
>-webkit-tap-highlight-color: none;
>-moz-tap-highlight: none;
>-moz-tap-highlight-color: none;
>-khtml-tap-highlight: none;
>-khtml-tap-highlight-color: none;
> }
> a {
>display: block; 
>text-align: center;
> }
> 
>
>
> 
> $(function(){
> var commands = {
>"random":"var rand = (Math.floor(Math.random() * 10)); 
> incoming(rand);",
>"commands":"var objstr = JSON.stringify(commands); objstr = 
> JSON.stringify(commands, null, 4); incoming(objstr)"
> }
> var responseSys = {
> "hi":"Hello There!",
> "bye":"GoodBye!"
> };
> function cmd(name, action){
>commands[name] = action;
> }
> function outgoing(text){
> var newMsg = "
" + text + "
"; > $("#messages").append(newMsg); > } > function incoming(text){ > var newMsg = "
" + text + "
"; > $("#messages").append(newMsg); > window.scrollTo(0, parseInt($("#messages").innerHeight)) > } > $("#send").click(function(){ > $("#msgbox").trigger("blur") > var text = $("#msgbox").val();

Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
HI this is my code:
{{for q in quizes:}}
{{quiz = q.message}}
{{pass}}



Chat Bot

Original



SEND





* {
   margin: 0px;
   user-select: none;
   -webkit-user-select: none;
   -moz-user-select: none;
}
body {
margin: 0px;
height:400px;
bottom:0;
}
#user {
width: 100vw;
position: fixed;
left: 0px;
bottom: 0px;
display: block;
background-color: #EEE;
white-space: nowrap;
height:105px;
}
#msgbox {
   width: calc(80% - 12px);
   min-height: 25px;
   max-height: 35px;
   padding: 5px;
   outline: none;
   border: solid 1px #AAA;
   display: inline-block;
   vertical-align: center;
   float: left;
   background-color: #FFF;
   border-radius: 25px;
   resize: none;
   margin: 0px;
   word-wrap:break-all;
}
#send {
   width: 20vw;
   height: 35px;
   display: inline-block
   outline: none;
   border: none;
   color: #FFF;
   background-color: #00F;
   float: left;
   border-radius: 25px;
   padding: 0px;
   cursor: pointer;
   margin: 0px;
}
#send:active {
   background-color: #00A;
   outline: none;
}
#header {
   display: flex;
   justify-content: left;
   align-items: center;
   width: calc(100% - 30px);
   height: 20px;
   padding: 15px;
   color: #FFF;
   font-size: 200%;
   font-weight: bolder;
   background-color: #00F;
   position: fixed;
   font-family: arial;
}
#messages {
   display: block;
   width: 100vw;
   height: calc(100% - 87px);
   background-color: #EEE;
   position: fixed;
   top: 50px;
   left: 0px;
   overflow: auto;
   overflow-x: hidden;
   overflow-y: auto;
}
.left {
   text-align: left;
   /*
   display: block;
   */
}
.right {
   text-align: right;
   /*
   display: block;
   */
}
.incoming {
   background-color: #FFF;
   color: #000;
   border: solid 1px #AAA;
}
.outgoing {
   background-color: #00F;
   color: #FFF;
}
.section {
   display: block;
   width: calc(100% - 30px);
   padding-left: 15px;
   padding-right: 15px;
   margin-top: 7.5px;
   margin-bottom: 7.5px;
}
.message {
   display: inline-flex;
   justify-content: left;
   align-items: center;
   border-radius: 25px;
   padding: 10px;
   font-size: 10pt;
}
input:first {
   color: #F00;
}
.incoming:active {
   background-color: #EEE;
}
.outgoing:active {
   background-color: #00A;
}
* {
   outline: none;
   tap-highlight: none;
   -webkit-tap-highlight: none;
   -webkit-tap-highlight-color: none;
   -moz-tap-highlight: none;
   -moz-tap-highlight-color: none;
   -khtml-tap-highlight: none;
   -khtml-tap-highlight-color: none;
}
a {
   display: block;
   text-align: center;
}




$(function(){
var commands = {
   "random":"var rand = (Math.floor(Math.random() * 10));
incoming(rand);",
   "commands":"var objstr = JSON.stringify(commands); objstr =
JSON.stringify(commands, null, 4); incoming(objstr)"
}
var responseSys = {
"hi":"Hello There!",
"bye":"GoodBye!"
};
function cmd(name, action){
   commands[name] = action;
}
function outgoing(text){
var newMsg = "
" + text + "
"; $("#messages").append(newMsg); } function incoming(text){ var newMsg = "
" + text + "
"; $("#messages").append(newMsg); window.scrollTo(0, parseInt($("#messages").innerHeight)) } $("#send").click(function(){ $("#msgbox").trigger("blur") var text = $("#msgbox").val(); if(text != null && text != ""){ $("#msgbox").val(""); text = text.replace(//ig, ">"); text = text.replace(/\n/ig, "
"); outgoing(text); reply(text) } else{ // Praise the Sun incoming("Please, don't send empty messages.") } }); $("#msgbox").keyup(function(e){ if(e.which == 13){ $("#send").trigger("click") } else{ // Do Nothing } }); incoming("Hello!
This is a small ChatBot made by Andrew Grider. Feel Free to implement any

Re: [web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
Hi
This is my code:


Chat Bot

Original



SEND





* {
   margin: 0px;
   user-select: none;
   -webkit-user-select: none;
   -moz-user-select: none;
}
body {
margin: 0px;
height:400px;
bottom:0;
}
#user {
width: 100vw;
position: fixed;
left: 0px;
bottom: 0px;
display: block;
background-color: #EEE;
white-space: nowrap;
height:105px;
}
#msgbox {
   width: calc(80% - 12px);
   min-height: 25px;
   max-height: 35px;
   padding: 5px;
   outline: none;
   border: solid 1px #AAA;
   display: inline-block;
   vertical-align: center;
   float: left;
   background-color: #FFF;
   border-radius: 25px;
   resize: none;
   margin: 0px;
   word-wrap:break-all;
}
#send {
   width: 20vw;
   height: 35px;
   display: inline-block
   outline: none;
   border: none;
   color: #FFF;
   background-color: #00F;
   float: left;
   border-radius: 25px;
   padding: 0px;
   cursor: pointer;
   margin: 0px;
}
#send:active {
   background-color: #00A;
   outline: none;
}
#header {
   display: flex;
   justify-content: left;
   align-items: center;
   width: calc(100% - 30px);
   height: 20px;
   padding: 15px;
   color: #FFF;
   font-size: 200%;
   font-weight: bolder;
   background-color: #00F;
   position: fixed;
   font-family: arial;
}
#messages {
   display: block;
   width: 100vw;
   height: calc(100% - 87px);
   background-color: #EEE;
   position: fixed;
   top: 50px;
   left: 0px;
   overflow: auto;
   overflow-x: hidden;
   overflow-y: auto;
}
.left {
   text-align: left;
   /*
   display: block;
   */
}
.right {
   text-align: right;
   /*
   display: block;
   */
}
.incoming {
   background-color: #FFF;
   color: #000;
   border: solid 1px #AAA;
}
.outgoing {
   background-color: #00F;
   color: #FFF;
}
.section {
   display: block;
   width: calc(100% - 30px);
   padding-left: 15px;
   padding-right: 15px;
   margin-top: 7.5px;
   margin-bottom: 7.5px;
}
.message {
   display: inline-flex;
   justify-content: left;
   align-items: center;
   border-radius: 25px;
   padding: 10px;
   font-size: 10pt;
}
input:first {
   color: #F00;
}
.incoming:active {
   background-color: #EEE;
}
.outgoing:active {
   background-color: #00A;
}
* {
   outline: none;
   tap-highlight: none;
   -webkit-tap-highlight: none;
   -webkit-tap-highlight-color: none;
   -moz-tap-highlight: none;
   -moz-tap-highlight-color: none;
   -khtml-tap-highlight: none;
   -khtml-tap-highlight-color: none;
}
a {
   display: block;
   text-align: center;
}




$(function(){
var commands = {
   "random":"var rand = (Math.floor(Math.random() * 10));
incoming(rand);",
   "commands":"var objstr = JSON.stringify(commands); objstr =
JSON.stringify(commands, null, 4); incoming(objstr)"
}
var responseSys = {
"hi":"Hello There!",
"bye":"GoodBye!"
};
function cmd(name, action){
   commands[name] = action;
}
function outgoing(text){
var newMsg = "
" + text + "
"; $("#messages").append(newMsg); } function incoming(text){ var newMsg = "
" + text + "
"; $("#messages").append(newMsg); window.scrollTo(0, parseInt($("#messages").innerHeight)) } $("#send").click(function(){ $("#msgbox").trigger("blur") var text = $("#msgbox").val(); if(text != null && text != ""){ $("#msgbox").val(""); text = text.replace(//ig, ">"); text = text.replace(/\n/ig, "
"); outgoing(text); reply(text) } else{ // Praise the Sun incoming("Please, don't send empty messages.") } }); $("#msgbox").keyup(function(e){ if(e.which == 13){ $("#send").trigger("click") } else{ // Do Nothing } }); incoming("Hello!
This is a small ChatBot made by Andrew Grider. Feel Free to implement any commands or functions but please don't change this

[web2py] Re: Retrieve database item using print vs return

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 7:41:55 PM UTC-8, Maurice Waka wrote:
>
> In my previous question: [web2py] How to get the last DB Field data :
> I got some good response. But my issue still persists.
> My code:
>
>
> 
> def view_searches():
> quizy = []
> form = SQLFORM(db.post).process()
> if request.vars.message:
> db.post.insert(message = request.vars.message)
> quizes = db(db.post.author == auth.user.id).select(db.post.ALL, 
> orderby=~db.post.created_on, limitby=(0,1))
> for q in quizes:
> quizy.append(q.message)
> quiz= quizy[0]
> print quiz
> return dict(form=form, quiz=quiz)
>
> Note the print quiz for illustration purpose.
> Now note the print screen below:
>
>
> 
>
>
> Notice the last post is;'God is love'
>
>
>- If using print, i get the exact last posted item
>- if I use return on the html page, I get aowirhsgporhj..previous 
>posted message, also shown on the terminal.
>- Note that the html page returns the random letter print;  
> aowirhsgporhj... 
>instead of 'God is love'
>- I used print to illustrate the erros. If i remove print function, 
>the error persists where i can't get the last posted item
>
> My request is how do i resolve this?
> Regards
>


Perhaps you should have gotten a clean console screen before the run that 
you wanted to include in the post :-)
It's a little bit hard to see the relevant part of the screen.

Also, did you ever show us the view template code you are using?
 
Now, commenting on your code above, I would expect quizy[0] to be the only 
element in quizy, due to your limitby=(0,1).  I am not yet seeing why your 
page isn't showing the right result yet.  I suspect something in your view, 
which is why I asked about the template code.  But what is the blue bubble 
above the Send button?  It says "God is love" ... are you putting the 
result in the wrong place?

/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: Routes.py to filter out file version numbers

2017-11-20 Thread Ian W. Scott
I saw it the other day, so I can find it again. I just didn't want to be 
bothered manually updating version numbers all the time. So I was looking 
to build something more automatic. Oh well. Thanks for your help, anyway.

Ian

On Monday, November 20, 2017 at 11:02:56 PM UTC-5, Dave S wrote:
>
>
>
> On Monday, November 20, 2017 at 7:04:00 PM UTC-8, Ian W. Scott wrote:
>>
>> I'm not getting web2py's 404 page because it's not the controller's page 
>> that isn't found. It's the stylesheet. 
>>
>
> Yeah, I just was about to admit I didn't try messing with anything from 
> static.
>  
>
>> So when I view all of the file requests in Chrome's dev tools (network 
>> tab) I see that the request for the stylesheet has returned 404. The 
>> requested URL was:
>>
>> http://127.0.0.1:8000/paideia/static/css/theme.1511232931.css  (Paideia 
>> is the name of the app).
>>
>> Is that the problem? Does web2py's rewrite system only work for the 
>> controller functions, but not for static files?
>>
>>
> Well, the default "static file versioning" works for static files, but 
> I've forgotten where that is handled.
>
> /dps
>  
>
>> On Monday, November 20, 2017 at 9:55:09 PM UTC-5, Dave S wrote:
>>>
>>>
>>>
>>> On Monday, November 20, 2017 at 6:02:38 PM UTC-8, Ian W. Scott wrote:

 Yes, that's right. I'm getting a 404 on each file with the added 
 version string, which must mean that the routes.py isn't pointing the 
 browser successfully to the real file (without the version string in the 
 name.

 For clarity's sake, here's the contents of my routes.py with the one 
 syntax error fixed:

 routes_in = ((r
 '.*/static/(?P(css|images|audio|js))/(?P.*)\.[\d]{10}\.(?P(css|js|ico|png|svg|jpe?g))'
 ,
   r'/static/\g/\g.\g'),
  )
 routes_out = [(x, y) for (y, x) in routes_in]

 I fixed the syntax error, but I'm still getting 404 errors.

>>>
>>>
>>> Does your 404 page show the URL?  The default web2py 404 will show 
>>> either invalid controller or invalid function, but not invalid application.
>>>
>>> /dps
>>>
>>>
 On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:
>
>
>
> On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>>
>> I'm still wondering if anyone can help with this. I found a minor 
>> error in the second member of the routes_in tuple (the period shouldn't 
>> be 
>> escaped). But it's still not working for me. I used re.sub to confirm 
>> that 
>> the second member *should be* outputting the right string. So far 
>> I'm just testing this on the bundled rocket server, so I don't think 
>> there's any issue with server settings.
>>
>> Any help would be much appreciated.
>>
>
> I tried to run the doctests on rewrite.py, but didn't do it right to 
> get the gluon imports working.  The module doesn't seem 
>
> Is the error that you're not getting the files you expect?  Are you 
> getting a 404 as a result?
>
> /dps
>
>  
>
>>
>> On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>>>
>>> Hi there. I'm dynamically adding version numbers to the filenames 
>>> for static assets like css, js, and image files. (These version numbers 
>>> aren't actually in the filenames. They're just added to the url in the 
>>>  and 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 7:04:00 PM UTC-8, Ian W. Scott wrote:
>
> I'm not getting web2py's 404 page because it's not the controller's page 
> that isn't found. It's the stylesheet. 
>

Yeah, I just was about to admit I didn't try messing with anything from 
static.
 

> So when I view all of the file requests in Chrome's dev tools (network 
> tab) I see that the request for the stylesheet has returned 404. The 
> requested URL was:
>
> http://127.0.0.1:8000/paideia/static/css/theme.1511232931.css  (Paideia 
> is the name of the app).
>
> Is that the problem? Does web2py's rewrite system only work for the 
> controller functions, but not for static files?
>
>
Well, the default "static file versioning" works for static files, but I've 
forgotten where that is handled.

/dps
 

> On Monday, November 20, 2017 at 9:55:09 PM UTC-5, Dave S wrote:
>>
>>
>>
>> On Monday, November 20, 2017 at 6:02:38 PM UTC-8, Ian W. Scott wrote:
>>>
>>> Yes, that's right. I'm getting a 404 on each file with the added version 
>>> string, which must mean that the routes.py isn't pointing the browser 
>>> successfully to the real file (without the version string in the name.
>>>
>>> For clarity's sake, here's the contents of my routes.py with the one 
>>> syntax error fixed:
>>>
>>> routes_in = ((r
>>> '.*/static/(?P(css|images|audio|js))/(?P.*)\.[\d]{10}\.(?P(css|js|ico|png|svg|jpe?g))'
>>> ,
>>>   r'/static/\g/\g.\g'),
>>>  )
>>> routes_out = [(x, y) for (y, x) in routes_in]
>>>
>>> I fixed the syntax error, but I'm still getting 404 errors.
>>>
>>
>>
>> Does your 404 page show the URL?  The default web2py 404 will show either 
>> invalid controller or invalid function, but not invalid application.
>>
>> /dps
>>
>>
>>> On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:



 On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>
> I'm still wondering if anyone can help with this. I found a minor 
> error in the second member of the routes_in tuple (the period shouldn't 
> be 
> escaped). But it's still not working for me. I used re.sub to confirm 
> that 
> the second member *should be* outputting the right string. So far I'm 
> just testing this on the bundled rocket server, so I don't think there's 
> any issue with server settings.
>
> Any help would be much appreciated.
>

 I tried to run the doctests on rewrite.py, but didn't do it right to 
 get the gluon imports working.  The module doesn't seem 

 Is the error that you're not getting the files you expect?  Are you 
 getting a 404 as a result?

 /dps

  

>
> On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>>
>> Hi there. I'm dynamically adding version numbers to the filenames for 
>> static assets like css, js, and image files. (These version numbers 
>> aren't 
>> actually in the filenames. They're just added to the url in the  
>> and 
>> 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Dave S
u

On Friday, November 17, 2017 at 7:12:58 AM UTC-8, Ian W. Scott wrote:
>
> Hi there. I'm dynamically adding version numbers to the filenames for 
> static assets like css, js, and image files. (These version numbers aren't 
> actually in the filenames. They're just added to the url in the  and 
> 

[web2py] Re: restful service + auth on same application/ different controllers = gives Not authorized message

2017-11-20 Thread Dave S


On Monday, November 13, 2017 at 6:14:00 AM UTC-8, Leandro Sebastian 
Salgueiro wrote:
>
> HI,
>
> I have two controllers on the same app:
>
> TestApp
> |
> |---default.py
> |---api.py
>
> api is a restful service that will call other services. For security 
> reasons I would like that all call to these services are passed by the api 
> restful. (it will work like a proxy in this case)
>
> I did try the following :
>
> in default.py :
>
> @auth.requires_login()
> def index():
> import requests
> json = requests.get(URL('api', 'apps', host=True))
> return {"json": json.content}
>
>
> in api.py:
>
> import requests
> apps_url = 'http://localhost:8091/apps'
>
>
> @auth.requires_login()
>
> @request.restful()
> def apps():
> response.view = 'generic.json'
> def GET(*args,**vars):
> r = requests.get(apps_url)
> return r
> return dict(GET=GET)
>
>
> If i test this without the api's login decorator everything works fine. 
> However I can access this restful from anywhere else... 
> I added then the requires_login to api controller and then i test both 
> URLs independently from browser, it works ok (login to web2py ->  go to 
> /api/apps -> get my results) however if I do the GET request using 
> requests.get from default controller i get a* Non Authorized *message and 
> redirect to login form.
>
> what i'm missing here? i thought that if I was in the same app, auth 
> session would be shared among different controllers... 
>
> any hint on this would be the most welcomed..
> Thanks in advanced.
> Leandro
>
>
You may be running into a twist that Anthony explained to me, where an API 
call's session doesn't last past the call (some qualifiers may be 
needed).   I'm not sure if that is true when the controller/function does 
an request "from the inside", but I would think about that.

I also think you might be better served using JWT for API authorization, 
and web2py has supported that for a while.  Look at the following thread 
for a little about using JWT, and for Anthony's comment about session 
lifetimes.

For more on JWT, look at the references in that thread (another thread, and 
gluon/tools.py).

/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] Retrieve database item using print vs return

2017-11-20 Thread Maurice Waka
In my previous question: [web2py] How to get the last DB Field data :
I got some good response. But my issue still persists.
My code:


def view_searches():
quizy = []
form = SQLFORM(db.post).process()
if request.vars.message:
db.post.insert(message = request.vars.message)
quizes = db(db.post.author == auth.user.id).select(db.post.ALL, 
orderby=~db.post.created_on, limitby=(0,1))
for q in quizes:
quizy.append(q.message)
quiz= quizy[0]
print quiz
return dict(form=form, quiz=quiz)

Note the print quiz for illustration purpose.
Now note the print screen below:




Notice the last post is;'God is love'


   - If using print, i get the exact last posted item
   - if I use return on the html page, I get aowirhsgporhj..previous 
   posted message, also shown on the terminal.
   - Note that the html page returns the random letter print;  aowirhsgporhj... 
   instead of 'God is love'
   - I used print to illustrate the erros. If i remove print function, the 
   error persists where i can't get the last posted item

My request is how do i resolve this?
Regards

-- 
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: restful service + auth on same application/ different controllers = gives Not authorized message

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 3:08:56 PM UTC-8, Val K wrote:
>
>
> Hi, you can use requests.Session:
>
> #in default
> session = requests.Session()
>

session is an already-defined global.
 

> url_login = 'http:///api/login.json'   
>

Shouldn't you be using the URL helper?  For my setup, I tried 
'URL("user/login",scheme="https", 
host=True)' since I don't have a second controller where I'm testing, and 
the default/user/login is the normal method for me.

#requests.packages.urllib3.disable_warnings()  # - uncomment if you use a 
self-signed 
> cert over https 
> r = session.get(url_login, verify=True) #set verify=False if you use a 
> self-signed 
> cert over https
>
>
I'm not sure about this.  As is, it produces a ticket for "get() takes no 
keyword arguments".  Taking out the verify, I get a result of 'None'.  That 
doesn't seem to be useful to me.

/dps

 

> form = dict( username = 'user',   password = 'password')
> r = session.post(url_login, data = form)
> if r.status_code==200: #server OK
>  response_data = json.loads(r.text)
>  logged_in = 'logged_in' in response_data.keys()
>  # if logged_in == True  -  session is authorized, so use 
>  session.post/get ...  to request api
>  
>
> #in api 
> @request.restful()
> def login():
> response.view = 'generic.json'
>user = request.vars.username
>password = request.vars.password
>   if auth.login_bare(user, password):
> return dict(logged_in = 'yes')
>
> # auth.requires_login()  redirects to login form, but it's redundant for 
> api 
> # instead of auth.requires_login() you can write your own simple decorator:
> def api_requires_login(f):
> if auth.is_logged_in():
> return f
> raise HTTP(401) # or return something
>
>
>
>
>
>
>
>
>
>
>
> On Tuesday, November 14, 2017 at 8:05:36 PM UTC+3, Carlos A. Armenta 
> Castro wrote:
>>
>> Hola Leandro, te escribo en español porque al ver tu nombre me parece que 
>> hablas castellano, corrigeme si me equivoco y te lo escribo en ingles, 
>>
>>
>>
>> El lunes, 13 de noviembre de 2017, 7:14:00 (UTC-7), Leandro Sebastian 
>> Salgueiro escribió:
>>
>> I added then the requires_login to api controller and then i test both 
>>> URLs independently from browser, it works ok (login to web2py ->  go to 
>>> /api/apps -> get my results) however if I do the GET request using 
>>> requests.get from default controller i get a* Non Authorized *message 
>>> and redirect to login form.
>>>
>>
>> En este caso en tu código:
>>
>> def index():
>> import requests
>> json = requests.get(URL('api', 'apps', host=True))
>>
>>
>> Lo que haces es iniciar otra sesión en tu misma APP pero no le estás 
>> enviando las credenciales para el Login, yo entiendo que cada ves que 
>> invocas a requests creas una nueva sesión entonces tienes que hacer Login 
>> cada vez.
>>
>> Me parece un poco extraño lo que haces en tu código porque si ya estás 
>> firmado no se porque buscas firmarte nuevamente. Te recomiendo abordar el 
>> problema de una manera distinta. Web2Py es Roca Solida en cuando a 
>> seguridad, no deberías preocuparte por problemas de seguridad una vez que 
>> ya estás firmado en tu App.
>>
>> Si necesitas seguridad Extra para tu APP, entonces te recomiendo usar JWT 
>> Tokens con Web2Py http://web2py.readthedocs.io/en/latest/tools.html
>>
>> jwt()[source] 
>>> 
>>>
>>> To use JWT authentication: 1) instantiate auth with:
>>>
>>> auth = Auth(db, jwt = {'secret_key':'secret'})
>>>
>>> where ‘secret’ is your own secret string.
>>>
>>>1. 
>>>
>>>Decorate functions that require login but should accept the JWT 
>>>token credentials:
>>>
>>>@auth.allows_jwt()@auth.requires_login()def myapi(): return 'hello %s' % 
>>> auth.user.email
>>>
>>>
>>> Notice jwt is allowed but not required. if user is logged in, myapi is 
>>> accessible.
>>>
>>>1. Use it!
>>>
>>> Now API users can obtain a token with
>>>
>>> http://.../app/default/user/jwt?username=...=
>>>
>>> (returns json object with a token attribute) API users can refresh an 
>>> existing token with
>>>
>>> http://.../app/default/user/jwt?token=...
>>>
>>> they can authenticate themselves when calling http:/.../myapi 
>>>  by injecting a header
>>>
>>> Authorization: Bearer 
>>>
>>> Saludos y suerte con tu APP. 
>>
>> HI,
>>>
>>> I have two controllers on the same app:
>>>
>>> TestApp
>>> |
>>> |---default.py
>>> |---api.py
>>>
>>> api is a restful service that will call other services. For security 
>>> reasons I would like that all call to these services are passed by the api 
>>> restful. (it will work like a proxy in this case)
>>>
>>> I did try the following :
>>>
>>> in default.py :
>>>
>>> @auth.requires_login()
>>> def index():
>>> import requests
>>> json = requests.get(URL('api', 'apps', host=True))
>>> return {"json": json.content}
>>>
>>>
>>> in 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Ian W. Scott
I'm not getting web2py's 404 page because it's not the controller's page 
that isn't found. It's the stylesheet. So when I view all of the file 
requests in Chrome's dev tools (network tab) I see that the request for the 
stylesheet has returned 404. The requested URL was:

http://127.0.0.1:8000/paideia/static/css/theme.1511232931.css  (Paideia is 
the name of the app).

Is that the problem? Does web2py's rewrite system only work for the 
controller functions, but not for static files?

On Monday, November 20, 2017 at 9:55:09 PM UTC-5, Dave S wrote:
>
>
>
> On Monday, November 20, 2017 at 6:02:38 PM UTC-8, Ian W. Scott wrote:
>>
>> Yes, that's right. I'm getting a 404 on each file with the added version 
>> string, which must mean that the routes.py isn't pointing the browser 
>> successfully to the real file (without the version string in the name.
>>
>> For clarity's sake, here's the contents of my routes.py with the one 
>> syntax error fixed:
>>
>> routes_in = ((r
>> '.*/static/(?P(css|images|audio|js))/(?P.*)\.[\d]{10}\.(?P(css|js|ico|png|svg|jpe?g))'
>> ,
>>   r'/static/\g/\g.\g'),
>>  )
>> routes_out = [(x, y) for (y, x) in routes_in]
>>
>> I fixed the syntax error, but I'm still getting 404 errors.
>>
>
>
> Does your 404 page show the URL?  The default web2py 404 will show either 
> invalid controller or invalid function, but not invalid application.
>
> /dps
>
>
>> On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:
>>>
>>>
>>>
>>> On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:

 I'm still wondering if anyone can help with this. I found a minor error 
 in the second member of the routes_in tuple (the period shouldn't be 
 escaped). But it's still not working for me. I used re.sub to confirm that 
 the second member *should be* outputting the right string. So far I'm 
 just testing this on the bundled rocket server, so I don't think there's 
 any issue with server settings.

 Any help would be much appreciated.

>>>
>>> I tried to run the doctests on rewrite.py, but didn't do it right to get 
>>> the gluon imports working.  The module doesn't seem 
>>>
>>> Is the error that you're not getting the files you expect?  Are you 
>>> getting a 404 as a result?
>>>
>>> /dps
>>>
>>>  
>>>

 On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>
> Hi there. I'm dynamically adding version numbers to the filenames for 
> static assets like css, js, and image files. (These version numbers 
> aren't 
> actually in the filenames. They're just added to the url in the  
> and 
> 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 6:02:38 PM UTC-8, Ian W. Scott wrote:
>
> Yes, that's right. I'm getting a 404 on each file with the added version 
> string, which must mean that the routes.py isn't pointing the browser 
> successfully to the real file (without the version string in the name.
>
> For clarity's sake, here's the contents of my routes.py with the one 
> syntax error fixed:
>
> routes_in = ((r
> '.*/static/(?P(css|images|audio|js))/(?P.*)\.[\d]{10}\.(?P(css|js|ico|png|svg|jpe?g))'
> ,
>   r'/static/\g/\g.\g'),
>  )
> routes_out = [(x, y) for (y, x) in routes_in]
>
> I fixed the syntax error, but I'm still getting 404 errors.
>


Does your 404 page show the URL?  The default web2py 404 will show either 
invalid controller or invalid function, but not invalid application.

/dps


> On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:
>>
>>
>>
>> On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>>>
>>> I'm still wondering if anyone can help with this. I found a minor error 
>>> in the second member of the routes_in tuple (the period shouldn't be 
>>> escaped). But it's still not working for me. I used re.sub to confirm that 
>>> the second member *should be* outputting the right string. So far I'm 
>>> just testing this on the bundled rocket server, so I don't think there's 
>>> any issue with server settings.
>>>
>>> Any help would be much appreciated.
>>>
>>
>> I tried to run the doctests on rewrite.py, but didn't do it right to get 
>> the gluon imports working.  The module doesn't seem 
>>
>> Is the error that you're not getting the files you expect?  Are you 
>> getting a 404 as a result?
>>
>> /dps
>>
>>  
>>
>>>
>>> On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:

 Hi there. I'm dynamically adding version numbers to the filenames for 
 static assets like css, js, and image files. (These version numbers aren't 
 actually in the filenames. They're just added to the url in the  and 
 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Ian W. Scott
Yes, that's right. I'm getting a 404 on each file with the added version 
string, which must mean that the routes.py isn't pointing the browser 
successfully to the real file (without the version string in the name.

For clarity's sake, here's the contents of my routes.py with the one syntax 
error fixed:

routes_in = ((r
'.*/static/(?P(css|images|audio|js))/(?P.*)\.[\d]{10}\.(?P(css|js|ico|png|svg|jpe?g))'
,
  r'/static/\g/\g.\g'),
 )
routes_out = [(x, y) for (y, x) in routes_in]

I fixed the syntax error, but I'm still getting 404 errors.

On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:
>
>
>
> On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>>
>> I'm still wondering if anyone can help with this. I found a minor error 
>> in the second member of the routes_in tuple (the period shouldn't be 
>> escaped). But it's still not working for me. I used re.sub to confirm that 
>> the second member *should be* outputting the right string. So far I'm 
>> just testing this on the bundled rocket server, so I don't think there's 
>> any issue with server settings.
>>
>> Any help would be much appreciated.
>>
>
> I tried to run the doctests on rewrite.py, but didn't do it right to get 
> the gluon imports working.  The module doesn't seem 
>
> Is the error that you're not getting the files you expect?  Are you 
> getting a 404 as a result?
>
> /dps
>
>  
>
>>
>> On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>>>
>>> Hi there. I'm dynamically adding version numbers to the filenames for 
>>> static assets like css, js, and image files. (These version numbers aren't 
>>> actually in the filenames. They're just added to the url in the  and 
>>> 

[web2py] Re: Routes.py to filter out file version numbers

2017-11-20 Thread Dave S


On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>
> I'm still wondering if anyone can help with this. I found a minor error in 
> the second member of the routes_in tuple (the period shouldn't be escaped). 
> But it's still not working for me. I used re.sub to confirm that the second 
> member *should be* outputting the right string. So far I'm just testing 
> this on the bundled rocket server, so I don't think there's any issue with 
> server settings.
>
> Any help would be much appreciated.
>

I tried to run the doctests on rewrite.py, but didn't do it right to get 
the gluon imports working.  The module doesn't seem 

Is the error that you're not getting the files you expect?  Are you getting 
a 404 as a result?

/dps

 

>
> On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>>
>> Hi there. I'm dynamically adding version numbers to the filenames for 
>> static assets like css, js, and image files. (These version numbers aren't 
>> actually in the filenames. They're just added to the url in the  and 
>> 

[web2py] Re: restful service + auth on same application/ different controllers = gives Not authorized message

2017-11-20 Thread Val K

Hi, you can use requests.Session:

#in default
session = requests.Session()
url_login = 'http:///api/login.json'   
#requests.packages.urllib3.disable_warnings()  # - uncomment if you use a 
self-signed 
cert over https 
r = session.get(url_login, verify=True) #set verify=False if you use a 
self-signed 
cert over https

form = dict( username = 'user',   password = 'password')
r = session.post(url_login, data = form)
if r.status_code==200: #server OK
 response_data = json.loads(r.text)
 logged_in = 'logged_in' in response_data.keys()
 # if logged_in == True  -  session is authorized, so use 
 session.post/get ...  to request api
 

#in api 
@request.restful()
def login():
response.view = 'generic.json'
   user = request.vars.username
   password = request.vars.password
  if auth.login_bare(user, password):
return dict(logged_in = 'yes')

# auth.requires_login()  redirects to login form, but it's redundant for 
api 
# instead of auth.requires_login() you can write your own simple decorator:
def api_requires_login(f):
if auth.is_logged_in():
return f
raise HTTP(401) # or return something











On Tuesday, November 14, 2017 at 8:05:36 PM UTC+3, Carlos A. Armenta Castro 
wrote:
>
> Hola Leandro, te escribo en español porque al ver tu nombre me parece que 
> hablas castellano, corrigeme si me equivoco y te lo escribo en ingles, 
>
>
>
> El lunes, 13 de noviembre de 2017, 7:14:00 (UTC-7), Leandro Sebastian 
> Salgueiro escribió:
>
> I added then the requires_login to api controller and then i test both 
>> URLs independently from browser, it works ok (login to web2py ->  go to 
>> /api/apps -> get my results) however if I do the GET request using 
>> requests.get from default controller i get a* Non Authorized *message 
>> and redirect to login form.
>>
>
> En este caso en tu código:
>
> def index():
> import requests
> json = requests.get(URL('api', 'apps', host=True))
>
>
> Lo que haces es iniciar otra sesión en tu misma APP pero no le estás 
> enviando las credenciales para el Login, yo entiendo que cada ves que 
> invocas a requests creas una nueva sesión entonces tienes que hacer Login 
> cada vez.
>
> Me parece un poco extraño lo que haces en tu código porque si ya estás 
> firmado no se porque buscas firmarte nuevamente. Te recomiendo abordar el 
> problema de una manera distinta. Web2Py es Roca Solida en cuando a 
> seguridad, no deberías preocuparte por problemas de seguridad una vez que 
> ya estás firmado en tu App.
>
> Si necesitas seguridad Extra para tu APP, entonces te recomiendo usar JWT 
> Tokens con Web2Py http://web2py.readthedocs.io/en/latest/tools.html
>
> jwt()[source] 
>> 
>>
>> To use JWT authentication: 1) instantiate auth with:
>>
>> auth = Auth(db, jwt = {'secret_key':'secret'})
>>
>> where ‘secret’ is your own secret string.
>>
>>1. 
>>
>>Decorate functions that require login but should accept the JWT token 
>>credentials:
>>
>>@auth.allows_jwt()@auth.requires_login()def myapi(): return 'hello %s' % 
>> auth.user.email
>>
>>
>> Notice jwt is allowed but not required. if user is logged in, myapi is 
>> accessible.
>>
>>1. Use it!
>>
>> Now API users can obtain a token with
>>
>> http://.../app/default/user/jwt?username=...=
>>
>> (returns json object with a token attribute) API users can refresh an 
>> existing token with
>>
>> http://.../app/default/user/jwt?token=...
>>
>> they can authenticate themselves when calling http:/.../myapi 
>>  by injecting a header
>>
>> Authorization: Bearer 
>>
>> Saludos y suerte con tu APP. 
>
> HI,
>>
>> I have two controllers on the same app:
>>
>> TestApp
>> |
>> |---default.py
>> |---api.py
>>
>> api is a restful service that will call other services. For security 
>> reasons I would like that all call to these services are passed by the api 
>> restful. (it will work like a proxy in this case)
>>
>> I did try the following :
>>
>> in default.py :
>>
>> @auth.requires_login()
>> def index():
>> import requests
>> json = requests.get(URL('api', 'apps', host=True))
>> return {"json": json.content}
>>
>>
>> in api.py:
>>
>> import requests
>> apps_url = 'http://localhost:8091/apps'
>>
>>
>> @auth.requires_login()
>>
>> @request.restful()
>> def apps():
>> response.view = 'generic.json'
>> def GET(*args,**vars):
>> r = requests.get(apps_url)
>> return r
>> return dict(GET=GET)
>>
>>
>> If i test this without the api's login decorator everything works fine. 
>> However I can access this restful from anywhere else... 
>> I added then the requires_login to api controller and then i test both 
>> URLs independently from browser, it works ok (login to web2py ->  go to 
>> /api/apps -> get my results) however if I do the GET request using 
>> requests.get from default controller i get a* Non Authorized *message 
>> and 

[web2py] Re: How to insert data into Database?

2017-11-20 Thread Anthony
Have you defined the blog1 table anywhere? If you have, the code looks OK 
-- what are you observing, and what do you expect instead?

Anthony

On Monday, November 20, 2017 at 4:46:07 PM UTC-5, Sandeep Patel wrote:
>
> I want to take data from the user using my HTML template and insert that 
> data into my database without using SQLFROM and FROM in my controller file.
> can I do it?
> Actually, I am new in web2py, please give me direction.
>
> Here file 
> #model file
> from gluon import DAL, Field
> mysql = DAL('mysql://:@***.
> cgaqtjjdhgni.ap-south-1.rds.amazonaws.com/saflta')
>
>
> #controller file
> def request_vars():
> if request.post_vars:
> mysql.blog1.insert(blog_title= request.post_vars.title)
> response.flash = T("Done")
> return locals()
>
>
> #view file
>
> {{extend 'layout.html'}}
> This is the basics/request_vars.html template
> 
> 
> 
> 
>
>

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


[web2py] How to insert data into Database?

2017-11-20 Thread Sandeep Patel
I want to take data from the user using my HTML template and insert that 
data into my database without using SQLFROM and FROM in my controller file.
can I do it?
Actually, I am new in web2py, please give me direction.

Here file 
#model file
from gluon import DAL, Field
mysql = 
DAL('mysql://:@***.cgaqtjjdhgni.ap-south-1.rds.amazonaws.com/saflta')


#controller file
def request_vars():
if request.post_vars:
mysql.blog1.insert(blog_title= request.post_vars.title)
response.flash = T("Done")
return locals()


#view file

{{extend 'layout.html'}}
This is the basics/request_vars.html template





-- 
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] Fwd: Us congress hearing of maan alsaan Money laundry قضية الكونغجرس لغسيل الأموال للمليادير معن الصانع

2017-11-20 Thread mike a
YouTube videos of



 U.S. Congress money laundering hearing


of

Saudi Billionaire  " Maan  Al sanea"

 with *bank of America*


and  The  owner of Saad Hospital and  Schools

 in the Eastern Province in *Saudi Arabia*



and the Chairman of the Board of Directors of Awal Bank  in *Bahrain*


With Arabic Subtitles





*موقع اليوتيوب الذي عرض جلسة استماع الكونجرس الأمريكي *

* لمتابعة نشاطات غسل الأموال ونشاطات*



*السعودي معن عبدالواحد الصانع*



*مالك مستشفى  وشركة سعد  ومدارس سعد بالمنطقة الشرقية بالسعودية   ورئيس مجلس
ادارة بنك اوال البحريني*



*مترجم باللغة العربية*



http://www.youtube.com/watch?v=mIBNnQvhU8s







-- 
You received this message because you are subscribed to the Google Groups
"Pakistan Human Resource Professionals" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to phrpro+unsubscr...@googlegroups.com.
To post to this group, send email to phr...@googlegroups.com.
Visit this group at https://groups.google.com/group/phrpro.
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] error: 'No module named sanitizer' after upgrading to 2.16.1

2017-11-20 Thread Ton Sjerps
After upgrading from 2.15.4 it gave the ticket below.
Unfortunately putting it back to the previous or an even older version did 
not solve the problem.
Searching the web it seems to be related to python libs *html5lib *and 
*bleach* 
reinstalling or updating them with 'pip install -U bleach' does not seem to 
help and neither does installing a previous version of the html5lib with 
'pip install html5lib==1.0b9'

The problem exists while testing locally on my laptop as well as on the 
server. 
The server I could only get back up and running by restoring it to the 
backup off last night.
(restored to version 2.14.6-stable+timestamp.2016.05.10.00.21.47  
Apache/2.4.18 (Ubuntu), Python 2.7.12) 

Anybody any suggestions on what the problem is and how to tackle it?

web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 
Python Python 2.7.14: D:\Python27\python.exe (prefix: D:\Python27) Traceback 

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



Traceback (most recent call last):
  File "F:\5-PCPROG\web2py_src\web2py\gluon\restricted.py", line 219, in 
restricted
exec(ccode, environment)
  File "F:/5-PCPROG/web2py_src/web2py/applications/apa/controllers/orders.py" 
, line 3, 
in 
from sanitizer import sanitize
  File "F:\5-PCPROG\web2py_src\web2py\gluon\custom_import.py", line 104, in 
custom_importer
raise ImportError(e1, import_tb)  # there an import error in the module
ImportError: (ImportError('No module named sanitizer',), )

-- 
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: Routes.py to filter out file version numbers

2017-11-20 Thread Ian W. Scott
I'm still wondering if anyone can help with this. I found a minor error in 
the second member of the routes_in tuple (the period shouldn't be escaped). 
But it's still not working for me. I used re.sub to confirm that the second 
member *should be* outputting the right string. So far I'm just testing 
this on the bundled rocket server, so I don't think there's any issue with 
server settings.

Any help would be much appreciated.

On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>
> Hi there. I'm dynamically adding version numbers to the filenames for 
> static assets like css, js, and image files. (These version numbers aren't 
> actually in the filenames. They're just added to the url in the  and 
> 

[web2py] Re: Import application from staging to production server

2017-11-20 Thread Anthony
On Sunday, November 19, 2017 at 10:03:12 PM UTC-5, Peter wrote:
>
>
> I don't understand the 'local_import'  in this line
>
> pygal = local_import('pygal')
>>
>>
> Can't find it in the documentation for web2py, pygal or  searching  python 
> local_import... 
>

local_import was deprecated after the web2py custom importer was created. 
It was used as a way to load modules local to the application and allow 
auto-reloading in development. It still works but is no longer necessary or 
recommended.

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: threading Lock

2017-11-20 Thread Leonel Câmara


Pretty much. Note that usually you can refer to the library documentation 
to know which parts are threadsafe. For instance matplotlib has an 
object-oriented interface that is thread safe as it is explained here:

https://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server





-- 
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: threading Lock

2017-11-20 Thread Pierre
 

from recent forum threads elements i assume the following  
'macro-situation':


(0) python libraries selected for a project should be thread-safe

(1) user uses python libaries at his own risk (there 's no mean to verify 
it's thread-safe)

(2) in order to minimize risks user should put a lock around all code using 
the libraries :


def dangerous() :
 with lock_libraryA : 
 do something with libraryA 
 with lock_libraryB : 
 do something with libraryB



(3) in case of application crashes where libraries are involved means 
libraries cannot be used and designers should look for alternatives 


is this correct ?


As regard the dangerous code 'micro-situation': 

I think it' ll be ok to lock between threads. One line of code instantiates 
the main library object (constructor takes 2 files arguments). Is that a 
potential problem at the process level ? (code is readonly nothing is  ever 
written to the files)


As regard processes concurrency :

Doing tests with several scheduler processes and lot's of tasks, i have had 
deadlocks so i wondered if postgreSQL Lock command could help prevent that ?

https://www.tutorialspoint.com/postgresql/postgresql_locks.htm



thanks guys for your support……. 



 @Dave : quote by Nietzsche 

« Partout on entend la voix de ceux qui prêchent la mort : et la terre est 
pleine de ceux à qui il convient de prêcher la mort. »




-- 
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] MIGRATE UPLOADS FROM SQLITE TO POSTGRESQL

2017-11-20 Thread Áureo Dias Neto
I migrated my data from sqlite to postgres, but I have file uploads on disk 
used in my database. I want to send them from my "disk" to my base in 
postgresql, to use it in a "blob (bytea, actually)" field. Thank you in 
advance, family.

-- 
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: SSL certificate on web2py (aws ec2 + Nginx + uwsgi)

2017-11-20 Thread Michele Comitini
Daniel,

The AWS certificate manager gives you certificates that you can use on a
ELB.  So you can put an ELB in front of your EC2 box and use the
certificate(s) from there.

mic


2017-11-20 2:29 GMT+01:00 Daniel Dos Santos Guilhermino <
danielguilherm...@gmail.com>:

> HI Dave,
>
> Many thanks, I'll check acme solution too.
>
> best regards,
>
>
> Em sexta-feira, 17 de novembro de 2017 22:22:18 UTC-2, Dave S escreveu:
>>
>>
>>
>> On Friday, November 17, 2017 at 4:16:50 PM UTC-8, Daniel Dos Santos
>> Guilhermino wrote:
>>>
>>> Thanks Dave!
>>>
>>> I'll search about let's encrypt, maybe help me.
>>>
>>> Best regards.
>>>
>>>
>>> Daniel Guilhermino
>>>
>>
>> I used certbot-auto from certbot.org, which is a sub-organization of EFF
>> and Let's Encrypt.   the -auto puts some virtenv wrapping around the
>> regular certbot (python); AWS linux is considered "experimental" by
>> certbot.  Some people prefer acme, which is a BASH script AIUI.
>>
>> /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.
>



-- 
Michele Comitini

tel: +39 335 66 71 336

-- 
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: User_agent is NoneType error

2017-11-20 Thread DaneW
Thanks. I have now upgraded to 2.16.1 but I'm afraid the problem is still 
there. The traceback is slightly different -

File "/home/appgov/web2py/gluon/globals.py", line 340, in user_agent
user_agent = user_agent_parser.detect(http_user_agent)
TypeError: argument of type 'NoneType' is not iterable

The problem occurs when a user tries to access my home page 
(www.appgov.org) but other users get through successfully.

I will file the issue in GitHub.


On Friday, 17 November 2017 18:20:41 UTC, Leonel Câmara wrote:
>
> Can you upgrade to the latest version, restart, and check if this still 
> happens? If it does, please file an issue in github explaining how to 
> reproduce.
>

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