Re: [web2py] keyError

2015-10-03 Thread 'DenesL' via web2py-users
[x['countryCode'] for x in location_data['postalcodes']]

will give you an array of the country codes in location_data, but note that 
you could have duplicated entries.

If you don't want duplicates you could do:

cc=[]
for x in location_data['postalcodes']:
  c=x['countryCode']
  if c not in cc:
cc.append(c)

Denes.




On Saturday, October 3, 2015 at 8:39:31 PM UTC-4, Alex Glaros wrote:
>
> Hi Denes,
>
> sorry, I want all the countries.  For example, if zip, is 95694, it exists 
> in more than one country,  I display all countries and let user choose 
> their country.
>
> What is syntax for all?  I've tried a million combinations, read 
> tutorials, and cannot find examples in discussion groups.
>
> "your_country" is the query for a grid.
>
> thanks,
>
> Alex
>

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


Re: [web2py] keyError

2015-10-03 Thread Alex Glaros
Hi Denes,

sorry, I want all the countries.  For example, if zip, is 95694, it exists 
in more than one country,  I display all countries and let user choose 
their country.

What is syntax for all?  I've tried a million combinations, read tutorials, 
and cannot find examples in discussion groups.

thanks,

Alex

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


Re: [web2py] keyError

2015-10-03 Thread 'DenesL' via web2py-users

The location_data received from geoNames can contain more than one country 
code, your first sample has 3: MK DE US.
Your second sample has only one: MX

By the name of the variable being used (your_country) I assume you want to 
get only one postalcode.
In any case you could use:

location_data['postalcodes'][0]['countryCode']

which gives you the countryCode of the first entry (check if there is at 
least one before hand).

Denes

On Saturday, October 3, 2015 at 2:31:48 PM UTC-4, Alex Glaros wrote:
>
> Single item works Laer,
>
> your_country = (db.Country.countryCode == 
> location_data['postalcodes'][5]['countryCode'])
>
> how can all of the values be accessed? See my guess below:
>
> your_country = (db.Country.countryCode == location_data['postalcodes'][ALL
> ]['countryCode'])
>
> thanks,
>
> Alex
>

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


[web2py] login_bare custom validation

2015-10-03 Thread 'DenesL' via web2py-users
Hello all,

Trying to do a custom validation using login_bare, which I have never 
needed before, but I get a ticket shown below, it includes the minimalist 
code to reproduce it.
The view just shows the form.

Using authentication by username: 
auth.define_tables(username=True, signature=False)

 'LazyCrypt' object has no attribute 
'__getitem__' web2py™ Version 2.12.3-stable+timestamp.2015.08.19.00.18.03 
Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.

Traceback (most recent call last):
  File "C:\w2p\web2py_21203_src\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 34, 
in 
  File "C:\w2p\web2py_21203_src\gluon\globals.py", line 412, in 
self._caller = lambda f: f()
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 13, 
in user
if form.validate(onvalidation=uservalidate, hideerror=True):
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 2238, in validate
if self.accepts(**kwargs):
  File "C:\w2p\web2py_21203_src\gluon\sqlhtml.py", line 1496, in accepts
**kwargs
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 2139, in accepts
call_as_list(onvalidation, self)
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 146, in call_as_list
item(*a, **b)
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 26, 
in uservalidate
user = auth.login_bare(u, p)
  File "C:\w2p\web2py_21203_src\gluon\tools.py", line 2352, in login_bare
settings.passfield].validate(password)[0]
  File "C:\w2p\web2py_21203_src\gluon\packages\dal\pydal\objects.py", line 
1625, in validate
(value, error) = validator(value)
  File "C:\w2p\web2py_21203_src\gluon\validators.py", line 2850, in __call__
value = value and value[:self.max_length]
TypeError: 'LazyCrypt' object has no attribute '__getitem__'

In file: C:\w2p\web2py_21203_src\applications\test\controllers/bare.py 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.

# -*- coding: utf-8 -*-
auth.settings.remember_me_form = False
auth.settings.login_url = URL 
('bare','user', args='login')


@auth.requires_login()
def index():
  return {}


def user():
  form = auth()
  if form.validate(onvalidation=uservalidate, hideerror=True):
redirect (URL 
('bare', 'index'))
  elif form.errors:
response .flash = ' 
'.join(form.errors.values())
  return {'form':form}



def uservalidate(f):
  u = f.vars.username or ''
  p = f.vars.password or ''
  print 'u: %s, p: %s' %(u,p)
  if u and p:
user = auth.login_bare(u, p)
print user
if not user:
  f.errors.password = 'Invalid Password'
return user
  else:
return False

response ._vars=response 
._caller(user)


Thanks for any hints,
Denes

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


Re: [web2py] keyError

2015-10-03 Thread Alex Glaros
Single item works Diogene

your_country = (db.Country.countryCode == 
location_data['postalcodes'][5]['countryCode'])

how all of the values be accessed. See my guess below:

your_country = (db.Country.countryCode == location_data['postalcodes'][ALL
]['countryCode'])

thanks,

Alex

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


[web2py] Re: API

2015-10-03 Thread Anthony
If you would like to access the web2py API from a module, see 
http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules.

Anthony

On Saturday, October 3, 2015 at 11:08:31 AM UTC-4, PAVAN DHAVALESWARAPU 
wrote:
>
> How can I use API in web2py modules ?
>

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


Re: [web2py] API

2015-10-03 Thread Kiran Subbaraman

Can you provide more details - which API are you talking about?
Are you thinking of creating APIs for your web2py application - see this 
for some ideas: 
http://web2py.com/books/default/chapter/29/10/services?search=REST#Remote-procedure-calls, 
and 
http://web2py.com/books/default/chapter/29/10/services?search=REST#Restful-Web-Services
[OR] intend to use the web APIs of other applications within your web2py 
application?



Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Sat, 03-10-2015 2:23 PM, PAVAN DHAVALESWARAPU wrote:

How can I use API in web2py modules ?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google 
Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to web2py+unsubscr...@googlegroups.com 
.

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


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] keyError

2015-10-03 Thread 'Diogene Laerce' via web2py-users
Hi Alex,

Le 03/10/2015 16:52, Alex Glaros a écrit :
> Can someone please tell me what is wrong with syntax?
>
> Below is result of API data from geoNames.org
>
> location_data =
>
> |
>  {u'postalcodes':[{u'placeName':u'Del
> Pante\xf3n',u'countryCode':u'MX',u'adminName3':u'Juan Rodr\xedguez
> Clara',u'lat':19.8537498,u'postalcode':u'95694',u'lng':-97.16653,u'adminName1':u'Veracruz
> de Ignacio de la Llave',u'adminName2':u'Juan Rodr\xedguez
> Clara',u'adminCode1':u'VER',u'adminCode2':u'094',u'adminCode3':u'27'},{u'placeName':u'Feliciano
> Ceballos',u'countryCode':u'MX',u'adminName3':u'Juan Rodr\xedguez
> Clara',u'lat':19.8537498,u'postalcode':u'95694',u'lng':-97.16653,u'adminName1':u'Veracruz
> de Ignacio de la Llave',u'adminName2':u'Juan Rodr\xedguez
> Clara',u'adminCode1':u'VER',u'adminCode2':u'094',u'adminCode3':u'27'},{u'placeName':u'La
> Bomba',u'countryCode':u'MX',u'adminName3':u'Juan Rodr\xedguez
> Clara',u'lat':19.43944,u'postalcode':u'95694',u'lng':-96.814169,u'adminName1':u'Veracruz
> de Ignacio de la Llave',u'adminName2':u'Juan Rodr\xedguez
> Clara',u'adminCode1':u'VER',u'adminCode2':u'094',u'adminCode3':u'27'},{u'placeName':u'Las
> Mercedes',u'countryCode':u'MX',u'adminName3':u'Juan Rodr\xedguez
> Clara',u'lat':20.26806,u'postalcode':u'95694',u'lng':-97.51889,u'adminName1':u'Veracruz
> de Ignacio de la Llave',u'adminName2':u'Juan Rodr\xedguez
> Clara',u'adminCode1':u'VER',u'adminCode2':u'094',u'adminCode3':u'27'},{u'placeName':u'Mehlmeisel',u'countryCode':u'DE',u'adminName3':u'Bayreuth',u'lat':49.9667,u'postalcode':u'95694',u'lng':11.85,u'adminName1':u'Bayern',u'adminName2':u'Oberfranken',u'adminCode1':u'BY',u'adminCode2':u'094',u'adminCode3':u'09472'},{u'placeName':u'Winters',u'countryCode':u'US',u'lat':38.5322,u'postalcode':u'95694',u'lng':-121.9676,u'adminName2':u'Yolo',u'adminCode1':u'CA',u'adminCode2':u'113',u'adminName1':u'California'}]}
> |
>
> When I run this
>
> |
> your_country =(db.Country.countryCode ==location_data['countryCode'])
> |
>
> I get 
>
>
>  'countryCode'
>
> your_country = (db.Country.countryCode == 
> location_data['countryCode'])KeyError: 'countryCode'

If I get it right you should access it with :

location_data['postalcodes'][1]['countryCode']


>
> Can someone type this into their controller and show me the syntax for
> manipulating individual items so I can see the syntax?  E.g., 
>
> location_data =  {u'postalcodes': [{u'placeName': u'Del
> Pante\xf3n', u'countryCode': u'MX', u'adminName3': u'Juan
> Rodr\xedguez
> Clara', u'lat': 19.8537498, u'postalcode': u'95694', u'lng': 
> -97.16653, u'adminName1': u'Veracruz
> de Ignacio de la Llave', u'adminName2': u'Juan Rodr\xedguez
> Clara', u'adminCode1': u'VER', u'adminCode2': u'094', u'adminCode3': 
> u'27'}]}
>
> your_country = location_data['countryCode']
>

Have a look at this : http://sthurlow.com/python/lesson06/

Good luck,

-- 
“One original thought is worth a thousand mindless quotings.”
“Le vrai n'est pas plus sûr que le probable.”

  Diogene Laerce


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


signature.asc
Description: OpenPGP digital signature


[web2py] Re: Web2py celery plugin

2015-10-03 Thread Luis Valladares
But how can you exec a web2py task (who may uses web2py internal components 
like Request, response, db, etc..) with a external celery app? i mean, if i 
wish to execute a task, for example: To insert a new register in a table of 
my web2py database, and in enqueue this task to a remote (or local) celery 
worker to do it, how i can get this worker to know about all the 
"environment" of web2py? the only idea i have its creating a worker that is 
aware of the web2py environment, but i dont know how to do this.

There is anyway to use celery queue to execute tasks that requires the 
web2py environment?

El viernes, 2 de octubre de 2015, 5:46:35 (UTC-4:30), Niphlod escribió:
>
> I'd say you're loosing yourself in a glass of water. In order to schedule 
> something, that something must work. If your "something" doesn't, it really 
> doesn't matter what tool are you issuing commands to.
>
> On Friday, October 2, 2015 at 11:56:55 AM UTC+2, Stefan van den Eertwegh 
> wrote:
>>
>> Hi Niphlod,
>>
>> Thanks for you answer.
>>
>> Why i am asking this is because i want to generate around 150 pdf's by 
>> weasyprint and per each pdf i want to queue a mail with it as an attachment.
>> Could this be done by the build in web2py Scheduler?
>>
>> PS: i tried the scheduler, but it tries to use the generic.html view but 
>> has not enough settings provided in the layout.html to use it, it fails.
>> is is not so that it executes the function from the model with database 
>> privileges and not uses a view? Or is it also using the default generic 
>> view?
>>
>> Thanks for responding!
>>
>> Best regards,
>> Stefan
>>
>> Op vrijdag 2 oktober 2015 11:21:07 UTC+2 schreef Niphlod:
>>>
>>> you won't ever get to start workers from web2py, either with the 
>>> embedded scheduler, with rq or with celery.that's pretty much a 
>>> requirement (being completely separated)
>>>
>>> PS: celery integration was done on a so old release of celery that it 
>>> won't ever be production ready
>>>
>>> PS2: you don't need any web2py plugin to push task to celery.
>>>
>>>
>>>

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


[web2py] Re: Interact Web2Py App with Android App Security

2015-10-03 Thread Luis Valladares
What if you create a small REST service for login? in the case of login it 
can be a get request which sends the username and password (PREVIOUSLY 
HASHED) check if it exist in web2py database and return 1 if exists, 0 if 
it doesnt exist.

You can connect to the rest service through HTTP request, you can read more 
about web2py services here: 
http://web2py.com/books/default/chapter/29/10/services#Restful-Web-Services

El viernes, 2 de octubre de 2015, 16:36:25 (UTC-4:30), Fábio Filho escribió:
>
> I'm sorry by my english
>
> How can i connect my android application in my web2py site using auth 
> authentication (@auth.requires_login)?
>
> I need make a secure connection between them
>
> for example: 
>
>
> Web2Py Side :
>
> @auth.requires_login()
> def get_examplet():
> return "{'code':'0'}"
>
>
>
>
> Android Java side: 
>
> new Thread(){
>   
>   @Override
>   public void run(){
>   
> Http.request("localhost:8080/mysite/controller/get_example") ; 
>  //  < i got a refused connection because that python line code 
> ("@auth.requires_login()"),
>   
>  //so of course that is expected 
> because i need to be logged in to make this request   
>   
>  // when a remove that python line code 
> above ("@auth.requires_login()"), i take it perfectly  
>
>}
>
> }.start();
>
>
>
> How can i do this above? 
>
>
>

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


[web2py] Re: Error: widgetId is a required parameter (2.12.2)

2015-10-03 Thread Massimo Di Pierro
what is widget.js? It does not come with web2py.

On Monday, 28 September 2015 04:58:10 UTC-5, Dennis Bauszus wrote:
>
> Web2py version 2.12.2.
>
> The admin site is throwing* Error: widgetId is a required parameter* from 
> the widget.js library.
>
> This is caused by the twitter-timeline link tag being inside a 
> twitter-timeline container element.
>
> This confuses the widget extraction code as noted in this post 
>  
> on the twitter community.
>
> I am only starting to work with web2py so I don't really understand where 
> the container name is defined within the web2py code.
>
>
> 
>
>
>
>

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


[web2py] Re: Interact Web2Py App with Android App Security

2015-10-03 Thread Fábio Filho
i thought i can use this session in my schema... 
but really, i have no idea what i need to do ...

i read something about base authentication in Web2Py,  is this helpful?





Em sexta-feira, 2 de outubro de 2015 19:47:09 UTC-3, Niphlod escreveu:
>
> what authentication do you want to support ? web2py's default use session 
> cookies, but you need to get to the login page and obtain one before 
> hitting a protected page 
>
> On Friday, October 2, 2015 at 11:06:25 PM UTC+2, Fábio Filho wrote:
>>
>> I'm sorry by my english
>>
>> How can i connect my android application in my web2py site using auth 
>> authentication (@auth.requires_login)?
>>
>> I need make a secure connection between them
>>
>> for example: 
>>
>>
>> Web2Py Side :
>>
>> @auth.requires_login()
>> def get_examplet():
>> return "{'code':'0'}"
>>
>>
>>
>>
>> Android Java side: 
>>
>> new Thread(){
>>   
>>   @Override
>>   public void run(){
>>   
>> Http.request("localhost:8080/mysite/controller/get_example") 
>> ;  //  < i got a refused connection because that python line code 
>> ("@auth.requires_login()"),
>>   
>>  //so of course that is expected 
>> because i need to be logged in to make this request   
>>   
>>  // when a remove that python line code 
>> above ("@auth.requires_login()"), i take it perfectly  
>>
>>}
>>
>> }.start();
>>
>>
>>
>> How can i do this above? 
>>
>>
>>

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


[web2py] Re: Web2py/Apache accessible via multiple host names

2015-10-03 Thread Michael Suelmann
Hello Niphlod,

The double WSGIScriptAlias is because the web2py apps aren't the only thing 
served by apache, so I can't just alias everything to wsgihandler.py. 
Actualy there are some more WSGIScriptAlias as there are more web2py apps 
on the server.
Anyway, I did a test with just the following WSGIScriptAlias:
WSGIScriptAlias / /var/wsgi/web2py/wsgihandler.py
And the result was the same.

Greetings
Michael

Am Samstag, 3. Oktober 2015 00:45:50 UTC+2 schrieb Niphlod:
>
> remove the double wsgiscriptalias.
> Or trade apache for nginx + uwsgi. Less headaches for everybody.
>
> On Friday, October 2, 2015 at 11:06:26 PM UTC+2, Michael Suelmann wrote:
>>
>> Hello,
>>
>> I'm running web2py 2.12.3-stable on Fedora 22 with apache-2.4.16, 
>> python-2.7.10 and use the following config lines for WSGI:
>> WSGIDaemonProcess default display-name=%{GROUP}
>> WSGIProcessGroup default
>> WSGIScriptAlias /welcome /var/wsgi/web2py/wsgihandler.py/welcome
>> WSGIScriptAlias /examples /var/wsgi/web2py/wsgihandler.py/examples
>> ...
>>
>> The server is reachable via multiple host names, like example.com and 
>> www.example.com. All should show the same content, so I use just one 
>>  in the apache config.
>>
>> If I restart apache and go to https://example.com/welcome all is fine. 
>> If I go to https://www.example.com/welcome after that I get the 
>> following error:
>>
>> Traceback (most recent call last):
>>   File "/var/wsgi/web2py/gluon/main.py", line 436, in wsgibase
>> session.connect(request, response)
>>   File "/var/wsgi/web2py/gluon/globals.py", line 960, in connect
>> session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
>>   File "/var/wsgi/web2py/gluon/storage.py", line 56, in 
>> __getnewargs__ = lambda self: getattr(dict,self).__getnewargs__(self)
>> TypeError: getattr(): attribute name must be string
>>
>>
>> After restarting apache again I can access https://www.example.com/welcome 
>> fine but https://example.com/welcome will then cause the error. This 
>> happens with all web2py apps.
>>
>> What can I do to get this to work except of redirecting all host names to 
>> one version?
>>
>> Greetings
>> Michael
>>
>>
>>

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


[web2py] Re: Interact Web2Py App with Android App Security

2015-10-03 Thread Relsi Maron

Enable basic authentication [1 

]:

auth.settings.allow_basic_login = True


so:

https://user:password@http://localhost:8080/mysite/controller/get_example




[1] 
http://www.web2py.com/books/default/chapter/29/09/access-control#Access-Control-and-Basic-Authentication








Em sexta-feira, 2 de outubro de 2015 18:06:25 UTC-3, Fábio Filho escreveu:
>
> I'm sorry by my english
>
> How can i connect my android application in my web2py site using auth 
> authentication (@auth.requires_login)?
>
> I need make a secure connection between them
>
> for example: 
>
>
> Web2Py Side :
>
> @auth.requires_login()
> def get_examplet():
> return "{'code':'0'}"
>
>
>
>
> Android Java side: 
>
> new Thread(){
>   
>   @Override
>   public void run(){
>   
> Http.request("localhost:8080/mysite/controller/get_example") ; 
>  //  < i got a refused connection because that python line code 
> ("@auth.requires_login()"),
>   
>  //so of course that is expected 
> because i need to be logged in to make this request   
>   
>  // when a remove that python line code 
> above ("@auth.requires_login()"), i take it perfectly  
>
>}
>
> }.start();
>
>
>
> How can i do this above? 
>
>
>

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


[web2py] API

2015-10-03 Thread PAVAN DHAVALESWARAPU
How can I use API in web2py modules ?

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


[web2py] keyError

2015-10-03 Thread Alex Glaros
Can someone please tell me what is wrong with syntax?

Below is result of API data from geoNames.org

location_data =

 {u'postalcodes': [{u'placeName': u'Del Pante\xf3n', u'countryCode': u'MX', 
u'adminName3': u'Juan Rodr\xedguez Clara', u'lat': 19.8537498, u
'postalcode': u'95694', u'lng': -97.16653, u'adminName1': u'Veracruz de 
Ignacio de la Llave', u'adminName2': u'Juan Rodr\xedguez Clara', u
'adminCode1': u'VER', u'adminCode2': u'094', u'adminCode3': u'27'}, {u
'placeName': u'Feliciano Ceballos', u'countryCode': u'MX', u'adminName3': 
u'Juan 
Rodr\xedguez Clara', u'lat': 19.8537498, u'postalcode': u'95694', u
'lng': -97.16653, u'adminName1': u'Veracruz de Ignacio de la Llave', u
'adminName2': u'Juan Rodr\xedguez Clara', u'adminCode1': u'VER', u
'adminCode2': u'094', u'adminCode3': u'27'}, {u'placeName': u'La Bomba', u
'countryCode': u'MX', u'adminName3': u'Juan Rodr\xedguez Clara', u'lat': 
19.43944, u'postalcode': u'95694', u'lng': -96.814169, u'adminName1'
: u'Veracruz de Ignacio de la Llave', u'adminName2': u'Juan Rodr\xedguez 
Clara', u'adminCode1': u'VER', u'adminCode2': u'094', u'adminCode3': u'27'}, 
{u'placeName': u'Las Mercedes', u'countryCode': u'MX', u'adminName3': u'Juan 
Rodr\xedguez Clara', u'lat': 20.26806, u'postalcode': u'95694', u'lng': -
97.51889, u'adminName1': u'Veracruz de Ignacio de la Llave', u'adminName2': 
u'Juan Rodr\xedguez Clara', u'adminCode1': u'VER', u'adminCode2': u'094', u
'adminCode3': u'27'}, {u'placeName': u'Mehlmeisel', u'countryCode': u'DE', u
'adminName3': u'Bayreuth', u'lat': 49.9667, u'postalcode': u'95694', u'lng': 
11.85, u'adminName1': u'Bayern', u'adminName2': u'Oberfranken', u
'adminCode1': u'BY', u'adminCode2': u'094', u'adminCode3': u'09472'}, {u
'placeName': u'Winters', u'countryCode': u'US', u'lat': 38.5322, u
'postalcode': u'95694', u'lng': -121.9676, u'adminName2': u'Yolo', u
'adminCode1': u'CA', u'adminCode2': u'113', u'adminName1': u'California'}]}

When I run this

your_country = (db.Country.countryCode == location_data['countryCode'])

I get 
 'countryCode'

your_country = (db.Country.countryCode == location_data['countryCode'])
KeyError: 'countryCode'


Can someone type this into their controller and show me the syntax for 
manipulating individual items so I can see the syntax?  E.g., 

location_data =  {u'postalcodes': [{u'placeName': u'Del Pante\xf3n', u
'countryCode': u'MX', u'adminName3': u'Juan Rodr\xedguez Clara', u'lat': 
19.8537498, u'postalcode': u'95694', u'lng': -97.16653, u
'adminName1': u'Veracruz de Ignacio de la Llave', u'adminName2': u'Juan 
Rodr\xedguez Clara', u'adminCode1': u'VER', u'adminCode2': u'094', u
'adminCode3': u'27'}]}

your_country = location_data['countryCode']


thanks,

Alex

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


[web2py] Re: Interact Web2Py App with Android App Security

2015-10-03 Thread Leonel Câmara

>
> Http.request("localhost:8080/mysite/controller/get_example") ; 
>  //  < i got a refused connection because that python line code 
> ("@auth.requires_login()"),
>   
>  //so of course that is expected 
> because i need to be logged in to make this request   
>   
>  // when a remove that python line code 
> above ("@auth.requires_login()"), i take it perfectly


localhost?

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


[web2py] Re: alias field names

2015-10-03 Thread 黄祥
perhaps you can use dal alias
ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Self-Reference-and-aliases

best regards,
stifan

On Saturday, October 3, 2015 at 3:03:45 PM UTC+7, Nguyen Minh Tuan wrote:
>
> Hi all,
>
> My situation is that I have to work with already defined tables.
> There is a field name 'pass', this is keyword of Python, I don't how to 
> solve this.
> So I think alias for table field is necessary.
>
> Anyone can suggest for this situation?
> Thanks in advance!
>
> Regards,
> Tuan.
>

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


[web2py] Re: alias field names

2015-10-03 Thread Nguyen Minh Tuan
Hi all,

My situation is that I have to work with already defined tables.
There is a field name 'pass', this is keyword of Python, I don't how to 
solve this.
So I think alias for table field is necessary.

Anyone can suggest for this situation?
Thanks in advance!

Regards,
Tuan.

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