Re: [web2py] How to use XML data

2012-03-09 Thread Bruno Rocha
def index():
import urllib2
temp = urllib2.urlopen('
http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
')
tempdata = temp.read()

*# parsing XML string*
parseddata = *TAG(tempdata.replace("000
*data = parseddata.elements('data')
if data:
current_condition = data[0].elements('current_condition')
if current_condition:
temp_c = current_condition[0].elements('temp_c')
if temp_c:
temp = temp_c[0].flatten()

return dict(temp = temp)

the following code in view:

{{extend 'layout.html'}}

{{=temp}}



I tested in my terminal:

>>> def index():
... import urllib2
... temp = urllib2.urlopen('
http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
')
... tempdata = temp.read()
...
... # parsing XML string
... parseddata = TAG(tempdata.replace("000
... data = parseddata.elements('data')
... if data:
... current_condition = data[0].elements('current_condition')
... if current_condition:
... temp_c = current_condition[0].elements('temp_c')
... if temp_c:
... temp = temp_c[0].flatten()
...
... return dict(temp = temp)
>>> index()
24: {'temp': '32'}
On Sat, Mar 10, 2012 at 4:38 AM, Praveen Bhat wrote:

> Hello Bruno,
>
> I am sorry to say that I am totally new to programming, so could you
> please eloborate where I can use the above line of code.\
>
> Or you can point to some example .
>
> Regards
> Praveen
>
> On Saturday, March 10, 2012 12:49:11 PM UTC+5:30, rochacbruno wrote:
>>
>> >>> print
>> TAG(tempdata.replace("> 32
>> >>>
>>
>> On Sat, Mar 10, 2012 at 4:04 AM, Praveen Bhat wrote:
>>
>>> Hello,
>>>
>>> I am getting the following error:
>>>
>>> ' 'str' object has no attribute
>>> 'elements'
>>>
>>> I have the following code in controller:
>>>
>>> def index():
>>> import urllib2
>>> temp = urllib2.urlopen('
>>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>>> ')
>>> tempdata = temp.read()
>>> parseddata = XML(tempdata).xml()
>>> return dict(parseddata = parseddata)
>>>
>>> the following code in view:
>>>
>>> {{extend 'layout.html'}}
>>>
>>> {{ for parseddata in parseddata: }}
>>>
>>> {{=XML(parseddata.element("temp_C"))}}
>>> {{pass}}
>>>
>>> Regards
>>> Praveen
>>>
>>>
>>>
>>> On Saturday, March 10, 2012 12:28:18 PM UTC+5:30, rochacbruno wrote:

 I guess it will work.

 {{ for parseddata in parseddata: }}

 {{=XML(parseddata.elements("temp_C"))}}

 {{pass}}

 On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat 
 wrote:

> Hello,
>
> I apologize as I could not reply...
>
> Yes I was able to get the parsed output but I want to display only
> the  data between < t e m p _ C >  < / t e m p _ C > in the outputted XML
> and not the whole XMl document
>
>
> Regards
> Praveen
>
>
> On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>>
>> As I can see, you got the XML and outputed it to the view.
>> I dont see what you want more. Tell us.
>>
>> 2012/3/6 Praveen Bhat :
>> > Hello,
>> >
>> > I have come to the point where the whole XML document is returned,
>> as u can
>> > see in the attached file.
>> >
>> > I have used the following code:
>> >
>> > Controller:
>> >
>> > def index():
>> > import urllib2
>> > temp =
>> > urllib2.urlopen('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>> ')
>> > tempdata = temp.read()
>> > parseddata = XML(tempdata).xml()
>> > return dict(parseddata = parseddata)
>> >
>> > View:
>> >
>> >
>> > {{ for parseddata in parseddata: }}
>> >
>> > {{=XML(parseddata)}}
>> >
>> > {{pass}}
>> >
>> > I am missing something here. Could you please help.
>> >
>> > Regards
>> >
>> >
>> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
>> >>
>> >> You can do something like in
>> http://web2py.com/books/default/chapter/29/5
>> >> :
>> >> Parsing
>> >>
>> >> The TAG object is also an XML/HTML parser. It can read text and
>> >> convert into a tree structure of helpers. This allows manipulation
>> >> using the API above:
>> >> >>> html = 'Titlethis is a test'
>> >> >>> parsed_html = TAG(html)
>> >> >>> parsed_html.element('span')[0]='TEST'
>> >> >>> print parsed_html
>> >> Titlethis is a TEST
>> >>
>> >> 2012/3/5 Praveen Bhat :
>> >> > Hello,
>> >> >
>> >> > I am using http://worldweatheronline.com API to display weather
>> info.
>> >> > The
>> >> > API returns the data in XML format.
>> >> >
>> >> > How can i render the same in a HTML page in Web2py.
>> 

Re: [web2py] How to use XML data

2012-03-09 Thread Praveen Bhat
Hello,

I tried this the view file:

{{extend 'layout.html'}}

{{ for parseddata in parseddatas: }}

{{TAG(parseddata.replace(" list index out of range

Regards

On Saturday, March 10, 2012 1:08:12 PM UTC+5:30, Praveen Bhat wrote:
>
> Hello Bruno,
>
> I am sorry to say that I am totally new to programming, so could you 
> please eloborate where I can use the above line of code.\
>
> Or you can point to some example .
>
> Regards
> Praveen
>
> On Saturday, March 10, 2012 12:49:11 PM UTC+5:30, rochacbruno wrote:
>>
>> >>> print 
>> TAG(tempdata.replace("> 32
>> >>> 
>>
>> On Sat, Mar 10, 2012 at 4:04 AM, Praveen Bhat wrote:
>>
>>> Hello,
>>>
>>> I am getting the following error:
>>>
>>> ' 'str' object has no attribute 
>>> 'elements'
>>>
>>> I have the following code in controller:
>>>
>>> def index():
>>> import urllib2
>>> temp = urllib2.urlopen('
>>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>>> ')
>>> tempdata = temp.read()
>>> parseddata = XML(tempdata).xml() 
>>> return dict(parseddata = parseddata)
>>>
>>> the following code in view:
>>>
>>> {{extend 'layout.html'}}
>>>
>>> {{ for parseddata in parseddata: }}
>>>
>>> {{=XML(parseddata.element("temp_C"))}}
>>> {{pass}}
>>>
>>> Regards
>>> Praveen
>>>
>>>
>>>
>>> On Saturday, March 10, 2012 12:28:18 PM UTC+5:30, rochacbruno wrote:

 I guess it will work.

 {{ for parseddata in parseddata: }}

 {{=XML(parseddata.elements("temp_C"))}}

 {{pass}}

 On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat 
 wrote:

> Hello,
>
> I apologize as I could not reply...
>
> Yes I was able to get the parsed output but I want to display only 
> the  data between < t e m p _ C >  < / t e m p _ C > in the outputted XML 
> and not the whole XMl document
>
>
> Regards
> Praveen
>
>
> On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>>
>> As I can see, you got the XML and outputed it to the view.
>> I dont see what you want more. Tell us.
>>
>> 2012/3/6 Praveen Bhat :
>> > Hello,
>> >
>> > I have come to the point where the whole XML document is returned, 
>> as u can
>> > see in the attached file.
>> >
>> > I have used the following code:
>> >
>> > Controller:
>> >
>> > def index():
>> > import urllib2
>> > temp =
>> > urllib2.urlopen('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>> ')
>> > tempdata = temp.read()
>> > parseddata = XML(tempdata).xml()
>> > return dict(parseddata = parseddata)
>> >
>> > View:
>> >
>> >
>> > {{ for parseddata in parseddata: }}
>> >
>> > {{=XML(parseddata)}}
>> >
>> > {{pass}}
>> >
>> > I am missing something here. Could you please help.
>> >
>> > Regards
>> >
>> >
>> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
>> >>
>> >> You can do something like in 
>> http://web2py.com/books/default/chapter/29/5
>> >> :
>> >> Parsing
>> >>
>> >> The TAG object is also an XML/HTML parser. It can read text and
>> >> convert into a tree structure of helpers. This allows manipulation
>> >> using the API above:
>> >> >>> html = 'Titlethis is a test'
>> >> >>> parsed_html = TAG(html)
>> >> >>> parsed_html.element('span')[0]='TEST'
>> >> >>> print parsed_html
>> >> Titlethis is a TEST
>> >>
>> >> 2012/3/5 Praveen Bhat :
>> >> > Hello,
>> >> >
>> >> > I am using http://worldweatheronline.com API to display weather 
>> info.
>> >> > The
>> >> > API returns the data in XML format.
>> >> >
>> >> > How can i render the same in a HTML page in Web2py.
>> >> >
>> >> > Link for accessing the API Data:
>> >> >
>> >> > Weather API
>> >> >
>> >> > I have done the same in PHP as following:
>> >> >
>> >> > > >> > $xml =
>> >> >
>> >> > simplexml_load_file('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
>> );
>> >> > $current = $xml->xpath("/data/current_condition");
>> >> > ?>
>> >> >
>> >> > 
>> >> > Weather :
>> >> > temp_C ?>° C,
>> >> > weatherDesc ?>
>> >> > 
>> >> >
>> >> > How can I do the same in web2py?
>> >> >
>> >> >
>> >> > Regards,
>> >> > Praveen
>> >> >
>> >>
>> >> --
>> >> Carlos J. Costa
>> >> Cientista da Computação
>> >> Esp. Gestão em Telecom
>> >>
>> >> EL MELECH NEEMAN!
>> >> אָמֵן
>>
>> -- 
>> Carlos J. Costa
>> Cientista da Computação
>> Esp. Gestão em Telecom
>>
>> EL MELECH NEEMAN!
>> אָמֵן
>>
>


 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]


>

Re: [web2py] How to use XML data

2012-03-09 Thread Praveen Bhat
Hello Bruno,

I am sorry to say that I am totally new to programming, so could you please 
eloborate where I can use the above line of code.\

Or you can point to some example .

Regards
Praveen

On Saturday, March 10, 2012 12:49:11 PM UTC+5:30, rochacbruno wrote:
>
> >>> print 
> TAG(tempdata.replace(" 32
> >>> 
>
> On Sat, Mar 10, 2012 at 4:04 AM, Praveen Bhat wrote:
>
>> Hello,
>>
>> I am getting the following error:
>>
>> ' 'str' object has no attribute 
>> 'elements'
>>
>> I have the following code in controller:
>>
>> def index():
>> import urllib2
>> temp = urllib2.urlopen('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>> ')
>> tempdata = temp.read()
>> parseddata = XML(tempdata).xml() 
>> return dict(parseddata = parseddata)
>>
>> the following code in view:
>>
>> {{extend 'layout.html'}}
>>
>> {{ for parseddata in parseddata: }}
>>
>> {{=XML(parseddata.element("temp_C"))}}
>> {{pass}}
>>
>> Regards
>> Praveen
>>
>>
>>
>> On Saturday, March 10, 2012 12:28:18 PM UTC+5:30, rochacbruno wrote:
>>>
>>> I guess it will work.
>>>
>>> {{ for parseddata in parseddata: }}
>>>
>>> {{=XML(parseddata.elements("temp_C"))}}
>>>
>>> {{pass}}
>>>
>>> On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat 
>>> wrote:
>>>
 Hello,

 I apologize as I could not reply...

 Yes I was able to get the parsed output but I want to display only the  
 data between < t e m p _ C >  < / t e m p _ C > in the outputted XML and 
 not the whole XMl document


 Regards
 Praveen


 On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>
> As I can see, you got the XML and outputed it to the view.
> I dont see what you want more. Tell us.
>
> 2012/3/6 Praveen Bhat :
> > Hello,
> >
> > I have come to the point where the whole XML document is returned, 
> as u can
> > see in the attached file.
> >
> > I have used the following code:
> >
> > Controller:
> >
> > def index():
> > import urllib2
> > temp =
> > urllib2.urlopen('
> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
> ')
> > tempdata = temp.read()
> > parseddata = XML(tempdata).xml()
> > return dict(parseddata = parseddata)
> >
> > View:
> >
> >
> > {{ for parseddata in parseddata: }}
> >
> > {{=XML(parseddata)}}
> >
> > {{pass}}
> >
> > I am missing something here. Could you please help.
> >
> > Regards
> >
> >
> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
> >>
> >> You can do something like in 
> http://web2py.com/books/default/chapter/29/5
> >> :
> >> Parsing
> >>
> >> The TAG object is also an XML/HTML parser. It can read text and
> >> convert into a tree structure of helpers. This allows manipulation
> >> using the API above:
> >> >>> html = 'Titlethis is a test'
> >> >>> parsed_html = TAG(html)
> >> >>> parsed_html.element('span')[0]='TEST'
> >> >>> print parsed_html
> >> Titlethis is a TEST
> >>
> >> 2012/3/5 Praveen Bhat :
> >> > Hello,
> >> >
> >> > I am using http://worldweatheronline.com API to display weather 
> info.
> >> > The
> >> > API returns the data in XML format.
> >> >
> >> > How can i render the same in a HTML page in Web2py.
> >> >
> >> > Link for accessing the API Data:
> >> >
> >> > Weather API
> >> >
> >> > I have done the same in PHP as following:
> >> >
> >> >  >> > $xml =
> >> >
> >> > simplexml_load_file('
> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
> );
> >> > $current = $xml->xpath("/data/current_condition");
> >> > ?>
> >> >
> >> > 
> >> > Weather :
> >> > temp_C ?>° C,
> >> > weatherDesc ?>
> >> > 
> >> >
> >> > How can I do the same in web2py?
> >> >
> >> >
> >> > Regards,
> >> > Praveen
> >> >
> >>
> >> --
> >> Carlos J. Costa
> >> Cientista da Computação
> >> Esp. Gestão em Telecom
> >>
> >> EL MELECH NEEMAN!
> >> אָמֵן
>
> -- 
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>

>>>
>>>
>>> -- 
>>>
>>> Bruno Rocha
>>> [http://rochacbruno.com.br]
>>>
>>>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

Re: [web2py] iframe and pdf

2012-03-09 Thread Bruno Rocha
def k():
if 'showpdf' in request.args:
return person2pdf(session.ids)
else:
return dict(ifr=IFRAME(_src=URL('default','k', args='showpdf')))



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] How to use XML data

2012-03-09 Thread Bruno Rocha
>>> print
TAG(tempdata.replace(">>

On Sat, Mar 10, 2012 at 4:04 AM, Praveen Bhat wrote:

> Hello,
>
> I am getting the following error:
>
> ' 'str' object has no attribute
> 'elements'
>
> I have the following code in controller:
>
> def index():
> import urllib2
> temp = urllib2.urlopen('
> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
> ')
> tempdata = temp.read()
> parseddata = XML(tempdata).xml()
> return dict(parseddata = parseddata)
>
> the following code in view:
>
> {{extend 'layout.html'}}
>
> {{ for parseddata in parseddata: }}
>
> {{=XML(parseddata.element("temp_C"))}}
> {{pass}}
>
> Regards
> Praveen
>
>
>
> On Saturday, March 10, 2012 12:28:18 PM UTC+5:30, rochacbruno wrote:
>>
>> I guess it will work.
>>
>> {{ for parseddata in parseddata: }}
>>
>> {{=XML(parseddata.elements("temp_C"))}}
>>
>> {{pass}}
>>
>> On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat wrote:
>>
>>> Hello,
>>>
>>> I apologize as I could not reply...
>>>
>>> Yes I was able to get the parsed output but I want to display only the
>>> data between < t e m p _ C >  < / t e m p _ C > in the outputted XML and
>>> not the whole XMl document
>>>
>>>
>>> Regards
>>> Praveen
>>>
>>>
>>> On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:

 As I can see, you got the XML and outputed it to the view.
 I dont see what you want more. Tell us.

 2012/3/6 Praveen Bhat :
 > Hello,
 >
 > I have come to the point where the whole XML document is returned, as
 u can
 > see in the attached file.
 >
 > I have used the following code:
 >
 > Controller:
 >
 > def index():
 > import urllib2
 > temp =
 > urllib2.urlopen('
 http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
 ')
 > tempdata = temp.read()
 > parseddata = XML(tempdata).xml()
 > return dict(parseddata = parseddata)
 >
 > View:
 >
 >
 > {{ for parseddata in parseddata: }}
 >
 > {{=XML(parseddata)}}
 >
 > {{pass}}
 >
 > I am missing something here. Could you please help.
 >
 > Regards
 >
 >
 > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
 >>
 >> You can do something like in
 http://web2py.com/books/default/chapter/29/5
 >> :
 >> Parsing
 >>
 >> The TAG object is also an XML/HTML parser. It can read text and
 >> convert into a tree structure of helpers. This allows manipulation
 >> using the API above:
 >> >>> html = 'Titlethis is a test'
 >> >>> parsed_html = TAG(html)
 >> >>> parsed_html.element('span')[0]='TEST'
 >> >>> print parsed_html
 >> Titlethis is a TEST
 >>
 >> 2012/3/5 Praveen Bhat :
 >> > Hello,
 >> >
 >> > I am using http://worldweatheronline.com API to display weather
 info.
 >> > The
 >> > API returns the data in XML format.
 >> >
 >> > How can i render the same in a HTML page in Web2py.
 >> >
 >> > Link for accessing the API Data:
 >> >
 >> > Weather API
 >> >
 >> > I have done the same in PHP as following:
 >> >
 >> > >>> >> > $xml =
 >> >
 >> > simplexml_load_file('
 http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
 );
 >> > $current = $xml->xpath("/data/current_condition");
 >> > ?>
 >> >
 >> > 
 >> > Weather :
 >> > temp_C ?>° C,
 >> > weatherDesc ?>
 >> > 
 >> >
 >> > How can I do the same in web2py?
 >> >
 >> >
 >> > Regards,
 >> > Praveen
 >> >
 >>
 >> --
 >> Carlos J. Costa
 >> Cientista da Computação
 >> Esp. Gestão em Telecom
 >>
 >> EL MELECH NEEMAN!
 >> אָמֵן

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

 EL MELECH NEEMAN!
 אָמֵן

>>>
>>
>>
>> --
>>
>> Bruno Rocha
>> [http://rochacbruno.com.br]
>>
>>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] iframe and pdf

2012-03-09 Thread Martin Weissenboeck
I have a function person2pdf, which creates a pdf-sheet. I want to show
this sheet in an iframe (or an object) inside a webpage. The following code
works well, but I wonder how to do the same without function k1?


def k1():
return person2pdf(session.ids)

def k():
return dict(ifr=IFRAME(_src=URL('default','k1')))

Regards, Martin


Re: [web2py] How to use XML data

2012-03-09 Thread Praveen Bhat
Hello,

I am getting the following error:

' 'str' object has no attribute 'elements'

I have the following code in controller:

def index():
import urllib2
temp = 
urllib2.urlopen('http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711')
tempdata = temp.read()
parseddata = XML(tempdata).xml() 
return dict(parseddata = parseddata)

the following code in view:

{{extend 'layout.html'}}

{{ for parseddata in parseddata: }}

{{=XML(parseddata.element("temp_C"))}}
{{pass}}

Regards
Praveen



On Saturday, March 10, 2012 12:28:18 PM UTC+5:30, rochacbruno wrote:
>
> I guess it will work.
>
> {{ for parseddata in parseddata: }}
>
> {{=XML(parseddata.elements("temp_C"))}}
>
> {{pass}}
>
> On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat wrote:
>
>> Hello,
>>
>> I apologize as I could not reply...
>>
>> Yes I was able to get the parsed output but I want to display only the  
>> data between < t e m p _ C >  < / t e m p _ C > in the outputted XML and 
>> not the whole XMl document
>>
>>
>> Regards
>> Praveen
>>
>>
>> On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>>>
>>> As I can see, you got the XML and outputed it to the view.
>>> I dont see what you want more. Tell us.
>>>
>>> 2012/3/6 Praveen Bhat :
>>> > Hello,
>>> >
>>> > I have come to the point where the whole XML document is returned, as 
>>> u can
>>> > see in the attached file.
>>> >
>>> > I have used the following code:
>>> >
>>> > Controller:
>>> >
>>> > def index():
>>> > import urllib2
>>> > temp =
>>> > urllib2.urlopen('
>>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>>> ')
>>> > tempdata = temp.read()
>>> > parseddata = XML(tempdata).xml()
>>> > return dict(parseddata = parseddata)
>>> >
>>> > View:
>>> >
>>> >
>>> > {{ for parseddata in parseddata: }}
>>> >
>>> > {{=XML(parseddata)}}
>>> >
>>> > {{pass}}
>>> >
>>> > I am missing something here. Could you please help.
>>> >
>>> > Regards
>>> >
>>> >
>>> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
>>> >>
>>> >> You can do something like in 
>>> http://web2py.com/books/default/chapter/29/5
>>> >> :
>>> >> Parsing
>>> >>
>>> >> The TAG object is also an XML/HTML parser. It can read text and
>>> >> convert into a tree structure of helpers. This allows manipulation
>>> >> using the API above:
>>> >> >>> html = 'Titlethis is a test'
>>> >> >>> parsed_html = TAG(html)
>>> >> >>> parsed_html.element('span')[0]='TEST'
>>> >> >>> print parsed_html
>>> >> Titlethis is a TEST
>>> >>
>>> >> 2012/3/5 Praveen Bhat :
>>> >> > Hello,
>>> >> >
>>> >> > I am using http://worldweatheronline.com API to display weather 
>>> info.
>>> >> > The
>>> >> > API returns the data in XML format.
>>> >> >
>>> >> > How can i render the same in a HTML page in Web2py.
>>> >> >
>>> >> > Link for accessing the API Data:
>>> >> >
>>> >> > Weather API
>>> >> >
>>> >> > I have done the same in PHP as following:
>>> >> >
>>> >> > >> >> > $xml =
>>> >> >
>>> >> > simplexml_load_file('
>>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
>>> );
>>> >> > $current = $xml->xpath("/data/current_condition");
>>> >> > ?>
>>> >> >
>>> >> > 
>>> >> > Weather :
>>> >> > temp_C ?>° C,
>>> >> > weatherDesc ?>
>>> >> > 
>>> >> >
>>> >> > How can I do the same in web2py?
>>> >> >
>>> >> >
>>> >> > Regards,
>>> >> > Praveen
>>> >> >
>>> >>
>>> >> --
>>> >> Carlos J. Costa
>>> >> Cientista da Computação
>>> >> Esp. Gestão em Telecom
>>> >>
>>> >> EL MELECH NEEMAN!
>>> >> אָמֵן
>>>
>>> -- 
>>> Carlos J. Costa
>>> Cientista da Computação
>>> Esp. Gestão em Telecom
>>>
>>> EL MELECH NEEMAN!
>>> אָמֵן
>>>
>>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

Re: [web2py] How to use XML data

2012-03-09 Thread Bruno Rocha
I guess it will work.

{{ for parseddata in parseddata: }}

{{=XML(parseddata.elements("temp_C"))}}

{{pass}}

On Sat, Mar 10, 2012 at 3:51 AM, Praveen Bhat wrote:

> Hello,
>
> I apologize as I could not reply...
>
> Yes I was able to get the parsed output but I want to display only the
> data between < t e m p _ C >  < / t e m p _ C > in the outputted XML and
> not the whole XMl document
>
>
> Regards
> Praveen
>
>
> On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>>
>> As I can see, you got the XML and outputed it to the view.
>> I dont see what you want more. Tell us.
>>
>> 2012/3/6 Praveen Bhat :
>> > Hello,
>> >
>> > I have come to the point where the whole XML document is returned, as u
>> can
>> > see in the attached file.
>> >
>> > I have used the following code:
>> >
>> > Controller:
>> >
>> > def index():
>> > import urllib2
>> > temp =
>> > urllib2.urlopen('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
>> ')
>> > tempdata = temp.read()
>> > parseddata = XML(tempdata).xml()
>> > return dict(parseddata = parseddata)
>> >
>> > View:
>> >
>> >
>> > {{ for parseddata in parseddata: }}
>> >
>> > {{=XML(parseddata)}}
>> >
>> > {{pass}}
>> >
>> > I am missing something here. Could you please help.
>> >
>> > Regards
>> >
>> >
>> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
>> >>
>> >> You can do something like in
>> http://web2py.com/books/default/chapter/29/5
>> >> :
>> >> Parsing
>> >>
>> >> The TAG object is also an XML/HTML parser. It can read text and
>> >> convert into a tree structure of helpers. This allows manipulation
>> >> using the API above:
>> >> >>> html = 'Titlethis is a test'
>> >> >>> parsed_html = TAG(html)
>> >> >>> parsed_html.element('span')[0]='TEST'
>> >> >>> print parsed_html
>> >> Titlethis is a TEST
>> >>
>> >> 2012/3/5 Praveen Bhat :
>> >> > Hello,
>> >> >
>> >> > I am using http://worldweatheronline.com API to display weather
>> info.
>> >> > The
>> >> > API returns the data in XML format.
>> >> >
>> >> > How can i render the same in a HTML page in Web2py.
>> >> >
>> >> > Link for accessing the API Data:
>> >> >
>> >> > Weather API
>> >> >
>> >> > I have done the same in PHP as following:
>> >> >
>> >> > > >> > $xml =
>> >> >
>> >> > simplexml_load_file('
>> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
>> );
>> >> > $current = $xml->xpath("/data/current_condition");
>> >> > ?>
>> >> >
>> >> > 
>> >> > Weather :
>> >> > temp_C ?>° C,
>> >> > weatherDesc ?>
>> >> > 
>> >> >
>> >> > How can I do the same in web2py?
>> >> >
>> >> >
>> >> > Regards,
>> >> > Praveen
>> >> >
>> >>
>> >> --
>> >> Carlos J. Costa
>> >> Cientista da Computação
>> >> Esp. Gestão em Telecom
>> >>
>> >> EL MELECH NEEMAN!
>> >> אָמֵן
>>
>> --
>> Carlos J. Costa
>> Cientista da Computação
>> Esp. Gestão em Telecom
>>
>> EL MELECH NEEMAN!
>> אָמֵן
>>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] How to use XML data

2012-03-09 Thread Praveen Bhat
Hello,

I apologize as I could not reply...

Yes I was able to get the parsed output but I want to display only the  
data between < t e m p _ C >  < / t e m p _ C > in the outputted XML and 
not the whole XMl document


Regards
Praveen


On Tuesday, March 6, 2012 4:50:21 PM UTC+5:30, yamandu wrote:
>
> As I can see, you got the XML and outputed it to the view.
> I dont see what you want more. Tell us.
>
> 2012/3/6 Praveen Bhat :
> > Hello,
> >
> > I have come to the point where the whole XML document is returned, as u 
> can
> > see in the attached file.
> >
> > I have used the following code:
> >
> > Controller:
> >
> > def index():
> > import urllib2
> > temp =
> > urllib2.urlopen('
> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
> ')
> > tempdata = temp.read()
> > parseddata = XML(tempdata).xml()
> > return dict(parseddata = parseddata)
> >
> > View:
> >
> >
> > {{ for parseddata in parseddata: }}
> >
> > {{=XML(parseddata)}}
> >
> > {{pass}}
> >
> > I am missing something here. Could you please help.
> >
> > Regards
> >
> >
> > On Monday, March 5, 2012 10:14:46 PM UTC+5:30, yamandu wrote:
> >>
> >> You can do something like in 
> http://web2py.com/books/default/chapter/29/5
> >> :
> >> Parsing
> >>
> >> The TAG object is also an XML/HTML parser. It can read text and
> >> convert into a tree structure of helpers. This allows manipulation
> >> using the API above:
> >> >>> html = 'Titlethis is a test'
> >> >>> parsed_html = TAG(html)
> >> >>> parsed_html.element('span')[0]='TEST'
> >> >>> print parsed_html
> >> Titlethis is a TEST
> >>
> >> 2012/3/5 Praveen Bhat :
> >> > Hello,
> >> >
> >> > I am using http://worldweatheronline.com API to display weather info.
> >> > The
> >> > API returns the data in XML format.
> >> >
> >> > How can i render the same in a HTML page in Web2py.
> >> >
> >> > Link for accessing the API Data:
> >> >
> >> > Weather API
> >> >
> >> > I have done the same in PHP as following:
> >> >
> >> >  >> > $xml =
> >> >
> >> > simplexml_load_file('
> http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=5&key=b019cd7d6a135850110711'
> );
> >> > $current = $xml->xpath("/data/current_condition");
> >> > ?>
> >> >
> >> > 
> >> > Weather :
> >> > temp_C ?>° C,
> >> > weatherDesc ?>
> >> > 
> >> >
> >> > How can I do the same in web2py?
> >> >
> >> >
> >> > Regards,
> >> > Praveen
> >> >
> >>
> >> --
> >> Carlos J. Costa
> >> Cientista da Computação
> >> Esp. Gestão em Telecom
> >>
> >> EL MELECH NEEMAN!
> >> אָמֵן
>
> -- 
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>


[web2py] Re: get the dynamically value from the list and send the mail by using the cron job

2012-03-09 Thread Ramkrishan Bhatt
Dont use for loop and in select(
> i am able to send the mail through the cron job but when i am going to 
> send the mail by fetching the email id from the database i got confused in 
> the logic :-
>
> i have the followng code :
>
> list = []
> import datetime
> currentdate = datetime.datetime.now()
> for row in db(db.employee.time == currentdate).select():
> list.append(row.empdetail)
> here is my send mail function it is sending only the last id i know the 
> for loop scope is ended that is the reason its happening but i am not be 
> able to get the proper solution to send the mail to the each of the id only 
> once with the all details when the date will be matched in the same table 
> more than one emp details are there so i want to send the mail to the 
> each individual employee at a time.
>
>

Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruno Rocha
I have a working website using two apps, hosted at different servers but
using the same database/session. I will take it to remember the
implementation in details and write a recipe in web2pyslices.

On Fri, Mar 9, 2012 at 11:00 PM, Bruce Wade  wrote:

> How about you provide an example, considering you sound like the expert at
> it :D
>
>
> On Fri, Mar 9, 2012 at 5:53 PM, Bruno Rocha  wrote:
>
>> **important: to share the same user/session information, you have to
>> share the same auth.hmac_key
>>
>>
>> --
>>
>> Bruno Rocha
>> [http://rochacbruno.com.br]
>>
>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] web2py site and disabling browser right clicks

2012-03-09 Thread Anthony
On Friday, March 9, 2012 7:14:14 PM UTC-5, rochacbruno wrote:
>
> Use flash/flex or MS Silverlight, you will have this by default :)
>

Though even those can be decompiled. 


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Anthony
One thing to be aware of when storing sessions in the db rather than the 
filesystem is that the session is not locked during a request, so if the 
same user makes multiple requests that affect the session at the same time 
(e.g., multiple browser windows open or several Ajax requests from the same 
page), you could get a race condition. Probably not an issue in most cases, 
but something to be aware of.

Anthony

On Friday, March 9, 2012 7:12:40 PM UTC-5, rochacbruno wrote:
>
> IMHO. CAS is very complicated do deal with.. It is too much easy to use 
> the same session-db for users. CAS would be a good idea when the 
> applications are of different technologies. I implemented a web2py app 
> which serves a CAS to web2py <--> C#/asp application using CAS protocol.
>
> But to use onky within web2py apps it is very better to simply share the 
> sessions and data.
>
> On Fri, Mar 9, 2012 at 8:54 PM, Anthony  wrote:
>
>> On Friday, March 9, 2012 6:43:33 PM UTC-5, pbreit wrote:
>>>
>>> Might not be a bad idea to have some code available that does sort of a 
>>> "single-signon" between apps. I doubt I'll get around to it but we'll see.
>>
>>
>> The built-in CAS mechanism does that, no?
>>
>>
>> http://web2py.com/books/default/chapter/29/9#Central-Authentication-Service
>>  
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

Re: [web2py] Re: Authenticate a user against Twitter and them create a user in web2py's db?

2012-03-09 Thread Bruno Rocha
here is the best example we had:
https://code.google.com/r/michelecomitini-facebookaccess/source/browse/#hg/applications/helloTwitter

YEs you can use only the username.

On Fri, Mar 9, 2012 at 11:23 PM, Stodge  wrote:

> Could you not use the Twitter username instead? Or does web2py only
> accept email addresses? Sorry new to web2py.
>
> On Mar 9, 9:20 pm, Bruno Rocha  wrote:
> > the only problem with twitter is that it does not inform user's email
> > address.
> >
> > On Fri, Mar 9, 2012 at 11:07 PM, Stodge  wrote:
> > > I have the simple authentication example working from
> > >http://dougwarren.org/2010/06/oauth-and-web2py-part-1/. Actually I
> > > think it's more like authorisation as it gives you access to Twitter
> > > data as well as authenticating the user. Anyway. Are there any
> > > tutorials for taking this a step further and creating users in the
> > > web2py database when a user authenticates against Twitter? Ideally,
> > > I'd like to try to store some Twitter user data in the db as well.
> > > Thanks
> >
> > --
> >
> > Bruno Rocha
> > [http://rochacbruno.com.br]
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: Authenticate a user against Twitter and them create a user in web2py's db?

2012-03-09 Thread Stodge
Could you not use the Twitter username instead? Or does web2py only
accept email addresses? Sorry new to web2py.

On Mar 9, 9:20 pm, Bruno Rocha  wrote:
> the only problem with twitter is that it does not inform user's email
> address.
>
> On Fri, Mar 9, 2012 at 11:07 PM, Stodge  wrote:
> > I have the simple authentication example working from
> >http://dougwarren.org/2010/06/oauth-and-web2py-part-1/. Actually I
> > think it's more like authorisation as it gives you access to Twitter
> > data as well as authenticating the user. Anyway. Are there any
> > tutorials for taking this a step further and creating users in the
> > web2py database when a user authenticates against Twitter? Ideally,
> > I'd like to try to store some Twitter user data in the db as well.
> > Thanks
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


Re: [web2py] Authenticate a user against Twitter and them create a user in web2py's db?

2012-03-09 Thread Bruno Rocha
the only problem with twitter is that it does not inform user's email
address.

On Fri, Mar 9, 2012 at 11:07 PM, Stodge  wrote:

> I have the simple authentication example working from
> http://dougwarren.org/2010/06/oauth-and-web2py-part-1/. Actually I
> think it's more like authorisation as it gives you access to Twitter
> data as well as authenticating the user. Anyway. Are there any
> tutorials for taking this a step further and creating users in the
> web2py database when a user authenticates against Twitter? Ideally,
> I'd like to try to store some Twitter user data in the db as well.
> Thanks




-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Authenticate a user against Twitter and them create a user in web2py's db?

2012-03-09 Thread Stodge
I have the simple authentication example working from
http://dougwarren.org/2010/06/oauth-and-web2py-part-1/. Actually I
think it's more like authorisation as it gives you access to Twitter
data as well as authenticating the user. Anyway. Are there any
tutorials for taking this a step further and creating users in the
web2py database when a user authenticates against Twitter? Ideally,
I'd like to try to store some Twitter user data in the db as well.
Thanks


[web2py]

2012-03-09 Thread Bruce Wade
Why does:
_action="/members/securityunlock?_next=%s%s" % (request.env.http_host,
request.env.web2py_original_uri)

Redirect to:
http://127.0.0.1:8000/127.0.0.1:8000/zh/adviewer/create_ad/?_signature=8265d7b603cbe44013fe22ceeb3000b706064348

Where as:
_action="/members/securityunlock?_next=%s" %
(request.env.web2py_original_uri)

Redirects to:
http://zh/adviewer/create_ad/?_signature=8265d7b603cbe44013fe22ceeb3000b706064348

That really doesn't make any since at all.
-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruce Wade
How about you provide an example, considering you sound like the expert at
it :D

On Fri, Mar 9, 2012 at 5:53 PM, Bruno Rocha  wrote:

> **important: to share the same user/session information, you have to share
> the same auth.hmac_key
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruno Rocha
**important: to share the same user/session information, you have to share
the same auth.hmac_key

-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread pbreit
I'm not really familiar with CAS but will check into it.

Re: [web2py] web2py site and disabling browser right clicks

2012-03-09 Thread Bruno Rocha
Use flash/flex or MS Silverlight, you will have this by default :)

On Fri, Mar 9, 2012 at 9:46 AM, Rahul  wrote:

> Hi All,
>  I don't want to allow people to  -
>
>1. Do "view page source" when they are viewing my site and
>2. Save the page of my site
>3. It would even be good if I was able to remove/disable the default
>right click across browsers when the users are viewing my web site
>
> What is the best way to achieve this in web2py?
>
> Any suggestions would be greatly appreciated.
>
> Thanks, Rahul (www.flockbird.com)
>
>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruno Rocha
IMHO. CAS is very complicated do deal with.. It is too much easy to use the
same session-db for users. CAS would be a good idea when the applications
are of different technologies. I implemented a web2py app which serves a
CAS to web2py <--> C#/asp application using CAS protocol.

But to use onky within web2py apps it is very better to simply share the
sessions and data.

On Fri, Mar 9, 2012 at 8:54 PM, Anthony  wrote:

> On Friday, March 9, 2012 6:43:33 PM UTC-5, pbreit wrote:
>>
>> Might not be a bad idea to have some code available that does sort of a
>> "single-signon" between apps. I doubt I'll get around to it but we'll see.
>
>
> The built-in CAS mechanism does that, no?
>
> http://web2py.com/books/default/chapter/29/9#Central-Authentication-Service
>
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruce Wade
Okay think I got it working.

On Fri, Mar 9, 2012 at 4:01 PM, Bruce Wade  wrote:

> From a fresh install I created an application signon used the methods for
> sharing sessions but getting this error now when I go to the welcome app.
>
> Traceback (most recent call last):
>
>   File "/home/bruce/Development/web2py/gluon/main.py", line 510, in wsgibase
>
> session._try_store_in_db(request, response)
>
>   File "/home/bruce/Development/web2py/gluon/globals.py", line 561, in 
> _try_store_in_db
>
> record_id = table.insert(**dd)
>
>   File "/home/bruce/Development/web2py/gluon/dal.py", line 6829, in insert
>
> return self._db._adapter.insert(self,self._listify(fields))
>
>   File "/home/bruce/Development/web2py/gluon/dal.py", line 928, in insert
>
> raise e
>
> ProgrammingError: relation "web2py_session_signon" does not exist
>
> LINE 1: INSERT INTO web2py_session_signon(client_ip,session_data,loc...
>
> *I just need a very simple example of the following:*
>
> *1) One app that will be used to handle logins, permissions, sessions*
>
> *2) Another app that uses the first app to signin, and can use the 
> auth.requires_. based on the members groups that are in the first apps 
> database etc...*
>
> *If someone can give me that little bit of an example I can work from it.*
>
>
> On Fri, Mar 9, 2012 at 3:54 PM, Anthony  wrote:
>
>> On Friday, March 9, 2012 6:43:33 PM UTC-5, pbreit wrote:
>>>
>>> Might not be a bad idea to have some code available that does sort of a
>>> "single-signon" between apps. I doubt I'll get around to it but we'll see.
>>
>>
>> The built-in CAS mechanism does that, no?
>>
>>
>> http://web2py.com/books/default/chapter/29/9#Central-Authentication-Service
>>
>>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruce Wade
>From a fresh install I created an application signon used the methods for
sharing sessions but getting this error now when I go to the welcome app.

Traceback (most recent call last):
  File "/home/bruce/Development/web2py/gluon/main.py", line 510, in wsgibase
session._try_store_in_db(request, response)
  File "/home/bruce/Development/web2py/gluon/globals.py", line 561, in
_try_store_in_db
record_id = table.insert(**dd)
  File "/home/bruce/Development/web2py/gluon/dal.py", line 6829, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/home/bruce/Development/web2py/gluon/dal.py", line 928, in insert
raise e
ProgrammingError: relation "web2py_session_signon" does not exist
LINE 1: INSERT INTO web2py_session_signon(client_ip,session_data,loc...

*I just need a very simple example of the following:*

*1) One app that will be used to handle logins, permissions, sessions*

*2) Another app that uses the first app to signin, and can use the
auth.requires_. based on the members groups that are in the first
apps database etc...*

*If someone can give me that little bit of an example I can work from it.*


On Fri, Mar 9, 2012 at 3:54 PM, Anthony  wrote:

> On Friday, March 9, 2012 6:43:33 PM UTC-5, pbreit wrote:
>>
>> Might not be a bad idea to have some code available that does sort of a
>> "single-signon" between apps. I doubt I'll get around to it but we'll see.
>
>
> The built-in CAS mechanism does that, no?
>
> http://web2py.com/books/default/chapter/29/9#Central-Authentication-Service
>
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Anthony
On Friday, March 9, 2012 6:43:33 PM UTC-5, pbreit wrote:
>
> Might not be a bad idea to have some code available that does sort of a 
> "single-signon" between apps. I doubt I'll get around to it but we'll see.


The built-in CAS mechanism does that, no?

http://web2py.com/books/default/chapter/29/9#Central-Authentication-Service
 


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread pbreit
Might not be a bad idea to have some code available that does sort of a 
"single-signon" between apps. I doubt I'll get around to it but we'll see.

Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruce Wade
Is there an actual working example of how to create a single user/session
database for all apps?

http://web2py.com/book/default/chapter/04#Cooperation doesn't really
provide much details on actually doing this.

On Fri, Mar 9, 2012 at 3:13 PM, Bruno Rocha  wrote:

> The first important thing when you want to create a multi-app site is to
> share the same session/auth and maybe share the same database, at least the
> same users database.
>
> with web2py you can easily use the same database to store users, and also
> you can store sessions on that database too, it is the first pass to keep
> state between applications.
>
> Another option is using CAS to centralize the users (but I personally like
> to use the "one-db-session" approach)
>
> Having users and its state on all applications now you have to decide if
> you will connect the apps using ajax, urls or API's, for the 3 cases web2py
> has a solution.
>
> {{=LOAD(URL("otherapp", "controller", "function"), null, 'target') for use
> ajax coponents
>
> URL("otherapp", "controller", "function") to simply link the apps
>
> See RESTFUL and webservices on the book for the API's approach.
>
> There is one more important thing you can do: Put your apps general
> functions, classes and table definitions in modules, put the modules in
> "web2py/site-packages" so in any application you can do "import something".
>
> Besides the initial work on setting up the same db and sessions for the
> users, I see that it is very simple to have a multi-app website.
>
>
> On Fri, Mar 9, 2012 at 7:54 PM, bussiere adrien wrote:
>
>> this doc is outdated is there anything news for making a website with
>> more than one app ?
>>
>> regards
>> Bussiere
>>
>> Le lundi 15 mars 2010 16:19:23 UTC+1, mdipierro a écrit :
>>>
>>> For now look at the following links that may help you:
>>>
>>> For an example of {{=LOAD(...)}}
>>>
>>>http://gluonframework.**wordpress.com/2010/03/07/**
>>> web2py-ajax-and-forms/
>>>
>>> You can load an action from the same app or other apps.
>>>
>>> For ways an app can share data with another app:
>>>
>>>   
>>> http://www.web2py.com/book/**default/section/4/19
>>>   
>>> http://www.web2py.com/book/**default/section/4/20
>>>
>>> Hope this helps.
>>>
>>> Massimo
>>>
>>> On Mar 12, 7:26 am, Rahul  wrote:
>>> > Hi All, Massimo,
>>> >I've been designing a  web app using web2py. Web2py is
>>> > really a
>>> > very well designed framework. I am considering it along with
>>> > Django for a
>>> > medium sized web app development. How ever I would like to know,
>>> > if I can
>>> > code more applications for a single complex site (as we can do in
>>> > Django)
>>> > and link it to one single application.I am not using CAS as I have
>>> > created
>>> > my own authentication system. Here's an example to make it clear
>>> > of what I
>>> > want-
>>> >  *my site*
>>> > |__ site pages along with main page
>>> > |__ link to app1 ( a blog that is a separate web2py app)
>>> > |__ link to a app2 (chat client)  ( again a separate
>>> > web2py app)
>>> > |__ link to my database triggered app3 (again a separate
>>> > web2py
>>> > app)
>>> >
>>> > In short how do I modularise my web2py project to combine
>>> > different
>>> > applications into my original site web2py project. From the web
>>> > I've seen a
>>> > post from Yarko that mentions this
>>> >
>>> > {{=LOAD(...,application='
>>> > otherapp')}}
>>> >
>>> > but technically I could not find any documentation either in your
>>> > online
>>> > book or site. Can you please provide methods of how this is
>>> > achievable
>>> > without sacrificing simplicity. I have also heard about plugins
>>> > but not
>>> > really sure what they are and should I be really using those.
>>> >
>>> > Please suggest.
>>> >
>>> > Sincerely, Rahul D
>>> > (India)
>>>
>>>
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: web2py site and disabling browser right clicks

2012-03-09 Thread Chris May
I'm sorry, Rahul. I may have misunderstood the reason behind your post, as I 
have heard similar requests in my time as a front-end developer. 

However, seeing that the site in your signature does potentially show sensitive 
information, the best thing I can recommend is to not send any more sensitive 
information to the browser than what is absolutely needed. Make sure you have 
good security on the pages this information is on. 

I don't know if that helps, but I only thought of it as I was walkin to my car. 


[web2py] Re: web2py site and disabling browser right clicks

2012-03-09 Thread Chris May
I agree with Wikus. Just by having a web site out in the public means just 
that. Don't publish anything that you wouldn't want printed in newspapers 
or announced to your grandmother. :) 

You may be different, but every one who has asked me to prevent users to 
view source code did not care about user experience, and were trying to 
hide things that were not at all important to the end user or to their 
company. In each case, the result ended up turning users away from their 
sites because they were so heavily restricted from achieving their goals.

Not to mention, the most talented web developers openly share their ideas 
and code to make the industry better... like this group. if you're trying 
to hide, the Internet isn't a great place to be.


Re: [web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread Bruno Rocha
The first important thing when you want to create a multi-app site is to
share the same session/auth and maybe share the same database, at least the
same users database.

with web2py you can easily use the same database to store users, and also
you can store sessions on that database too, it is the first pass to keep
state between applications.

Another option is using CAS to centralize the users (but I personally like
to use the "one-db-session" approach)

Having users and its state on all applications now you have to decide if
you will connect the apps using ajax, urls or API's, for the 3 cases web2py
has a solution.

{{=LOAD(URL("otherapp", "controller", "function"), null, 'target') for use
ajax coponents

URL("otherapp", "controller", "function") to simply link the apps

See RESTFUL and webservices on the book for the API's approach.

There is one more important thing you can do: Put your apps general
functions, classes and table definitions in modules, put the modules in
"web2py/site-packages" so in any application you can do "import something".

Besides the initial work on setting up the same db and sessions for the
users, I see that it is very simple to have a multi-app website.

On Fri, Mar 9, 2012 at 7:54 PM, bussiere adrien  wrote:

> this doc is outdated is there anything news for making a website with more
> than one app ?
>
> regards
> Bussiere
>
> Le lundi 15 mars 2010 16:19:23 UTC+1, mdipierro a écrit :
>>
>> For now look at the following links that may help you:
>>
>> For an example of {{=LOAD(...)}}
>>
>>http://gluonframework.**wordpress.com/2010/03/07/**
>> web2py-ajax-and-forms/
>>
>> You can load an action from the same app or other apps.
>>
>> For ways an app can share data with another app:
>>
>>   
>> http://www.web2py.com/book/**default/section/4/19
>>   
>> http://www.web2py.com/book/**default/section/4/20
>>
>> Hope this helps.
>>
>> Massimo
>>
>> On Mar 12, 7:26 am, Rahul  wrote:
>> > Hi All, Massimo,
>> >I've been designing a  web app using web2py. Web2py is
>> > really a
>> > very well designed framework. I am considering it along with
>> > Django for a
>> > medium sized web app development. How ever I would like to know,
>> > if I can
>> > code more applications for a single complex site (as we can do in
>> > Django)
>> > and link it to one single application.I am not using CAS as I have
>> > created
>> > my own authentication system. Here's an example to make it clear
>> > of what I
>> > want-
>> >  *my site*
>> > |__ site pages along with main page
>> > |__ link to app1 ( a blog that is a separate web2py app)
>> > |__ link to a app2 (chat client)  ( again a separate
>> > web2py app)
>> > |__ link to my database triggered app3 (again a separate
>> > web2py
>> > app)
>> >
>> > In short how do I modularise my web2py project to combine
>> > different
>> > applications into my original site web2py project. From the web
>> > I've seen a
>> > post from Yarko that mentions this
>> >
>> > {{=LOAD(...,application='
>> > otherapp')}}
>> >
>> > but technically I could not find any documentation either in your
>> > online
>> > book or site. Can you please provide methods of how this is
>> > achievable
>> > without sacrificing simplicity. I have also heard about plugins
>> > but not
>> > really sure what they are and should I be really using those.
>> >
>> > Please suggest.
>> >
>> > Sincerely, Rahul D
>> > (India)
>>
>>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Database trigger like django save ?

2012-03-09 Thread bussiere adrien
Thanks i will look forward to it.


regards
Bussiere

Le vendredi 9 mars 2012 23:48:30 UTC+1, rochacbruno a écrit :
>
> in web2py's DAL there is no "save" you have only two ways to store/update 
> data and it is by using a dbset method such as .update or .insert and using 
> a update_record functions that is stored in every Row object.
>
> To do what Django does we need to have some "hooks' for that 3 events 
> (dbset.insert, dbsert.update and Row.update_record)
>
> I can see that if you extend DAL it is possible to redefine via monkey 
> patching the .insert method.
>
> But it will be very better if DAL can handle this out of the box.
>
> A suggestions is adding an "callback" in .insert method
>
> def myfunction(id):
> .
>
> db(db...).insert(**., _callback=myfunction)
>
> But I dont know if it is possible...
>
> On Fri, Mar 9, 2012 at 7:34 PM, bussiere adrien wrote:
>
>> Is there a way to do that in web2py :
>> i've found only this :
>> http://russcomp.wordpress.com/2011/10/12/web2py-re-db-events-trigger/ 
>>
>> To perform action on a save ?
>>
>> class Acteur(models.Model):
>> Pseudo = models.CharField(max_length=200,null=True,blank=True)
>> Tag = models.ManyToManyField('tags.Tag',null=True,blank=True)
>> FamilleTag = 
>> models.ManyToManyField('tags.FamilleTag',null=True,blank=True)
>> Description_courte = 
>> models.CharField(max_length=200,null=True,blank=True)
>> Description = models.CharField(max_length=400,null=True,blank=True)
>> Texte_contenu = 
>> models.ManyToManyField('presentation.Texte_contenu',null=True,blank=True)
>> Lien = models.ForeignKey('liens.Lien',null=True,blank=True)
>> Note_divers = 
>> models.ManyToManyField('notes.Note_divers',null=True,blank=True)
>> Image_Acteur = 
>> models.ManyToManyField(ImageActeur,null=True,blank=True)
>> def ___str__(self):
>> return self.Pseudo
>> def __unicode__(self):
>> return self.Pseudo
>> def save(self, *args, **kwargs):
>> super(Acteur, self).save(*args, **kwargs) # Call the "real" 
>> save() method.
>> page = deepcopy(Page.objects.get(Nom="Acteur_Modele"))
>> #page.pk = None
>> page.Nom = self.Pseudo
>> page.Acteurs = [self]
>> page.ImageActeur = self.Image_Acteur
>> page.save()
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

[web2py] Re: How to call other web2py applications from within a web2py application

2012-03-09 Thread bussiere adrien
this doc is outdated is there anything news for making a website with more 
than one app ?

regards
Bussiere

Le lundi 15 mars 2010 16:19:23 UTC+1, mdipierro a écrit :
>
> For now look at the following links that may help you:
>
> For an example of {{=LOAD(...)}}
>
>http://gluonframework.wordpress.com/2010/03/07/web2py-ajax-and-forms/
>
> You can load an action from the same app or other apps.
>
> For ways an app can share data with another app:
>
>   http://www.web2py.com/book/default/section/4/19
>   http://www.web2py.com/book/default/section/4/20
>
> Hope this helps.
>
> Massimo
>
> On Mar 12, 7:26 am, Rahul  wrote:
> > Hi All, Massimo,
> >I've been designing a  web app using web2py. Web2py is
> > really a
> > very well designed framework. I am considering it along with
> > Django for a
> > medium sized web app development. How ever I would like to know,
> > if I can
> > code more applications for a single complex site (as we can do in
> > Django)
> > and link it to one single application.I am not using CAS as I have
> > created
> > my own authentication system. Here's an example to make it clear
> > of what I
> > want-
> >  *my site*
> > |__ site pages along with main page
> > |__ link to app1 ( a blog that is a separate web2py app)
> > |__ link to a app2 (chat client)  ( again a separate
> > web2py app)
> > |__ link to my database triggered app3 (again a separate
> > web2py
> > app)
> >
> > In short how do I modularise my web2py project to combine
> > different
> > applications into my original site web2py project. From the web
> > I've seen a
> > post from Yarko that mentions this
> >
> > {{=LOAD(...,application='
> > otherapp')}}
> >
> > but technically I could not find any documentation either in your
> > online
> > book or site. Can you please provide methods of how this is
> > achievable
> > without sacrificing simplicity. I have also heard about plugins
> > but not
> > really sure what they are and should I be really using those.
> >
> > Please suggest.
> >
> > Sincerely, Rahul D
> > (India)
>
>

Re: [web2py] Database trigger like django save ?

2012-03-09 Thread Bruno Rocha
in web2py's DAL there is no "save" you have only two ways to store/update
data and it is by using a dbset method such as .update or .insert and using
a update_record functions that is stored in every Row object.

To do what Django does we need to have some "hooks' for that 3 events
(dbset.insert, dbsert.update and Row.update_record)

I can see that if you extend DAL it is possible to redefine via monkey
patching the .insert method.

But it will be very better if DAL can handle this out of the box.

A suggestions is adding an "callback" in .insert method

def myfunction(id):
.

db(db...).insert(**., _callback=myfunction)

But I dont know if it is possible...

On Fri, Mar 9, 2012 at 7:34 PM, bussiere adrien  wrote:

> Is there a way to do that in web2py :
> i've found only this :
> http://russcomp.wordpress.com/2011/10/12/web2py-re-db-events-trigger/
>
> To perform action on a save ?
>
> class Acteur(models.Model):
> Pseudo = models.CharField(max_length=200,null=True,blank=True)
> Tag = models.ManyToManyField('tags.Tag',null=True,blank=True)
> FamilleTag =
> models.ManyToManyField('tags.FamilleTag',null=True,blank=True)
> Description_courte =
> models.CharField(max_length=200,null=True,blank=True)
> Description = models.CharField(max_length=400,null=True,blank=True)
> Texte_contenu =
> models.ManyToManyField('presentation.Texte_contenu',null=True,blank=True)
> Lien = models.ForeignKey('liens.Lien',null=True,blank=True)
> Note_divers =
> models.ManyToManyField('notes.Note_divers',null=True,blank=True)
> Image_Acteur = models.ManyToManyField(ImageActeur,null=True,blank=True)
> def ___str__(self):
> return self.Pseudo
> def __unicode__(self):
> return self.Pseudo
> def save(self, *args, **kwargs):
> super(Acteur, self).save(*args, **kwargs) # Call the "real" save()
> method.
> page = deepcopy(Page.objects.get(Nom="Acteur_Modele"))
> #page.pk = None
> page.Nom = self.Pseudo
> page.Acteurs = [self]
> page.ImageActeur = self.Image_Acteur
> page.save()
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Database trigger like django save ?

2012-03-09 Thread bussiere adrien
Is there a way to do that in web2py :
i've found only this :
http://russcomp.wordpress.com/2011/10/12/web2py-re-db-events-trigger/ 

To perform action on a save ?

class Acteur(models.Model):
Pseudo = models.CharField(max_length=200,null=True,blank=True)
Tag = models.ManyToManyField('tags.Tag',null=True,blank=True)
FamilleTag = 
models.ManyToManyField('tags.FamilleTag',null=True,blank=True)
Description_courte = 
models.CharField(max_length=200,null=True,blank=True)
Description = models.CharField(max_length=400,null=True,blank=True)
Texte_contenu = 
models.ManyToManyField('presentation.Texte_contenu',null=True,blank=True)
Lien = models.ForeignKey('liens.Lien',null=True,blank=True)
Note_divers = 
models.ManyToManyField('notes.Note_divers',null=True,blank=True)
Image_Acteur = models.ManyToManyField(ImageActeur,null=True,blank=True)
def ___str__(self):
return self.Pseudo
def __unicode__(self):
return self.Pseudo
def save(self, *args, **kwargs):
super(Acteur, self).save(*args, **kwargs) # Call the "real" save() 
method.
page = deepcopy(Page.objects.get(Nom="Acteur_Modele"))
#page.pk = None
page.Nom = self.Pseudo
page.Acteurs = [self]
page.ImageActeur = self.Image_Acteur
page.save()


[web2py] Re: Auth redefinition for all apps

2012-03-09 Thread bussiere adrien
thanks i will do that

Bussiere

Le vendredi 9 mars 2012 23:18:36 UTC+1, pbreit a écrit :
>
> I don't think there's a way to redefine auth for all apps short of 
> modifying Web2py itself (which I would not advise).
>
> I would suggest simply putting your customization into each project where 
> you need it. You could create an auth_user.py model file and just drop it 
> into each app's models directory.
>


[web2py] Re: Auth redefinition for all apps

2012-03-09 Thread pbreit
I don't think there's a way to redefine auth for all apps short of 
modifying Web2py itself (which I would not advise).

I would suggest simply putting your customization into each project where 
you need it. You could create an auth_user.py model file and just drop it 
into each app's models directory.


[web2py] Auth redefinition for all apps

2012-03-09 Thread bussiere adrien
i 've found this :
http://web2py.com/books/default/chapter/29/9#Customizing-Auth 

But how redefine auth db for all apps ?


Regards 
Bussiere


[web2py] Re: looking for tutorial extends user and related to an other app

2012-03-09 Thread bussiere adrien
i've found this :
http://stackoverflow.com/questions/7121146/web2py-custom-user-profile
But i still have problems to find how to make list:related to an ohter app 
or make a global auth extend in db for all app.

Regards
Bussiere


Le jeudi 8 mars 2012 21:47:08 UTC+1, bussiere adrien a écrit :
>
> Hello i'am looking for tutorial to :
>
> Extends user add field to database.
>
> Then :
> an app street
> an app buildint
>
> link building field with street field
>
> And more tutorial
>
> Regards
>
> Bussiere
>


Re: [web2py] Re: DAL speed - an idea

2012-03-09 Thread nick name
On Friday, March 9, 2012 2:18:58 PM UTC-5, viniciusban wrote:
>
> Anthony, I'm not supposed to retrieve tens os thousands records from a
> single query in a web app


It's all a question of what each layer is doing. Let's say you have a 
database with 100,000 records. You need a summary:

select sum(cost) from items where (units*unit_cost - :discount >= cost);

where "discount" is an input you received from the web page. You got one 
line of response, but unless you have an index on (units*unit_cost - cost) 
AND a smart optimizer, your database will do a full scan. 

Now, what if your criterion cannot be expressed in SQL at all? You have to 
do the full scan in the app. It might not even take long. However, you need 
all the records in your app to do that.
 

> I would address this problem to app structure, instead of to DAL.
>
For my app, a < 10 line change in the call to select (entirely in app code, 
though relying on DAL internals), produced x60 speedup. Restructuring the 
app would have been a much bigger and more risky undertaking. The 
suggestion breaks that 10 line change into two 5 line changes, one inside 
DAL, and one outside -- that makes it much more general, and not dependent 
on DAL internals.
 

> Anyway, we can execute raw SQL statements via DAL, right?
>
Yes, that's how my speedup is implemented right now (Issue 
701has all the details)


[web2py] Re: DAL speed - an idea

2012-03-09 Thread nick name

On Friday, March 9, 2012 1:48:06 PM UTC-5, spiffytech wrote:
>
> Before we add special features to the DAL, has anyone profiled the DAL 
> with queries and data similar to nick name's to see if there's any 
> low-hanging fruit we can tackle to speed up the normal select()?


The suggested change is very small (~5 lines), backward compatible, and 
useful for other stuff as well (e.g. saving memory and speeding up 
Rows.as_list()  as long as only one table is involved, which is a very 
common use case).

nick name, can you please provide your table schema so we can test 
> performance on data sets similar to yours?
>

No time now, but I'll try to set up a test case for future evaluations over 
the weekend. 


[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
I'm tryng to do something similar to what i saw at web2py book but i need 
them to be distinct

Book:
http://web2py.com/books/default/chapter/29/6#Grouping-and-counting

 count = db.person.id.count()
 for row in db(db.person.id==db.dog.owner).select(db.person.name, count, 
groupby=db.person.name):
print row.person.name, row[count]



What I'm trying:
count = db.contadores.id_impressora.count()
for row in db((db.contadores.id
>0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
print row.contadores.data, row[count]

In the book its mentioned the distinct argument but I couldn't use it in 
this case
Em sexta-feira, 9 de março de 2012 15h25min36s UTC-3, Massimo Di Pierro 
escreveu:
>
> This API is not defined:
>
> db.contadores._count()
>
> What do expect it to do? You can do:
>
> db(db.contadores).count()
> db(db.contadores)._count()
>
> On Friday, 9 March 2012 11:25:14 UTC-6, Fabiano Faver wrote:
>>
>> Same thing...
>>
>> print db(db.contadores.id>0)._count()   -  it respond a sql (with or 
>> without argument)
>> print db.contadores._count()  - it does not work
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 205, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 614, in 
>>   File "C:\web2py\gluon\globals.py", line 173, in 
>> self._caller = lambda f: f()
>>   File "C:\web2py\gluon\tools.py", line 2575, in f
>> return action(*a, **b)
>>   File "C:\web2py\gluon\tools.py", line 2575, in f
>> return action(*a, **b)
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 529, in timeline_opm
>> count = db.contadores._count()
>>   File "C:\web2py\gluon\dal.py", line 6774, in __getattr__
>> return self[key]
>>   File "C:\web2py\gluon\dal.py", line 6714, in __getitem__
>> return dict.__getitem__(self, str(key))
>> KeyError: '_count'
>>
>>
>> Em sexta-feira, 9 de março de 2012 12h31min01s UTC-3, Fabiano Faver 
>> escreveu:
>>>
>>> I'm using version 1.99.4.
>>> I will test it in 1.99.7 to see if it stop giving this error
>>>
>>> Em sexta-feira, 9 de março de 2012 12h21min22s UTC-3, Niphlod escreveu:

 last version is working ok (1.99.7), what web2py version are you using ?

 if db.contadores is a table, then it definitely has a "_count" method...



 Il giorno venerdì 9 marzo 2012 15:55:42 UTC+1, Fabiano Faver ha scritto:
>
> Niphlod, this is what i got, using distinct argument or not:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 613, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 528, in timeline_opm
> print db.contadores._count(distinct=db.contadores.id_impressora)
>   File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
> return self[key]
>   File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: '_count'
>
>
>
> @Bruno
> While I can`t get all grouped records at once I am query them 
> individually one by one using argument distinct
>
> for dias in range(loop_back):
> d = timedelta(days=dias)
> dias_passado = dia_hoje - d
> header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
> contador_no_dia = db((db.contadores.id
> >0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)
>
> Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:
>>
>> ooops, sorry, the _count method is on the table, not the field
>> try with
>>
>> db.contadores._count(distinct=db.contadores.id_impressora)
>>
>>
>>
>> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha 
>> scritto:
>>>
>>> I have phpmyadmin to test it but I didn`t manage to get the 
>>> generated sql using underline.
>>>
>>> with or without distinct argument it gives 
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>> exec ccode in environment
>>>   Fi

Re: [web2py] Re: DAL speed - an idea

2012-03-09 Thread Anthony

>
> Anthony, I'm not supposed to retrieve tens os thousands records from a
> single query in a web app.


Mostly true, but not 
always: https://groups.google.com/d/msg/web2py/A11z4UdMaIc/882_shAVk4UJ

Of course, if you've got a busy site with lots of queries, it can add up 
even for relatively smaller result sets.
 

> Anyway, we can execute raw SQL statements via DAL, right?
>
Yes, it's possible to create your own manual workarounds -- this would just 
be an added convenience. At least a basic version of this shouldn't be hard 
to implement -- just return the raw db response without any further 
processing.

Anthony



[web2py] YASQ 3: smartgrid and auth.accessible_query

2012-03-09 Thread Martin Weissenboeck
YASQ 3 (yet another smartgrid question):

Hi, I have the tables auth_group, auth_membership and auth_permission and a
smartgrid like

grid = SQLFORM.smartgrid(db.auth_user,
user_signature=False,
linked_tables=['phone'],
fields=[db.auth_user.id, db.auth_user.first_name],
constraints=dict(auth_user=query),
)

I have tried some queries:

   - query = db.auth_user>0 # shows the whole table - ok
   - query=auth.accessible_query('read', db.auth_user, 1)
   # User 1 is a member of group "teacher" and teachers have the permission
   to read some auth_user-records.
   # The grid shows these auth_users, it is ok


Now I want to select all "auth_user"s which are members of group #1. I want
something like

   - query = auth.has_membership(group_id=1)
   - query = auth.has_membership(role='teacher')

I have tried (thanks to Anthony):

   - query =(db.auth_user.id==db.auth_membership.user_id) &
   (db.auth_membership.group_id==1)
   # yes, all members of group 1 are shown, but the link to the phone-table
   (the "phone"-button) does not work

Any ideas?
Regards, Martin


Re: [web2py] Re: DAL speed - an idea

2012-03-09 Thread Vinicius Assef
Anthony, I'm not supposed to retrieve tens os thousands records from a
single query in a web app.

I would address this problem to app structure, instead of to DAL.
Anyway, we can execute raw SQL statements via DAL, right?

--
Vinicius Assef



On Fri, Mar 9, 2012 at 4:12 PM, Anthony  wrote:
> mcm made some initial attempts and indicated about a 25% improvement, with
> the expectation that some further improvement could be made with more
> effort: https://groups.google.com/forum/#!topic/web2py-developers/Tp6HXsSf7lk/discussion.
> However, it sounded like we wouldn't be likely to get enough improvement to
> substantially help with large selects (i.e., tens of thousands of rows) --
> for that case, we probably need something like what nick name is proposing
> (which will actually be easier to implement, anyway).
>
> Anthony
>
>
> On Friday, March 9, 2012 1:48:06 PM UTC-5, spiffytech wrote:
>>
>> Before we add special features to the DAL, has anyone profiled the DAL
>> with queries and data similar to nick name's to see if there's any
>> low-hanging fruit we can tackle to speed up the normal select()?
>>
>> nick name, can you please provide your table schema so we can test
>> performance on data sets similar to yours?
>>
>>
>> On Thursday, February 9, 2012 1:51:47 PM UTC-5, nick name wrote:
>>>
>>> One of my controllers need to go through a lot of records to provide a
>>> meaningful answer -- as in, 60k records.
>>>
>>> Just loading them from the database takes about 100ms
>>> (db.executesql("select * from table order by id;")); Doing the same through
>>> DAL takes over 6 seconds. I realize that the DAL does do a lot of additional
>>> work, which in general is helpful -- but I can do without all the parsing /
>>> Rows() generation for this.
>>>
>>> What do people here think about adding a db.rawselect(...), which is a
>>> slim rapper for db.executesql(db._select())  that wraps everything with
>>> a named tuple? It solves most of the speed problem when it is needed, but
>>> still maintains a lot of the features of the SQL DAL processing.
>>>
>
> On Friday, March 9, 2012 1:48:06 PM UTC-5, spiffytech wrote:
>>
>> Before we add special features to the DAL, has anyone profiled the DAL
>> with queries and data similar to nick name's to see if there's any
>> low-hanging fruit we can tackle to speed up the normal select()?
>>
>> nick name, can you please provide your table schema so we can test
>> performance on data sets similar to yours?
>>
>>
>> On Thursday, February 9, 2012 1:51:47 PM UTC-5, nick name wrote:
>>>
>>> One of my controllers need to go through a lot of records to provide a
>>> meaningful answer -- as in, 60k records.
>>>
>>> Just loading them from the database takes about 100ms
>>> (db.executesql("select * from table order by id;")); Doing the same through
>>> DAL takes over 6 seconds. I realize that the DAL does do a lot of additional
>>> work, which in general is helpful -- but I can do without all the parsing /
>>> Rows() generation for this.
>>>
>>> What do people here think about adding a db.rawselect(...), which is a
>>> slim rapper for db.executesql(db._select())  that wraps everything with
>>> a named tuple? It solves most of the speed problem when it is needed, but
>>> still maintains a lot of the features of the SQL DAL processing.
>>>
>


[web2py] Re: DAL speed - an idea

2012-03-09 Thread Anthony
mcm made some initial attempts and indicated about a 25% improvement, with 
the expectation that some further improvement could be made with more 
effort: 
https://groups.google.com/forum/#!topic/web2py-developers/Tp6HXsSf7lk/discussion.
 
However, it sounded like we wouldn't be likely to get enough improvement to 
substantially help with large selects (i.e., tens of thousands of rows) -- 
for that case, we probably need something like what nick name is proposing 
(which will actually be easier to implement, anyway).

Anthony

On Friday, March 9, 2012 1:48:06 PM UTC-5, spiffytech wrote:
>
> Before we add special features to the DAL, has anyone profiled the DAL 
> with queries and data similar to nick name's to see if there's any 
> low-hanging fruit we can tackle to speed up the normal select()?
>
> nick name, can you please provide your table schema so we can test 
> performance on data sets similar to yours?
>
>
> On Thursday, February 9, 2012 1:51:47 PM UTC-5, nick name wrote:
>>
>> One of my controllers need to go through a lot of records to provide a 
>> meaningful answer -- as in, 60k records.
>>
>> Just loading them from the database takes about 100ms 
>> (db.executesql("select * from table order by id;")); Doing the same through 
>> DAL takes over 6 seconds. I realize that the DAL does do a lot of 
>> additional work, which in general is helpful -- but I can do without all 
>> the parsing / Rows() generation for this.
>>
>> What do people here think about adding a db.rawselect(...), which is a 
>> slim rapper for db.executesql(db._select())  that wraps everything with 
>> a named tuple? It solves most of the speed problem when it is needed, but 
>> still maintains a lot of the features of the SQL DAL processing.
>>
>>
On Friday, March 9, 2012 1:48:06 PM UTC-5, spiffytech wrote:
>
> Before we add special features to the DAL, has anyone profiled the DAL 
> with queries and data similar to nick name's to see if there's any 
> low-hanging fruit we can tackle to speed up the normal select()?
>
> nick name, can you please provide your table schema so we can test 
> performance on data sets similar to yours?
>
>
> On Thursday, February 9, 2012 1:51:47 PM UTC-5, nick name wrote:
>>
>> One of my controllers need to go through a lot of records to provide a 
>> meaningful answer -- as in, 60k records.
>>
>> Just loading them from the database takes about 100ms 
>> (db.executesql("select * from table order by id;")); Doing the same through 
>> DAL takes over 6 seconds. I realize that the DAL does do a lot of 
>> additional work, which in general is helpful -- but I can do without all 
>> the parsing / Rows() generation for this.
>>
>> What do people here think about adding a db.rawselect(...), which is a 
>> slim rapper for db.executesql(db._select())  that wraps everything with 
>> a named tuple? It solves most of the speed problem when it is needed, but 
>> still maintains a lot of the features of the SQL DAL processing.
>>
>>

[web2py] Re: DAL speed - an idea

2012-03-09 Thread spiffytech
Before we add special features to the DAL, has anyone profiled the DAL with 
queries and data similar to nick name's to see if there's any low-hanging 
fruit we can tackle to speed up the normal select()?

nick name, can you please provide your table schema so we can test 
performance on data sets similar to yours?


On Thursday, February 9, 2012 1:51:47 PM UTC-5, nick name wrote:
>
> One of my controllers need to go through a lot of records to provide a 
> meaningful answer -- as in, 60k records.
>
> Just loading them from the database takes about 100ms 
> (db.executesql("select * from table order by id;")); Doing the same through 
> DAL takes over 6 seconds. I realize that the DAL does do a lot of 
> additional work, which in general is helpful -- but I can do without all 
> the parsing / Rows() generation for this.
>
> What do people here think about adding a db.rawselect(...), which is a 
> slim rapper for db.executesql(db._select())  that wraps everything with 
> a named tuple? It solves most of the speed problem when it is needed, but 
> still maintains a lot of the features of the SQL DAL processing.
>
>

[web2py] Re: Key Error: auth_user on GAE

2012-03-09 Thread Sushant Taneja
Please ignore the above.
Found the error. I had a conditional model file for the controller which 
was shadowing the global db variable.
Removed it, now everything is working fine.

On Friday, March 9, 2012 9:31:40 PM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> I have extended the default auth_user table in my model file db.py as 
> follows:
>
> db = DAL('google:datastore')
>
> from gluon.tools import Auth
> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>
> auth.settings.extra_fields['auth_user'] = [
> Field('first_name','string',required=True, notnull=True),
> Field('last_name','string',default=''),
> Field('fb_id','string',length=512,required=True),
> Field('create_ts','datetime'),
> Field('change_ts','datetime')
> ]
>
> auth.define_tables()
>
> Also below this code I have also written an insert for inserting data in 
> the auth_user table as:
>
> def new_user(first_name, last_name, email, passw,fb_id):
> users = db(db.auth_user.email==email).select()
> if users:
> return users[0].id
> else:
> my_crypt = CRYPT(key=auth.settings.hmac_key)
> crypt_pass = my_crypt(passw)[0]
> id_user= db.auth_user.insert(
>first_name=first_name,
>last_name=last_name,
>email = email,
>password = crypt_pass,
>fb_id = fb_id
>)
> return id_user
>
> iduser = new_user('ABCD','EFGH','sushant.tanej...@gmail.com
> ','password','8345935345')
>
> This insert I got from some other post in the group. The insert was 
> successful and auth_user table has been created.
> Although no other auth table was created.
>
> Now in my controller function I check if fb_id of a user already exists in 
> my auth_user table or not 
>
> def get_existing_friends():
> """ This function returns a CSV text of FB_IDs of friends which 
> already exists """
>
> user_fb_id = request.vars.userFBID
> if db(db.auth_user.fb_id==user_fb_id).select():
> return "jQuery('.foundFriends').html('This facebook user is 
> already registered');"
>
> On execution nothing happens and GAE logs the following error message:
>
> Traceback (most recent call last):
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/restricted.py", 
> line 204, in restricted
> exec ccode in environment
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
>  
> line 63, in 
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/globals.py", 
> line 172, in 
> self._caller = lambda f: f()
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
>  
> line 19, in get_existing_friends
> if db(db.auth_user.fb_id==user_fb_id).select():
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", line 
> 5119, in __getattr__
> return self[key]
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", line 
> 5113, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: 'auth_user'
>
> Can somebody help me understand the above ?
>
> Thanks,
> Sushant
>


[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Massimo Di Pierro
This API is not defined:

db.contadores._count()

What do expect it to do? You can do:

db(db.contadores).count()
db(db.contadores)._count()

On Friday, 9 March 2012 11:25:14 UTC-6, Fabiano Faver wrote:
>
> Same thing...
>
> print db(db.contadores.id>0)._count()   -  it respond a sql (with or 
> without argument)
> print db.contadores._count()  - it does not work
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 205, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 614, in 
>   File "C:\web2py\gluon\globals.py", line 173, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 2575, in f
> return action(*a, **b)
>   File "C:\web2py\gluon\tools.py", line 2575, in f
> return action(*a, **b)
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 529, in timeline_opm
> count = db.contadores._count()
>   File "C:\web2py\gluon\dal.py", line 6774, in __getattr__
> return self[key]
>   File "C:\web2py\gluon\dal.py", line 6714, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: '_count'
>
>
> Em sexta-feira, 9 de março de 2012 12h31min01s UTC-3, Fabiano Faver 
> escreveu:
>>
>> I'm using version 1.99.4.
>> I will test it in 1.99.7 to see if it stop giving this error
>>
>> Em sexta-feira, 9 de março de 2012 12h21min22s UTC-3, Niphlod escreveu:
>>>
>>> last version is working ok (1.99.7), what web2py version are you using ?
>>>
>>> if db.contadores is a table, then it definitely has a "_count" method...
>>>
>>>
>>>
>>> Il giorno venerdì 9 marzo 2012 15:55:42 UTC+1, Fabiano Faver ha scritto:

 Niphlod, this is what i got, using distinct argument or not:

 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 204, in restricted
 exec ccode in environment
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 613, in 
   File "C:\web2py\gluon\globals.py", line 172, in 
 self._caller = lambda f: f()
   File "C:\web2py\gluon\tools.py", line 2533, in f
 return action(*a, **b)
   File "C:\web2py\gluon\tools.py", line 2533, in f
 return action(*a, **b)
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 528, in timeline_opm
 print db.contadores._count(distinct=db.contadores.id_impressora)
   File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
 return self[key]
   File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
 return dict.__getitem__(self, str(key))
 KeyError: '_count'



 @Bruno
 While I can`t get all grouped records at once I am query them 
 individually one by one using argument distinct

 for dias in range(loop_back):
 d = timedelta(days=dias)
 dias_passado = dia_hoje - d
 header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
 contador_no_dia = db((db.contadores.id
 >0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)

 Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:
>
> ooops, sorry, the _count method is on the table, not the field
> try with
>
> db.contadores._count(distinct=db.contadores.id_impressora)
>
>
>
> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha 
> scritto:
>>
>> I have phpmyadmin to test it but I didn`t manage to get the generated 
>> sql using underline.
>>
>> with or without distinct argument it gives 
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , 
>> line 610, in 
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>> self._caller = lambda f: f()
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , 
>> line 529, in timeline_opm
>> print 
>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>> AttributeError: 'Field' object has no attribute '_count'
>>
>>
>> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod 

[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
Same thing...

print db(db.contadores.id>0)._count()   -  it respond a sql (with or 
without argument)
print db.contadores._count()  - it does not work

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 205, in restricted
exec ccode in environment
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
614, in 
  File "C:\web2py\gluon\globals.py", line 173, in 
self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 2575, in f
return action(*a, **b)
  File "C:\web2py\gluon\tools.py", line 2575, in f
return action(*a, **b)
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
529, in timeline_opm
count = db.contadores._count()
  File "C:\web2py\gluon\dal.py", line 6774, in __getattr__
return self[key]
  File "C:\web2py\gluon\dal.py", line 6714, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_count'


Em sexta-feira, 9 de março de 2012 12h31min01s UTC-3, Fabiano Faver 
escreveu:
>
> I'm using version 1.99.4.
> I will test it in 1.99.7 to see if it stop giving this error
>
> Em sexta-feira, 9 de março de 2012 12h21min22s UTC-3, Niphlod escreveu:
>>
>> last version is working ok (1.99.7), what web2py version are you using ?
>>
>> if db.contadores is a table, then it definitely has a "_count" method...
>>
>>
>>
>> Il giorno venerdì 9 marzo 2012 15:55:42 UTC+1, Fabiano Faver ha scritto:
>>>
>>> Niphlod, this is what i got, using distinct argument or not:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>> exec ccode in environment
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 613, in 
>>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>> self._caller = lambda f: f()
>>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>> return action(*a, **b)
>>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>> return action(*a, **b)
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 528, in timeline_opm
>>> print db.contadores._count(distinct=db.contadores.id_impressora)
>>>   File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
>>> return self[key]
>>>   File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
>>> return dict.__getitem__(self, str(key))
>>> KeyError: '_count'
>>>
>>>
>>>
>>> @Bruno
>>> While I can`t get all grouped records at once I am query them 
>>> individually one by one using argument distinct
>>>
>>> for dias in range(loop_back):
>>> d = timedelta(days=dias)
>>> dias_passado = dia_hoje - d
>>> header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
>>> contador_no_dia = db((db.contadores.id
>>> >0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)
>>>
>>> Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:

 ooops, sorry, the _count method is on the table, not the field
 try with

 db.contadores._count(distinct=db.contadores.id_impressora)



 Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:
>
> I have phpmyadmin to test it but I didn`t manage to get the generated 
> sql using underline.
>
> with or without distinct argument it gives 
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 610, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 529, in timeline_opm
> print 
> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
> AttributeError: 'Field' object has no attribute '_count'
>
>
> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>>
>> ok, can you print here what is the result of :
>>
>>
>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>>
>> (mind the _ before count.)
>>
>> If you can fire off queries on your db using another tool than web2py 
>> (let's say, phpmyadmin), try to copy the resulting string into th

[web2py] Re: unicode problem in DAL

2012-03-09 Thread Phyo Arkar
Yeah , the problem is you cannot store unicode .. Its not web2py fault tho
. thats how Python works.

You have to "Encode" before storing.

So here is how it works:

When you read data from a source , decode.
When you store data to source , encode

After retrieving data from a source (File,Database) and you want to
mainipulate that data , decode it.
When you've done something with that data Encode it.

So when you read data from text file , Decode that text file .
--- Do what you want with that file.
and then Encode (ever field's values) before inserting into database.

Use appropriate encoding , and if you can;t get encoding use UTF-8.


On Fri, Mar 9, 2012 at 1:15 PM, weheh  wrote:

>
> Did you ever get your unicode issue resolved last year? I've been
> having trouble with unicode and was wondering if you had a general
> method for dealing with it? I'm uploading text into a db by 2 methods:
> first method is reading a text field, 2nd method is uploading a text
> file. I need a reliable way of making sure all text is in same utf8
> format. Do you know how to do this?
>
>
> On Jun 1 2011, 5:01 pm, Phyo Arkar  wrote:
> > So the value has to be Endcoded FromUnicodeinto UTF8 before
> > inserting? i am sure keys are str.
> >
> > We cannot storeUnicodevalues ?
> >
> > On 5/31/11, Massimo Di Pierro  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I am not sure there is a problem here. I cannot help without seeing an
> > > example of the data you insert.
> >
> > > If you do:
> >
> > > db.table.insert(**a)
> >
> > > a must be a dictionary with str key and str (ut8 encoded) values. You
> > > cannot haveunicodefield names.
> >
> > > Massimo
> >
> > > On May 31, 2:40 am, Phyo Arkar  wrote:
> > >> I have the exactly same problem here.
> >
> > >> Can anyone look into it? thanks alot.
> >
> > >> Stef have you found a solution?
> >
> > >> On Fri, Nov 5, 2010 at 5:47 PM, Stef Mientki 
> > >> wrote:
> >
> > >> > I'm trying to insert a record with a filed value
> > >> >  u"ëLocatie"
> >
> > >> > and I get an error in sql.Table._insert at the last line:
> > >> >return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f,
> sql_v)
> >
> > >> > here the traceback
> > >> >  File "D:\Data_Python_25\support\Web2Py_DAL_support.py", line 250,
> in
> > >> > DAL_Table
> > >> >Description = Value[3][:-1])
> > >> >  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2035, in
> insert
> > >> >query = self._insert(**fields)
> > >> >  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2028, in
> _insert
> > >> >return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
> > >> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
> position 35:
> > >> > ordinal not in range(128)
> >
> > >> > I don't understand the problem and know what I'm doing wrong
> >
> > >> > Wwith print statements I tried to narrow the problem, and in :
> > >> > def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'):
> >
> > >> > there's is this part
> > >> >if isinstance(obj,unicode):
> > >> >print '', type(obj),obj
> > >> >if len(obj)>0 : print ord(obj[0])
> > >> >obj = obj.encode(db_codec)
> > >> >print '', type(obj)
> > >> >if len(obj)>0 : print ord(obj[0])
> >
> > >> > which seems to convert theunicodeto a string with byte values larger
> > >> > than 128.
> >
> > >> > Am I doing something wrong, or is this a bug ?
> > >> > And of course far more interesting, how do I solve this problem ?
> >
> > >> > thanks,
> > >> > Stef Mientki
>


[web2py] installing as a window service

2012-03-09 Thread Muscillo Luigi
i'm trying to install web2py as a window server; I followed all
instructions issued about the argument but id doesnt'work;
i tried both with binary distribution and source distribution but when
i try to start service it doesn't start!
does anybody help me?


Re: [web2py] New Translation engine suggestions

2012-03-09 Thread Anthony

>
> html = DIV("foo", SPAN("bar"))
>
> {{=XML(str(T(str(html}}
>
Note, instead of str(T(...)), you can now do:

{{=XML(T(str(html), lazy=False))}}

You can also do:

{{T.lazy = False}}
{{=XML(T(str(html)))}}
{{=XML(T(str(other_html)))}}

Once T.lazy is set to False, all subsequent calls to T() will return 
strings instead of lazyT objects.

Anthony 


Re: [web2py] New Translation engine suggestions

2012-03-09 Thread Bruno Rocha
html = DIV("foo", SPAN("bar"))

{{=XML(str(T(str(html}}

it works but there is an aditional overhead.

http://zerp.ly/rochacbruno
Em 09/03/2012 12:14, "Bruce Wade"  escreveu:

> Hi,
>
> Now that I am working on my 4th site that requires translations I am
> starting to run into the problem where one design looks good and is layout
> well for a specific language, however when translating into a different
> language it doesn't fit the design.
>
> For example in English:
>
> WE APPRECIATE
> YOUR TIME FOR FILLING
> THIS APPLICATION
>
> HTML:
> 
> {{=SPAN(T('WE APPRECIATE'), _class='big-registertext')}}
> {{=SPAN(T('YOUR TIME FOR FILLING'), _class='small-registertext')}}
> {{=SPAN(T('THIS APPLICATION'), _class='middle-registertext')}}
> {{=P(T('The information provided in this application will be used
> ONLY for training purposes and your data won\'t be shared at any level'),
> _class='plain-registertext')}}
> 
>
> Looks good (see screenshot).
>
> However because we want to translate and don't want the translator to
> understand HTML, when they change the text it doesn't look good in Chinese
> for example because their language isn't so wordy and forcing to use
> multiple lines makes it look bad.
>
> Now what if the translation tool could handle HTML tags with a text
> editor. That way if you wrap T('') around HTML tags it would show as is in
> the translation tool, then when someone types a different language they
> have full control over the content. Allow a designer to design specific for
> a language not for the in-forced HTML tags.
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] Key Error: auth_user on GAE

2012-03-09 Thread Sushant Taneja
Hi,

I have extended the default auth_user table in my model file db.py as 
follows:

db = DAL('google:datastore')

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())

auth.settings.extra_fields['auth_user'] = [
Field('first_name','string',required=True, notnull=True),
Field('last_name','string',default=''),
Field('fb_id','string',length=512,required=True),
Field('create_ts','datetime'),
Field('change_ts','datetime')
]

auth.define_tables()

Also below this code I have also written an insert for inserting data in 
the auth_user table as:

def new_user(first_name, last_name, email, passw,fb_id):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
   first_name=first_name,
   last_name=last_name,
   email = email,
   password = crypt_pass,
   fb_id = fb_id
   )
return id_user

iduser = 
new_user('ABCD','EFGH','sushant.tanej...@gmail.com','password','8345935345')

This insert I got from some other post in the group. The insert was 
successful and auth_user table has been created.
Although no other auth table was created.

Now in my controller function I check if fb_id of a user already exists in 
my auth_user table or not 

def get_existing_friends():
""" This function returns a CSV text of FB_IDs of friends which already 
exists """

user_fb_id = request.vars.userFBID
if db(db.auth_user.fb_id==user_fb_id).select():
return "jQuery('.foundFriends').html('This facebook user is already 
registered');"

On execution nothing happens and GAE logs the following error message:

Traceback (most recent call last):
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/restricted.py", 
line 204, in restricted
exec ccode in environment
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
 
line 63, in 
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/globals.py", 
line 172, in 
self._caller = lambda f: f()
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
 
line 19, in get_existing_friends
if db(db.auth_user.fb_id==user_fb_id).select():
  File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", 
line 5119, in __getattr__
return self[key]
  File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", 
line 5113, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'auth_user'

Can somebody help me understand the above ?

Thanks,
Sushant


[web2py] Re: CHANGE DEFAULT DATABASE

2012-03-09 Thread Massimo Di Pierro
Correct. Admin does not rely on a database.

On Friday, 9 March 2012 08:27:27 UTC-6, Alan Etkin wrote:
>
> Not completely sure, but I belive the admin app does not use a 
> database connection (except for multi-user mode as I've seen in the 
> admin model, in which case the default connection is with sqlite). It 
> stores sites data as the error tickets in the file system. If you want 
> more accurate information on the admin app, you could check the manual 
> at 3.11 "More on admin" 
>
> On 9 mar, 10:58, Luke Southam  wrote: 
> > hi, i was wondering if it was possible to change the default database 
> for 
> > web2py. Not just for one application but to change it for the admin ide 
> > also.



[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
I'm using version 1.99.4.
I will test it in 1.99.7 to see if it stop giving this error

Em sexta-feira, 9 de março de 2012 12h21min22s UTC-3, Niphlod escreveu:
>
> last version is working ok (1.99.7), what web2py version are you using ?
>
> if db.contadores is a table, then it definitely has a "_count" method...
>
>
>
> Il giorno venerdì 9 marzo 2012 15:55:42 UTC+1, Fabiano Faver ha scritto:
>>
>> Niphlod, this is what i got, using distinct argument or not:
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 613, in 
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>> self._caller = lambda f: f()
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 528, in timeline_opm
>> print db.contadores._count(distinct=db.contadores.id_impressora)
>>   File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
>> return self[key]
>>   File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
>> return dict.__getitem__(self, str(key))
>> KeyError: '_count'
>>
>>
>>
>> @Bruno
>> While I can`t get all grouped records at once I am query them 
>> individually one by one using argument distinct
>>
>> for dias in range(loop_back):
>> d = timedelta(days=dias)
>> dias_passado = dia_hoje - d
>> header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
>> contador_no_dia = db((db.contadores.id
>> >0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)
>>
>> Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:
>>>
>>> ooops, sorry, the _count method is on the table, not the field
>>> try with
>>>
>>> db.contadores._count(distinct=db.contadores.id_impressora)
>>>
>>>
>>>
>>> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:

 I have phpmyadmin to test it but I didn`t manage to get the generated 
 sql using underline.

 with or without distinct argument it gives 

 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 204, in restricted
 exec ccode in environment
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 610, in 
   File "C:\web2py\gluon\globals.py", line 172, in 
 self._caller = lambda f: f()
   File "C:\web2py\gluon\tools.py", line 2533, in f
 return action(*a, **b)
   File "C:\web2py\gluon\tools.py", line 2533, in f
 return action(*a, **b)
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 529, in timeline_opm
 print 
 db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
 AttributeError: 'Field' object has no attribute '_count'


 Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>
> ok, can you print here what is the result of :
>
>
> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>
> (mind the _ before count.)
>
> If you can fire off queries on your db using another tool than web2py 
> (let's say, phpmyadmin), try to copy the resulting string into that and 
> watch if the query raises an error.
>
> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha 
> scritto:
>>
>> MySQL
>>
>> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod 
>> escreveu:
>>>
>>> what db are you using ?
>>>
>>>
>>> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha 
>>> scritto:

 I`m trying to select distinct printers used in each day but i`m not 
 managing to use the distinct argument

 count = db.contadores.id_impressora.count()
 for row in db((db.contadores.id
 >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
 print row.contadores.data, row[count]

 if I use something like
 
   
 db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)

 it gives:

 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 204, in restricted
 exec ccode in environment
   File "C:/web2py/applications/OPM/controllers/default.py" 
 

[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Niphlod
last version is working ok (1.99.7), what web2py version are you using ?

if db.contadores is a table, then it definitely has a "_count" method...



Il giorno venerdì 9 marzo 2012 15:55:42 UTC+1, Fabiano Faver ha scritto:
>
> Niphlod, this is what i got, using distinct argument or not:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 613, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 528, in timeline_opm
> print db.contadores._count(distinct=db.contadores.id_impressora)
>   File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
> return self[key]
>   File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: '_count'
>
>
>
> @Bruno
> While I can`t get all grouped records at once I am query them individually 
> one by one using argument distinct
>
> for dias in range(loop_back):
> d = timedelta(days=dias)
> dias_passado = dia_hoje - d
> header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
> contador_no_dia = db((db.contadores.id
> >0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)
>
> Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:
>>
>> ooops, sorry, the _count method is on the table, not the field
>> try with
>>
>> db.contadores._count(distinct=db.contadores.id_impressora)
>>
>>
>>
>> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:
>>>
>>> I have phpmyadmin to test it but I didn`t manage to get the generated 
>>> sql using underline.
>>>
>>> with or without distinct argument it gives 
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>> exec ccode in environment
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 610, in 
>>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>> self._caller = lambda f: f()
>>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>> return action(*a, **b)
>>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>> return action(*a, **b)
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 529, in timeline_opm
>>> print 
>>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>>> AttributeError: 'Field' object has no attribute '_count'
>>>
>>>
>>> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:

 ok, can you print here what is the result of :

 db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)

 (mind the _ before count.)

 If you can fire off queries on your db using another tool than web2py 
 (let's say, phpmyadmin), try to copy the resulting string into that and 
 watch if the query raises an error.

 Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:
>
> MySQL
>
> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>>
>> what db are you using ?
>>
>>
>> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha 
>> scritto:
>>>
>>> I`m trying to select distinct printers used in each day but i`m not 
>>> managing to use the distinct argument
>>>
>>> count = db.contadores.id_impressora.count()
>>> for row in db((db.contadores.id
>>> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
>>> print row.contadores.data, row[count]
>>>
>>> if I use something like
>>> 
>>>   
>>> db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>>>
>>> it gives:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>> exec ccode in environment
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , 
>>> line 581, in 
>>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>> self._caller = lambda f: f()
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> ,

[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
Niphlod, this is what i got, using distinct argument or not:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
exec ccode in environment
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
613, in 
  File "C:\web2py\gluon\globals.py", line 172, in 
self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 2533, in f
return action(*a, **b)
  File "C:\web2py\gluon\tools.py", line 2533, in f
return action(*a, **b)
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
528, in timeline_opm
print db.contadores._count(distinct=db.contadores.id_impressora)
  File "C:\web2py\gluon\dal.py", line 5542, in __getattr__
return self[key]
  File "C:\web2py\gluon\dal.py", line 5482, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_count'



@Bruno
While I can`t get all grouped records at once I am query them individually 
one by one using argument distinct

for dias in range(loop_back):
d = timedelta(days=dias)
dias_passado = dia_hoje - d
header.append(TH(dias_passado.strftime("%d/%m"),_width='60px'))
contador_no_dia = 
db((db.contadores.id>0)&(db.contadores.data==dias_passado)).count(distinct=db.contadores.id_impressora)

Em sexta-feira, 9 de março de 2012 10h54min59s UTC-3, Niphlod escreveu:
>
> ooops, sorry, the _count method is on the table, not the field
> try with
>
> db.contadores._count(distinct=db.contadores.id_impressora)
>
>
>
> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:
>>
>> I have phpmyadmin to test it but I didn`t manage to get the generated sql 
>> using underline.
>>
>> with or without distinct argument it gives 
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 610, in 
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>> self._caller = lambda f: f()
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>> return action(*a, **b)
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 529, in timeline_opm
>> print 
>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>> AttributeError: 'Field' object has no attribute '_count'
>>
>>
>> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>>>
>>> ok, can you print here what is the result of :
>>>
>>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>>>
>>> (mind the _ before count.)
>>>
>>> If you can fire off queries on your db using another tool than web2py 
>>> (let's say, phpmyadmin), try to copy the resulting string into that and 
>>> watch if the query raises an error.
>>>
>>> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:

 MySQL

 Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>
> what db are you using ?
>
>
> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha 
> scritto:
>>
>> I`m trying to select distinct printers used in each day but i`m not 
>> managing to use the distinct argument
>>
>> count = db.contadores.id_impressora.count()
>> for row in db((db.contadores.id
>> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
>> print row.contadores.data, row[count]
>>
>> if I use something like
>> 
>>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>>
>> it gives:
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , 
>> line 581, in 
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>> self._caller = lambda f: f()
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , 
>> line 516, in timeline_opm
>> count = db.contadores.id_impressora.count(distinct=('id_impressora'))
>> TypeError: count() got an unexpected keyword argument 'distinct' 
>>
>>
>> How can I use distinct count here?
>>
>

Re: [web2py] Re: query using groupby and distinct count

2012-03-09 Thread Niphlod
both seems to work ok...

db(db.products.id>0)._count('id') 

or

db(db.products.id>0)._count(db.products.id) 



[web2py] Re: CHANGE DEFAULT DATABASE

2012-03-09 Thread Alan Etkin
Not completely sure, but I belive the admin app does not use a
database connection (except for multi-user mode as I've seen in the
admin model, in which case the default connection is with sqlite). It
stores sites data as the error tickets in the file system. If you want
more accurate information on the admin app, you could check the manual
at 3.11 "More on admin"

On 9 mar, 10:58, Luke Southam  wrote:
> hi, i was wondering if it was possible to change the default database for
> web2py. Not just for one application but to change it for the admin ide
> also.


[web2py] Re: db.mytable.myfield.represent= ???

2012-03-09 Thread Anthony

>
> My only defence for wasting your time is the remaining ambiguity regards 
> the input parameters in the book. I do believe the book could benefit by 
> the inclusion of your words as quoted below...
>

Good point. Previously, represent took only the field value, not the row. I 
guess the book content wasn't fully updated to reflect the change (though 
the examples were updated).

Anthony 


Re: [web2py] Re: query using groupby and distinct count

2012-03-09 Thread Bruno Rocha
the only argument you can pass to count() is a fieldname, so it will
countusing distinct
db(db.products.id>0)._count('id')
>>> 'SELECT count(DISTINCT id) FROM products WHERE (products.id > 0)'




On Fri, Mar 9, 2012 at 10:54 AM, Niphlod  wrote:

> ooops, sorry, the _count method is on the table, not the field
> try with
>
> db.contadores._count(distinct=db.contadores.id_impressora)
>
>
>
> Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:
>
>> I have phpmyadmin to test it but I didn`t manage to get the generated sql
>> using underline.
>>
>> with or without distinct argument it gives
>>
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.**py", line 204, in restricted
>>
>> exec ccode in environment
>>
>>   File "C:/web2py/applications/OPM/**controllers/default.py" 
>> , line 
>> 610, in 
>>
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>
>> self._caller = lambda f: f()
>>
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>
>> return action(*a, **b)
>>
>>   File "C:\web2py\gluon\tools.py", line 2533, in f
>>
>> return action(*a, **b)
>>
>>   File "C:/web2py/applications/OPM/**controllers/default.py" 
>> , line 
>> 529, in timeline_opm
>>
>> print 
>> db.contadores.id_impressora._**count(distinct=db.contadores.i**d_impressora)
>> AttributeError: 'Field' object has no attribute '_count'
>>
>>
>> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>>>
>>> ok, can you print here what is the result of :
>>>
>>> db.contadores.id_impressora._**count(distinct=db.contadores.**
>>> id_impressora)
>>>
>>> (mind the _ before count.)
>>>
>>> If you can fire off queries on your db using another tool than web2py
>>> (let's say, phpmyadmin), try to copy the resulting string into that and
>>> watch if the query raises an error.
>>>
>>> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:

 MySQL

 Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>
> what db are you using ?
>
>
> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha
> scritto:
>>
>> I`m trying to select distinct printers used in each day but i`m not
>> managing to use the distinct argument
>>
>> count = db.contadores.id_impressora.**count()
>> for row in db((db.contadores.id>0)&(db.**contadores.data<=today)).**
>> select(db.contadores.data,**count,groupby=db.contadores.**data):
>> print row.contadores.data, row[count]
>>
>> if I use something like
>>   db.contadores.id_impressora.**count(distinct=db.contadores.**
>> id_impressora)
>>
>> it gives:
>>
>>
>> Traceback (most recent call last):
>>
>>   File "C:\web2py\gluon\restricted.**py", line 204, in restricted
>>
>> exec ccode in environment
>>
>>   File "C:/web2py/applications/OPM/**controllers/default.py" 
>> , 
>> line 581, in 
>>
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>
>> self._caller = lambda f: f()
>>
>>   File "C:/web2py/applications/OPM/**controllers/default.py" 
>> , 
>> line 516, in timeline_opm
>>
>> count = 
>> db.contadores.id_impressora.co**unt(distinct=('id_impressora')**)
>> TypeError: count() got an unexpected keyword argument 'distinct'
>>
>>
>> How can I use distinct count here?
>>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: CHANGE DEFAULT DATABASE

2012-03-09 Thread Niphlod
there is no such thing as "default database".

one dal instance is pointed to a specific database. if you want to 
switch them, define different DAL instances or make the database URI 
variable

Il giorno venerdì 9 marzo 2012 14:58:08 UTC+1, Luke Southam ha scritto:
>
> hi, i was wondering if it was possible to change the default database for 
> web2py. Not just for one application but to change it for the admin ide 
> also.



[web2py] CHANGE DEFAULT DATABASE

2012-03-09 Thread Luke Southam
hi, i was wondering if it was possible to change the default database for 
web2py. Not just for one application but to change it for the admin ide 
also.

[web2py] web2py 1.99.4 window service: error starting service

2012-03-09 Thread Muscillo Luigi
hi to all,
I am  trying to install web2py as a window service, I followed all the 
instructions issued in docs but the service still doesn't work;
I succesfully installed it, or it seems to be, but when I try to start 
service (both from console and windows interface) returns an error (1053 
win err).
all are done on winxp!
can anyone help me?
thanks,


[web2py] Re: set.update(field=lambda row: row.field + 1) is possible?

2012-03-09 Thread Niphlod
no problem, glad I was able to interpret the subject  ;-)



[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Niphlod
ooops, sorry, the _count method is on the table, not the field
try with

db.contadores._count(distinct=db.contadores.id_impressora)



Il giorno venerdì 9 marzo 2012 13:37:16 UTC+1, Fabiano Faver ha scritto:
>
> I have phpmyadmin to test it but I didn`t manage to get the generated sql 
> using underline.
>
> with or without distinct argument it gives 
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 610, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:\web2py\gluon\tools.py", line 2533, in f
> return action(*a, **b)
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 529, in timeline_opm
> print 
> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
> AttributeError: 'Field' object has no attribute '_count'
>
>
> Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>>
>> ok, can you print here what is the result of :
>>
>> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>>
>> (mind the _ before count.)
>>
>> If you can fire off queries on your db using another tool than web2py 
>> (let's say, phpmyadmin), try to copy the resulting string into that and 
>> watch if the query raises an error.
>>
>> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:
>>>
>>> MySQL
>>>
>>> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:

 what db are you using ?


 Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:
>
> I`m trying to select distinct printers used in each day but i`m not 
> managing to use the distinct argument
>
> count = db.contadores.id_impressora.count()
> for row in db((db.contadores.id
> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
> print row.contadores.data, row[count]
>
> if I use something like
> 
>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>
> it gives:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 581, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , 
> line 516, in timeline_opm
> count = db.contadores.id_impressora.count(distinct=('id_impressora'))
> TypeError: count() got an unexpected keyword argument 'distinct' 
>
>
> How can I use distinct count here?
>


[web2py] Re: web2py site and disabling browser right clicks

2012-03-09 Thread Anthony

>
> Perhaps requesting the content with an 
> ajax call when it loads client-side (I am not sure if this is 
> unaccessible for the browser anyway).


That's not a bad idea. Using the browser's view source feature should only 
show the HTML of the initial page load, not any subsequent Ajax calls. Of 
course, users can still view the contents of Ajax calls, but they have to 
be a little more technically savvy to do so, using the browser's developer 
tools or some other external tool. Ultimately, you cannot prevent users 
from seeing whatever you send to the browser, but you can make it more 
difficult for non-technical users.

Anthony 

 


[web2py] Re: web2py site and disabling browser right clicks

2012-03-09 Thread Wikus van de Merwe
It looks like you don't understand how the world wide web works. There is 
nothing you can do to stop me from seeing the HTML code of your website. 
Blocking right click gets you nowhere as I can still use the browser menu, 
numerous plugins or simply download the page code directly without even 
using the browser. Even if you would javascript to generate the HTML 
dynamically, I can still access that generated code. So don't waste your 
time.


[web2py] Re: web2py site and disabling browser right clicks

2012-03-09 Thread Alan Etkin
You can (I think) change the right click event handler with
javascript, but how are you going to prevent the users to do edit ->
view source code in their web browser? Maybe you can do some
obfuscation to render the source code difficult to read (by processing
the web2py response output). Perhaps requesting the content with an
ajax call when it loads client-side (I am not sure if this is
unaccessible for the browser anyway).

On 9 mar, 09:46, Rahul  wrote:
> Hi All,
>          I don't want to allow people to  -
>
>    1. Do "view page source" when they are viewing my site and
>    2. Save the page of my site
>    3. It would even be good if I was able to remove/disable the default
>    right click across browsers when the users are viewing my web site
>
> What is the best way to achieve this in web2py?
>
> Any suggestions would be greatly appreciated.
>
> Thanks, Rahul (www.flockbird.com)


[web2py] Re: CRUD onaccept question

2012-03-09 Thread Gian Luca Decurtins
Thank you Alan!


> onaccept=lambda form: locate(request.args(0)) 


It now works as expected!
-Luca. 


[web2py] web2py site and disabling browser right clicks

2012-03-09 Thread Rahul
Hi All,
 I don't want to allow people to  - 

   1. Do "view page source" when they are viewing my site and
   2. Save the page of my site 
   3. It would even be good if I was able to remove/disable the default 
   right click across browsers when the users are viewing my web site
   
What is the best way to achieve this in web2py? 

Any suggestions would be greatly appreciated. 

Thanks, Rahul (www.flockbird.com)




[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
I have phpmyadmin to test it but I didn`t manage to get the generated sql 
using underline.

with or without distinct argument it gives 

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
exec ccode in environment
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
610, in 
  File "C:\web2py\gluon\globals.py", line 172, in 
self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 2533, in f
return action(*a, **b)
  File "C:\web2py\gluon\tools.py", line 2533, in f
return action(*a, **b)
  File "C:/web2py/applications/OPM/controllers/default.py" 
, line 
529, in timeline_opm
print 
db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
AttributeError: 'Field' object has no attribute '_count'


Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>
> ok, can you print here what is the result of :
>
> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>
> (mind the _ before count.)
>
> If you can fire off queries on your db using another tool than web2py 
> (let's say, phpmyadmin), try to copy the resulting string into that and 
> watch if the query raises an error.
>
> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:
>>
>> MySQL
>>
>> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>>>
>>> what db are you using ?
>>>
>>>
>>> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:

 I`m trying to select distinct printers used in each day but i`m not 
 managing to use the distinct argument

 count = db.contadores.id_impressora.count()
 for row in db((db.contadores.id
 >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
 print row.contadores.data, row[count]

 if I use something like
 
   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)

 it gives:

 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 204, in restricted
 exec ccode in environment
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 581, in 
   File "C:\web2py\gluon\globals.py", line 172, in 
 self._caller = lambda f: f()
   File "C:/web2py/applications/OPM/controllers/default.py" 
 , 
 line 516, in timeline_opm
 count = db.contadores.id_impressora.count(distinct=('id_impressora'))
 TypeError: count() got an unexpected keyword argument 'distinct' 


 How can I use distinct count here?

>>>

[web2py] Re: Many to Many?

2012-03-09 Thread Wikus van de Merwe
What pbreit suggested assumes that all the company servers are at the same 
location as the company, which I guess is not what you wanted.
It think it should rather be:

db.define_table('company',
Field('name'),
Field('location', db.location))

db.define_table('server',
Field('name'),
Field('company', db.company),
Field('location', db.location))

db.define_table('location',
Field('name'))


[web2py] Re: set.update(field=lambda row: row.field + 1) is possible?

2012-03-09 Thread Alan Etkin
I wasn't aware of the book's 6.17.8 (Expressions) section. So the
answer is yes, there is something similar (or better) that what I was
looking for.

Thank you very much

On 9 mar, 08:52, Niphlod  wrote:
> I don't get it
> Are you aware that
>
> db.persons.update(howmany=db.persons.howmany + 1)
>
> is working?
> It seems that that is what you want.
>
> Il giorno venerdì 9 marzo 2012 12:04:59 UTC+1, Alan Etkin ha scritto:
>
>
>
>
>
>
>
>
>
> > Is it currently possible something similar to the command in the
> > subject? If not, would it be a good enhancement? In case it is, the
> > patch is easy to implement?


[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Niphlod
ok, can you print here what is the result of :

db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)

(mind the _ before count.)

If you can fire off queries on your db using another tool than web2py 
(let's say, phpmyadmin), try to copy the resulting string into that and 
watch if the query raises an error.

Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:
>
> MySQL
>
> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>>
>> what db are you using ?
>>
>>
>> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:
>>>
>>> I`m trying to select distinct printers used in each day but i`m not 
>>> managing to use the distinct argument
>>>
>>> count = db.contadores.id_impressora.count()
>>> for row in db((db.contadores.id
>>> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
>>> print row.contadores.data, row[count]
>>>
>>> if I use something like
>>> 
>>>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>>>
>>> it gives:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>> exec ccode in environment
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 581, in 
>>>   File "C:\web2py\gluon\globals.py", line 172, in 
>>> self._caller = lambda f: f()
>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>> , line 
>>> 516, in timeline_opm
>>> count = db.contadores.id_impressora.count(distinct=('id_impressora'))
>>> TypeError: count() got an unexpected keyword argument 'distinct' 
>>>
>>>
>>> How can I use distinct count here?
>>>
>>

[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Fabiano Faver
MySQL

Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>
> what db are you using ?
>
>
> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:
>>
>> I`m trying to select distinct printers used in each day but i`m not 
>> managing to use the distinct argument
>>
>> count = db.contadores.id_impressora.count()
>> for row in db((db.contadores.id
>> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
>> print row.contadores.data, row[count]
>>
>> if I use something like
>> 
>>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>>
>> it gives:
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 581, in 
>>   File "C:\web2py\gluon\globals.py", line 172, in 
>> self._caller = lambda f: f()
>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>> , line 
>> 516, in timeline_opm
>> count = db.contadores.id_impressora.count(distinct=('id_impressora'))
>> TypeError: count() got an unexpected keyword argument 'distinct' 
>>
>>
>> How can I use distinct count here?
>>
>

[web2py] Re: query using groupby and distinct count

2012-03-09 Thread Niphlod
what db are you using ?


Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:
>
> I`m trying to select distinct printers used in each day but i`m not 
> managing to use the distinct argument
>
> count = db.contadores.id_impressora.count()
> for row in db((db.contadores.id
> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
> print row.contadores.data, row[count]
>
> if I use something like
> 
>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>
> it gives:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 581, in 
>   File "C:\web2py\gluon\globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "C:/web2py/applications/OPM/controllers/default.py" 
> , line 
> 516, in timeline_opm
> count = db.contadores.id_impressora.count(distinct=('id_impressora'))
> TypeError: count() got an unexpected keyword argument 'distinct' 
>
>
> How can I use distinct count here?
>


[web2py] Re: set.update(field=lambda row: row.field + 1) is possible?

2012-03-09 Thread Niphlod
I don't get it
Are you aware that 

db.persons.update(howmany=db.persons.howmany + 1)

is working?
It seems that that is what you want.

Il giorno venerdì 9 marzo 2012 12:04:59 UTC+1, Alan Etkin ha scritto:
>
> Is it currently possible something similar to the command in the 
> subject? If not, would it be a good enhancement? In case it is, the 
> patch is easy to implement? 
>


[web2py] Re: CRUD onaccept question

2012-03-09 Thread Alan Etkin
> "... onvalidation, oncreate, onupdate and ondelete are callback
> functions. All
> but ondelete take a form object as input. ..."

Sorry, those are SQLFORM.grid arguments, the CRUD method signatures
are at 7.4.3 (Methods)


[web2py] Re: CRUD onaccept question

2012-03-09 Thread Alan Etkin
"... onvalidation, oncreate, onupdate and ondelete are callback
functions. All
but ondelete take a form object as input. ..."

I'd try replacing onaccept with something like this (not tested):

onaccept: lambda form: locate(request.args(0))

That way the action will call the function after the form is sent. In
your code, locate() is called on form instantiation (before
submission)


Re: [web2py] Web2py + uWSGI and timeouts!!

2012-03-09 Thread Phyo Arkar
*Only uWSGI HTTP server is used and no other HTTP Servers .


On Fri, Mar 9, 2012 at 2:38 PM, Phyo Arkar  wrote:

> Only uWSGI is used and no HTTP.
>


[web2py] CRUD onaccept question

2012-03-09 Thread Gian Luca Decurtins
Hi all

Once again a question related to CRUD: Why is onaccept executed before 
pressing the "Submit" button?
I've written a function "update()" which calls crud.update. After 
submitting new values I would like to look up the location's latitude and 
longitude.
At the moment I'm facing the problem that the function 
"locate(request.args(0))" is called before displaying the location details.
What do I have to change to lookup latitude and longitude after update? Is 
there a way to lookup the coordinates asynchronously?

-Luca.


@auth.requires_signature()
def update():
form = 
crud.update(db.location,request.args(0),next=URL('location','select', 
user_signature=True),onaccept=locate(request.args(0)))
return dict(form=form)

@auth.requires_signature()
def locate(locationId):
from gluon.tools import geocode
location = db.location(db.location.id==locationId)
(lat, long) = geocode("%s %s %s" % (location.country, location.city, 
location.street))
location.update_record(latitude = lat,longitude = long)

@auth.requires_signature()
def select():
db.location.name.represent = lambda name, row: \
   A(name,_href=URL('location','update', args=(row.id), 
user_signature=True))
form = crud.select(table=db.location)
return dict(form=form)


[web2py] set.update(field=lambda row: row.field + 1) is possible?

2012-03-09 Thread Alan Etkin
Is it currently possible something similar to the command in the
subject? If not, would it be a good enhancement? In case it is, the
patch is easy to implement?


[web2py] Re: This code is right?

2012-03-09 Thread Alan Etkin
But what if there is not GAE environment, although most unlikely. The
action wouldn't return a valid form (I guess)
You could test for request.env.web2py_runtime_gae and serve the form
in case it's appropiate

On Mar 8, 9:44 pm, sungchi  wrote:
> I want to separation of the default login and google login.
>
> *models/db.py:*
> from gluon.contrib.login_methods.gae_google_account import GaeGoogleAccount
>
> *view/default/googlelogin.html:*
> {{=form}}
>
> *controller/default.py*
> def login():
>     if auth.user_id:
>         redirect(session.old_referer)
>     login_form=author_func()
>     return dict(login_form=login_form)
> def googlelogin():
>     auth.settings.login_form=GaeGoogleAccount()
>     return dict(form=auth.login(next=URL(r=request, c='default',
> f='index')))
>
> Thanks.


[web2py] ajax() and mobilize

2012-03-09 Thread flando
Hi Guys

I am struggling with @mobilize and ajax().
I have a form with two SELECT whereby changes on the first select will 
update the options on the second select using ajax().
When I access the page, the form gets perfectly "mobilized" by using "
plugin_jqmobile/layout.html".
Both select fields look well formatted and designed for mobile use.
When I now change the option in the first select-field the second 
select-field gets updated but the design changes to the common design (not 
mobilized).
How can I achieve that returned data from ajax() gets "mobilized"?
Thank you for any hints! :-)

rgds, Fritz


Here my example code:
@mobilize
def getForm()
form=FORM(\

DIV(mkSimpleSelectBox(db(db.category.id>0).select(),'category_id',category_id,CategoryOnChange)),\

DIV(mkSimpleSelectBox(db(db.subcategory.category_id==category_id).select(orderby=db.subcategory.seq),'subcategory_id',subcategory_id,SubcategoryOnChange),_id='subcategory_selection'),\



[web2py] add the drop-down and multiple selection in grid

2012-03-09 Thread Sanjeet Kumar
How can i add the drop-down in the grid for the better searching and when i 
select the multiple check box at a time should be able to delete it by 
using the one button 

[web2py] Re: Current user's username? Customized access control with Auth and LDAP?

2012-03-09 Thread szimszon
dn: cn=Admin,ou=Groups,dc=domain,dc=com
objectClass: top
objectClass: posixGroup
cn: Admin
gidNumber: 5095
memberUid: root
memberUid: toor
memberUid: smith


2012. március 8., csütörtök 23:46:34 UTC+1 időpontban Aaron a következőt 
írta:
>
> Thank you, sir! This looks just right for my group needs (though I'm not 
> sure how I'd get a list of the current user's groups).
>
> Also, as I mentioned, I'm new to LDAP, so if you could provide sample LDIF 
> files for the groups, that'd help greatly.
>
> Unfortunately I'm also using OpenLDAP, so I can't help you test with AD.
>
> Thanks again.
>
> On Thursday, March 8, 2012 1:40:29 PM UTC-8, szimszon wrote:
>>
>> Group control is already in ldap_auth.py:
>>
>>
>> http://www.web2pyslices.com/slice/show/1476/ldap-auth-with-allowed-groups-and-manage-groups
>>
>> And I work now on storing first name, last name, and email user prefs 
>> from ldap. I think I can send a patch to Massimo tomorrow.
>>
>> 2012. március 8., csütörtök 20:25:12 UTC+1 időpontban Aaron a következőt 
>> írta:
>>>
>>> Also, what meaning does the @auth.requires_membership() decorator have 
>>> in the context of LDAP authentication?
>>> Based on my limited knowledge of LDAP (pretty much what's on  
>>> http://ldapman.org/articles/intro_to_ldap.html), it doesn't look like 
>>> LDAP implements groups; the closest thing to it would be an entry's 
>>> Distinguished Name/Domain Components.
>>>
>>> Thanks,
>>> Aaron
>>>
>>> On Thursday, March 8, 2012 6:04:15 AM UTC-8, Aaron wrote:

 I'm using gluon.tools.Auth and the default ldap_auth login_method to 
 provide access control to my web2py application.
 Now, once the user has successfully logged in (@auth.require_login() 
 passes), I want to find out which user is logged in, and some of this 
 user's attributes.
 I could get additional information from the LDAP server (using 
 python-ldap) if I knew the user name; however, the only entry I see in 
 Auth
  that 
 provides similar information is Auth.user_id, and I don't know how this ID 
 maps to the current user's LDAP username.

 More generally, is there a good way for me to take control of my 
 application's interaction with our LDAP server, while still leveraging the 
 many built-ins Auth has to offer?
 Should I modify the ldap_auth login_method to store the username and 
 password information in the session object?
 Should I write my own custom login_method? If so, what resources exist 
 to help me along?

>>>
> On Thursday, March 8, 2012 1:40:29 PM UTC-8, szimszon wrote:
>>
>> Group control is already in ldap_auth.py:
>>
>>
>> http://www.web2pyslices.com/slice/show/1476/ldap-auth-with-allowed-groups-and-manage-groups
>>
>> And I work now on storing first name, last name, and email user prefs 
>> from ldap. I think I can send a patch to Massimo tomorrow.
>>
>> 2012. március 8., csütörtök 20:25:12 UTC+1 időpontban Aaron a következőt 
>> írta:
>>>
>>> Also, what meaning does the @auth.requires_membership() decorator have 
>>> in the context of LDAP authentication?
>>> Based on my limited knowledge of LDAP (pretty much what's on  
>>> http://ldapman.org/articles/intro_to_ldap.html), it doesn't look like 
>>> LDAP implements groups; the closest thing to it would be an entry's 
>>> Distinguished Name/Domain Components.
>>>
>>> Thanks,
>>> Aaron
>>>
>>> On Thursday, March 8, 2012 6:04:15 AM UTC-8, Aaron wrote:

 I'm using gluon.tools.Auth and the default ldap_auth login_method to 
 provide access control to my web2py application.
 Now, once the user has successfully logged in (@auth.require_login() 
 passes), I want to find out which user is logged in, and some of this 
 user's attributes.
 I could get additional information from the LDAP server (using 
 python-ldap) if I knew the user name; however, the only entry I see in 
 Auth
  that 
 provides similar information is Auth.user_id, and I don't know how this ID 
 maps to the current user's LDAP username.

 More generally, is there a good way for me to take control of my 
 application's interaction with our LDAP server, while still leveraging the 
 many built-ins Auth has to offer?
 Should I modify the ldap_auth login_method to store the username and 
 password information in the session object?
 Should I write my own custom login_method? If so, what resources exist 
 to help me along?

>>>

[web2py] Re: How to display reference field in sqltable?

2012-03-09 Thread Edward Shave
Many, many thanks for that. I ran your fix and now all is present and 
correct.

Thanks again,
Ed

On Friday, 9 March 2012 07:01:25 UTC, nick name wrote:
>
> On Thursday, March 8, 2012 8:52:34 PM UTC-5, Edward Shave wrote:
>>
>> Many thanks for reply, unfortunately it didn't work in this instance... I 
>> wonder if it is because the table is referencing itself?
>
>
> By coincidence, I noticed the same problem earlier myself and opened 
> ticket #700 http://code.google.com/p/web2py/issues/detail?id=700 .
>
> It's not just self-referencing tables; it's referencing any table that has 
> not yet been defined. I also posted a more general solution in the ticket. 
>


[web2py] Re: db.mytable.myfield.represent= ???

2012-03-09 Thread Edward Shave
Hi Anthony,

Many thanks for the detailed reply. It seems I had my head on backwards 
when I penned the question. I should explain I am new to both web2py and 
python...

After reading your reply the scales have lifted from my eyes and all is 
clear.

My only defence for wasting your time is the remaining ambiguity regards 
the input parameters in the book. I do believe the book could benefit by 
the inclusion of your words as quoted below...

*"represent" should be a callable that takes two arguments. When the field 
in question is being represented (e.g., in a SQLFORM or SQLTABLE), the 
field value will be passed to the represent function as the first argument, 
and the entire row object that contains the field value will be passed as 
the second argument. The function itself can then do whatever you want with 
those two arguments to generate a representation of the field.*

Thanks again,
Ed.


Re: [web2py] Web2py + uWSGI and timeouts!!

2012-03-09 Thread Phyo Arkar
Only uWSGI is used and no HTTP.

I have posted my setup details on other thread.

On Fri, Mar 9, 2012 at 4:12 AM, Roberto De Ioris  wrote:

>
> > When i check i got this error :
> >
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> >
> > 7.
> > 8.
> > 9.
> > 10.
> > 11.
> >
> > Traceback (most recent call last):
> >
> >   File "/home/v3ss/WorkSpace/FastTract/web2py/gluon/main.py", line
> > 447, in wsgibase
> >
> > parse_get_post_vars(request, environ)
> >   File "/home/v3ss/WorkSpace/FastTract/web2py/gluon/main.py", line
> > 275, in parse_get_post_vars
> >
> > request.body = copystream_progress(request) ### stores request body
> >
> >   File "/home/v3ss/WorkSpace/FastTract/web2py/gluon/main.py", line
> > 143, in copystream_progress
> >
> > copystream(source, dest, size, chunk_size)
> >
> >   File "/home/v3ss/WorkSpace/FastTract/web2py/gluon/fileutils.py",
> > line 376, in copystream
> >
> > data = src.read(chunk_size)
> > IOError: error waiting for wsgi.input data
> >
> >
> >
>
> If you are on chrome + https on cherokee, it will not works. it is a
> cherokee bug, you can try with latest svn snapshot (iirc it has been fixed
> there)
>
> --
> Roberto De Ioris
> http://unbit.it
>