Re: [web2py] Re: Polymer and SQLFORM

2017-04-28 Thread Luis Valladares
We choose to use materializecss instead of polymer because polymer was not
very stable at the time.

El vie., abr. 28, 2017 10:13 AM,  escribió:

> @Luis Valladares I also like the idea of Polymer + web2py. Where you able
> to use both in combination? If so - do you have some example code to share
> on Github?
>
> Cheers
> Tset
>
>
> Am Montag, 21. September 2015 01:51:00 UTC+2 schrieb Luis Valladares:
>>
>> Hello!
>>
>> I'm building a web2py site and i want to use polymer as my front-end
>> "framework", as you may know polymer uses web elements with custom html
>> tags, i mean, a input is something can be something like
>>
>> 
>>
>> I want to integrate this "feature" with the web2py SQLFORM module, after
>> a bit of research i came with this approach, im not sure if its correct so
>> i accept suggestion:
>>
>> i've to override all the FormWidget class inside sqlhtml.py and modify
>> all widget to generate a HTML output adapted to my custom tags, also create
>> a custom formstyle related to polymer and maybe (and this is one of the
>> problems i've found) create some sort of custom HTML helper for generating
>> the HTML custom tags.
>>
>> I think i miss a lot of changes needed for this to work well, so i am
>> looking for opinions in this matter, i'm correct in my planning, or maybe
>> there is a easier path to join SQLFORM and Polymer, or may be better to
>> work without SQLFORM?
>>
>> Thank for any help you can provide
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/15GvZ-M9WBo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Pydal ids customs

2016-10-10 Thread Luis Valladares
It appear that i've sorted this out in the last crazy test, my problem 
where in filter fields, this was my code before:

 accion = 
self.dbNueva.estatus_contratacion.validate_and_insert(**self.dbNueva.estatus_contratacion._filter_fields(x)).as_dict()

Where x is a dict with all the fields i want to insert (including the id of 
the field), but when i insert this, the id is ignored an its assigned the 
next autoincrement id, i changed the code for this:

accion = self.dbNueva.estatus_contratacion.validate_and_insert(id=x["id"], 
**self.dbNueva.estatus_contratacion._filter_fields(x)).as_dict()

And it work perfectly. i dont know if this is a bug or this is the way it 
should work, but ._filter_fields appears to filter also the ID of the dict.

Thanks for all your help anthony, i hope this can help other people.

El lunes, 10 de octubre de 2016, 10:42:19 (UTC-4), Anthony escribió:
>
> OK, so what does your code look like? Why can't you preserve the id's?
>
> Anthony
>
> On Monday, October 10, 2016 at 9:43:50 AM UTC-4, 
> luis.va...@metamaxzone.com  wrote:
>>
>> I thin that method doesnt work for me, let me explain better what i want 
>> to do:
>>
>> 6 months ago i released a production APP, now we will launch the second 
>> version of this app and there are several (big) differences between the 
>> database structure in production and the one i will deploy now, but i dont 
>> want to lose all the data collected in production, so what i want to do can 
>> be resumed in 3 steps:
>>
>> 1. Get all the information from the production database with the OLD 
>> structure
>> 2. Format this information to the NEW structure (some fields will be 
>> deleted, other will be added... there are several changes)
>> 3. Insert this data in the NEW structure database.
>>
>> Also, this app is created with a microservices architecture which means 
>> that i dont have only one database, instead i've 14 database that have 
>> cross data between them (i mean, the id stored for a user in the users 
>> database are also used in several other databases as reference to the user)
>>
>> So because this if i change the ids i will need to make a big coherence 
>> check around my 14 databases, with (approximately) 10 tables each one, this 
>> is a big deal as you can see.
>>
>> Thanks a lot for the help and i hope you can keep helping me.
>>
>> El jueves, 6 de octubre de 2016, 14:19:49 (UTC-4), Anthony escribió:
>>>
>>> Do you really need the id's to remain the same? Note, if you use this 
>>> method 
>>> 
>>>  
>>> to migrate, web2py will automatically update any reference fields so they 
>>> contain the new ids of referenced records.
>>>
>>> Anthony
>>>
>>> On Wednesday, October 5, 2016 at 5:47:36 PM UTC-4, 
>>> argenio...@metamaxzone.com wrote:

 I'm doing a migrate data of 2 databases with diferents tables.

 My only problems is with ids! 

 table 1
 id: 5, name: Diana
 id: 8, name: Carlos


 when i migrate this data to databases 2
 id: 1, name: Diana
 id: 2, name: Carlos

 Look the id's not the same.

 what is the method to save the same id?
 I read about primarekey parameters but dont work.

 The process of migrate if a script with 2 Pydal, one for the old 
 database and other for new databases.
 I execute one select() of everithing (not much data), later convert to 
 the new structure and all work perfectly. the only problem is with ID .

 Please help me, 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] Re: Pydal ids customs

2016-10-10 Thread luis . valladares
I thin that method doesnt work for me, let me explain better what i want to 
do:

6 months ago i released a production APP, now we will launch the second 
version of this app and there are several (big) differences between the 
database structure in production and the one i will deploy now, but i dont 
want to lose all the data collected in production, so what i want to do can 
be resumed in 3 steps:

1. Get all the information from the production database with the OLD 
structure
2. Format this information to the NEW structure (some fields will be 
deleted, other will be added... there are several changes)
3. Insert this data in the NEW structure database.

Also, this app is created with a microservices architecture which means 
that i dont have only one database, instead i've 14 database that have 
cross data between them (i mean, the id stored for a user in the users 
database are also used in several other databases as reference to the user)

So because this if i change the ids i will need to make a big coherence 
check around my 14 databases, with (approximately) 10 tables each one, this 
is a big deal as you can see.

Thanks a lot for the help and i hope you can keep helping me.

El jueves, 6 de octubre de 2016, 14:19:49 (UTC-4), Anthony escribió:
>
> Do you really need the id's to remain the same? Note, if you use this 
> method 
> 
>  
> to migrate, web2py will automatically update any reference fields so they 
> contain the new ids of referenced records.
>
> Anthony
>
> On Wednesday, October 5, 2016 at 5:47:36 PM UTC-4, 
> argenio...@metamaxzone.com  wrote:
>>
>> I'm doing a migrate data of 2 databases with diferents tables.
>>
>> My only problems is with ids! 
>>
>> table 1
>> id: 5, name: Diana
>> id: 8, name: Carlos
>>
>>
>> when i migrate this data to databases 2
>> id: 1, name: Diana
>> id: 2, name: Carlos
>>
>> Look the id's not the same.
>>
>> what is the method to save the same id?
>> I read about primarekey parameters but dont work.
>>
>> The process of migrate if a script with 2 Pydal, one for the old database 
>> and other for new databases.
>> I execute one select() of everithing (not much data), later convert to 
>> the new structure and all work perfectly. the only problem is with ID .
>>
>> Please help me, thanks.
>>
>

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


Re: [web2py] Re: Partial flush of request

2016-10-03 Thread luis . valladares
That sounds really promising, thanks a lot! i will test it ASAP and if i 
have any troubles i will comeback here.

El lunes, 3 de octubre de 2016, 12:57:21 (UTC-4), Anthony escribió:
>
> On Sunday, October 2, 2016 at 11:26:11 PM UTC-4, 
> luis.va...@metamaxzone.com  wrote:
>>
>> The second sounds good to me, but i dont know really where to store it, 
>> my front end is REST and has no database connected to it, all the info i 
>> get its from microservices, so i need some sort of variable or environment 
>> space where to store the token when i receive it and retrieve it in the 
>> case of an error, there is anything like that in web2py?
>>
>
> Well, the error handler receives request.env.request_uri via the 
> requested_uri query string parameter, so you might be able to do something 
> like:
>
> request.env.request_uri += '&token=%s' % token
>
> Then in the error handler, you would have to parse 
> request.vars.request_uri to extract the token.
>
> Alternatively, this might work:
>
> request.wsgi.environ['token'] = token
>
> Note, I haven't tried either of the above, so not sure if they will work.
>
> 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.


Re: [web2py] Re: Partial flush of request

2016-10-02 Thread luis . valladares
The second sounds good to me, but i dont know really where to store it, my 
front end is REST and has no database connected to it, all the info i get 
its from microservices, so i need some sort of variable or environment 
space where to store the token when i receive it and retrieve it in the 
case of an error, there is anything like that in web2py?

El domingo, 2 de octubre de 2016, 11:59:13 (UTC-4), Anthony escribió:
>
> On Sunday, October 2, 2016 at 7:52:04 AM UTC-4, Luis Valladares wrote:
>>
>> Because my application has a microservice architecture, this means there 
>> is another app storing the token in the database and the only thing my 
>> web2py front end does is make a http request to that microservice and 
>> format the received data, but if during that formatting some exception is 
>> raised I lost all the content (in this case the token) that I want to send 
>> in request.cookies, this mean the user still have the old token when the 
>> microservice already have changed that token in their database.
>>
>
> You could either wrap your web2py code in a try/except to ensure you catch 
> any errors directly, or use routes_onerror in routes.py to route any errors 
> to a separate error handling app/controller (in the latter case, you'll 
> need to make sure the relevant token data have been saved somewhere the 
> error handler can access).
>
> 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.


Re: [web2py] Re: Partial flush of request

2016-10-02 Thread Luis Valladares
Because my application has a microservice architecture, this means there is
another app storing the token in the database and the only thing my web2py
front end does is make a http request to that microservice and format the
received data, but if during that formatting some exception is raised I
lost all the content (in this case the token) that I want to send in
request.cookies, this mean the user still have the old token when the
microservice already have changed that token in their database.

El sáb., oct. 1, 2016 9:40 PM, Anthony  escribió:

> On Saturday, October 1, 2016 at 4:19:59 PM UTC-4, Luis Valladares wrote:
>
> They expire, when I generate a new token I store it in the database and
> send to the user browser, each time the token is expired I generate a new
> one, overwrite the token in the database (and because this the other token
> is lost) and sent to the user.
>
>
> I'm not sure I understand. Every HTTP request is wrapped in a database
> transaction, so if an error occurs during a request, any database
> operations that had been made prior to the error will be rolled back before
> returning the error response. So, how is it that your token overwriting is
> not being rolled back upon error?
>
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Dx52cLv-8-Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Partial flush of request

2016-10-01 Thread Luis Valladares
They expire, when I generate a new token I store it in the database and
send to the user browser, each time the token is expired I generate a new
one, overwrite the token in the database (and because this the other token
is lost) and sent to the user.

But that's not really my problem (maybe I don't explain it well in the last
post) what I want to do is send a partial response to the user browser and
then keep processing. specifically I want to set a cookie in the browser
and then I will continue data processing.

Thanks for your help Anthony!

El sáb., oct. 1, 2016 2:10 PM, Anthony  escribió:

> On Saturday, October 1, 2016 at 9:52:18 AM UTC-4,
> luis.vallada...@metamaxzone.com wrote:
>
> Hello!
>
> Im creating a website with a microservices architecture, and for
> authentication i'm using JWT token stored in the cookies, this tokens are
> automatically renewed each 5 minutes, the basic flow of this is:
>
> 1 My front end makes a request to a microservice
> 2 The microservice check if the token its expired
> 3 If its expired check if its the same stored in our database
> 4 If its the same generate a new token, and send it to the front end
> 4.1 If its not the same answer a Non-authorized response to the front end
> 5 My web2py front end will change the token cookie for the new one.
>
> My problem happens if (by any problem) i get a ticket on web2py, when this
> happens the new cookie are not sended in the response, the user still
> storing the old token, and the next time it makes a petition the step 3
> isnt found and close the user session
>
>
> Are you saying the record is not in the database on the next attempt? If
> not, why not? What happens to the record during the initial request?
>
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Dx52cLv-8-Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Partial flush of request

2016-10-01 Thread luis . valladares
Hello!

Im creating a website with a microservices architecture, and for 
authentication i'm using JWT token stored in the cookies, this tokens are 
automatically renewed each 5 minutes, the basic flow of this is:

1 My front end makes a request to a microservice
2 The microservice check if the token its expired
3 If its expired check if its the same stored in our database
4 If its the same generate a new token, and send it to the front end
4.1 If its not the same answer a Non-authorized response to the front end
5 My web2py front end will change the token cookie for the new one.

My problem happens if (by any problem) i get a ticket on web2py, when this 
happens the new cookie are not sended in the response, the user still 
storing the old token, and the next time it makes a petition the step 3 
isnt found and close the user session

So, bottom line: What i want to do is "flush" (Php like: 
http://php.net/manual/es/function.flush.php) the cookie to the browser and 
after that still managing the response (because i want to format the 
response, send to a view...)

Its important to say that the functionality of token renewal and request is 
stored in a module

Thanks a lot!

-- 
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: profanity filter

2016-09-01 Thread luis . valladares
I've found some python packages, maybe it suits your needs:

https://pypi.python.org/pypi/profanity/1.1
https://github.com/jared-mess/profanity-filter

Or maybe adapting this:
https://www.languagetool.org/

El miércoles, 31 de agosto de 2016, 17:34:54 (UTC-4), Alex Glaros escribió:
>
> anyone have a working profanity filter I could copy?
>
> thanks
>
> Alex Glaros
>

-- 
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: one to many joins repeated parent

2016-08-29 Thread luis . valladares
Hello!

Thanks for your help! but it means that for every record inside events 
table i should do an additional query in the modificators table, so if in a 
query i want to get 100 events and his modificators i should do 101 queries 
to the database, i think (im not sure, i'll will talk tomorrow with the 
DevOps) that database queries are expensives.

Or instead, loop over all the modificators, find the ID, do a query using 
pydal belongs and do a matchup between the two responses to relationate 
each modificator to his respective events.

After i'll check this option tomorrow with my DevOps i will edit this 
message

El lunes, 29 de agosto de 2016, 9:17:20 (UTC-4), Mirek Zvolský escribió:
>
> With pydal (ie. db=DAL()) you can get the records in 2 queries:
> event = db(db.events.id == wish_event_id).select()
> and event_modificators = db(db.modificator.events_id 
> == wish_event_id).select()
>
> then convert to the list:
> event_modificators = [row for row in event_modificators]# item is 
> whole row
> or event_modificators = [row.modificator for row in event_modificators]   
>  # item is one field only.
>
> 
> If modificator has just 1 field (+ 2nd id field),
> then instead of solution with 2 tables you could use just 1 table with 
> Field(..., type="list:string").
> This has special support on Google App Engine NoSQL, but on any other SQL 
> database (SQLite, Postgres) it is supported as 'text' with '|' separators 
> inside. I think you will get a list immediately when asking for such field. 
> And it is supported in SQLFORM() too to set 1+ modificators.
>
>
>
>
>
> Dne neděle 28. srpna 2016 23:21:31 UTC+2 luis.va...@metamaxzone.com 
> napsal(a):
>>
>> Hello!
>>
>> I've this data structure in my database: i've two tables events and 
>> modificators, one event can have many modificators so i've a one to many 
>> relation. Im trying to build an HTTP endpoint that returns a json with 
>> multiple events and all the asociated modificators, i order to do this i do 
>> a join and return the select as a list, but my problem (and i understand 
>> this problem is related to the way SQL works) is that the parent is 
>> repeating on every record, so i've an event A with four modificators B, C, 
>> D and E i get something like this:
>>
>> [{"events": A, "modificator": B}, {"events": A, "modificator": C}, 
>> {"events": A, "modificator": D}, {"events": A, "modificator": E}]
>>
>> instead of this i want something like
>>
>>  [{"events": A, "modificator": [B, C, D, E]}]
>>
>> i now i can do this with a for and creating my own custom dictionary, but 
>> i think this problem will be repeated several times along the api im 
>> developing because my database has multiple one to many relations so it 
>> would be good to get some "generic" solution instead of creating a lot of 
>> nested fors for each case, also i think is a little bit inefficient doing 
>> it on this way.
>>
>> I was wondering if the DAL or web2py himself has some method for this, or 
>> if you can recomend a external library because i thinks this is a fair 
>> common case, even if you can give me some guidance to develop a common 
>> class, or function for this problem.
>>
>> By the way,  i read this example in the web2py manual:
>>
>> >>> for person in db().select(db.person.ALL):
>> print person.name
>> for thing in person.thing.select():
>> print '', thing.nameAlex
>>  Boat
>>  ChairBob
>>  ShoesCarl
>>
>> but i think it doesnt fit my needs because of the high database I/O, im 
>> deploying my app on EC2 (Amazon) and the databases instances have a really 
>> high cost, this is combined with my database having a LOT of records (about 
>> 2000 events and 5800 modificators) and growing.
>>
>>
>> Thanks for any help or guidance you can provide!
>>
>

-- 
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: how to redirect to an 'external' url in a view?

2016-08-28 Thread luis . valladares
Can you post the full traceback? it seems like youre trying to convert the 
url to some numeric class. So with the full trace back we can get a clear 
look of that

El domingo, 28 de agosto de 2016, 19:25:10 (UTC-4), Steven Vannoy escribió:
>
> That seemed promising but gave me an exception with top-most error as:
>
> * invalid literal for long() with base 10: 
> 'www.huffingtonpost.com '*
>
>
> You can see that I'm using 'www.huffingtonpost.com' as my test case, 
> which does resolve correctly if pasted strait into the browser.
>
>
>
> On Sunday, August 28, 2016 at 6:57:37 PM UTC-4, luis.va...@metamaxzone.com 
> wrote:
>>
>> Hello!
>>
>> Try this:
>>
>> {{=site.website}}
>>
>>
>> El domingo, 28 de agosto de 2016, 17:29:40 (UTC-4), Steven Vannoy 
>> escribió:
>>>
>>> I have a view that displays a database form. One of the fields in that 
>>> form is my user's own website. I'd like to display that as an active link 
>>> in the browser. I've tried two different forms, the first produces an error 
>>> because it is trying to resolve to a view within my application, and the 
>>> other just reloads the current page.
>>>
>>> Here is the code in my view
>>>
>>> {{if site.website is not None:}}
>>> {{=A(T("Web Site"), _href=site.website)}}
>>> 
>>> {{=site.website}}
>>> {{pass}}
>>>
>>>
>>> Any help is much appreciated 
>>>
>>>
>>>

-- 
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: how to redirect to an 'external' url in a view?

2016-08-28 Thread luis . valladares
Hello!

Try this:

{{=site.website}}


El domingo, 28 de agosto de 2016, 17:29:40 (UTC-4), Steven Vannoy escribió:
>
> I have a view that displays a database form. One of the fields in that 
> form is my user's own website. I'd like to display that as an active link 
> in the browser. I've tried two different forms, the first produces an error 
> because it is trying to resolve to a view within my application, and the 
> other just reloads the current page.
>
> Here is the code in my view
>
> {{if site.website is not None:}}
> {{=A(T("Web Site"), _href=site.website)}}
> 
> {{=site.website}}
> {{pass}}
>
>
> Any help is much appreciated 
>
>
>

-- 
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] one to many joins repeated parent

2016-08-28 Thread luis . valladares
Hello!

I've this data structure in my database: i've two tables events and 
modificators, one event can have many modificators so i've a one to many 
relation. Im trying to build an HTTP endpoint that returns a json with 
multiple events and all the asociated modificators, i order to do this i do 
a join and return the select as a list, but my problem (and i understand 
this problem is related to the way SQL works) is that the parent is 
repeating on every record, so i've an event A with four modificators B, C, 
D and E i get something like this:

[{"events": A, "modificator": B}, {"events": A, "modificator": C}, 
{"events": A, "modificator": D}, {"events": A, "modificator": E}]

instead of this i want something like

 [{"events": A, "modificator": [B, C, D, E]}]

i now i can do this with a for and creating my own custom dictionary, but i 
think this problem will be repeated several times along the api im 
developing because my database has multiple one to many relations so it 
would be good to get some "generic" solution instead of creating a lot of 
nested fors for each case, also i think is a little bit inefficient doing 
it on this way.

I was wondering if the DAL or web2py himself has some method for this, or 
if you can recomend a external library because i thinks this is a fair 
common case, even if you can give me some guidance to develop a common 
class, or function for this problem.

By the way,  i read this example in the web2py manual:

>>> for person in db().select(db.person.ALL):
print person.name
for thing in person.thing.select():
print '', thing.nameAlex
 Boat
 ChairBob
 ShoesCarl

but i think it doesnt fit my needs because of the high database I/O, im 
deploying my app on EC2 (Amazon) and the databases instances have a really 
high cost, this is combined with my database having a LOT of records (about 
2000 events and 5800 modificators) and growing.


Thanks for any help or guidance you can provide!

-- 
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] Mongo list type field update

2016-08-05 Thread luis . valladares

Hello!

I'm using pydal to work with a mongoDB database, im using this structure:

db.define_table('tarifas',
Field('fk_hotel_id',
  'integer',
  required=True,
  notnull=True,
  requires=IS_INT_IN_RANGE(0)),
Field('fk_habitacion_id',
  'integer',
  required=True,
  default=None,
  requires=IS_INT_IN_RANGE(0)),
Field('tarifa_min',
  'decimal(11, 2)',
  required=True,
  default=None,
  requires=IS_DECIMAL_IN_RANGE(-1e100, 1e100)),
Field('tarifa_max',
  'decimal(11, 2)',
  required=True,
  default=None,
  requires=IS_DECIMAL_IN_RANGE(-1e100, 1e100)),
Field('modificador_semana',
  'decimal(2, 2)',
  length=2,
  requires=IS_EMPTY_OR(IS_DECIMAL_IN_RANGE(0, 
99))),
Field('modificador_eventos',
  'list:string'))

The modificador_eventos field will be a json with a list format, so im 
trying to insert a list in it using this code:

eventos = json.loads(eventos)
lista = [eventos, eventos, eventos]
respuesta = db(db.tarifas.id == 
id).validate_and_update(modificador_eventos=lista).as_dict()

Where var eventos is:

{
"nombre": "qq",
"fecha_inicio": "12/12/2012",
"fecha_fin": "14/12/2012",
"existencias": "3",
"descuento": "21"
}

When i try to do that i receive this exception:

  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", 
line 130, in handle
self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", 
line 171, in handle_request
respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python2.7/dist-packages/falcon/api.py", line 182, in 
__call__
responder(req, resp, **params)
  File "/usr/share/nginx/html/falcon/tarifas/controlador/api.py", line 158, 
in on_post
resultado = self.tarifas.insertarEvento(req)
  File "../modelos/tarifas.py", line 52, in insertarEvento
respuesta = db(db.tarifas.id == 
id).validate_and_update(modificador_eventos=lista).as_dict()
  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 
2116, in validate_and_update
ret = self.db._adapter.update(tablename, self.query, fields)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", 
line 447, in update
expanded = Expansion(self, 'update', query, fields)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", 
line 635, in __init__
self._expand_fields(self._fields_loop_abort)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", 
line 751, in _expand_fields
self._expand_field(field, value, mid_loop)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", 
line 762, in _expand_field
expanded = self.adapter.expand(value, field.type)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", 
line 187, in _expand
raise NotImplementedError("How did you reach this line of code???")
NotImplementedError: How did you reach this line of code???

However if i insert just the dict (i mean, the var eventos without 
convertir it to list) everythings works fine. I also tried this:

db(db.tarifas.id == 
id).validate_and_update(modificador_eventos=json.dumps(lista).as_dict()

And i dont recieve any exception, but it insert in a weird format, looks 
like this:

[{\"nombre\": \"qq\", \"fecha_inicio\": \"12/12/2012\", \"fecha_fin\": 
\"14/12/2012\", \"descuento\": \"21\", \"existencias\": \"3\"}, 
{\"nombre\": \"qq\", \"fecha_inicio\": \"12/12/2012\", \"fecha_fin\": 
\"14/12/2012\", \"descuento\": \"21\", \"existencias\": \"3\"}, 
{\"nombre\": \"qq\", \"fecha_inicio\": \"12/12/2012\", \"fecha_fin\": 
\"14/12/2012\", \"descuento\": \"21\", \"existencias\": \"3\"}]

Im pretty sure this happens beacause the mongo plugin converts it to json 
again. So, you have any suggestion in this matter or some workaround for 
what i want to do?

Thanks very much for any help you can provide

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

[web2py] Re: web2py session disable

2016-07-23 Thread luis . valladares
Here is my ticket traceback:

Traceback (most recent call last):
  File "/usr/share/nginx/html/web2py/gluon/main.py", line 457, in wsgibase
session._try_store_in_db(request, response)
  File "/usr/share/nginx/html/web2py/gluon/globals.py", line 1158, in 
_try_store_in_db
self.save_session_id_cookie()
  File "/usr/share/nginx/html/web2py/gluon/globals.py", line 1058, in 
save_session_id_cookie
if not current._session_cookie_key:
AttributeError: 'thread._local' object has no attribute '_session_cookie_key'


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


[web2py] Re: web2py session disable

2016-07-21 Thread luis . valladares
Thanks for your help but didnt work, im havin a ticket using  (), the 
ticket say something about key_session_cookie not existing in 
_thread().local

Anyone has disabled python sessions succesfully and can guide me how to do 
it?

El jueves, 21 de julio de 2016, 2:57:00 (UTC-4), T.R.Rajkumar escribió:
>
>
> it should be routes_in = (('/init', '/init', dict(web2py_disable_session=
> True))
> no square brackets.
>
> On Friday, January 8, 2016 at 4:30:17 PM UTC+5:30, T.R.Rajkumar wrote:
>>
>> I have in my routes.py in web2py folder the following.
>> routes_in = (
>>   ('/ts2', '/web_ts2_site/home/home'),
>>   
>> )
>> routes_out = ()
>>
>> Now I want to disable session for web_ts2_site app. If I add the below it 
>> gives error. How to go about that?
>>
>> routes_in = [('/web_ts2_site', '/web_ts2_site', dict(
>> web2py_disable_session=True)]
>>
>> Thank you for reading.
>>
>

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


[web2py] Re: web2py session disable

2016-07-20 Thread luis . valladares
Hello!

Anyone can help here? im having exactly the same issue, my route is:

routes_in = [('/init', '/init', dict(web2py_disable_session=True)]

and i'm getting a ticket with any route in my system but if i comment that 
everything start working fine.

I dont use the session mechanism of web2py in my app and i want to fully 
disable the cookie generation and the session storage in certain apps, but 
i cant do it

El viernes, 8 de enero de 2016, 6:30:17 (UTC-4:30), T.R.Rajkumar escribió:
>
> I have in my routes.py in web2py folder the following.
> routes_in = (
>   ('/ts2', '/web_ts2_site/home/home'),
>   
> )
> routes_out = ()
>
> Now I want to disable session for web_ts2_site app. If I add the below it 
> gives error. How to go about that?
>
> routes_in = [('/web_ts2_site', '/web_ts2_site', dict(
> web2py_disable_session=True)]
>
> Thank you for reading.
>

-- 
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] standalone pyDAL dont close connections

2016-05-25 Thread luis . valladares
Hello!

Im using pyDAL with falcon (http://falconframework.org/) for microservices 
building but im having troubles in the way pyDAL handle the connections, i 
think pydal isnt telling my MySQL server to close the connection after each 
query, i've writen an example method with just a select, and put the 
Connection limit of MySQL in 500, after i make 500 requests to my API, the 
MySQL gives me "Too many connections".

In my code i simply declare a DAL object wit this: 

db = DAL(uri, pool_size=0, check_reserved=['all'], lazy_tables=False, 
migrate=True,   folder=os.path.dirname(os.path.realpath(__file__))+"/database")

And create an example table with two fields, make a simple query like:

db(db.comentario.fk_app_id == 1).select()

So, i dont know if there are any suggestions on this case, like a method in 
pyDAL to manually close the connection after each transaction and create a new 
one.

I'm using pydal 16.3, Thanks for your help!

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


[web2py] Invalid function after compiling app

2016-04-24 Thread luis . valladares
Hello!

i've a web2py app that works well, my default controller is "inicio" and 
his default function is index, so the index page of my app si 
app/inicio/index, this works well uncompiled, but when i go to the web2py 
admin app and compile this app the next request returns: invalid function 
(inicio/index) and every requests say this, im using the version 
"2.12.3-stable+timestamp.2015.08.18.19.14.07" 
and after i delet the compiled files, everything works good again. What can 
be the problem?

Thanks for your help!

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


[web2py] web2py slices down

2016-04-24 Thread luis . valladares
Web2py slices (http://www.web2pyslices.com/home) is down, shows a ticket 
when try to access

Internal errorTicket issued: unknown 


-- 
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] mongoDB dal adapter and dbref

2016-04-21 Thread luis . valladares
Hello!

I've been looking in web2py book and in pydal documentation searching 
information about the implementation of mongo database reference 
(https://docs.mongodb.org/manual/reference/database-references/) but didnt 
find anything. This is implemented in some way by pyDAL?

Thanks for your help!

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


[web2py] Re: Bootstrap is really killing web2py

2016-03-21 Thread Luis Valladares
Hello!

I agree with this post subject about bootstrap killing web2py, i use web2py 
in 4 different projects using CSS framewors like materialize, material 
design lite and material-ui and its really hard to use things like 
SQLFORM.smartgrid because it has the classes hardcoded, maybe this can be 
updated and made it fully configurable to allow it to be used with other 
CSS frameworks?.

I know this is actually configurable but is really hard to change the 
classes because are too deep or too hidden.

-- 
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: Alternate way for ticket handling

2016-03-07 Thread luis . valladares
I dont want to be anoying but i still need some help and didnt find any 
information. My "solution" cant catch models or views errors.

Thanks!

El lunes, 22 de febrero de 2016, 16:45:26 (UTC-4:30), 
luis.va...@metamaxzone.com escribió:
>
> Hello!
>
> I want to manage and catch all the error of my website using sentry (
> https://getsentry.com/welcome/), reading some post in this forum i found 
> this: 
> https://groups.google.com/forum/#!searchin/web2py/disable$20tickets$20error/web2py/0E73_7KbGJI/9WEfWCpty-4J
>
> Based in that solution i've created this inside one of my models.
>
> from raven import Client
>
>
> def mycacher(f):
> client = 
> Client('*')
> try:
> d = f()
> return d
> except:
> client.captureException()
>
> response._caller = mycacher
>
> With this i'm able to catch all the exceptions originated by a function in 
> the controller or by a function call inside a controller is handled with 
> this code, but the problems comes when a code inside the models (but 
> outside functions) is executed, for example, database definitions etc...
>
> I know i can wrap all my code with a try... Except to catch this but there 
> is any other solution for entirely "Bypassing" the ticket system in order 
> to use other system?
>
> Thanks for your help!
>

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


[web2py] Alternate way for ticket handling

2016-02-22 Thread luis . valladares
Hello!

I want to manage and catch all the error of my website using sentry 
(https://getsentry.com/welcome/), reading some post in this forum i found 
this: 
https://groups.google.com/forum/#!searchin/web2py/disable$20tickets$20error/web2py/0E73_7KbGJI/9WEfWCpty-4J

Based in that solution i've created this inside one of my models.

from raven import Client


def mycacher(f):
client = 
Client('*')
try:
d = f()
return d
except:
client.captureException()

response._caller = mycacher

With this i'm able to catch all the exceptions originated by a function in 
the controller or by a function call inside a controller is handled with 
this code, but the problems comes when a code inside the models (but 
outside functions) is executed, for example, database definitions etc...

I know i can wrap all my code with a try... Except to catch this but there 
is any other solution for entirely "Bypassing" the ticket system in order 
to use other system?

Thanks for your help!

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


Re: [web2py] Re: web2py 2.13.3 is OUT

2015-12-30 Thread Luis Valladares
Now I'm using a token based authentication but it's server side, I store
the data of the tokens inside a redis cluster server and make a request
every time I want to retrieve this token data
El dic. 30, 2015 8:33 PM, "Dave S"  escribió:

>
>
> On Wednesday, December 30, 2015 at 4:07:35 PM UTC-8, Luis Valladares wrote:
>>
>> All my applications are REST so CAS doesn't work I think
>>
>
> Currently not requiring login? You're using the REST decorator? And you
> want to add JWT for security?
>
> In that direction, I'm wondering what @response.restfull() does with
> sessions.
>  http://web2py.com/books/default/chapter/29/10/services#Services-and-Authentication
> >
> It appears that sessions (e.g. session cookies) are supported,
> and I'd be trying to use the CAS approach in the call() routine.
>
> This is speculation on my part; I'm not even a power user for auth.
>
> /dps
>
>
> El dic. 30, 2015 7:19 PM, "Dave S"  escribió:
>>
>>> On Wednesday, December 30, 2015 at 2:33:46 PM UTC-8,
>>> luis.va...@metamaxzone.com wrote:
>>>>
>>>> What if i've two different applications (event in two differents
>>>> machines) one for the front end of my site (all my views, form, etc...) and
>>>> other to authenticate my users, i mean, a micro service architecture.
>>>>
>>>
>>> Does the web2py CAS support help with this?  Assuming you're
>>> investigating the JWT support.
>>>
>>> >> http://web2py.com/books/default/chapter/29/09/access-control#Central-Authentication-Service
>>> >
>>>
>>> /dps
>>>
>>>
>>>
>>>>
>>>> El jueves, 24 de diciembre de 2015, 10:51:42 (UTC-4:30), Massimo Di
>>>> Pierro escribió:
>>>>>
>>>>> web2py 2.13.3 is out. MERRY CHRISTMAS EVERYBODY!!!
>>>>>
>>>>> It contains some bug fixes for bugs introduced in 2.13.1-2 and most
>>>>> importantly it contains experimental support for JWT. Here is how it 
>>>>> works:
>>>>>
>>>>> 1) instantiate auth with
>>>>>
>>>>> auth = Auth(db, jwt = {'secret_key':'secret'})
>>>>>
>>>>> where 'secret' is your own secret string.
>>>>>
>>>>> 2) Secorate functions that require login but should accept the
>>>>> JWT token credentials:
>>>>>
>>>>> @auth.allows_jwt()
>>>>> @auth.requires_login()
>>>>> def myapi(): return 'hello %s' % auth.user.email
>>>>>
>>>>> Notice jwt is allowed but not required. if user is logged in,
>>>>> myapi is accessible.
>>>>>
>>>>> 3) Use it!
>>>>> Now API users can obtain a token with
>>>>>
>>>>> http://.../app/default/user/jwt?username=...&password=
>>>>>
>>>>> (returns json object with a token attribute)
>>>>> API users can refresh an existing token with
>>>>>
>>>>> http://.../app/default/user/jwt?token=...
>>>>>
>>>>> they can authenticate themselves when calling http:/.../myapi
>>>>> by injecting a header
>>>>>
>>>>> Authorization: Bearer 
>>>>>
>>>>> Any additional attributes in the jwt argument of Auth() below:
>>>>>
>>>>>auth = Auth(db, jwt = {...})
>>>>>
>>>>> are passed to the constructor of class AuthJWT. Look there for
>>>>> documentation.
>>>>>
>>>>> Thanks Niphlod again for implementing this.
>>>>> Please help us check it so we will declare it stable in the next
>>>>> release.
>>>>>
>>>>> Massimo
>>>>>
>>>>>
>>>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit

Re: [web2py] Re: web2py 2.13.3 is OUT

2015-12-30 Thread Luis Valladares
All my applications are REST so CAS doesn't work I think
El dic. 30, 2015 7:19 PM, "Dave S"  escribió:

> On Wednesday, December 30, 2015 at 2:33:46 PM UTC-8,
> luis.va...@metamaxzone.com wrote:
>>
>> What if i've two different applications (event in two differents
>> machines) one for the front end of my site (all my views, form, etc...) and
>> other to authenticate my users, i mean, a micro service architecture.
>>
>
> Does the web2py CAS support help with this?  Assuming you're investigating
> the JWT support.
>
>  http://web2py.com/books/default/chapter/29/09/access-control#Central-Authentication-Service
> >
>
> /dps
>
>
>
>>
>> El jueves, 24 de diciembre de 2015, 10:51:42 (UTC-4:30), Massimo Di
>> Pierro escribió:
>>>
>>> web2py 2.13.3 is out. MERRY CHRISTMAS EVERYBODY!!!
>>>
>>> It contains some bug fixes for bugs introduced in 2.13.1-2 and most
>>> importantly it contains experimental support for JWT. Here is how it works:
>>>
>>> 1) instantiate auth with
>>>
>>> auth = Auth(db, jwt = {'secret_key':'secret'})
>>>
>>> where 'secret' is your own secret string.
>>>
>>> 2) Secorate functions that require login but should accept the
>>> JWT token credentials:
>>>
>>> @auth.allows_jwt()
>>> @auth.requires_login()
>>> def myapi(): return 'hello %s' % auth.user.email
>>>
>>> Notice jwt is allowed but not required. if user is logged in,
>>> myapi is accessible.
>>>
>>> 3) Use it!
>>> Now API users can obtain a token with
>>>
>>> http://.../app/default/user/jwt?username=...&password=
>>>
>>> (returns json object with a token attribute)
>>> API users can refresh an existing token with
>>>
>>> http://.../app/default/user/jwt?token=...
>>>
>>> they can authenticate themselves when calling http:/.../myapi by
>>> injecting a header
>>>
>>> Authorization: Bearer 
>>>
>>> Any additional attributes in the jwt argument of Auth() below:
>>>
>>>auth = Auth(db, jwt = {...})
>>>
>>> are passed to the constructor of class AuthJWT. Look there for
>>> documentation.
>>>
>>> Thanks Niphlod again for implementing this.
>>> Please help us check it so we will declare it stable in the next release.
>>>
>>> Massimo
>>>
>>>
>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/NUDpOmGLDTQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: web2py 2.13.3 is OUT

2015-12-30 Thread luis . valladares
What if i've two different applications (event in two differents machines) 
one for the front end of my site (all my views, form, etc...) and other to 
authenticate my users, i mean, a micro service architecture.

El jueves, 24 de diciembre de 2015, 10:51:42 (UTC-4:30), Massimo Di Pierro 
escribió:
>
> web2py 2.13.3 is out. MERRY CHRISTMAS EVERYBODY!!!
>
> It contains some bug fixes for bugs introduced in 2.13.1-2 and most 
> importantly it contains experimental support for JWT. Here is how it works:
>
> 1) instantiate auth with
>
> auth = Auth(db, jwt = {'secret_key':'secret'})
>
> where 'secret' is your own secret string. 
>
> 2) Secorate functions that require login but should accept the JWT 
> token credentials:
>
> @auth.allows_jwt()
> @auth.requires_login()
> def myapi(): return 'hello %s' % auth.user.email
> 
> Notice jwt is allowed but not required. if user is logged in, 
> myapi is accessible.
>
> 3) Use it!
> Now API users can obtain a token with
>
> http://.../app/default/user/jwt?username=...&password=
>
> (returns json object with a token attribute)
> API users can refresh an existing token with
>
> http://.../app/default/user/jwt?token=...
>
> they can authenticate themselves when calling http:/.../myapi by 
> injecting a header
>
> Authorization: Bearer 
>
> Any additional attributes in the jwt argument of Auth() below:
>
>auth = Auth(db, jwt = {...})
>
> are passed to the constructor of class AuthJWT. Look there for 
> documentation.
>
> Thanks Niphlod again for implementing this. 
> Please help us check it so we will declare it stable in the next release.
>
> Massimo
>
>
>

-- 
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] HTML5 Local storage and web2py

2015-12-28 Thread luis . valladares
Hello!

I want to use the HTML5 Local Storage 
(http://diveintohtml5.info/storage.html) to store session and other 
persisent data of my web2py application. There is any way to do this inside 
web2py or i must do this only with javascript?

Maybe it could be an interesting feature to add if it doesnt exist

Thanks for any help!

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


[web2py] Re: best way to execute eternal js

2015-12-23 Thread luis . valladares
Okay this is a really great idea and i can use it perfectly, but i wonder 
(only for making it easy to me) if there is a way to do this with a 
javascript that depends of the data associated with the page request? maybe 
a way to pass all the params recieved by the view from the controller to my 
server_js method in order to pass this parameters also to the .js file.

El miércoles, 23 de diciembre de 2015, 16:31:52 (UTC-4:30), Anthony 
escribió:
>
> On Wednesday, December 23, 2015 at 3:50:58 PM UTC-5, 
> luis.va...@metamaxzone.com  wrote:
>>
>> the first solution is a very good approach to my problem because i've a 
>> considerable amount of python code inside my javascript, in fact if i 
>> define variables for this content i will have between 80-120 vars per view. 
>> But i still have one problem with this solution: For the navigator is 
>> exactly like i have the code inline with my html and this mean that it'll 
>> not be cached as a javascript file. It would be really good if the 
>> navigator could cache this file.
>>
>
> If the content of the JS doesn't depend on other data associated with the 
> page request, you could serve the JS via a separate request and cache it:
>
> @cache.action(...)
> def serve_js():
> response.view = 'views/js/%s' % request.args(0)
> return dict()
>
> Then in your main view:
>
> 
>
> Anthony
>

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


[web2py] Re: best way to execute eternal js

2015-12-23 Thread luis . valladares
the first solution is a very good approach to my problem because i've a 
considerable amount of python code inside my javascript, in fact if i 
define variables for this content i will have between 80-120 vars per view. 
But i still have one problem with this solution: For the navigator is 
exactly like i have the code inline with my html and this mean that it'll 
not be cached as a javascript file. It would be really good if the 
navigator could cache this file.

Thanks for your help!

El miércoles, 23 de diciembre de 2015, 13:31:00 (UTC-4:30), Anthony 
escribió:
>
> If you're just worried about code organization and want the JS code in a 
> separate file, you could move it to its own template and then include it 
> where needed. For example, move your JS code to a file like /views/my.js. 
> Then in your view:
>
> 
> {{include 'my.js'}}
> 
>
> However, that will be somewhat inefficient if you've got lots of 
> Javascript code but only a little bit of dynamically generated web2py 
> content mixed in. An alternative is to define the dynamically generated 
> web2py variables in one block of Javascript in the template, and then load 
> a static JS file that simply refers to those variables (this is how 
> web2py_ajax.html works -- notice that it defines several JS variables, 
> which are then used by web2py.js). So, in your view:
>
> 
> var someVar = '{{=T('some phrase to be translated')}}';
> var someURL = '{{=URL('default', 'myfunction')}}';
> 
> 
>
> Then in my.js, you can refer to someVar and someURL.
>
> Anthony
>
> On Wednesday, December 23, 2015 at 12:48:03 PM UTC-5, 
> luis.va...@metamaxzone.com  wrote:
>>
>> Yes, inside my javascript i have a lot of web2py helpers for string 
>> internationalization and even for looping between a dictionary of data and 
>> generating a set of markers for google maps, also i use the web2py URL 
>> helpers for the ajax requests URL. I can change the way i handle the loop 
>> and the URL, but for internationalization i have not found any way to 
>> handle the internationalization
>>
>> El miércoles, 23 de diciembre de 2015, 12:07:46 (UTC-4:30), Anthony 
>> escribió:
>>>
>>> Are you saying some of your Javascript code is generated via web2py 
>>> templates? If so, it's hard to say what the best approach would be without 
>>> seeing some code.
>>>
>>> Anthony
>>>
>>> On Wednesday, December 23, 2015 at 9:46:41 AM UTC-5, 
>>> luis.va...@metamaxzone.com wrote:

 Hello!

 I've been analyzing how to work around in the best form an "issue", 
 this doesnt affect the functionality of my code but it is against good 
 practices.

 My website have a full internationalization and uses some variables 
 passed by the controller inside the javascript to generate a highly 
 dynamical page, this is no problem if i have my javascript inline my HTML 
 templates, but for sake of order and good practices i wish to have my .js 
 and .html in different files, but if i've the js outside my template it 
 doesnt know how to process a web2py helper instruction.

 So i've been thinking in some workarounds but i dont find a good 
 solution for now, may be some of you have a suggestion for this.

 Thank you very much!

>>>

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


[web2py] Re: best way to execute eternal js

2015-12-23 Thread luis . valladares
Yes, inside my javascript i have a lot of web2py helpers for string 
internationalization and even for looping between a dictionary of data and 
generating a set of markers for google maps, also i use the web2py URL 
helpers for the ajax requests URL. I can change the way i handle the loop 
and the URL, but for internationalization i have not found any way to 
handle the internationalization

El miércoles, 23 de diciembre de 2015, 12:07:46 (UTC-4:30), Anthony 
escribió:
>
> Are you saying some of your Javascript code is generated via web2py 
> templates? If so, it's hard to say what the best approach would be without 
> seeing some code.
>
> Anthony
>
> On Wednesday, December 23, 2015 at 9:46:41 AM UTC-5, 
> luis.va...@metamaxzone.com  wrote:
>>
>> Hello!
>>
>> I've been analyzing how to work around in the best form an "issue", this 
>> doesnt affect the functionality of my code but it is against good practices.
>>
>> My website have a full internationalization and uses some variables 
>> passed by the controller inside the javascript to generate a highly 
>> dynamical page, this is no problem if i have my javascript inline my HTML 
>> templates, but for sake of order and good practices i wish to have my .js 
>> and .html in different files, but if i've the js outside my template it 
>> doesnt know how to process a web2py helper instruction.
>>
>> So i've been thinking in some workarounds but i dont find a good solution 
>> for now, may be some of you have a suggestion for this.
>>
>> Thank you very much!
>>
>

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


[web2py] best way to execute eternal js

2015-12-23 Thread luis . valladares
Hello!

I've been analyzing how to work around in the best form an "issue", this 
doesnt affect the functionality of my code but it is against good practices.

My website have a full internationalization and uses some variables passed 
by the controller inside the javascript to generate a highly dynamical 
page, this is no problem if i have my javascript inline my HTML templates, 
but for sake of order and good practices i wish to have my .js and .html in 
different files, but if i've the js outside my template it doesnt know how 
to process a web2py helper instruction.

So i've been thinking in some workarounds but i dont find a good solution 
for now, may be some of you have a suggestion for this.

Thank you very much!

-- 
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: Can web2py "front-end" an API?

2015-10-20 Thread Luis Valladares
What if you use a model-less aplication? thats the way we handled this, we 
have a web2py application that consumes a lot of microservices, this 
application doesnt have any DB object and doesnt use the dal, it makes HTTP 
request to the api inside the controllers (Using the python requests 
library), format it and send to the views.

El domingo, 18 de octubre de 2015, 0:55:50 (UTC-4:30), pbreit escribió:
>
> Is there an easy way to use web2py to "front-end" and API? What I mean by 
> that is that given a public API (for example, Stripe's API), could I write 
> some models that correspond to the API structure and then call the DAL as 
> if the API was a back-end DB? Does that make any sense?
>

-- 
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: PyCharm license for web2py dev - who wants?

2015-10-14 Thread Luis Valladares
+1. Thanks for the info BTW!

El domingo, 11 de octubre de 2015, 14:51:16 (UTC-4:30), Francisco Ribeiro 
escribió:
>
> Hello all,
>
> for those who know PyCharm is a great IDE from JetBrains that provides 
> free licenses for Open Source projects like web2py ( 
> https://www.jetbrains.com/buy/opensource/?product=pycharm ). To request 
> such a license, I need to know how many of you would want one of these as 
> well so I can provide them with a number of seats. 
>
> A "+1" response for me is enough but I will also need your email address 
> to send you the license key (which you can send on a private message).
>
> Kind regards,
> Francisco
>

-- 
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] Redis cluster

2015-10-10 Thread Luis Valladares
Hello!

I was wondering if exist any implementation or experiencies with redis 
cluster in web2py? i googled this but cant found anything

Here is a link explaining what is redis cluster: 
http://redis.io/topics/cluster-tutorial

Thanks for your help!

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


Re: [web2py] Re: Web2py celery plugin

2015-10-04 Thread Luis Valladares
Thanks Mark! I think this will work, i will try it on the job and come here 
if i have any troubles.

El domingo, 4 de octubre de 2015, 8:59:37 (UTC-4:30), Mark Graves escribió:
>
> As documented in the web2py book,
>
> The "web2py.py" script can take many command-line arguments specifying the 
> maximum number of threads, enabling of SSL, etc. For a complete list type:
>
> >>> python web2py.py -h
>
> For example, a shell script called async_events.sh can be called at reboot as 
> follows:
>
> #! /bin/bash
>
> cd /home/www-data/web2py
>
> python web2py.py -S YOUR_APPLICATION_NAME -M -R 
> applications/YOUR_APPLICATION_NAME/private/async_events.py
>
>
> The contents of async_events.py are a simple python script run as if it 
> were a request from web2py
>
> For example:
>
> import time 
>
>  
>
> def create_pdfs(db):
>> while True:
>> ALL YOUR PDF PROCESSING LOGIC HERE
>
> time.sleep(60) 
>
>>  
>
>  
>
> create_pdfs(db)
>
>
>
> The above is an example script where your create_pdfs function handles all 
> the processing logic.
>
> The time.sleep(60) means run every minute.
>
> You would run this task once @reboot so python would handle the interval 
> between tasks.
>  
> From there, you can use all the internal web2py API including mail.send() 
> etc
>
>
> -Mark
>
>
>
> On Sun, Oct 4, 2015 at 8:16 AM, Luis Valladares  > wrote:
>
>> Hello mark! thanks for you answer.
>>
>> Your approach sounds really nice, but exactly how you run a cron task 
>> inside web2py environment? you start the web2py client with the console 
>> option and there execute the task? may you give me an example of this?
>>
>>
>> El domingo, 4 de octubre de 2015, 8:31:20 (UTC-4:30), Mark Graves 
>> escribió:
>>>
>>> Luis,
>>>
>>> I've never personally used celery to queue tasks to execute in a web2py 
>>> environment.
>>>
>>> I found myself in a similar situation recently and just used a cron task 
>>> running a python script in the web2py environment from the command line.
>>>
>>> Is there a particular reason this workflow would not work for you?
>>>
>>> -Mark
>>>
>>> On Saturday, October 3, 2015 at 10:40:47 AM UTC-5, Luis Valladares wrote:
>>>>
>>>> But how can you exec a web2py task (who may uses web2py internal 
>>>> components like Request, response, db, etc..) with a external celery app? 
>>>> i 
>>>> mean, if i wish to execute a task, for example: To insert a new register 
>>>> in 
>>>> a table of my web2py database, and in enqueue this task to a remote (or 
>>>> local) celery worker to do it, how i can get this worker to know about all 
>>>> the "environment" of web2py? the only idea i have its creating a worker 
>>>> that is aware of the web2py environment, but i dont know how to do this.
>>>>
>>>> There is anyway to use celery queue to execute tasks that requires the 
>>>> web2py environment?
>>>>
>>>> El viernes, 2 de octubre de 2015, 5:46:35 (UTC-4:30), Niphlod escribió:
>>>>>
>>>>> I'd say you're loosing yourself in a glass of water. In order to 
>>>>> schedule something, that something must work. If your "something" 
>>>>> doesn't, 
>>>>> it really doesn't matter what tool are you issuing commands to.
>>>>>
>>>>> On Friday, October 2, 2015 at 11:56:55 AM UTC+2, Stefan van den 
>>>>> Eertwegh wrote:
>>>>>>
>>>>>> Hi Niphlod,
>>>>>>
>>>>>> Thanks for you answer.
>>>>>>
>>>>>> Why i am asking this is because i want to generate around 150 pdf's 
>>>>>> by weasyprint and per each pdf i want to queue a mail with it as an 
>>>>>> attachment.
>>>>>> Could this be done by the build in web2py Scheduler?
>>>>>>
>>>>>> PS: i tried the scheduler, but it tries to use the generic.html view 
>>>>>> but has not enough settings provided in the layout.html to use it, it 
>>>>>> fails.
>>>>>> is is not so that it executes the function from the model with 
>>>>>> database privileges and not uses a view? Or is it also using the default 
>>>>>> generic view?
>>>>>>
>>>>>> Thank

[web2py] Re: Web2py celery plugin

2015-10-04 Thread Luis Valladares
Hello mark! thanks for you answer.

Your approach sounds really nice, but exactly how you run a cron task 
inside web2py environment? you start the web2py client with the console 
option and there execute the task? may you give me an example of this?

El domingo, 4 de octubre de 2015, 8:31:20 (UTC-4:30), Mark Graves escribió:
>
> Luis,
>
> I've never personally used celery to queue tasks to execute in a web2py 
> environment.
>
> I found myself in a similar situation recently and just used a cron task 
> running a python script in the web2py environment from the command line.
>
> Is there a particular reason this workflow would not work for you?
>
> -Mark
>
> On Saturday, October 3, 2015 at 10:40:47 AM UTC-5, Luis Valladares wrote:
>>
>> But how can you exec a web2py task (who may uses web2py internal 
>> components like Request, response, db, etc..) with a external celery app? i 
>> mean, if i wish to execute a task, for example: To insert a new register in 
>> a table of my web2py database, and in enqueue this task to a remote (or 
>> local) celery worker to do it, how i can get this worker to know about all 
>> the "environment" of web2py? the only idea i have its creating a worker 
>> that is aware of the web2py environment, but i dont know how to do this.
>>
>> There is anyway to use celery queue to execute tasks that requires the 
>> web2py environment?
>>
>> El viernes, 2 de octubre de 2015, 5:46:35 (UTC-4:30), Niphlod escribió:
>>>
>>> I'd say you're loosing yourself in a glass of water. In order to 
>>> schedule something, that something must work. If your "something" doesn't, 
>>> it really doesn't matter what tool are you issuing commands to.
>>>
>>> On Friday, October 2, 2015 at 11:56:55 AM UTC+2, Stefan van den Eertwegh 
>>> wrote:
>>>>
>>>> Hi Niphlod,
>>>>
>>>> Thanks for you answer.
>>>>
>>>> Why i am asking this is because i want to generate around 150 pdf's by 
>>>> weasyprint and per each pdf i want to queue a mail with it as an 
>>>> attachment.
>>>> Could this be done by the build in web2py Scheduler?
>>>>
>>>> PS: i tried the scheduler, but it tries to use the generic.html view 
>>>> but has not enough settings provided in the layout.html to use it, it 
>>>> fails.
>>>> is is not so that it executes the function from the model with database 
>>>> privileges and not uses a view? Or is it also using the default generic 
>>>> view?
>>>>
>>>> Thanks for responding!
>>>>
>>>> Best regards,
>>>> Stefan
>>>>
>>>> Op vrijdag 2 oktober 2015 11:21:07 UTC+2 schreef Niphlod:
>>>>>
>>>>> you won't ever get to start workers from web2py, either with the 
>>>>> embedded scheduler, with rq or with celery.that's pretty much a 
>>>>> requirement (being completely separated)
>>>>>
>>>>> PS: celery integration was done on a so old release of celery that it 
>>>>> won't ever be production ready
>>>>>
>>>>> PS2: you don't need any web2py plugin to push task to celery.
>>>>>
>>>>>
>>>>>

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


[web2py] Re: Web2py celery plugin

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

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

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

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


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

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

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

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

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


[web2py] Re: Multi file upload

2015-09-20 Thread Luis Valladares
Hello! turns out that i've not handled it well from the server, so in 
changed my approach to this and worked flawlessly:

In the view:

 
  {{=T('Archivo')}} 
#1   
  {{=T('Descripción')}} 
#1Añadir otra foto  


The "añadir otra foto" button adds another field, with the formar foto_X 
descripcion_x where X is a consecutive number.

Later in the controller i do this:

 if var.startswith('foto_') and request.vars[var] != '':
uploaded = request.vars[var]descName = var.replace('foto', 
'descripcion')descripcion = request.vars[descName]  
  db.hoteles_fotos.insert(fk_hotel_id=id, 
descripcion=descripcion,
ruta=db.hoteles_fotos.ruta.store(uploaded.file, uploaded.filename))



El jueves, 13 de agosto de 2015, 13:25:06 (UTC-4:30), Val K escribió:
>
> Hi!
> It seems, that  your view has no  form-tag (i.e.   submit-button ...  so, I suppose,   it doesn't send anything at all! But 
> may be there are some mega-cool-js-hidden-magic? How it works?
> And if it works  web2py couldn't  process request.vars  with name like 
> "file[1]",  because request.vars is Storage-object (not array or list!) and 
> provide dot-property-notation  access, so request.vars.file[1] - 
> inadmissible
>
>
> On Wednesday, August 12, 2015 at 11:36:43 PM UTC+3, Luis Valladares wrote:
>>
>> Hello!
>>
>> I'm trying to create a form in order to upload multiple files with 
>> description for each file, i've something like this:
>>
>> View:
>> 
>>   
>>  
>>   {{=T('Archivo')}}
>>   
>> 
>>   
>>   
>>  
>>   {{=T('Descripción')}}
>>   > />
>> 
>>   
>>   
>>  
>>   {{=T('Archivo')}}
>>   
>> 
>>   
>>   
>>  
>>   {{=T('Descripción')}}
>>   > />
>> 
>>   
>>   
>>  
>>   {{=T('Archivo')}}
>>   
>> 
>>   
>>   
>>  
>>   {{=T('Descripción')}}
>>   > />
>> 
>>   
>> 
>>
>> Controller:
>> for archivo, descripcion in zip(form.vars.file, form.vars.description):
>> db.fotos.insert(
>> fk_id=id, descripcion=descripcion, ruta=archivo)
>>
>> But when i send this form i get this error: "> 'exceptions.TypeError'> zip argument #1 must support iteration"
>>
>> any suggestion? Thanks a lot for your help!
>>
>>
>>
>>

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


[web2py] Re: Questions about authentication and authorization

2015-09-20 Thread Luis Valladares
After some discussion with my team we come with this architecture:

We will have a service to manage authentication and authorization, all our 
services will query him in order to get permission and credential, for 
authentication we will use CAS and for authorization RBAC over sended over 
JSON.

I've another question, exactly how CAS works? i mean, i know the theory 
that you log in the CAS provider and you will be logged in the CAS 
consumer, but how this works? with session cookies and a token? or how CAS 
communicate with the consumers

El lunes, 14 de septiembre de 2015, 21:54:30 (UTC-4:30), Luis Valladares 
escribió:
>
> Thanks for your answer!
>
> I've been reading about JWT too, and i consider it for application 
> authorization, the thing is i dont feel comfortable sending the parameters 
> through JSON, i prefer to send it via POST parameters and so, but after 
> reading the link you posted sounds like a good solution for app 
> authentication, and i will consider this along with Amazon approach and 
> OAuth2. The thing that is really bottering me is the authorization of 
> users. Any sugestion on this field?
>
> Thank you very much!
>
> El lunes, 14 de septiembre de 2015, 18:19:12 (UTC-4:30), Dave S escribió:
>>
>>
>>
>> On Monday, September 14, 2015 at 3:35:20 PM UTC-7, Luis Valladares wrote:
>>>
>>> Since i do the post i found some interesting articles, and now i have a 
>>> better implementation idea, but i'm still looking for the solution on a 
>>> subject. Here is what i have now:
>>>
>>> I will handle the authentication of my applications using the amazon 
>>> approach (
>>> http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/)
>>>  
>>> and the user authentication using CAS in order to centralize al the 
>>> services auth providers, but i'm still searching for a way to handle the 
>>> authorization for user, i read about Spring security but i didnt see any 
>>> implementation in python or web2py
>>>
>>> Again, thanks for any help!
>>>
>>
>> Perhaps Niphlod's JWT implementation would work for you, too.
>>
>> Quoting his example again:
>>
>>
>>> As per "original" demand of covering one-time-issued tokens, the "jti" 
>>> claim is the standard, and can be easily implemented, imagining to store 
>>> valid tokens in a database table:
>>>
>>> db.define_table('jwt_tokens', Field('token'), Field('user_id'), Field(
>>> 'inserted_on', 'datetime', default=request.now))
>>>
>>> def myadditional_payload(payload):
>>>  res = db(db.jwt_tokens.user_id == payload['user']['id']).select(
>>> orderby=~db.jwt_tokens.inserted_on).first()
>>>  payload['jti'] = res.token
>>>  return payload
>>>
>>> def mybefore_authorization(tokend):
>>>  res = db(
>>> (db.jwt_tokens.user_id == tokend['user']['id']) & 
>>> (db.jwt_tokens.token == tokend['jti'])
>>>  ).select().first()
>>>  if not res:
>>>  raise HTTP(400, u'Invalid JWT jti claim')
>>>
>>> myjwt = Web2pyJwt('secret', auth, 
>>>   additional_payload=additional_payload, 
>>>   before_authorization=mybefore_authorization)
>>>  
>>
>>
>> The list of features is in his post in the developer's forum.
>> > https://groups.google.com/d/msg/web2py-developers/dXfUrHNI5Sg/gqNa3kXsCQAJ
>> >
>>
>> If you need some background on JWT, my reading list recently included
>> https://self-issued.info/docs/draft-ietf-oauth-json-web-token.html>
>> (that's the standard as of May; it's actually readable by users of 
>> standards as well the writers, I think)
>>
>> /dps
>>
>>  
>>
>

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


[web2py] Re: Grid without consulting database

2015-09-20 Thread Luis Valladares
Sorry for the late response! i will test this ASAP

El viernes, 11 de septiembre de 2015, 13:48:56 (UTC-4:30), pjryan126 
escribió:
>
> I haven't tested any of this -- I would need a little time to put 
> something together, but I would attack the problem like this:
>
> 1. Create a Table object with appropriate fields and set migrate=False 
> (This creates a dummy table) 
> 2. Convert row values into a list of tuples
> 3. Use db._adapter.parse to create a DAL Rows object using the dummy table:
>
> t_rows = db._adapter.parse(rows, fields=[f for f in db.dummy_table], 
> colnames=db.dummy_table.fields)
>
>
> 4. Create a SQLFORM.grid in controller and then replace the rows with your 
> rows object using the DOM parser.
>
> grid = SQLFORM.grid(db.dummy_table)
> table = grid.element('.web2py_table')
> table[0] = t_rows
>
>
> On Thursday, September 10, 2015 at 6:50:49 PM UTC-4, Luis Valladares wrote:
>>
>> Well, that sounds like a big mess of db i/o, i think it will be better to 
>> use javascript. Maybe this can be put in a "wish list" for future 
>> development in web2py?
>>
>> Thanks for your help!
>>
>> El jueves, 10 de septiembre de 2015, 18:03:01 (UTC-4:30), Leonel Câmara 
>> escribió:
>>>
>>> Well there is, but, it's not pretty. You could create a DAL instance 
>>> using sqlite mem, then you put everything you get from the service there, 
>>> then you send a query in that DAL instance to the grid.  
>>>   
>>> Frankly, this is not a good idea and you'll probably run into problems, 
>>> you're better off using one of the many javascript grid options.
>>>
>>> Here are some options:
>>>
>>> http://handsontable.com/
>>> https://github.com/tonytomov/jqGrid/tree/master
>>> http://datatables.net/
>>>
>>> Or really just make it yourself it's really easy with stuff like 
>>> ractivejs or similar.
>>>  
>>>
>>

-- 
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] Polymer and SQLFORM

2015-09-20 Thread Luis Valladares
Hello!

I'm building a web2py site and i want to use polymer as my front-end 
"framework", as you may know polymer uses web elements with custom html 
tags, i mean, a input is something can be something like



I want to integrate this "feature" with the web2py SQLFORM module, after a 
bit of research i came with this approach, im not sure if its correct so i 
accept suggestion:

i've to override all the FormWidget class inside sqlhtml.py and modify all 
widget to generate a HTML output adapted to my custom tags, also create a 
custom formstyle related to polymer and maybe (and this is one of the 
problems i've found) create some sort of custom HTML helper for generating 
the HTML custom tags.

I think i miss a lot of changes needed for this to work well, so i am 
looking for opinions in this matter, i'm correct in my planning, or maybe 
there is a easier path to join SQLFORM and Polymer, or may be better to 
work without SQLFORM?

Thank for any help you can provide

-- 
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: Questions about authentication and authorization

2015-09-14 Thread Luis Valladares
Thanks for your answer!

I've been reading about JWT too, and i consider it for application 
authorization, the thing is i dont feel comfortable sending the parameters 
through JSON, i prefer to send it via POST parameters and so, but after 
reading the link you posted sounds like a good solution for app 
authentication, and i will consider this along with Amazon approach and 
OAuth2. The thing that is really bottering me is the authorization of 
users. Any sugestion on this field?

Thank you very much!

El lunes, 14 de septiembre de 2015, 18:19:12 (UTC-4:30), Dave S escribió:
>
>
>
> On Monday, September 14, 2015 at 3:35:20 PM UTC-7, Luis Valladares wrote:
>>
>> Since i do the post i found some interesting articles, and now i have a 
>> better implementation idea, but i'm still looking for the solution on a 
>> subject. Here is what i have now:
>>
>> I will handle the authentication of my applications using the amazon 
>> approach (
>> http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/)
>>  
>> and the user authentication using CAS in order to centralize al the 
>> services auth providers, but i'm still searching for a way to handle the 
>> authorization for user, i read about Spring security but i didnt see any 
>> implementation in python or web2py
>>
>> Again, thanks for any help!
>>
>
> Perhaps Niphlod's JWT implementation would work for you, too.
>
> Quoting his example again:
>
>
>> As per "original" demand of covering one-time-issued tokens, the "jti" 
>> claim is the standard, and can be easily implemented, imagining to store 
>> valid tokens in a database table:
>>
>> db.define_table('jwt_tokens', Field('token'), Field('user_id'), Field(
>> 'inserted_on', 'datetime', default=request.now))
>>
>> def myadditional_payload(payload):
>>  res = db(db.jwt_tokens.user_id == payload['user']['id']).select(
>> orderby=~db.jwt_tokens.inserted_on).first()
>>  payload['jti'] = res.token
>>  return payload
>>
>> def mybefore_authorization(tokend):
>>  res = db(
>> (db.jwt_tokens.user_id == tokend['user']['id']) & 
>> (db.jwt_tokens.token == tokend['jti'])
>>  ).select().first()
>>  if not res:
>>  raise HTTP(400, u'Invalid JWT jti claim')
>>
>> myjwt = Web2pyJwt('secret', auth, 
>>   additional_payload=additional_payload, 
>>   before_authorization=mybefore_authorization)
>>  
>
>
> The list of features is in his post in the developer's forum.
>  https://groups.google.com/d/msg/web2py-developers/dXfUrHNI5Sg/gqNa3kXsCQAJ
> >
>
> If you need some background on JWT, my reading list recently included
> https://self-issued.info/docs/draft-ietf-oauth-json-web-token.html>
> (that's the standard as of May; it's actually readable by users of 
> standards as well the writers, I think)
>
> /dps
>
>  
>

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


[web2py] Re: Questions about authentication and authorization

2015-09-14 Thread Luis Valladares
Since i do the post i found some interesting articles, and now i have a 
better implementation idea, but i'm still looking for the solution on a 
subject. Here is what i have now:

I will handle the authentication of my applications using the amazon 
approach 
(http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/)
 
and the user authentication using CAS in order to centralize al the 
services auth providers, but i'm still searching for a way to handle the 
authorization for user, i read about Spring security but i didnt see any 
implementation in python or web2py

Again, thanks for any help!

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


[web2py] Questions about authentication and authorization

2015-09-14 Thread Luis Valladares
Hello!

Im now developing an app that will consume from several microservices, 
everything done in web2py, and i want to be sure that my app will be the 
only who makes requests to my service, so in order to do this i have this 
structure in mind:

Use CAS for authentication between the services and the application.
Use OAuth2(?) to check the origin of the request and validate it
Use ? for authorization between the services and the application.

As you can see i've a lot of blank spaces, so im looking for some help to 
clarify my ideas.

Thanks for any help you can provide!

-- 
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: Grid without consulting database

2015-09-10 Thread Luis Valladares
Well, that sounds like a big mess of db i/o, i think it will be better to 
use javascript. Maybe this can be put in a "wish list" for future 
development in web2py?

Thanks for your help!

El jueves, 10 de septiembre de 2015, 18:03:01 (UTC-4:30), Leonel Câmara 
escribió:
>
> Well there is, but, it's not pretty. You could create a DAL instance using 
> sqlite mem, then you put everything you get from the service there, then 
> you send a query in that DAL instance to the grid.  
>   
> Frankly, this is not a good idea and you'll probably run into problems, 
> you're better off using one of the many javascript grid options.
>
> Here are some options:
>
> http://handsontable.com/
> https://github.com/tonytomov/jqGrid/tree/master
> http://datatables.net/
>
> Or really just make it yourself it's really easy with stuff like ractivejs 
> or similar.
>

-- 
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] Grid without consulting database

2015-09-10 Thread Luis Valladares
Hello! I'm trying to use SQLFORM.grid (or something like this) to my 
website, but this page doesnt have a database because it consumes all the 
data form a service, so i ask the service for the list of records in a 
table and i recieve it in json format and transform to dictionary.

What i want to do is use this dictionary to create a grid (Like the 
SQLFORM.grid) but the grid doesnt work if i dont specify a query, there is 
a way to create a grid without query and instead with a dictionary?

Thanks for any help you can give!

-- 
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] Restful API

2015-08-21 Thread Luis Valladares
Hello! I want to buid an applicaton using the microservices architecture, 
in order to do this i will implement some Restful APIs using web2py that 
will be accesed by my applications using HTTP request.

This project will be a large scale application with a huge amount of 
request, so i need to optimize all the tiers the best i can, because web2py 
is a framework with a bunch of features enabled by default i want to 
minimize all this features, because the idea of the Restful api is only to 
authenticate the request (via OAuth) do db i/o operation and some 
processing on the recieved data from the request.

I was wondering if this any way to create a web2py in a more granular way, 
by picking the services/libraries i want to run, and if any of you has 
experience in this architecture and can give me some advice it will be 
appreciated.

Thank you very much por any help you can give and sorry for the bad english!

-- 
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] Multi file upload

2015-08-12 Thread Luis Valladares
Hello!

I'm trying to create a form in order to upload multiple files with 
description for each file, i've something like this:

View:

  
 
  {{=T('Archivo')}}
  

  
  
 
  {{=T('Descripción')}}
  

  
  
 
  {{=T('Archivo')}}
  

  
  
 
  {{=T('Descripción')}}
  

  
  
 
  {{=T('Archivo')}}
  

  
  
 
  {{=T('Descripción')}}
  

  


Controller:
for archivo, descripcion in zip(form.vars.file, form.vars.description):
db.fotos.insert(
fk_id=id, descripcion=descripcion, ruta=archivo)

But when i send this form i get this error: " 
zip argument #1 must support iteration"

any suggestion? Thanks a lot for your help!



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


[web2py] Re: avoid controller to sanitize html

2015-08-07 Thread Luis Valladares
Thanks Anthony! using the option helper and returning without the 
dictionary solved my issue, there is other errors on the javascript but i 
already solved it, now works well, one more question: There is no built-in 
function that creates a dropdown list from a DAL select?

El viernes, 7 de agosto de 2015, 11:34:31 (UTC-4:30), Anthony escribió:
>
> If your function returns a dictionary, web2py assumes you want to execute 
> a view. If you haven't created a view, it will use generic.html (by 
> default, this only works for local requests). If you just want to return 
> the raw HTML generated in the controller without then executing a view, 
> then just return the HTML (i.e., no dictionary).
>
> Additionally, you might want to consider building the HTML using the 
> web2py HTML helpers rather than building it via strings. In that case, you 
> can just return the final HTML helper, and it will automatically be 
> converted to an HTML string before returning to the browser.
>
> If you do actually have a view that is being executed and you want to 
> insert raw HTML, you would wrap it in XML() (though, again, you could 
> instead just use the web2py HTML helpers and not bother with XML()).
>
> Anthony
>
> On Friday, August 7, 2015 at 11:50:47 AM UTC-4, Luis Valladares wrote:
>>
>> Hello!
>>
>> I've a form where i store country, state and municipality and i need to 
>> dynamcally change the value based on the select, i mean: If i select a X 
>> country i need to display only the states of the country "X" in the states 
>> dropdown, the same with municipality
>>
>> I used a basic approach that i've used many times befores in other 
>> languages, a jquery function on dropdown change that ajax call a page and 
>> it returns the options and put it into the dropdown, i've been researching 
>> and found this really helpful: 
>> http://stackoverflow.com/questions/10387672/web2py-dropdown-menu, so 
>> based on this answer i build this structure:
>>
>> On the controller: 
>>
>> def ajaxMunicipio():
>> if request.args(0) in db.estados.id:
>> response.generic_patterns = ['load']
>> data = db(db.municipios.estado == request.args(0)).select()
>> html = "\"
>> for fila in data:
>> html += "\> )+"\"\>"+fila.nombre+"\"
>> html += "\"
>> return dict(form=html)
>> else:
>> raise HTTP(404)
>>
>>
>>
>>
>>
>> And on the view:
>>
>>   jQuery(function() {
>> jQuery('#no_table_estado_id').change(function() {
>>   var request = $.ajax({
>> url: "{{=URL('hot', 'ajaxMunicipio.load')}}" + "/" + 
>> jQuery(this).val(),
>> method: "GET",
>> dataType: "html"
>> });
>>   request.done(function(html) {
>> console.log(html)
>> $("#no_table_municipio_id").val(html);
>>   });
>> })
>>   })
>>
>>
>>
>> everything works well on the call side but i recieve the HTML sanitized 
>> like this: \<select\>\<option 
>> value="1"\>LIBERTADOR\</option\>\</select\>
>>
>> So i'm looking for a way to avoid web2py to sanitize the html, or maybe a 
>> cleanest way to do this because i dont really like looping the data in the 
>> controller in order to create the HTML
>>
>> I appreciate any help you can give! Thanks for your atention
>>
>>
>>

-- 
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] avoid controller to sanitize html

2015-08-07 Thread Luis Valladares
Hello!

I've a form where i store country, state and municipality and i need to 
dynamcally change the value based on the select, i mean: If i select a X 
country i need to display only the states of the country "X" in the states 
dropdown, the same with municipality

I used a basic approach that i've used many times befores in other 
languages, a jquery function on dropdown change that ajax call a page and 
it returns the options and put it into the dropdown, i've been researching 
and found this really helpful: 
http://stackoverflow.com/questions/10387672/web2py-dropdown-menu, so based 
on this answer i build this structure:

On the controller: 

def ajaxMunicipio():
if request.args(0) in db.estados.id:
response.generic_patterns = ['load']
data = db(db.municipios.estado == request.args(0)).select()
html = "\"
for fila in data:
html += "\"+fila.nombre+"\"
html += "\"
return dict(form=html)
else:
raise HTTP(404)





And on the view:

  jQuery(function() {
jQuery('#no_table_estado_id').change(function() {
  var request = $.ajax({
url: "{{=URL('hot', 'ajaxMunicipio.load')}}" + "/" + 
jQuery(this).val(),
method: "GET",
dataType: "html"
});
  request.done(function(html) {
console.log(html)
$("#no_table_municipio_id").val(html);
  });
})
  })



everything works well on the call side but i recieve the HTML sanitized 
like this: \\

So i'm looking for a way to avoid web2py to sanitize the html, or maybe a 
cleanest way to do this because i dont really like looping the data in the 
controller in order to create the HTML

I appreciate any help you can give! Thanks for your atention


-- 
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: execute model only one time

2015-08-04 Thread Luis Valladares
I used a similar approach, in my appconfig.ini after pool_size i added 
first_run = True and wrapped every sentence i want to run only one time 
with if (myconf.take('db.first_run') == 'True'):

Thanks for the help!

El martes, 4 de agosto de 2015, 9:55:22 (UTC-4:30), Lisandro escribió:
>
> The way I do it is this: I define a module and I define in there a 
> function that does db initialization. 
>
> modules/myfunctions.py
> # -*- coding: utf-8 -*-
>
> from gluon import *
>
> def initialize_db():
> db = current.db
> # here, do all needed inserts to database tables
>
>
> Then, in db.py (after table definitions):
>
> FIRST_RUN = False
>
> if FIRST_RUN:
> from myfunctions import initialize_db
> initialize_db()
>
>
> So only thing  you need to do is set FIRST_RUN = True, run the website one 
> time, and then set it back to False.
> A better approach would be reading FIRST_RUN from a configuration file, an 
> ini file or something like that.
>
>
> Of course you could do it directly in db.py, for example, checking the 
> total count of records of some table you know how many records should have 
> (for example, auth_group table), but that's not good for performance. 
>
>
> El martes, 4 de agosto de 2015, 11:08:04 (UTC-3), Luis Valladares escribió:
>>
>> Hello!
>>
>> Im trying to populate some fields inside my database each time is 
>> created, things like creating some groups in auth_groups, creating triggers 
>> for all the tables and adding some records in other tables, but i want this 
>> to be done ONLY when web2py creates the database because a lot of this 
>> records must be unique, so i created a file inside models to add all this 
>> info, but it get executed on every request of the site, i managed tu handle 
>> this using try..except Exception, but i dont think this is a good practice 
>> because it stops at every error without notifying me.
>>
>> There is a way to set a model file, or a set of instructions to execute 
>> ONLY when web2py create the tables of the database?
>>
>> Thanks a lot!
>>
>

-- 
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] execute model only one time

2015-08-04 Thread Luis Valladares
Hello!

Im trying to populate some fields inside my database each time is created, 
things like creating some groups in auth_groups, creating triggers for all 
the tables and adding some records in other tables, but i want this to be 
done ONLY when web2py creates the database because a lot of this records 
must be unique, so i created a file inside models to add all this info, but 
it get executed on every request of the site, i managed tu handle this 
using try..except Exception, but i dont think this is a good practice 
because it stops at every error without notifying me.

There is a way to set a model file, or a set of instructions to execute 
ONLY when web2py create the tables of the database?

Thanks a lot!

-- 
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] Create table without crud

2015-08-02 Thread luis . valladares
Hello!

I'm trying to define a table within web2py (with audit purpose) that doesnt 
generate any crud in any site of the website (including the appadmin) 
because this table only have to be modified using triggers inside the 
database but i cant find any proper option inside DAL documentation to do 
this

Any help would be great!

-- 
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 in register

2015-07-23 Thread Luis Valladares
Hello, I've modified the auth_user table using Auth.settings.extra_fields and 
added 3 fields, the problem is that the verify password field appears at the 
button of the page after all my custom fields, but the password field is before 
all my custom fields, I've tried to create a virtual field in auth_user but 
doesn't seem to work, and I don't want to create a new register view to avoid 
resource and code sparing, there is any way to move up the verify password 
field? 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.