[web2py] Re: AWS Lambda Deployment Recipe

2019-09-17 Thread Jaime Sempere
Hi Mike,

I've been following your recipe, but I have an 'read-only file system 
issue' (I think is due that I did not set up a database and web2py is 
trying to create the datatables files)


So, can you give me some clues about it? Also, how should i set up and 
configure my rds to work with web2py? I have not noticed anything about it 
on the recipe.

Check my log error from Zappa:

[1568721920013] [ERROR] 2019-09-17T12:05:20.12Z 
75fc21f1-e92e-4c80-ada1-a3e042112bf3 Traceback (most recent call last):
  File "/var/task/gluon/restricted.py", line 219, in restricted
  exec(ccode, environment)
  File "/var/task/applications/zerca_maps/models/db.py", line 179, in 

  Field('registered', 'boolean', default=False),
  File "/var/task/gluon/packages/dal/pydal/base.py", line 590, in 
define_table
  table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "/var/task/gluon/packages/dal/pydal/base.py", line 624, in 
lazy_define_table
  polymodel=polymodel)
  File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 798, in 
create_table
  return self.migrator.create_table(*args, **kwargs)
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 318, in 
create_table
  fake_migrate=fake_migrate
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 463, in 
migrate_table
  self.save_dbt(table, sql_fields_current)
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 472, in 
save_dbt
  tfile = self.file_open(table._dbt, 'wb')
  File "/var/task/gluon/packages/dal/pydal/migrator.py", line 495, in 
file_open
  fileobj = portalocker.LockedFile(filename, mode)
  File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
185, in __init__
  self.file = open_file(filename, mode.replace('w', 'a'))
  File "/var/task/gluon/packages/dal/pydal/contrib/portalocker.py", line 
170, in open_file
  f = open(filename, mode)
IOError: [Errno 30] Read-only file system: 
'/var/task/applications/zerca_maps/databases/c
*8b669d15150d7109e5f7ab36744a5b7_retailers.table*'

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c9ca824e-da0d-4c26-8dfc-573b7de4a2f7%40googlegroups.com.


[web2py] Re: AWS Lambda Deployment Recipe

2019-08-20 Thread Jaime Sempere
That's receipe is great, thanks for the work.

One thing that I have not seen is which database are you using? I think 
with Zappa you need to use RDS, at least that's what I have seen with 
Django apps.

So, I would like to ask you two questions:

1) Can you confirm about the database (is a RDS)?
2) After this time using Zappa+web2py for Lambda... is it a robust and 
mantainable environment? Have you confronted any important issues?

I am asking #2, because for me lambda + web2py would be a win-win, but I 
find it somekind of 'mixing too much environments/framework'... I smell 
danger xD So, I would like to know if I can use it as a 'robust/final' 
solution for my projects.

Thanks in advance


El miércoles, 28 de noviembre de 2018, 20:06:34 (UTC+1), appj...@gmail.com 
escribió:
>
> Thank you Anthony, I added the wsgibase wrapper after my initial post.  I 
> was modifying gluon/main.py but I added the wrapper (lambda_handler.py) to 
> avoid that.
>
> I confirmed which environ variables are coming through as unicode and 
> submitted an issue to zappa.
> https://github.com/Miserlou/Zappa/issues/1713
>
> I'll also modify the recipe to make it more clear that this is likely a 
> zappa and not a web2py issue.
>
> On Wednesday, November 28, 2018 at 8:39:51 AM UTC-6, Anthony wrote:
>>
>> On Tuesday, November 27, 2018 at 6:51:54 PM UTC-5, appj...@gmail.com 
>> wrote:
>>>
>>> I've created a first pass at an AWS Lambda deployment recipe which uses 
>>> an open-source tool called Zappa.
>>>
>>> I welcome any comments or suggested improvements.  In particular, step 3 
>>> requires modifying gluon/main.py which I would like to avoid.
>>>
>>
>> I wouldn't say that is modifying gluon/main.py -- it is simply providing 
>> a wrapper around gluon.main.wsgibase. In fact, the web2py gaehandler.py 
>> handler does something very similar: 
>> https://github.com/web2py/web2py/blob/master/handlers/gaehandler.py#L83.
>>
>> Note, according to PEP , strings passed to the server should not be 
>> unicode: https://www.python.org/dev/peps/pep-/#unicode-issues.
>>
>> Actually, it looks like Zappa is already handling this here: 
>> https://github.com/Miserlou/Zappa/blob/master/zappa/wsgi.py#L110 (see 
>> also, https://github.com/Miserlou/Zappa/blob/master/zappa/wsgi.py#L110). 
>> Perhaps there is still some unicode getting through from Zappa, so maybe 
>> you can open an issue with Zappa.
>>
>> Anthony
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4c9685ed-a3c9-4ceb-856d-7fe7f6a9fe17%40googlegroups.com.


[web2py] Re: Multitenant static generator blog

2018-10-22 Thread Jaime Sempere
Thx a lot for the tip, Anthony.

And how could I map the folder to the customer's custom domain? Using an 
ALIAS register?


El lunes, 22 de octubre de 2018, 15:23:20 (UTC+2), Anthony escribió:
>
> If you are serving static sites, you do not want to use web2py to serve 
> the files but should instead configure the front end web server (e.g., 
> Nginx) to serve the files directly. In that case, though, there is no 
> particular reason the files need to go inside the /static folder of a 
> web2py app -- you can put them anywhere on the filesystem.
>
> Anthony
>
> On Sunday, October 21, 2018 at 9:22:05 AM UTC-4, Jaime Sempere wrote:
>>
>> Hello to everyone,
>>
>> I need some tips of how to approach a new project that I want to develop.
>>
>> I would like to build a static generator, every user would be able to 
>> build his/her own blog using my CMS built with web2py.
>>
>> I would plan to build static pages and leaving them on static/ folder. 
>> Maybe every user could have his own folder inside of static, like:
>>
>> static/username/index
>> static/username/category/
>> static/username/page/
>> static/username/title-of-post-1
>>
>> and so on... (maybe I could split in subfolders starting by username 
>> first letter -for not hitting max folders limit in a possible future, like:
>>
>> static/a/alessandro/index
>>/category
>>/page
>> 
>>
>> Every user should be able to use his own custom domain and point to his 
>> own folder.
>>
>> I mean: johndoe.com/index should point to static/j/johndoe/index
>>
>>
>> How could I achieve these requirements with web2py? Could you point me a 
>> little to this? Also, I always mess with CNAME, ALIAS registers, and so 
>> on... what kind of registers should I need? Would I need to create 
>> registers for every user? Which kind?
>>
>> Thanks a lot, I really need some tips here.
>>
>> Jaime
>>
>

-- 
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: just for the records: API rest with basic auth

2018-10-21 Thread Jaime Sempere
I guess you are right, it shouldn't be a raise, but it works. I dont know 
how exactly should I return a 200 using this api rest approach, any 
comment/advice is welcome.

Thanks

El martes, 16 de octubre de 2018, 1:26:36 (UTC+2), Dave S escribió:
>
>
>
> On Sunday, October 14, 2018 at 7:05:56 AM UTC-7, Jaime Sempere wrote:
>>
>> Hi,
>>
>> I have had a lot of problems to set up an API REST with basic auth, 
>> finally I have used the next code, I left it here for anyone that may need 
>> it:
>>
>> from gluon.serializers import json
>> auth.settings.allow_basic_login = True
>>
>>
>> @request.restful()
>> def api():
>>
>> response.view = 'generic.json'
>> response.headers["Access-Control-Allow-Origin"] = '*'
>> response.headers['Access-Control-Max-Age'] = 86400
>> response.headers['Access-Control-Allow-Headers'] = '*'
>> response.headers['Access-Control-Allow-Methods'] = '*'
>> response.headers['Access-Control-Allow-Credentials'] = 'true'
>>
>> @auth.requires_login()
>> def GET(id):
>> return json(get_post_if_user_belongs_to_blog(id, auth))
>>
>> @auth.requires_login()
>> def PUT(id, **fields):
>> return get_post_if_user_belongs_to_blog(id, 
>> auth).update_record(**fields)
>>
>> @auth.requires_login()
>> def POST(*args, **fields):
>> return db.posts.validate_and_insert(blog_id=auth.user.blog_id, 
>> user_id=auth.user.id, **fields)
>>
>> @auth.requires_login()
>> def DELETE(id):
>> get_post_if_user_belongs_to_blog(id, auth).delete_record()
>> return dict(action="deleted", status="ok", id=id)
>>
>> def OPTIONS(args, **vars):
>> print 'doing post options'
>> headers = {"Access-Control-Allow-Origin": '*', 
>> 'Access-Control-Max-Age': 86400,
>>'Access-Control-Allow-Headers': '*', 
>> 'Access-Control-Allow-Methods': '*',
>>'Access-Control-Allow-Credentials': 'true'}
>> raise HTTP(200, **headers)
>>
>> return locals()
>>
>>
>> def get_post_if_user_belongs_to_blog(id, auth):
>> my_post = db.posts[id]
>> if my_post.blog_id != auth.user.blog_id:
>> return 'not authorized'
>> return my_post
>>
>>
>> Forget about most part of the code and pay attention to annotations.
>>
>> Maybe I am not 100% right in all the approach, but this is what I have 
>> needed:
>>
>> - OPTIONS need to be without authentication, so I have removed 
>> @auth.requires_login from main methond (def api()) and I have annotated the 
>> GET,PUT,POST and DELETE methods.
>> - I have needed to set up headers on OPTIONS too, for avoiding CORS issues
>>
>> I hope that this can helps to anybody. I plan to move basic auth to JWT 
>> or another auth method.
>>
>> Thanks!
>>
>
>
> Why is OPTIONS doing a raise HTTP if the status you're setting is 200?
>
> /dps
>  
>

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


[web2py] Multitenant static generator blog

2018-10-21 Thread Jaime Sempere
Hello to everyone,

I need some tips of how to approach a new project that I want to develop.

I would like to build a static generator, every user would be able to build 
his/her own blog using my CMS built with web2py.

I would plan to build static pages and leaving them on static/ folder. 
Maybe every user could have his own folder inside of static, like:

static/username/index
static/username/category/
static/username/page/
static/username/title-of-post-1

and so on... (maybe I could split in subfolders starting by username first 
letter -for not hitting max folders limit in a possible future, like:

static/a/alessandro/index
   /category
   /page


Every user should be able to use his own custom domain and point to his own 
folder.

I mean: johndoe.com/index should point to static/j/johndoe/index


How could I achieve these requirements with web2py? Could you point me a 
little to this? Also, I always mess with CNAME, ALIAS registers, and so 
on... what kind of registers should I need? Would I need to create 
registers for every user? Which kind?

Thanks a lot, I really need some tips here.

Jaime

-- 
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] just for the records: API rest with basic auth

2018-10-14 Thread Jaime Sempere
Hi,

I have had a lot of problems to set up an API REST with basic auth, finally 
I have used the next code, I left it here for anyone that may need it:

from gluon.serializers import json
auth.settings.allow_basic_login = True


@request.restful()
def api():

response.view = 'generic.json'
response.headers["Access-Control-Allow-Origin"] = '*'
response.headers['Access-Control-Max-Age'] = 86400
response.headers['Access-Control-Allow-Headers'] = '*'
response.headers['Access-Control-Allow-Methods'] = '*'
response.headers['Access-Control-Allow-Credentials'] = 'true'

@auth.requires_login()
def GET(id):
return json(get_post_if_user_belongs_to_blog(id, auth))

@auth.requires_login()
def PUT(id, **fields):
return get_post_if_user_belongs_to_blog(id, 
auth).update_record(**fields)

@auth.requires_login()
def POST(*args, **fields):
return db.posts.validate_and_insert(blog_id=auth.user.blog_id, 
user_id=auth.user.id, **fields)

@auth.requires_login()
def DELETE(id):
get_post_if_user_belongs_to_blog(id, auth).delete_record()
return dict(action="deleted", status="ok", id=id)

def OPTIONS(args, **vars):
print 'doing post options'
headers = {"Access-Control-Allow-Origin": '*', 
'Access-Control-Max-Age': 86400,
   'Access-Control-Allow-Headers': '*', 
'Access-Control-Allow-Methods': '*',
   'Access-Control-Allow-Credentials': 'true'}
raise HTTP(200, **headers)

return locals()


def get_post_if_user_belongs_to_blog(id, auth):
my_post = db.posts[id]
if my_post.blog_id != auth.user.blog_id:
return 'not authorized'
return my_post


Forget about most part of the code and pay attention to annotations.

Maybe I am not 100% right in all the approach, but this is what I have 
needed:

- OPTIONS need to be without authentication, so I have removed 
@auth.requires_login from main methond (def api()) and I have annotated the 
GET,PUT,POST and DELETE methods.
- I have needed to set up headers on OPTIONS too, for avoiding CORS issues

I hope that this can helps to anybody. I plan to move basic auth to JWT or 
another auth method.

Thanks!

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


[web2py] Just a silly thread to say... thanks to all web2py developers team

2018-02-09 Thread Jaime Sempere
Hi,

this is gonna sound a littile silly, but I have been wanting to publish a 
thread like this from years ago.

I just wanna say to Massimo and all the web2py developers one thing: 
thanks. Thanks a lot.

I love web2py and I enjoy programming and developing with it.

I can notice all the effort and all the work you have made to create a 
super simple, easy, fun, and good programmed framework for web2py.

Everytime I need to develop a new personal project, I always choose web2py 
if I can.

I see magic and simplicity in every aspect of web2py. I could not imagine a 
quicker framework than web2py.

And everytime I need to do something new, when I look to the book, I always 
find a very easy and simple way to do it. And that's something I love: I 
find that you have worked a lot to build something simple and powerful. 
Programming should be like that: simple, non verbose, and fun.

And by the way, vim and web2py make a wonderful team. I feel like a super 
fanatic boy of both of them...

Well I do not know if this sounds too foolish, but I just want to say to 
all the members that made and make web2py a solid framework that: thanks, 
my respects and keep making this framework a reality.

Plus, this group is wonderful support.

Well, that's enough. For a last time, thanks to all of you.

Jaime

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


[web2py] How to integrate sendgrid or similar for 'password reset' mail

2016-05-06 Thread Jaime Sempere

Hi, 

I am using last web2py version but for any reason I am not able of sending 
email from GAE. I am just trying the forget password mail but after giving 
my email to the form, I am only redirected to login and I dont receive any 
mail

I am using this settings:

mail.settings.server = 'gae'
mail.settings.sender = 'mygaeadminem...@gmail.com'
mail.settings.login =  'mygaeadminem...@gmail.com:password'

I think that's all. But I have not have any success.

Anyway I dont like the mail support of google app engine because I would 
like to use my custom domain mail. So... I am thinking of using sendgrid or 
sparkpost for this... but I dont have any idea of where to start. I have 
been taking a look to Mail class on gluon tools... do I need to rewrite 
this class? Can I hook the action of send reset password any other place 
and then using sendgrid web api?

Thanks a lot for any clue about it.

-- 
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: Trying to build a post api.

2016-02-14 Thread Jaime Sempere
Just for future viewers:

I have needed to wrap the answer into a response.json() to be able to parse 
the response in the client:

this works for me :

return 
response.json(db.Questions.validate_and_insert(**fields))

this doesnt work :

return db.Questions.validate_and_insert(**fields)

(in this case the answer just says 'errorsid')


-- 
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: Static files inside of folder with spaces (url encoding)

2015-12-09 Thread Jaime Sempere
Yes, that's my problem the web2py server looks like he is not able to 
handle spaces on static paths to access those files... any other advice?


El miércoles, 9 de diciembre de 2015, 14:31:36 (UTC+1), Anthony escribió:
>
> Are you serving web2py via the built-in server? If not, you can configure 
> your web server (e.g., nginx or Apache) to server static files directly.
>
> Anthony
>
>>
>>

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


[web2py] Static files inside of folder with spaces (url encoding)

2015-12-08 Thread Jaime Sempere
Hi,

I am trying to put some files inside of folder with a space (i.e: static/my 
things/), but I am not been able to handle on web2p, when I try to access 
the files on that folder. 

It doesn't matter  how I encode the url (I tried to replace the ' ' for 
'%20') it keeps saying 'invalid request'. 

I have read that web2py does not like spaces in folder... so is this a 
'bug' known and 'accepted' or is there any workaround to handle this?

Thanks in advance

PS: I am working on a music project, each folder will be an album (for 
example 'Abbey Road'), and inside of this folder I will have the files. I 
would like to copy/paste folders without editing spaces. Plus, I would use 
the folder's name to feed the database.

-- 
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: GAE: BadRequestError: projection and keys_only cannot both be set

2015-08-22 Thread Jaime Sempere

Done!

El domingo, 23 de agosto de 2015, 2:10:27 (UTC+2), Massimo Di Pierro 
escribió:
>
> Can you please open a pydal issue about this?
>
> On Friday, 21 August 2015 18:44:02 UTC-5, Jaime Sempere wrote:
>>
>> Hi,
>>
>>
>> Im using web2py 2.9.12, Im developing on local gae, and when I tried to 
>> execute this query:
>>
>> pics = db(db.pics.user_id==user_id).select(db.pics.img_link, 
>> projection=True 
>>,orderby=~db.pics.up_date, limitby=(num_min, num_max))
>>
>>
>> I got that error 
>>
>>  WARNING  2015-08-21 23:40:54,728 tasklets.py:410] suspended generator 
>> run_to_queue(query.py:938) raised BadRequestError(projection and keys_only 
>> cannot both be set)
>> WARNING  2015-08-21 23:40:54,729 tasklets.py:410] suspended generator 
>> helper(context.py:876) raised BadRequestError(projection and keys_only 
>> cannot both be set)
>> WARNING  2015-08-21 23:40:54,729 tasklets.py:410] suspended generator 
>> has_next_async(query.py:1760) raised BadRequestError(projection and 
>> keys_only cannot both be set)
>> WARNING  2015-08-21 23:40:54,730 tasklets.py:410] suspended generator 
>> _fetch_page_async(query.py:1349) raised BadRequestError(projection and 
>> keys_only cannot both be set)
>> ERROR2015-08-21 23:40:54,736 restricted.py:69]  Unable to store in 
>> FILE: 
>> /home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py
>>
>> Traceback (most recent call last):
>>   File "/home/jukvoxman/uweb2py2.9.12/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py", 
>> line 224, in 
>>   File "/home/jukvoxman/uweb2py2.9.12/gluon/globals.py", line 412, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py", 
>> line 82, in getPicsRangeByUserId
>> projection=True,orderby=~db.pics.up_date, limitby=(num_min, 
>> num_max))
>>   File 
>> "/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/objects.py", line 
>> 2026, in select
>> return adapter.select(self.query,fields,attributes)
>>   File 
>> "/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/adapters/google_adapters.py",
>>  
>> line 484, in select
>> (items, tablename, fields) = self.select_raw(query,fields,attributes)
>>   File 
>> "/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/adapters/google_adapters.py",
>>  
>> line 449, in select_raw
>> keys, cursor, more = items.fetch_page(limit,**fetch_args)
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/utils.py", line 
>> 142, in positional_wrapper
>> return wrapped(*args, **kwds)
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
>> 1331, in fetch_page
>> return self.fetch_page_async(page_size, **q_options).get_result()
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
>> line 326, in get_result
>> self.check_success()
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
>> line 369, in _help_tasklet_along
>> value = gen.throw(exc.__class__, exc, tb)
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
>> 1349, in _fetch_page_async
>> while (yield it.has_next_async()):
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
>> line 369, in _help_tasklet_along
>> value = gen.throw(exc.__class__, exc, tb)
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
>> 1760, in has_next_async
>> yield self._fut
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/context.py", 
>> line 876, in helper
>> batch, i, ent = yield inq.getq()
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
>> 938, in run_to_queue
>> batch = yield rpc
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
>> line 455, in _on_rpc_completion
>> result = rpc.get_result()
>>   File 
>> "/home/jukvoxman/google_appengine/google/appengine/api/apiproxy

[web2py] GAE: BadRequestError: projection and keys_only cannot both be set

2015-08-21 Thread Jaime Sempere
Hi,


Im using web2py 2.9.12, Im developing on local gae, and when I tried to 
execute this query:

pics = db(db.pics.user_id==user_id).select(db.pics.img_link, 
projection=True 
   ,orderby=~db.pics.up_date, limitby=(num_min, num_max))


I got that error 

 WARNING  2015-08-21 23:40:54,728 tasklets.py:410] suspended generator 
run_to_queue(query.py:938) raised BadRequestError(projection and keys_only 
cannot both be set)
WARNING  2015-08-21 23:40:54,729 tasklets.py:410] suspended generator 
helper(context.py:876) raised BadRequestError(projection and keys_only 
cannot both be set)
WARNING  2015-08-21 23:40:54,729 tasklets.py:410] suspended generator 
has_next_async(query.py:1760) raised BadRequestError(projection and 
keys_only cannot both be set)
WARNING  2015-08-21 23:40:54,730 tasklets.py:410] suspended generator 
_fetch_page_async(query.py:1349) raised BadRequestError(projection and 
keys_only cannot both be set)
ERROR2015-08-21 23:40:54,736 restricted.py:69]  Unable to store in 
FILE: 
/home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py

Traceback (most recent call last):
  File "/home/jukvoxman/uweb2py2.9.12/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py", 
line 224, in 
  File "/home/jukvoxman/uweb2py2.9.12/gluon/globals.py", line 412, in 

self._caller = lambda f: f()
  File 
"/home/jukvoxman/uweb2py2.9.12/applications/relatos/controllers/default.py", 
line 82, in getPicsRangeByUserId
projection=True,orderby=~db.pics.up_date, limitby=(num_min, 
num_max))
  File "/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/objects.py", 
line 2026, in select
return adapter.select(self.query,fields,attributes)
  File 
"/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/adapters/google_adapters.py",
 
line 484, in select
(items, tablename, fields) = self.select_raw(query,fields,attributes)
  File 
"/home/jukvoxman/uweb2py2.9.12/gluon/packages/dal/pydal/adapters/google_adapters.py",
 
line 449, in select_raw
keys, cursor, more = items.fetch_page(limit,**fetch_args)
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/utils.py", line 
142, in positional_wrapper
return wrapped(*args, **kwds)
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
1331, in fetch_page
return self.fetch_page_async(page_size, **q_options).get_result()
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
line 326, in get_result
self.check_success()
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
line 369, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
1349, in _fetch_page_async
while (yield it.has_next_async()):
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
line 369, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
1760, in has_next_async
yield self._fut
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/context.py", 
line 876, in helper
batch, i, ent = yield inq.getq()
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/query.py", line 
938, in run_to_queue
batch = yield rpc
  File 
"/home/jukvoxman/google_appengine/google/appengine/ext/ndb/tasklets.py", 
line 455, in _on_rpc_completion
result = rpc.get_result()
  File 
"/home/jukvoxman/google_appengine/google/appengine/api/apiproxy_stub_map.py", 
line 613, in get_result
return self.__get_result_hook(self)
  File 
"/home/jukvoxman/google_appengine/google/appengine/datastore/datastore_query.py",
 
line 2897, in __query_result_hook
self._batch_shared.conn.check_rpc_success(rpc)
  File 
"/home/jukvoxman/google_appengine/google/appengine/datastore/datastore_rpc.py", 
line 1373, in check_rpc_success
raise _ToDatastoreError(err)
BadRequestError: projection and keys_only cannot both be set




I have set and index on img_link row (pics entity) like this to be able to 
make the projection query on this row:

- kind: pics
  properties:
  - name: user_id
  - name: img_link
  - name: up_date
direction: desc


But still no luck... is this a bug or could someone give me a workaround to 
fix it?

Thanks in advance!

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


[web2py] Re: auth.settings.registration_requires_approval has no effect

2015-08-19 Thread Jaime Sempere

Im using same web2py version and python 2.7.x

My db.py works (user is inserted on db marked as 'pending') with this 
configuration:

from gluon.tools import Auth, Service, PluginManager

auth = Auth(db)

service = Service() plugins = PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.settings.login_after_registration = False
auth.settings.reset_password_requires_verification = True


Try with all this configuration to see if it works...


El miércoles, 19 de agosto de 2015, 15:22:32 (UTC+2), Karl-Thomas Schmidt 
escribió:
>
> Hi@ all, 
>
> Having this lines in db.py 
> auth = Auth(db) 
> auth.settings.registration_requires_approval = True 
> auth.settings.login_after_registration = False 
> a new registration immediatly logs in and corresponding db field is still 
> empty. 
>
> Running 2.11.2-stable+timestamp.2015.05.30.16.33.24 (Running on 
> nginx/1.2.1, 
> Python 2.7.3) 
>
> What do i miss here? 
>
>
>

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


Re: [web2py] Re: creating a taggable post with upload field

2015-08-19 Thread Jaime Sempere

Dont worry, I learned to do it too thanks to your question, plus I have 
learned a new cool term... 'RTFM' question xD... Manual has a lot of 
details that sometimes is easy to miss.

Anyway is always good to return some of the help to this group (this group 
rocks by the way :) )


El miércoles, 19 de agosto de 2015, 19:12:55 (UTC+2), Carlos Cesar 
Caballero escribió:
>
> Works perfectly, many thaks for your answer in a RTFM-like question...
>
> El 18/08/15 a las 15:31, Jaime Sempere escribió:
>
>
> I have just checked a side project that I did today, and noticed that I 
> wasnt able to see the pic either. I have been able to fix it using the 
> upload field:
>
> form = SQLFORM(db.person, record, upload=URL('download'))
>
>
> I simply added that : upload=URL('download') to my SQLFORM() syntax and 
> it worked. But I dont think it will work on create, just on updates 
> (because you wont able to see the pic until is submitted, so it wouldnt be 
> possible to see it on create).
>
> Give it a try
>
>
>
> El martes, 18 de agosto de 2015, 17:47:43 (UTC+2), Carlos Cesar Caballero 
> escribió: 
>>
>> Hi, I am creatig a blog app and I am having a problem with the grid, when 
>> I create or update a post, the post image is never visible in the form (the 
>> form show that there is no image), but everything is ok in the db, I 
>> supouse that is something related with the code for tagging, there is my 
>> view code:
>>
>> {{if 'edit' in request.args or 'new' in request.args:
>> value = ', '.join(tags)tags_field = DIV(LABEL(T('Tags')+':', 
>> _class='control-label col-sm-3'), DIV(INPUT(_name='tags',value=value, 
>> _class='form-control string'), _class='col-sm-9'), _class='form-group')
>> grid[0].insert(-1, tags_field)pass}}
>> {{=grid}}
>>
>>
>> and my controller:
>>
>> def posts():
>> db.post.created_by.readable = Truedb.post.created_on.readable = True 
>>db.post.modified_by.readable = Truedb.post.modified_on.readable = 
>> Trueposts_query = (db.post.created_by == auth.user_id)
>> create_post = Falseif auth.has_membership('admin') or 
>> auth.has_membership('editor'):
>> posts_query = db.post
>>
>> if auth.has_membership('admin') or auth.has_membership('editor') or 
>> auth.has_membership('author'):
>> create_post = Truegrid = SQLFORM.grid(posts_query, 
>> orderby=~db.post.created_on,fields=[db.post.lang, 
>> db.post.title, db.post.published, db.post.created_on],   
>>  paginate=10, create=create_post,)
>>
>> if request.args(0) in ['edit']:
>> db.post.created_on.readable = Truepost = 
>> db.post(request.args(2))
>> form = SQLFORM(db.post, post)
>> if form.process().accepted:
>> new_tags = [tag.strip() for tag in request.vars.tags.split(',')]
>> post.update_tags(new_tags)
>> response.flash = T("Post Updated")
>> return dict(grid=form, tags=post.tags)
>>
>> if request.args(0) in ['new']:
>> form = SQLFORM.factory(db.post)
>> post_tags = []
>> if form.process().accepted:
>> post_id = db.post.insert(**db.post._filter_fields(form.vars))
>> post = db(db.post.id == post_id).select().first()
>> new_tags = [tag.strip() for tag in request.vars.tags.split(',')]
>> post.update_tags(new_tags)
>> post_tags = post.tags
>> redirect(URL('dashboard', 'posts'))
>> return dict(grid=form, tags=post_tags)
>>
>> return dict(grid=grid)
>>
>> and the model:
>>
>> """Post model file""""""Table definition"""import 
>> redb.define_table('post',Field('lang', label=T('Language')), 
>>Field('title', unique=True, label=T('Title')),
>> Field('url', unique=True, label=T('URL')),Field('abstract', 
>> 'text', label=T('Abstract')),Field('body', 'text', 
>> widget=ckeditor.widget, label=T('Body')),Field('image', 
>> 'upload', autodelete=True, 

[web2py] Re: creating a taggable post with upload field

2015-08-18 Thread Jaime Sempere

I have just checked a side project that I did today, and noticed that I 
wasnt able to see the pic either. I have been able to fix it using the 
upload field:

form = SQLFORM(db.person, record, upload=URL('download'))


I simply added that : upload=URL('download') to my SQLFORM() syntax and it 
worked. But I dont think it will work on create, just on updates (because 
you wont able to see the pic until is submitted, so it wouldnt be possible 
to see it on create).

Give it a try



El martes, 18 de agosto de 2015, 17:47:43 (UTC+2), Carlos Cesar Caballero 
escribió:
>
> Hi, I am creatig a blog app and I am having a problem with the grid, when 
> I create or update a post, the post image is never visible in the form (the 
> form show that there is no image), but everything is ok in the db, I 
> supouse that is something related with the code for tagging, there is my 
> view code:
>
> {{if 'edit' in request.args or 'new' in request.args:
> value = ', '.join(tags)tags_field = DIV(LABEL(T('Tags')+':', 
> _class='control-label col-sm-3'), DIV(INPUT(_name='tags',value=value, 
> _class='form-control string'), _class='col-sm-9'), _class='form-group')
> grid[0].insert(-1, tags_field)pass}}
> {{=grid}}
>
>
> and my controller:
>
> def posts():
> db.post.created_by.readable = Truedb.post.created_on.readable = True  
>   db.post.modified_by.readable = Truedb.post.modified_on.readable = True  
>   posts_query = (db.post.created_by == auth.user_id)
> create_post = Falseif auth.has_membership('admin') or 
> auth.has_membership('editor'):
> posts_query = db.post
>
> if auth.has_membership('admin') or auth.has_membership('editor') or 
> auth.has_membership('author'):
> create_post = Truegrid = SQLFORM.grid(posts_query, 
> orderby=~db.post.created_on,fields=[db.post.lang, 
> db.post.title, db.post.published, db.post.created_on],
> paginate=10, create=create_post,)
>
> if request.args(0) in ['edit']:
> db.post.created_on.readable = Truepost = 
> db.post(request.args(2))
> form = SQLFORM(db.post, post)
> if form.process().accepted:
> new_tags = [tag.strip() for tag in request.vars.tags.split(',')]
> post.update_tags(new_tags)
> response.flash = T("Post Updated")
> return dict(grid=form, tags=post.tags)
>
> if request.args(0) in ['new']:
> form = SQLFORM.factory(db.post)
> post_tags = []
> if form.process().accepted:
> post_id = db.post.insert(**db.post._filter_fields(form.vars))
> post = db(db.post.id == post_id).select().first()
> new_tags = [tag.strip() for tag in request.vars.tags.split(',')]
> post.update_tags(new_tags)
> post_tags = post.tags
> redirect(URL('dashboard', 'posts'))
> return dict(grid=form, tags=post_tags)
>
> return dict(grid=grid)
>
> and the model:
>
> """Post model file""Table definition"""import 
> redb.define_table('post',Field('lang', label=T('Language')),  
>   Field('title', unique=True, label=T('Title')),
> Field('url', unique=True, label=T('URL')),Field('abstract', 
> 'text', label=T('Abstract')),Field('body', 'text', 
> widget=ckeditor.widget, label=T('Body')),Field('image', 
> 'upload', autodelete=True, label=T('Image')),
> Field('published', 'boolean', default=True, label=T('Published')),
> Field('show_title', 'boolean', default=True, label=T('Show title')),  
>   Field('show_comments', 'boolean', default=True, label=T('Show 
> comments')),Field('close_comments', 'boolean', default=False, 
> label=T('Close comments')),Field('show_tags', 'boolean', 
> default=True, label=T('Show tags')),auth.signature,   
>  )
> # post image thumbnailsthumb.create(db.post.image, (175, 175), 
> use_imageops=True)
> # Make table sercheablesearch.create(db.post.body)"""Virtual and method 
> fields"""# get post tags objectsdb.post.get_post_tags = Field.Method(lambda 
> row: [post_tag for post_tag
> in db(db.post_tags.post_id == 
> row.post.id).select()])
> # virtual field for post tagsdb.post.tags = Field.Virtual(lambda row: 
> [post_tag.tag_id.name for post_tag
> in db(db.post_tags.post_id == 
> row.post.id).select()])
>
> # update post tagsdef _(row, new_tags):
> self = row.post
> db(db.post_tags.post_id == self.id).delete()
> for tag in new_tags:
> if tag:
> if not db((db.tags.name == tag) & (db.tags.lang == 
> self.lang)).select():
> db.tags.insert(name=tag, lang=self.lang)
> tag_id = db((db.tags.name == tag) & (db.tags.lang == 
> self.lang)).select().first().id
> db.post_tags.insert(pos

[web2py] Re: GAE unicodeDecodeError: 'ascii' codec can't decode byte... unable to fix it

2015-08-18 Thread Jaime Sempere
Hi, 

thanks a lot for the help Paollo, I have tried that but the error is still 
there with the development version. But... I have been able to 'fix it' 

I went to _compat.py line 27 and just print the obj:

if not isinstance(obj, unicode):
print obj
return unicode(obj)


which printed this:

pbkdf2(1000,20,sha512)$b8b00733df3c78b5$d38f7cc89b3b3b7ecae02c062b6497cfbe5a0037
Grupo asignado únicamente al usuario 5865619656278016

Notice the damned 'ú' on that string. Im from Spain, and that string comes 
from es.py ... I just remove that ú for a u... and finally the error is 
gone

I dont have any idea of what this is doing exactly, and if I should to 
worry (I dont think so)... but any extra information would be good to know.


-- 
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: Proposal: Documentation in form of a wiki

2015-08-17 Thread Jaime Sempere
I like the idea. I think we would need something like web2pyslices but in a 
more modern/updated way... and easy to contribute. Web2py has a lot of 
details very good to know but difficult to learn or to get. Also it would 
be great to be able to upload litlle projects (I have just implemented some 
days ago a multifile upload solution, I took some posts from this group and 
adapt it a lot, and I would have liked to share the 'final' solution in an 
easy way)...

well ideas, ideas... any super hero wanna take the flag? :)



El lunes, 17 de agosto de 2015, 12:40:18 (UTC+2), Najtsirk escribió:
>
> Hi,
>
> I was wondering: would it be ok to have a documentation in form of a wiki 
> or something so anybody can contribute to it? And sure...Massimo has to 
> confirm it before publishing it.
>
> My idea goes in this way: if i get my problem solved here on google 
> groups, I will be willing to contribute a short article to wiki about it. 
> Maybe wouldn't be a perfect solutions but somebody else could build upon it 
> and make better example.
>
> Best,
> Najtsirk
>

-- 
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] GAE unicodeDecodeError: 'ascii' codec can't decode byte... unable to fix it

2015-08-17 Thread Jaime Sempere
Hi,

I am having problems when I try to deploy my app on local SDK GAE.

I can start the app on my local gae, but when I try to register first user, 
after fill the form and press submit, I got this:

Traceback (most recent call last):
  File "/home/jukvoxman/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File 
"/home/jukvoxman/web2py/applications/relatos/controllers/default.py", line 
219, in 
  File "/home/jukvoxman/web2py/gluon/globals.py", line 412, in 
self._caller = lambda f: f()
  File 
"/home/jukvoxman/web2py/applications/relatos/controllers/default.py", line 
196, in user
return dict(form=auth())
  File "/home/jukvoxman/web2py/gluon/tools.py", line 1594, in __call__
return getattr(self, args[0])()
  File "/home/jukvoxman/web2py/gluon/tools.py", line 2901, in register
self.settings.create_user_groups % form.vars, description)
  File "/home/jukvoxman/web2py/gluon/tools.py", line 3636, in add_group
role=role, description=description)
  File "/home/jukvoxman/web2py/gluon/packages/dal/pydal/objects.py", line 
691, in insert
ret = self._db._adapter.insert(self, self._listify(fields))
  File 
"/home/jukvoxman/web2py/gluon/packages/dal/pydal/adapters/google_adapters.py", 
line 549, in insert
dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields)
  File 
"/home/jukvoxman/web2py/gluon/packages/dal/pydal/adapters/google_adapters.py", 
line 549, in 
dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields)
  File 
"/home/jukvoxman/web2py/gluon/packages/dal/pydal/adapters/google_adapters.py", 
line 171, in represent
obj = NoSQLAdapter.represent(self, obj, fieldtype)
  File "/home/jukvoxman/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 1858, in represent
obj = to_unicode(obj)
  File "/home/jukvoxman/web2py/gluon/packages/dal/pydal/_compat.py", line 
27, in to_unicode
return unicode(obj)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: 
ordinal not in range(128)


I have done everything: look for other posts, I have deleted any special 
character found on my code (0xc3 is supposed to be an Á, which is strange 
because I have not found any of them on code), deleted the 'list:strings' 
fields, and so on I have tried with 2.11.2 version and the just 
released one.

I have tried a lot of things, but I have just given up... could any one 
give some light on my issue? 

I'd really appreciate it. Thanks in advance!

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


[web2py] Re: routes.py confusion

2014-05-26 Thread Jaime Sempere

I guess you did not reload routes.py... from the admin panel there is a 
botton that says "reload routes.py"... other option (I guess you did this) 
is restart web2py server

El martes, 27 de mayo de 2014 05:23:46 UTC+2, Jesse Ferguson escribió:
>
> It seems to be working now... I guess it just takes a while to kick in??
>

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


[web2py] Re: routes.py confusion

2014-05-26 Thread Jaime Sempere

Theorically that should do the trick, and mywebsite.com should load your 
index page. Just silly question, do you have index.html and def index():

Btw, maybe you are checking in it in no-local server (i mean 'live' server, 
internet server, or whatever is called), and you are using the general 
template layout (which is not allowed in no-local server)... check if it 
works local, and if it works local and not in your 'live' server 99% is due 
to you are using the general template layout. Just create a index.html




El martes, 27 de mayo de 2014 00:08:20 UTC+2, Jesse Ferguson escribió:
>
> I deployed my app using the nginx script and created a routes.py file like 
> so:
>
> # -*- coding: utf-8 -*-
>>
>>
>>> routers = dict(
>>
>> BASE = dict(
>>
>> default_application='myapp', )
>>
>> )
>>
>>
>>
> However when i go to mywebsite.com  i get 
> "invalid request" 
>
> but mywebsite.com/myapp  loads the application... how can i change this 
> behavior so the application is at the domains root ie: mywebsite.com?
>
>
>
>

-- 
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: Verify password does not fit formstyle

2014-05-26 Thread Jaime Sempere

>
> Hi Annet, 
>

that looks very nice, but doesn't change anything in my case (same html).

Could you copy and past all your definition of def bootstrap3(form, fields) 
?

The problem is that verify passwords fields (label & input) are not wrapped 
with  like other input fields, leaving him outside 
of the patter style.

Thanks in advance!

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


[web2py] Verify password does not fit formstyle

2014-05-25 Thread Jaime Sempere
Hi,

I am having the same issue pointed here by Ricardo Pedroso:

https://groups.google.com/forum/#!searchin/web2py/verify$20password$20style/web2py/ZzRYjegMHw8/8iHikvlR23sJ


See, I use this:

auth.settings.formstyle='bootstrap3'

for making the register form in bootstrap style but verify password field 
is not styled by bootstrap, which leaves the form awful. Is there any quick 
fix to this other than hack js or custom css?

Thanks in advance

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


[web2py] Re: Failing importing .py module that imports .c file

2014-04-10 Thread Jaime Sempere
Thanks a lot, Niphlod!

I didn't know that about GAE, my "excuses".

You rock, web2py rocks, and this group rocks :)

El miércoles, 9 de abril de 2014 23:12:02 UTC+2, Niphlod escribió:
>
> simply put, GAE doesn't allow any python package that includes c 
> extensions. 
>
> usually, there are alternatives for "famous" packages that solve with pure 
> python what c extensions do in the "original" package. A simple google 
> search for "tweepy gae" brought up this 
> https://github.com/firelabi/tweepy-gae
>
> On Wednesday, April 9, 2014 10:33:04 PM UTC+2, Jaime Sempere wrote:
>>
>>
>> Hi,
>>
>> I am using Tweepy which uses ssl, and developing on GAE. 
>>
>> I donwload Tweepy and put the folder on /modules... then it failed due to 
>> I needed ssl module too. I did the same, and then it failed again:
>>
>> ImportError: Cannot import module '_ssl2'
>>
>> _ssl2 is a .c file that is in /modules/ssl/_ssl2.c
>>
>>
>> I think web2py is looking for python module instead of _ssl2.c
>>
>> How could I solve this?
>>
>>
>> Thanks a lot in advance
>>
>

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


[web2py] Failing importing .py module that imports .c file

2014-04-09 Thread Jaime Sempere

Hi,

I am using Tweepy which uses ssl, and developing on GAE. 

I donwload Tweepy and put the folder on /modules... then it failed due to I 
needed ssl module too. I did the same, and then it failed again:

ImportError: Cannot import module '_ssl2'

_ssl2 is a .c file that is in /modules/ssl/_ssl2.c


I think web2py is looking for python module instead of _ssl2.c

How could I solve this?


Thanks a lot in advance

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


[web2py] Re: Displaying computed data from form submission

2014-01-24 Thread Jaime Sempere
I still don't see where are you storing them or where you would like to 
show them... Where should appear them? In the form?

El viernes, 24 de enero de 2014 21:53:31 UTC+1, Chris Hepworth escribió:
>
> I feel ridiculous admitting this, but I didn't realize I had omitted the 
> code saving them into the global variables. The result set doesn't need to 
> be persistent, so storing it to the database would be unnecessary. It will 
> only be displayed to the user once.
>
> On Friday, January 24, 2014 1:38:01 PM UTC-7, Jaime Sempere wrote:
>>
>>
>> Maybe I am wrong, but i think you are not storing the images. When you do 
>> :
>>
>> form=FORM(fields, onvalidation=qrparse)
>>
>> Did you guessed qrparse return values are being stored in form or 
>> somewhere?
>>
>> You need to store in a cookie, global variable (and then show them in the 
>> view using {{=}}) or maybe save in in the form like a prepopulate field (I 
>> don't know where you want to show the images).
>>
>> Could you tell us where would you like to show the images?
>>
>

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


[web2py] Re: Warning about using web2py URL rewrite?

2014-01-24 Thread Jaime Sempere

That link is outdated, check 
this: http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite

And for  www.example.com/someapp/default/index to www.example.com/

you only need to do:

routers = dict(
  BASE  = dict(default_application='someapp'),
)

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


[web2py] Re: Displaying computed data from form submission

2014-01-24 Thread Jaime Sempere

You are not storing the images. When you do :

form=FORM(fields, onvalidation=qrparse)

Did you guessed qrparse return values are being stored in form or somewhere?

You need to store in a cookie, global variable, or maybe in the form (I 
don't know where you want to show the images).

Could you tell us where would you like to show the images?

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


[web2py] "How much" can be cached?

2014-01-23 Thread Jaime Sempere

I would like to cache every row of my database table, in order to be able 
to do updates based in the key query.

This would be my table:

channel :string (Unique)
id_playing: integer
tstart: integer
duration:integer
order: integer


The querys are like this:   db(db.mytable.channel==channel).select().first(), 
based on the channel string.


I would be interested in clearing/updating the rows cached, using "channel" 
like the key (i.e. erase the cache with the key channel=rock). 

Could I use cache for this? I have never used any type of cache, so I 
really don't have any idea about this. I have read that this is not the 
usual scenary (I understand the usual would be erasing all the cache, or 
storing just a few values)... Someone could give me some hints about this 
or any other approach that I could use?

I guess my application is not gonna be the next viral app, but just in 
case... how many rows could I cache... which order or gap? Betwen 100-1k, 
1k-10k... 100k...1M? 

I know it's a vague question and can depends a lot of server and so on... 
but I don't have any clue, so some points would be apreciated. 

Another question would be about using ram or disk... I gues ram is not very 
advisable for this purpose... so the question would be, caching in disk is 
only limited by the space of your server?

Thanks and sorry if it seems too foolish question


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


[web2py] Re: Baffling Problem with Email Verification

2014-01-23 Thread Jaime Sempere

This could be 
related: 
https://groups.google.com/forum/#!searchin/web2py/gmail/web2py/CU_1qWYixjI/A2IuDsRDJ_oJ

(Although you said that email works in another app which is weird)

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


[web2py] Re: How to change SQLFORM values after submission and then show the form again?

2014-01-22 Thread Jaime Sempere
Damn... I forgot the 
link:  
https://groups.google.com/forum/#!searchin/web2py/prepopulate$20form/web2py/GF2sDS7uWi8/x8SVU09CFIoJ

El jueves, 23 de enero de 2014 02:07:19 UTC+1, Jaime Sempere escribió:
>
>
> I don't understand completely the flow of the process...  do you have two 
> submitt buttons, one for "autocomplete" and the other for "final submit?
>
> I am not very sure, but here are my thoughts: What I would do is use 
> SQLFORM.factory something like this:
>
> new_post_form = SQLFORM.factory(db.posts)
> if new_thread_form.process().accepted:
>  if (autocomplete):
>   Do your process, and save it in the form.vars
>  else: 
>   Do the final update using db().update()
>
>
>
>
> And check this topic too to return the prepolutaded form, keeping the 
> values that you processed after "if (autocomplete)"
>

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


[web2py] Re: Important New Year News: Edison Award

2014-01-22 Thread Jaime Sempere

Good luck! And glad to hear news like this. I am using again web2py and I 
am loving it. It was long time ago since I didn't enjoy programming so 
much. And I think you can see almost everywhere of 'him' the effort of the 
creators for develope something easy and fast to use. So.. as everyone say 
best wishes, Massimo & web2py community!

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


[web2py] Re: How to change SQLFORM values after submission and then show the form again?

2014-01-22 Thread Jaime Sempere

I don't understand completely the flow of the process...  do you have two 
submitt buttons, one for "autocomplete" and the other for "final submit?

I am not very sure, but here are my thoughts: What I would do is use 
SQLFORM.factory something like this:

new_post_form = SQLFORM.factory(db.posts)
if new_thread_form.process().accepted:
 if (autocomplete):
  Do your process, and save it in the form.vars
 else: 
  Do the final update using db().update()




And check this topic too to return the prepolutaded form, keeping the 
values that you processed after "if (autocomplete)"

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


[web2py] Can someone clarify me about routes_in and out?

2014-01-19 Thread Jaime Sempere

Hi, 

I am having some doubts about routes.py

I going to explain what I think I understand:

routes_in = (
  ('/', '/welcome/default/'),
)

This will maplocalhost:8000to  localhost:8000/welcome/default. 


What about routes_out?

routes_out = (
  ('/welcome/default/','/'),
)

I guess this is for doing the oppossite and rewrite the url, i.e., someone 
writes localhost:8000/welcome/default   and the url is rewritten as 
localhost:8000/, isn't it? 


If I am right with this assumption, routes_out is not working for me, the 
browser doesn't rewrite the url to localhost:8000.

If I am wrong... I still would like to find something for rewriting the url.

Thanks!
 


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


[web2py] Re: How to update the whole column after new insert

2014-01-19 Thread Jaime Sempere

Thanks a lot (and it was great adding support for several playlist), just 
for future reference there is a small typo on db definition: 
'playlist_name' should be 'playlist_title'

But I wanted to ask you... I would change the query:

  query = db.playlist.playlist_title==record.playlist_title

for this

  query = db.playlist.id==record.id


Shouldn't this be a little more efficient? Is there any particular reason 
for not re-writing like that? I guess in real cases there is no differences 
on performance, but I just want to know that if could do that without any 
side-effect.

thanks again

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


[web2py] Re: How can I use a view in combination with a service ?

2014-01-19 Thread Jaime Sempere

Damn... I click reply to the author (which sends him an email) instead to 
post the answer here... and he replied to me... I just leave the answers 
here for reference:



I found another solution, without services:
in the html
Link

and in the controler
   ID   = int ( request.args [0] )

cheers,
Stef

On 19-01-14 4:37, Jaime Sempere wrote:


I have just discovered "services" in web2py xD

When I needed to pass a parameter via link is in the classic way:
yourlink.com?myvar=value <http://yourlink.com/?myvar=value>

and then you can grab them using   value=request.vars.myvar


Thats what you want to accomplish?

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


[web2py] Re: automatically count field edits

2014-01-18 Thread Jaime Sempere


> I'm trying to automatically count each time a record is being updated. I 
> could make a lambda function that worked for a dictionary:
> Field('edits', 'integer', compute=lambda r: int(r['edits'] or 0) + 1 ),
>
> However, I don't get this to work in practice. Can a lambda for edits not 
> use its own value?
>

I think you are right in that point, from book:


   - compute is an optional function. If a record is inserted or updated, 
   the compute function will be executed and the field will be populated with 
   the function result. The record is passed to the compute function as a 
   dict, and *the dict will not include the current value of that, or any 
   other compute field.*

 

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


[web2py] Re: call a function inside the same view

2014-01-18 Thread Jaime Sempere

I think you are mixing concepts you cannot return something from 
process().accepted, you need to return at the end of your "tracer_form()" 
function, is the function who returns things. In the proccess().accepted 
you can do some operations, and modify variables that will be later 
returned by the function (like response.flash)

I would do this:

{{extend 'layout.html'}}
Tracking
{{=form}}

{{=grid}}

{{=BEAUTIFY(request.vars)}}  http://127.0.0.1:8000/WnD/default/show_form";>Show Records -- this is a 
link to show_form()
 


def tracker_form():
record = db.content(request.args(0))
show_record = request.args(0)
form = SQLFORM(db.content, record)
grid = None
if form.process().accepted:
response.flash = 'Submitted Successfully!'
response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
#show_form function here!
grid=SQLFORM.grid(db.content)

elif form.errors:
response.flash = 'Form is not correct'

else:
response.flash = 'Please fill out the damn form'

   
return dict(form=form, grid = grid)


def show_form(results):
return dict(grid=SQLFORM.grid(db.content))


This is if you want to hide the grid in the beggining and show it only 
after submission. If you want to show the grid from the beggining just move 
the line of grid = SQLFORM(...) where grid= None


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


[web2py] Re: Update table data on form submission

2014-01-18 Thread Jaime Sempere

>
>
> I have tried this and work, let me know if it's the think you wanted. I 
have used SQLFORM but i guess the code will be the same for CRUD (I have 
never used it)

Just my workaround, I think there will be a better method perhaps
 
import time   # This is required to include time module.
import datetime


db.define_table(  'sample',
   Field('end_time','integer'),
   Field('duration','integer'),
   Field('mytimestamp','datetime', readable=False,
 writable=False)
   )

form = SQLFORM(db.sample)
if form.process().accepted:
  response.flash = 'form accepted'
  db(db.sample.id == 
form.vars.id).update(mytimestamp=datetime.datetime.now())


return dict(form=form)

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


[web2py] How to update the whole column after new insert

2014-01-18 Thread Jaime Sempere

Hi everyone,

Although I have used database serveral times, I have not done anything 
beyond very basic, so I am wondering what would be the best practice for 
this case:


I have a database table for storing a 'real-time' playlist of songs like 
this:

db.define_table('playlist',Field('title','string'),
Field('start_time','integer'),
Field('duration','integer')
)

For example:  

  row 0:   Title:Imagine;   start time: 
0:00; duration 3:43  
  row 1:   Title:My way;   start  time: 
3:43   ; duration  4:00
  row 2:   Title:I feel good;   start  time: 
7:43   ; duration  4:00

 
As you see, start time of every song stands for the 'real time' at which 
the song will be played.

What I need to know is the best approach in web2py for insert a new row in 
the middle of the table and update songs below. 

Example, say that I add, "my song" between 0 and 1:

  row 0:   Title:Imagine;   start time: 
0:00; duration 3:43  
  row 1:   Title:My Song;   start time: 
3:43; duration 3:00  
  row 2:   Title:My way;   start  time: 
7:43   ; duration  4:00
  row 3:   Title:I feel good;   start  time: 
11:43   ; duration  4:00

I need to update and change start times for old rows 1 and 2...

I have never face this kind of problem but I have seen that in a SQL 
triggers could do the update. How could I approach this problem in web2py?

Thanks in advance

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


[web2py] Architecture & hosting considerations. Just 1 query/minute but "high" traffic app

2014-01-14 Thread Jaime Sempere

Hi everyone, 

I plan to do an app for webs that have about 10k-100k visits per day. This 
app would be an iframe of my own webpage/app. 

I don't need a lot of bandwith (say that I will send an STATIC page, size 
less than 30-20kb per request), but I need to update some data of this 
static page each minute, querying my database, and here is my first big 
question.

What would be the best approach? I don't need to query database in every 
request, just query everyminute, and update the static page that is being 
returned. Here is my first big question. 

My first thought would be access to the static file and modify/update it 
every minute. This doesn't look to me like the best approach, but I have no 
experience in a case like this. Could anyone give me some hints or any 
other approaches? Cache, store the query on server...? 



I ask this here too, because I think is related with the hosting that I 
will need to choose... GAE was my first thought but I am worried about 
price, and also that I couldn't use my approach as I cannot modify 
filesystem from GAE.


Thanks in advance



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


[web2py] Can't get web2py working with GAE locally

2014-01-02 Thread Jaime Sempere
Hi everyone, this is driving me mad.

I used web2py and GAE one year ago and I liked a lot, fast and easy to work 
with gae. Now that I wanted to start another app, I have download GAE and 
Web2Py again (for having last releases and starting in a clean&new folder).

So, first change that I see is that when I run dev_appserver from GAE 
forces to use python 2.7. My first guess then, is that I need to change 
gaehandler in app.yaml and leave the code like this:

application: myapp
version: 1
api_version: 1


  #script: gaehandler.py # CGI
  script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
  secure: optional

But when I do a http://localhost:8080/

I obtain this error in console:

ERROR2014-01-03 02:25:39,821 wsgi.py:262] 
Traceback (most recent call last):
  File 
"/home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py",
 
line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File 
"/home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py",
 
line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
  File 
"/home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py",
 
line 84, in LoadObject
obj = __import__(path[0])
ImportError: No module named gaehandler
INFO 2014-01-03 02:25:39,834 module.py:617] default: "GET / HTTP/1.1" 
500 -
INFO 2014-01-03 02:25:40,208 module.py:617] default: "GET /favicon.ico 
HTTP/1.1" 304 -




And of course I can't see any html returned. Why gaehandler is missing?

I can reach localhost:8001/myapp   (web2py server)
But not   localhost:8080  (gae)

And second question: for running my appGAE locally do I need to have 
running web2py server? I used to have both running, but now I have seen 
that I need to change default port 8000 to other (i.e. 8001), because gae 
is using 8000 and 8080.


Any help would be very appreciated. Thank you 

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


[web2py] Re: does Field attribiute unique=True work on GAE?

2013-03-25 Thread Jaime Sempere
Sorry to bump this up, but I have not been able of using unique as it is 
described here (no validators).

Also I have tried to use instead of unique IS_NOT_IN_DB as in this other 
thread is suggested: 
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/gae$20unique/web2py/ZepLjcBowZs/FuKiSYZGzUAJ
 ; 
but same results

Introducir código aquí...db.define_table('likes',
  Field('user_id', 'reference users', 
notnull='True'),
  Field('post_id', 'reference posts', 
notnull='True'),
  Field('unique_key', unique=True, compute= lambda 
row: "%(user_id)s-%(post_id)s" %row)
)


This worked for me in web2py but not in GAE (by the way I don't know if I 
should add ,'string', after 'unique_key'. Anyway I have tried to add it 
with same luck).

I could check manually if 'unique_key' is already in DB before inserting as 
Massimo suggested in the other thread, but I prefer not adding more code (I 
have several unique fields that I would like to fix with a simple 
solution). What am I doing wrong? 

Thanks in advance


El viernes, 24 de septiembre de 2010 06:50:01 UTC+2, mdipierro escribió:
>
> yes and no. It will not be enforced at the database level but if you 
> do not specify validators, it will use it to pick default validator 
> that enforce the uniqueness at the web2py level 
>
> On Sep 23, 11:17 am, Carl  wrote: 
> > My db.py includes... 
> > 
> > db.define_table('voucher', 
> > Field('code', 'string', length=128, unique=True, notnull=True, 
> > required=True), 
> >  
> > 
> > Locally on sqlite when I insert a second record with the same 'code' 
> > as an existing record insert() throws an except. I catch the exception 
> > and report back to the user. 
> > 
> > Locally on dev_appserver the "duplicate" insert() successfully inserts 
> > a duplicate record; no exception is thrown. 
> > 
> > I've looked at the 2nd edition book and this group but can't find 
> > anything that say that GAE doesn't support unqiue=True. 
> > 
> > Can anyone clarify this use of unique=True on GAE? 
> > And if it's not supported is there a recommended alternative approach?

-- 

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




[web2py] Re: session vs cookies performance

2013-03-10 Thread Jaime Sempere

Thanks for the answer and the advice. After reading your answers I think I 
will use just simple sessions, as you said it makes sense. If in the future 
I need something more, I'll try the sessions in cookies, sounds like a good 
alternative.

El domingo, 10 de marzo de 2013 14:43:10 UTC+1, Anthony escribió:
>
> Using session makes sense. If for some reason you prefer cookies rather 
> than server-side sessions, there is an option to store sessions in cookies 
> -- see near the end of this section: 
> http://web2py.com/books/default/chapter/29/04#session. In that case, you 
> won't have to change any code and still have the convenience of working 
> with the session object.
>
> Anthony
>
>

-- 

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




[web2py] Re: session vs cookies performance

2013-03-10 Thread Jaime Sempere


El domingo, 10 de marzo de 2013 14:32:59 UTC+1, Niphlod escribió:
>
>
>
> On Sunday, March 10, 2013 2:20:02 PM UTC+1, Jaime Sempere wrote:
>>
>> Thanks for your answer.
>>
>> I am not storing too much, currenty I am storing for every user these 
>> strings:
>>
>> facebook_id
>> another string for the category of the forum where the user is right now
>> the thread page were the user is
>> the page of thread list
>>
>> This is for every user. I've been trying to use cookies instead of 
>> sessions, but I have not been able to do it right. I do a lot of ajax calls 
>> and I think I am having issues with cookies and ajax (cookies set at wrong 
>> time and not updated at the right time). Sessions is very easy to manage..
>>
>
> perfect. I assume you mean cookies set by you vs sessions stored in 
> cookies.
>


By the way, see a correction (in bold letters) in my previous message 
(these strings, instead of "this string")

Err... I thought that I knew what cookies and session meant, but I am not 
so sure right now (for me session was always stored in server, using *
"session.name"* in web2py... cookies are stored in user browser... and I am 
not very sure of how to use them, I think they are set using 
response.cookies and I can get them using request.cookies.value['name']).

Anyway as session are stored in server I was thinking "ok, maybe is better 
to use cookies and not store anything in server". This is my main question. 
As I said I'm storing about 4 strings in 4 sessions variables. 

I guess this is just a little storage and with a bit of luck I won't need 
to care too much, uh? 
 

>  
>
>>
>> I see you talk about 20 instances of web2py. My app is for facebook and I 
>> would like to support more than 20 users at the same times... so am I in 
>> problems?
>>
>
> 20 instances means 20 different servers running web2py!
>

xD. Well, newbie here.
 

>  
>
>>
>> Another approach that I've tried is to use global variables (I only need 
>> to store my variables as long as the page is not reloaded), but in ajax 
>> calls it seems to reload the default value. I mean:
>>
>> var_global = 1
>> def index():
>> .
>>
>> *def increment_global*():
>> global var_global
>> var_global = var_global + 1
>> return var_global
>>
>> If I call *def_increment_global* using ajax from javascript, var_global 
>> always returns 2.
>>
>> Any advice?
>>
>
> there's no global variable unless you cache it. Every request all the 
> models and the controller get executed in a fresh environment. 
>

Ok, this clarifies some questions that I had. 

-- 

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




[web2py] Re: session vs cookies performance

2013-03-10 Thread Jaime Sempere
Thanks for your answer.

I am not storing too much, currenty I am storing for every user this string:

facebook_id
another string for the category of the forum where the user is right now
the thread page were the user is
the page of thread list

This is for every user. I've been trying to use cookies instead of 
sessions, but I have not been able to do it right. I do a lot of ajax calls 
and I think I am having issues with cookies and ajax (cookies set at wrong 
time and not updated at the right time). Sessions is very easy to manage..

I see you talk about 20 instances of web2py. My app is for facebook and I 
would like to support more than 20 users at the same times... so am I in 
problems?

Another approach that I've tried is to use global variables (I only need to 
store my variables as long as the page is not reloaded), but in ajax calls 
it seems to reload the default value. I mean:

var_global = 1
def index():
.

*def increment_global*():
global var_global
var_global = var_global + 1
return var_global

If I call *def_increment_global* using ajax from javascript, var_global 
always returns 2.

Any advice?

-- 

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




[web2py] session vs cookies performance

2013-03-09 Thread Jaime Sempere
Hi, 

I have an application for facebook where I need to store some variables. 
The application is like a little forum but with just one page and 
everything is loaded via Ajax calls, so I need to store for example, the 
user that is logged in, the page of the forum where he is right now... etc. 
Now I am using 4 variables stored in sessions, I would like to know if this 
practice is considered correct. 

Also, as sessions are stored in server side, I was thinking to use cookies 
instead of sessions. Would this be better in terms of performance and 
storage? If not I would like to keep using sessions, I found them easier to 
handle, and I would avoid to rewrite the code.

Thanks in advance

-- 

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




Re: [web2py] GAE "orderby date" not working

2013-03-06 Thread Jaime Sempere
Thanks a lot for pointing me the way, now is working

I am a beginner in web2py & GAE and I didn't know anything about 
index.yaml. I was developing locally with web2py and uploading directly to 
GAE (in the beginning I used locally GAE, but later I skipped this step). 
So index.yaml was not being generated. Now is generated and working 
properly.

Really, thanks a lot for your help

-- 

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




Re: [web2py] Re: proper way to transform a query GAE #1

2013-03-06 Thread Jaime Sempere
Thanks a lot for pointing me the way, now is working

I am a beginner in web2py & GAE and I didn't know anything about 
index.yaml. I was developing locally with web2py and uploading directly to 
GAE (in the beginning I used locally GAE, but later I skipped this step). 
So index.yaml was not being generated. Now is generated and working 
properly.

Really, thanks a lot for your help

El jueves, 12 de agosto de 2010 02:23:51 UTC+2, Jonathan Lundell escribió:
>
> On Aug 11, 2010, at 5:14 PM, Rob wrote:
>
> > Where is this syntax documented?
> > 
> > db(query1)(query2)
> > 
> > Is this the same as 'db(query1 & query2)' except web2py does the join
> > and not the database?
>
> It's identical.
>
> db(query) returns a Set instance. And calling a Set instance that already 
> has a query combines the queries with &:
>
> def __call__(self, query):
> if self._query:
> return Set(self._db, self._query & query)
> else:
> return Set(self._db, query)
>
> (this is from dal.py; sql.py isn't quite so readable)
>
> As for documentation, I think that all these DAL behaviors ought to be 
> better documented. Maybe the next rev of the book
>
>

-- 

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




[web2py] GAE "orderby date" not working

2013-03-06 Thread Jaime Sempere
Hi,

I've been searching about this but can't found any info abut it. 

I have an application which locally work well, but when I upload and test 
it in google app engine this line gives me error:

for row in db(db.posts.thread_id==thread_id).select(orderby=db.posts.
post_date):


Google app engine  thows this error:

(dp0 S'output' p1 S" no matching index 
found.\nThe suggested index for this query is:\n- kind: posts\n 
properties:\n - name: thread_id\n - name: post_date" blablabla

As you can see it seems to have some issue with the index "post_date" but 
is really declared. If instead of .post_date I order by id or thread_id, 
everything works fine in GAE, but not with post_date.

See the table declaration:

db.define_table('posts',  Field('thread_id','integer'),
  Field('user_id','reference users'),
  
Field('post_message','text',requires=IS_LENGTH(minsize=2,maxsize=800),
  #Field('post_message','text',label=''),
  Field('like_author','boolean',default=False),
  Field('likes','integer',default=0),
  Field('post_date', 'datetime')
  )


What can be happening here? I really have no idea. I have tried also to run 
the query inside of gae interfacer using gae interface: SELECT * FROM posts 
ORDER BY post_date 
and it works without problem.

Any help? thanks in advance

-- 

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




Re: [web2py] Re: Best Method to implement a "like" button

2013-03-05 Thread Jaime Sempere
A little correction for any future visitor:

compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s"),
should be:
compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" %row),

Anyway the solution is great. Thanks a lot.

El miércoles, 12 de septiembre de 2012 00:54:45 UTC+2, rochacbruno escribió:
>
> db.define_table('likes',
> Field('username', 'reference auth_user'),
>
> Field('songname', 'reference songs'),
> Field('playlist_name', 'reference playlist'),
> Field('unique_key', unique=True, notnull=True,  compute= lambda row: 
> "%(username)s-%(songname)s-%(playlist_name)s"),
>  
> )
>
> Now on any attempt to insert duplicates DAL will have an exception, 
> because unique_key is unique and the computation will try to add same 
> values.
>
> try:
> db.likes.insert(..)
> except:
> #YOU ALREADY LIKE THIS
>
>
> *Bruno Cezar Rocha** - @rochacbruno*
> rocha...@gmail.com  | Mobile: +55 (11) 99210-8821
> www.CursoDePython.com.br | www.rochacbruno.com.br
> Blog: Using Python to get all the external links from a 
> webpage
>   Get a signature like this. 
> 
>  Click 
> here.
>
>
>
>
>

-- 

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




Re: [web2py] 'Morsel' object has no attribute 'split' ?

2013-02-27 Thread Jaime Sempere
Hi, i'm getting mad using facebook.py, I cannot get it work.

Anyway, I have almost been able of using your facebook.py, but I am using 
Google App Engine, so urllib doens't work there. Web2py book suggest using 
fetch instead of urllib for GAE: 
http://web2py.com/books/default/chapter/29/14#Fetching-an-external-URL

Anyway as at this moment I only use uid I have commented access_token use 
of urllib. Anyway thanks for your work and help

El jueves, 14 de febrero de 2013 16:14:23 UTC+1, Leonel Câmara escribió:
>
> Done, I 've placed my facebook.py in attachment.
>
> Not sure if any changes to web2py are necessary as I'm using a slightly 
> modified (by me and applying a few patches on the rep) version of 
> http://code.google.com/p/cfhowes/source/browse/#hg/web2py_multiauth instead 
> of the standard auth.  
>   
> My guess is that no changes to web2py are necessary, as 
> that get_user_from_cookie simply does not work as it is and it just does 
> with this change.
>
>
>

-- 

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