Re: [web2py] SQLFORM.grid change form vars

2016-03-19 Thread Vinyl Darkscratch-Kazotetsu
Ah, I see what my problem is — the default was defined after the SQLFORM.grid() 
in the controller, not before it.  Works like a charm, no errors or issues.

As for onvalidation, I’ll give it a whirl and see how it goes.  Thank you.

> On Mar 15, 2016, at 22:42, Anthony  wrote:
> 
> On Wednesday, March 16, 2016 at 1:32:26 AM UTC-4, Vinyl Darkscratch-Kazotetsu 
> wrote:
> I see it now — I had assumed that you could set the default in the controller 
> function, but it seems that it has to be in the model file.  Thank you for 
> your help on this issue.
> 
> No, default can be set after the model declaration, including in the 
> controller (but before the grid is created, as the grid method handles the 
> form processing and database insert, so any model attributes must be set 
> before calling the grid).
>  
> Still, though…I would like to know how to edit the variables submitted by the 
> form, and still unsure how to do that.  For example, if a staff member were 
> to post their Inkbunny link, I would want to force that link’s explicit field 
> to true, but by default they provide the choice of marking it as explicit 
> content or not.  Any good suggestions there?
> 
> Not exactly clear what you want to do, but maybe an onvalidation function 
> would work (it takes the form object, so you can access and manipulate 
> form.vars).
> 
> 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/I9Xg4BI5SA8/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: Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread pbreit
I would suggest getting started on your computer and building a lot of your 
app before worrying too much about deploying. You've got several options 
for deployment all of which I suspect you'll be able to figure out.

Some others to consider are running on your own server:
https://www.digitalocean.com/community/tutorials/how-to-deploy-web2py-python-applications-with-uwsgi-and-nginx-on-ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-use-the-web2py-framework-to-quickly-build-your-python-app

or heroku:
http://www.renedohmen.nl/blog/2013/01/installing-your-web2py-stack-on-the-heroku-cloud-in-4-simple-steps/




On Saturday, March 19, 2016 at 9:04:23 PM UTC-7, John Gall wrote:
>
> Thank you for your suggestion!
>
> I'd classify myself as an intermediate in Python, but I have zero 
> experience with Web Dev or Network programming. I had actually never heard 
> of Google App Engine, and I only just found out about PythonAnywhere from 
> going through the introductory tutorials on the website. I think this is 
> the way to go to fulfill my needs and cut down on development time. I'm 
> leaning towards PythonAnywhere at the moment since looking at Google App 
> Engine, it has a lot of moving parts and I'd rather not inundate myself 
> with that at this early stage of network/web programming. It may be 
> something I look into in the future.
>
> I'll check out the other technologies you listed too. I have to admit I'm 
> a little excited at the doors that were just opened by examining what 
> PythonAnywhere can do for me, and I'm going to dive in and start tinkering 
> with a few things right now.
>
> On Saturday, March 19, 2016 at 6:26:12 PM UTC-4, webm...@trytha.com wrote:
>>
>> Everything you mentioned seems easy enough with Web2py.  Do you have any 
>> experience in web development or with Python?  Web2py could definitely do 
>> everything you want, but there are other options as well depending on if 
>> you have experience with anything specific.  I find Python to be the most 
>> intuitive language (in a broad sense), so even if you don't have 
>> experience, this might be a good place for you to start.
>>
>> Web2py comes bundled with a bunch of functionality that should really 
>> benefit your project, but I highly recommend reading the book before 
>> starting anything (I know it can be a lot all at once, but a quick, light 
>> reading will help immensely with finding answers to any future problems).  
>> http://www.web2py.com/book
>>
>> As for additional software, how granular do you mean?  You'll need to 
>> deploy to some sort of server.  The best two options are PythonAnywhere or 
>> Google App Engine.  GAE is intimidating at first, but has some significant 
>> benefits (massive scalability, almost zero DB upkeep), whereas 
>> PythonAnywhere is a good, free way to get started just to see if you're 
>> really going to enjoy Web2py.
>>
>> Web2py comes with bootstrap, but I find that to be cumbersome and poorly 
>> designed (styles should be fully defined in CSS, not in HTML (col-md-6 is a 
>> style element, not a class)).  I prefer using the lightweight Jeet (with 
>> Rupture) and Axis (though Axis buttons can lose some styling on iOS 
>> devices).  I also use Jade to make HTML look much more pleasant (it also 
>> forces you to follow good programming habits in HTML).
>>
>> If you want even more granular, Atom is the best software for where 
>> you're actually going to be spending your time.  Some people will argue 
>> differently, but it's only because they haven't tried it or have some 
>> extremely esoteric way of doing things that they learned from an old 
>> system.  Atom is open source and EXTREMELY customizable.  I have 25 add-ons 
>> for it that make it a coding beast.
>>
>> I've got a script I wrote for myself to get Web2py 99% functioning on GAE 
>> with an Ubuntu VM dev environment from a fresh OSX install if that would 
>> help you.  It's a bit raw (doesn't actually run yet, I just use it for 
>> reference), but I could post it if it would help.
>>
>> On Saturday, March 19, 2016 at 12:22:55 PM UTC-7, John Gall wrote:
>>>
>>> Hello!
>>>
>>> I'm starting a new project I plan to work on over the next six months, 
>>> and I originally planned to use web2py in conjunction with other frameworks 
>>> to accomplish my goal. I've been told that this project is not possible 
>>> with web2py, and I wanted to get an opinion from someone who has worked 
>>> with it before I look into switching technologies. Here is my original post 
>>> from Reddit detailing the scope of my project, and my original question:
>>>
>>>
>>> I'm in the early phase of a project I hope to spend the next six months 
 working on and I'm trying to find some guidance on what technologies and 
 frameworks I should look into in order to accomplish my goal. To start, 
 I'm 
 an intermediate level Python programmer, but I have no experience working 
 with networked applications, nor do I have 

[web2py] Re: Couple of questions about improving performance in models

2016-03-19 Thread Anthony
On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:
>
> Thank you very much for the quick answer.
>
> Your first comment made me think about the "lazy_tables" with the 
> definition of virtual method fields.
> If you say that doing db.tablename the table is no longer lazy, *then it 
> wouldn't make sense to use lazy_tables in a particular case where almost 
> each table has a virtual method field, am I right?*
>
> I mean, for example, if this is my model:
>
> db.define_table('first_table', Field('field1'), Field('field2'))
>
> db.first_table.field3 = Field.Method(lambda row: 'value for field3')
>

This won't help with db.auth_user, which is defined automatically (though 
you can define it manually yourself if preferred), but you can simply do:

db.define_table('first_table',
Field('field1'),
Field('field2'),
Field.Method('Field3', lambda row: 'value for field3'))

Note, the first argument of Field.Method() and Field.Virtual() should 
always be the field name anyway, even if you are defining them like this:

db.mytable.myfield = Field.Method('myfield', ...)

There are particular cases where leaving the name out can lead to problems.

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: Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread webmaster
I started on PythonAnywhere and it is an excellent service.  I learned a 
lot and they are extremely helpful.  And you don't need to put that much 
thought into worrying about your host, as your app is extremely portable. 
 GAE definitely has more moving parts, but Google is putting a LOT of 
effort into it.  Give it another year and I bet it'll be a lot more 
accessible.

You might want to make a simple TO DO list app or something before you dive 
into your main project so you get an idea of how best to design your 
databases and their interactions.  And as I mentioned before, read the 
book, learn the book, love the book:  http://www.web2py.com/book

Good luck!

On Saturday, March 19, 2016 at 9:04:23 PM UTC-7, John Gall wrote:
>
> Thank you for your suggestion!
>
> I'd classify myself as an intermediate in Python, but I have zero 
> experience with Web Dev or Network programming. I had actually never heard 
> of Google App Engine, and I only just found out about PythonAnywhere from 
> going through the introductory tutorials on the website. I think this is 
> the way to go to fulfill my needs and cut down on development time. I'm 
> leaning towards PythonAnywhere at the moment since looking at Google App 
> Engine, it has a lot of moving parts and I'd rather not inundate myself 
> with that at this early stage of network/web programming. It may be 
> something I look into in the future.
>
> I'll check out the other technologies you listed too. I have to admit I'm 
> a little excited at the doors that were just opened by examining what 
> PythonAnywhere can do for me, and I'm going to dive in and start tinkering 
> with a few things right now.
>
> On Saturday, March 19, 2016 at 6:26:12 PM UTC-4, webm...@trytha.com wrote:
>>
>> Everything you mentioned seems easy enough with Web2py.  Do you have any 
>> experience in web development or with Python?  Web2py could definitely do 
>> everything you want, but there are other options as well depending on if 
>> you have experience with anything specific.  I find Python to be the most 
>> intuitive language (in a broad sense), so even if you don't have 
>> experience, this might be a good place for you to start.
>>
>> Web2py comes bundled with a bunch of functionality that should really 
>> benefit your project, but I highly recommend reading the book before 
>> starting anything (I know it can be a lot all at once, but a quick, light 
>> reading will help immensely with finding answers to any future problems).  
>> http://www.web2py.com/book
>>
>> As for additional software, how granular do you mean?  You'll need to 
>> deploy to some sort of server.  The best two options are PythonAnywhere or 
>> Google App Engine.  GAE is intimidating at first, but has some significant 
>> benefits (massive scalability, almost zero DB upkeep), whereas 
>> PythonAnywhere is a good, free way to get started just to see if you're 
>> really going to enjoy Web2py.
>>
>> Web2py comes with bootstrap, but I find that to be cumbersome and poorly 
>> designed (styles should be fully defined in CSS, not in HTML (col-md-6 is a 
>> style element, not a class)).  I prefer using the lightweight Jeet (with 
>> Rupture) and Axis (though Axis buttons can lose some styling on iOS 
>> devices).  I also use Jade to make HTML look much more pleasant (it also 
>> forces you to follow good programming habits in HTML).
>>
>> If you want even more granular, Atom is the best software for where 
>> you're actually going to be spending your time.  Some people will argue 
>> differently, but it's only because they haven't tried it or have some 
>> extremely esoteric way of doing things that they learned from an old 
>> system.  Atom is open source and EXTREMELY customizable.  I have 25 add-ons 
>> for it that make it a coding beast.
>>
>> I've got a script I wrote for myself to get Web2py 99% functioning on GAE 
>> with an Ubuntu VM dev environment from a fresh OSX install if that would 
>> help you.  It's a bit raw (doesn't actually run yet, I just use it for 
>> reference), but I could post it if it would help.
>>
>> On Saturday, March 19, 2016 at 12:22:55 PM UTC-7, John Gall wrote:
>>>
>>> Hello!
>>>
>>> I'm starting a new project I plan to work on over the next six months, 
>>> and I originally planned to use web2py in conjunction with other frameworks 
>>> to accomplish my goal. I've been told that this project is not possible 
>>> with web2py, and I wanted to get an opinion from someone who has worked 
>>> with it before I look into switching technologies. Here is my original post 
>>> from Reddit detailing the scope of my project, and my original question:
>>>
>>>
>>> I'm in the early phase of a project I hope to spend the next six months 
 working on and I'm trying to find some guidance on what technologies and 
 frameworks I should look into in order to accomplish my goal. To start, 
 I'm 
 an intermediate level Python programmer, but I have no experience working 
 with 

[web2py] web2pyslices unsuable

2016-03-19 Thread zendevel
Web2pyslices is down and all the content is missing. Is there any owner of 
the site? It seems like it was hacked or something.  It was been a wealth 
of knowledge for the community I hate to see it go to pot. I would be 
willing to host it if needed.

-- 
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 do you use web2py app work with phonegap?

2016-03-19 Thread pbreit
Ionic is a good choice.

As mentioned, Web2py will run on your server and mostly deliver and receive 
JSON to/from the mobile app.


On Saturday, March 19, 2016 at 3:12:42 AM UTC-7, eric cuver wrote:
>
> hi Leonel,
>
> which client (boostrap, jquery mobile, ionic.)  for design with 
> phonegap advises you ?
>
>
> Le vendredi 18 mars 2016 18:41:22 UTC+1, Leonel Câmara a écrit :
>>
>> I'm sorry but you show fundamental misconceptions about what phonegap 
>> does, what web2py does, how they run in the devices and server, and about 
>> how they can and should interact.  
>>   
>> Your questions don't even make sense. I can't help you until you know 
>> more about web2py, phonegap, what REST APIs are and how do you access them 
>> using javascript.  
>>
>

-- 
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: Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread John Gall
Thank you for your suggestion!

I'd classify myself as an intermediate in Python, but I have zero 
experience with Web Dev or Network programming. I had actually never heard 
of Google App Engine, and I only just found out about PythonAnywhere from 
going through the introductory tutorials on the website. I think this is 
the way to go to fulfill my needs and cut down on development time. I'm 
leaning towards PythonAnywhere at the moment since looking at Google App 
Engine, it has a lot of moving parts and I'd rather not inundate myself 
with that at this early stage of network/web programming. It may be 
something I look into in the future.

I'll check out the other technologies you listed too. I have to admit I'm a 
little excited at the doors that were just opened by examining what 
PythonAnywhere can do for me, and I'm going to dive in and start tinkering 
with a few things right now.

On Saturday, March 19, 2016 at 6:26:12 PM UTC-4, webm...@trytha.com wrote:
>
> Everything you mentioned seems easy enough with Web2py.  Do you have any 
> experience in web development or with Python?  Web2py could definitely do 
> everything you want, but there are other options as well depending on if 
> you have experience with anything specific.  I find Python to be the most 
> intuitive language (in a broad sense), so even if you don't have 
> experience, this might be a good place for you to start.
>
> Web2py comes bundled with a bunch of functionality that should really 
> benefit your project, but I highly recommend reading the book before 
> starting anything (I know it can be a lot all at once, but a quick, light 
> reading will help immensely with finding answers to any future problems).  
> http://www.web2py.com/book
>
> As for additional software, how granular do you mean?  You'll need to 
> deploy to some sort of server.  The best two options are PythonAnywhere or 
> Google App Engine.  GAE is intimidating at first, but has some significant 
> benefits (massive scalability, almost zero DB upkeep), whereas 
> PythonAnywhere is a good, free way to get started just to see if you're 
> really going to enjoy Web2py.
>
> Web2py comes with bootstrap, but I find that to be cumbersome and poorly 
> designed (styles should be fully defined in CSS, not in HTML (col-md-6 is a 
> style element, not a class)).  I prefer using the lightweight Jeet (with 
> Rupture) and Axis (though Axis buttons can lose some styling on iOS 
> devices).  I also use Jade to make HTML look much more pleasant (it also 
> forces you to follow good programming habits in HTML).
>
> If you want even more granular, Atom is the best software for where you're 
> actually going to be spending your time.  Some people will argue 
> differently, but it's only because they haven't tried it or have some 
> extremely esoteric way of doing things that they learned from an old 
> system.  Atom is open source and EXTREMELY customizable.  I have 25 add-ons 
> for it that make it a coding beast.
>
> I've got a script I wrote for myself to get Web2py 99% functioning on GAE 
> with an Ubuntu VM dev environment from a fresh OSX install if that would 
> help you.  It's a bit raw (doesn't actually run yet, I just use it for 
> reference), but I could post it if it would help.
>
> On Saturday, March 19, 2016 at 12:22:55 PM UTC-7, John Gall wrote:
>>
>> Hello!
>>
>> I'm starting a new project I plan to work on over the next six months, 
>> and I originally planned to use web2py in conjunction with other frameworks 
>> to accomplish my goal. I've been told that this project is not possible 
>> with web2py, and I wanted to get an opinion from someone who has worked 
>> with it before I look into switching technologies. Here is my original post 
>> from Reddit detailing the scope of my project, and my original question:
>>
>>
>> I'm in the early phase of a project I hope to spend the next six months 
>>> working on and I'm trying to find some guidance on what technologies and 
>>> frameworks I should look into in order to accomplish my goal. To start, I'm 
>>> an intermediate level Python programmer, but I have no experience working 
>>> with networked applications, nor do I have any experience with web 
>>> development. I'll be working on this project with one other person who has 
>>> a lot of experience with using web2py, so that'll be the web framework 
>>> we'll be using unless we have a very compelling reason to use something 
>>> else like Django. That said, I expect to be doing a large majority of the 
>>> work, so I would like to be familiar with all aspects of this program.
>>>
>>> The project I'm working on is a Table-top gaming aid that I can use to 
>>> manage a game session for a custom built gaming system.
>>>
>>>
>>> Here's a brief list of the requirements I'm looking to implement:
>>>
>>>- 
>>>
>>>The project is for personal use and won't be something that is 
>>>publicly available. Thus, security isn't a major concern, and I will 
>>> 

[web2py] Re: Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread pbreit
It sounds like it would be fine on web2py. Web2py is one of the more 
capable and easy general purpose frameworks. Was there anything in 
particular that people thought was going to be difficult or impossible?

When you say "players need to be notified" are you just referring to 
something simple like an email?



On Saturday, March 19, 2016 at 12:22:55 PM UTC-7, John Gall wrote:
>
> Hello!
>
> I'm starting a new project I plan to work on over the next six months, and 
> I originally planned to use web2py in conjunction with other frameworks to 
> accomplish my goal. I've been told that this project is not possible with 
> web2py, and I wanted to get an opinion from someone who has worked with it 
> before I look into switching technologies. Here is my original post from 
> Reddit detailing the scope of my project, and my original question:
>
>
> I'm in the early phase of a project I hope to spend the next six months 
>> working on and I'm trying to find some guidance on what technologies and 
>> frameworks I should look into in order to accomplish my goal. To start, I'm 
>> an intermediate level Python programmer, but I have no experience working 
>> with networked applications, nor do I have any experience with web 
>> development. I'll be working on this project with one other person who has 
>> a lot of experience with using web2py, so that'll be the web framework 
>> we'll be using unless we have a very compelling reason to use something 
>> else like Django. That said, I expect to be doing a large majority of the 
>> work, so I would like to be familiar with all aspects of this program.
>>
>> The project I'm working on is a Table-top gaming aid that I can use to 
>> manage a game session for a custom built gaming system.
>>
>>
>> Here's a brief list of the requirements I'm looking to implement:
>>
>>- 
>>
>>The project is for personal use and won't be something that is 
>>publicly available. Thus, security isn't a major concern, and I will only 
>>require what is necessary to protect an application of this scope.
>>- 
>>
>>Ideally, this program should be deployed via web. I need a deployment 
>>method that is the most accessible. Most of the players will have access 
>> to 
>>a Smartphone or tablet and I considered making it a mobile app, but I 
>> think 
>>a web app would also accomplish the goals of the project and would be 
>>simpler.
>>- 
>>
>>There should be an authentication process in place so that there are 
>>options available for the individual running the game, and each of the 
>>players can only view characters that belong to them.
>>- 
>>
>>All of the players and the host will connect to the same session.
>>- 
>>
>>Everything is turn based. Players will need to be notified when it is 
>>their turn so that they can take actions, and may only take actions when 
>> it 
>>is their turn.
>>- 
>>
>>Enemies will be loaded from a database. Player actions will reference 
>>their character's stats and their enemy's stats to perform actions. These 
>>actions need to update the game state (So if a player damages a 
>> particular 
>>enemy, that enemy's current health persists for each player's turn until 
>> it 
>>is removed from the current session.)
>>
>> --
>>
>>
>> With that said, I am looking to use as few technologies required as 
>> possible to accomplish this. UI will mostly be a series of menus, and kept 
>> as basic as possible. I've looked around online and there are A LOT of 
>> different options, and it's difficult to suss out what would be the most 
>> appropriate for what I'm looking to accomplish. I've looked into Tornado, 
>> node.js, and HTML5. At this point I think I have information paralysis and 
>> I'm looking for someone that has more experience in this field than I do to 
>> help me choose what would best help me achieve my design goals. I'm 
>> confident once I settle on a technology or framework I can teach myself how 
>> to use it.
>>
>>
>> Thank you!
>>
>
>

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


[web2py] Re: Adding a new table to web2py with a reference field to an established table and getting error

2016-03-19 Thread Anthony
According to the error, your field name is "field1reference table1", so you 
probably have an error in the field definition. Please show your model code.

Anthony

On Thursday, March 17, 2016 at 8:28:00 AM UTC-4, Heather Dawe wrote:
>
> Hi there,
>
> I have had this error in a couple of scenarios now. I have an established 
> and working web2py app and I wish to add a couple of tables to the model. A 
> number of fields in these new tables reference fields in established 
> tables. I get this error when trying to create the new tables
>
>  Field: invalid field name: field1reference 
> table1, use rname for "funny" names
>
> where 'field1' is the name of a field in the new table I am trying to 
> create that references table1 (the id field in table1). Given that all I am 
> trying to do is add a new table to my model which has a field that 
> references an existing table I don't see why this is a problem? I have 
> looked into it and searched for the error etc. I have tried to fix it by 
> changing to migrate='false' and fake_migrate='true' etc. but this has not 
> solved it. Can anyone please advise why I am getting this error and how to 
> sort it out?
>
> Many thanks,
> Heather
>

-- 
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] Using MySQL in GAE locally (is it actually possible?)

2016-03-19 Thread webmaster
I've got MySQL working locally in GAE, but since GAE doesn't write to the 
file system, it can't touch /databases.  Am I doing something wrong?  Has 
anyone actually gotten GAE working with MySQL locally?  I can't find a 
single tutorial related to this.  If someone shows me this last step, I can 
put together a tutorial from fresh OSX install to fully-functional web dev 
environment with web2py on GAE in a Virtualbox VM (a tutorial web2py 
desperately needs).  I already have all the steps in an Evernote, just need 
to figure this last part out.

I even tried putting "folder='/home/www-data/web2py...'" in my DAL 
connection string, but nothing gets written in the /databases folder still. 
 GAE does all the MySQL creation and then hits me with a corrupted *.table 
error the first time I refresh because nothing is written in /databases.

Can I write the databases to memcache or datastore somehow?  How is GAE 
handling this on the server side without errors?

-- 
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: Functional programming in web2py...

2016-03-19 Thread Leonel Câmara
This is more of a python question than a web2py one. Usually people just 
use list comprehensions and generators for this. You can easily chain 
generators. Also take a look at the itertools python module if you're 
interested in programming this way in python.

-- 
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: XML object

2016-03-19 Thread Jerry Liu
Yes, I am using it on html page.
It doesn't work when html contains iframe tag.
iframe tag will still be escaped.
so I tried override, still not working.

On Wed, Mar 16, 2016 at 12:21 PM, Anthony  wrote:

> Are you inserting it in the view somehow:
>
> {{=XML(...)}}
>
> If so, what are you seeing in the final rendered HTML?
>
> Anthony
>
>
> On Wednesday, March 16, 2016 at 3:12:04 PM UTC-4, Jerry Liu wrote:
>>
>>
>> Hi, all
>>
>> I want to use XML object to stop html from being escaped. But the object  
>> seems
>> not working on iframe tag.
>>
>> I override it like this:
>>
>> XML(text, sanitize=True,
>> permitted_tags=['iframe', ...],
>> allowed_attributes={'iframe':[...]})
>>
>> --
> 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/-m2WWuOZ3Qw/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: how to resend verification email?

2016-03-19 Thread Massimo Di Pierro
The reliability of this depends on the smtp server certificates. using 
postfix on localhost is very unreliable. Using a commercial service is 
better

On Wednesday, 16 March 2016 07:41:21 UTC-5, Yibing Liu wrote:
>
> Hello everyone, I developed a website with web2py. I have 
> set auth.settings.registration_requires_verification = True to verify the 
> register's email. However some of the users tell me that they can't receive 
> the verification email. They try to re-register with the same email to get 
> the verification emailIs, but they get the message"the email has been 
> registered". Is there any method to re-send the verification email to the 
> user? Thank you.
>

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


[web2py] Re: is there an easy way to add member to the db.auth_membership?

2016-03-19 Thread Dave S


On Wednesday, March 16, 2016 at 7:28:48 AM UTC-7, Yibing Liu wrote:
>
> I want to add member to the db.auth__membership. I have too many users in 
> db.auth_user, so it's very hard to add a specified user to the membership. 
> Could anyone help me? 
>

Would the autocomplete widget help?  That would narrow down the choices as 
you type.
 

> The following is the screenshot
>
>
> 
>
>
>
/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: Testing

2016-03-19 Thread Pierre Thibault
OK, sorry for the noise.

Le lundi 14 mars 2016 13:01:48 UTC-4, Leonel Câmara a écrit :
>
> Yeah this group is moderated so you have to wait until your messages are 
> aproved the first few times until you're whitelisted.
>

-- 
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: border in view

2016-03-19 Thread Dave S


On Friday, March 18, 2016 at 8:08:38 AM UTC-7, Imre wrote:
>
> Hi,
> please help. I use SQLTABLE in view and I want see border. I try 
> table, th, td {border: 1px solid black}
> in web2py.css but it is not work.
>
>
You may need to make the change to a Web2Py class.

For instance, my SQLFORM uses even/odd coloring,
and the rows are
[...] 
[...]

On the other hand, my view file does have a style block (in the body!) that 
looks like


*.odd  {background-color: #E5EECC}  /* light desert-y green */
*.odd  {background-color: #ddffcc}  /* light green-bar  */
*.odd  {background-color: #d0d0f0}  /* light blue grey  */


but that is read after web2py.css and web2py_bootstrap.css, so it does have 
a chance to override the includes.

/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: fighting with the widget

2016-03-19 Thread Pierre
ok ..I don't want to spend too much efforts on a widget so I am making 
a simple function derived from ListWidget classmethod. I cloned he original 
ul.w2p_list css only changing its name, so far everything works

-- 
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] Insert ignored when using time

2016-03-19 Thread Joel Samuelsson
Hi, 

I have a table like this:
db.define_table('speed',
Field('speed', 'integer'),
Field('startTime', 'time'),
Field('stopTime', 'time'),
migrate=False,
fake_migrate=True
)

The database is a MySQL db.
speed is of type int,
startTime is of type time,
stopTime is of type time,
The table was created with phpmyadmin.


If I do a call like this:
db.speed.insert(
speed = 30,
startTime = None,
stopTime = None,
)
everything works fine.

However, if I do a call like this:
db.speed.insert(
speed = 30,
startTime = datetime.time(hour=8, minute=30),
stopTime = datetime.time(hour=18, minute=30),
)
the call is simply ignored. I get no exception or anything but nothing 
appears in the database afterwards.
I've also tried this:
db.speed.insert(
speed = 30,
startTime = "08:30:00",
stopTime = "18:30:00",
)
with the same result (i.e. ignored).

What am I doing wrong?

-- 
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] Couple of questions about improving performance in models

2016-03-19 Thread Lisandro
Straight to the point:
I'm using *lazy_tables=True* and *migrate=False*


*In my model, I have several Method Fields.*
Some of them use a function that is declared inside the same model, like 
this:

db.auth_user.give_me_data = Field.Method(lambda row: _give_me_data(row.
auth_user))

def _give_me_data(user):
# calculation and obtention of data
# return data

So first question: *should I move declaration of _give_me_data function to 
a module?* 
Or is it the same because I would have to import it anyway in the model?
*Just to remind, I'm using lazy_tables=False, so maybe the code isn't 
really executed until the table is called. I'm not sure about this.*



*Usage of Storage class objects*
In my models, I create some Storage objects, because it's really useful for 
setting and retrieving data from those objects. I use them like this:

from gluon.tools import Storage

CONFIG = Storage()
CONFIG.variable1 = 'value-variable-1'
CONFIG.variable2 = 'value-variable-2'

I don't put much data inside them, just config variables.
However, my question is: *should I use other data type to storage those 
variables?* Or it won't make any difference?


Thats all for now. Any comment will be appreciated. Thanks in advance!

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


[web2py] Re: fighting with the widget

2016-03-19 Thread Leonel Câmara
It's enough to use just a function. However if you want your widget to be 
configurable you could use a function that returns a function for a widget 
and you would make 
widget=function_that_returns_a_function(**my_widget_options). 

Another alternative is to have a class and set class attributes and then 
have a classmethod you put on the widget, this way you don't need an 
instance of the class. Another alternative would be to have a class with a 
__call__ method then you could create an instance and put that on widget.  
   

-- 
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: Big Bug: Cloud SQL completely broken? Steps and solution.

2016-03-19 Thread webmaster
As penance, you can tell me how to store images in the datastore while 
using Cloud SQL for everything else (I haven't seen any actual examples of 
using both at the same time, but the book says it can be done).

On Saturday, March 19, 2016 at 2:57:11 PM UTC-7, webm...@trytha.com wrote:
>
> And thus we discover the true problem.  Try using pydal from 
> http://www.web2py.com/examples/static/web2py_src.zip (the link from 
> Source Code for Normal Users).  -result:  Failure
>
> Now try the pydal from 
> http://web2py.com/examples/static/2.12.2/web2py_src.zip -result:  Success
>
> Now try the pydal from 
> http://web2py.com/examples/static/2.13.3/web2py_src.zip (apparently the 
> latest one accessible by specific version number) -result:  Failure
>
> So. I hate you so much right now.  Give me back my two days!
>
> There needs to be a way to mark your own answer as the "best answer"...
>
>
> On Saturday, March 19, 2016 at 1:09:16 PM UTC-7, Massimo Di Pierro wrote:
>>
>> I tested this. I am using trunk code with latest github and I cannot 
>> reproduce. I am pretty sure this is fixed. Make sure you have the latest 
>> pydal.
>>
>> On Friday, 18 March 2016 15:55:21 UTC-5, webm...@trytha.com wrote:
>>>
>>> Steps to replicate (3 mins):
>>>
>>>
>>>1. Load Web2py from source off website.  Copy gaehandler.py and 
>>>app.yaml to /web2py.  
>>>2. In applications/welcome/models/db.py, change the DAL connection 
>>>to "db = DAL('google:sql://[$project]:[$instance]/[$database]')"
>>>3. python dev_appserver.py --host=0.0.0.0 --mysql_host=localhost 
>>>--mysql_port=3306 --mysql_user=root --mysql_password= 
>>>/home/www-data/web2py
>>>4. Load, then refresh the Welcome app and it crashes because it 
>>>thinks it can't access the /databases folder.
>>>
>>> Solution (1 min):
>>>
>>>1. Delete /gluon/packages/dal/pydal
>>>2. Replace with /gluon/packages/dal/pydal from version 2.12.2 of 
>>>web2py.  (http://web2py.com/examples/static/2.12.2/web2py_src.zip)
>>>
>>> Am I doing something really crazy?  How has nobody run across this in 
>>> the six months it's been broken?  Seems like kind of a massive bug.
>>>
>>

-- 
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: Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread webmaster
Everything you mentioned seems easy enough with Web2py.  Do you have any 
experience in web development or with Python?  Web2py could definitely do 
everything you want, but there are other options as well depending on if 
you have experience with anything specific.  I find Python to be the most 
intuitive language (in a broad sense), so even if you don't have 
experience, this might be a good place for you to start.

Web2py comes bundled with a bunch of functionality that should really 
benefit your project, but I highly recommend reading the book before 
starting anything (I know it can be a lot all at once, but a quick, light 
reading will help immensely with finding answers to any future problems). 
 http://www.web2py.com/book

As for additional software, how granular do you mean?  You'll need to 
deploy to some sort of server.  The best two options are PythonAnywhere or 
Google App Engine.  GAE is intimidating at first, but has some significant 
benefits (massive scalability, almost zero DB upkeep), whereas 
PythonAnywhere is a good, free way to get started just to see if you're 
really going to enjoy Web2py.

Web2py comes with bootstrap, but I find that to be cumbersome and poorly 
designed (styles should be fully defined in CSS, not in HTML (col-md-6 is a 
style element, not a class)).  I prefer using the lightweight Jeet (with 
Rupture) and Axis (though Axis buttons can lose some styling on iOS 
devices).  I also use Jade to make HTML look much more pleasant (it also 
forces you to follow good programming habits in HTML).

If you want even more granular, Atom is the best software for where you're 
actually going to be spending your time.  Some people will argue 
differently, but it's only because they haven't tried it or have some 
extremely esoteric way of doing things that they learned from an old 
system.  Atom is open source and EXTREMELY customizable.  I have 25 add-ons 
for it that make it a coding beast.

I've got a script I wrote for myself to get Web2py 99% functioning on GAE 
with an Ubuntu VM dev environment from a fresh OSX install if that would 
help you.  It's a bit raw (doesn't actually run yet, I just use it for 
reference), but I could post it if it would help.

On Saturday, March 19, 2016 at 12:22:55 PM UTC-7, John Gall wrote:
>
> Hello!
>
> I'm starting a new project I plan to work on over the next six months, and 
> I originally planned to use web2py in conjunction with other frameworks to 
> accomplish my goal. I've been told that this project is not possible with 
> web2py, and I wanted to get an opinion from someone who has worked with it 
> before I look into switching technologies. Here is my original post from 
> Reddit detailing the scope of my project, and my original question:
>
>
> I'm in the early phase of a project I hope to spend the next six months 
>> working on and I'm trying to find some guidance on what technologies and 
>> frameworks I should look into in order to accomplish my goal. To start, I'm 
>> an intermediate level Python programmer, but I have no experience working 
>> with networked applications, nor do I have any experience with web 
>> development. I'll be working on this project with one other person who has 
>> a lot of experience with using web2py, so that'll be the web framework 
>> we'll be using unless we have a very compelling reason to use something 
>> else like Django. That said, I expect to be doing a large majority of the 
>> work, so I would like to be familiar with all aspects of this program.
>>
>> The project I'm working on is a Table-top gaming aid that I can use to 
>> manage a game session for a custom built gaming system.
>>
>>
>> Here's a brief list of the requirements I'm looking to implement:
>>
>>- 
>>
>>The project is for personal use and won't be something that is 
>>publicly available. Thus, security isn't a major concern, and I will only 
>>require what is necessary to protect an application of this scope.
>>- 
>>
>>Ideally, this program should be deployed via web. I need a deployment 
>>method that is the most accessible. Most of the players will have access 
>> to 
>>a Smartphone or tablet and I considered making it a mobile app, but I 
>> think 
>>a web app would also accomplish the goals of the project and would be 
>>simpler.
>>- 
>>
>>There should be an authentication process in place so that there are 
>>options available for the individual running the game, and each of the 
>>players can only view characters that belong to them.
>>- 
>>
>>All of the players and the host will connect to the same session.
>>- 
>>
>>Everything is turn based. Players will need to be notified when it is 
>>their turn so that they can take actions, and may only take actions when 
>> it 
>>is their turn.
>>- 
>>
>>Enemies will be loaded from a database. Player actions will reference 
>>their character's stats and their 

[web2py] multiple id selection using request.vars.name

2016-03-19 Thread Ron Chatterjee

I have checkbox and from there I read my ids, which is request.vars.name 
generated from a button in view 


In my controller I use

Post_selected   = db.Post(request.vars.name);

It works fine if one id is selected lets say '22'.

if
request.vars.name
'22'

len(request.vars.name) is  2.

but if
request.vars.name
['22', '23']

len(request.vars.name) = is also 2


So, I am having hard time looping through the array and distinguish them.

What would be the best way to get all the posts of selected id, ['22'] and 
for multiple checkbox selection lets say ['22','23','24'] with 
request.vars.name

In other words, if my request.vars.name is ['22','23','24'] I get all the 
posts associated with the id. If one e.g., '22', then just one.  Thanks in 
advance.

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


[web2py] Re: Big Bug: Cloud SQL completely broken? Steps and solution.

2016-03-19 Thread webmaster
And thus we discover the true problem.  Try using pydal 
from http://www.web2py.com/examples/static/web2py_src.zip (the link from 
Source Code for Normal Users).  -result:  Failure

Now try the pydal 
from http://web2py.com/examples/static/2.12.2/web2py_src.zip -result: 
 Success

Now try the pydal from 
http://web2py.com/examples/static/2.13.3/web2py_src.zip (apparently the 
latest one accessible by specific version number) -result:  Failure

So. I hate you so much right now.  Give me back my two days!

There needs to be a way to mark your own answer as the "best answer"...


On Saturday, March 19, 2016 at 1:09:16 PM UTC-7, Massimo Di Pierro wrote:
>
> I tested this. I am using trunk code with latest github and I cannot 
> reproduce. I am pretty sure this is fixed. Make sure you have the latest 
> pydal.
>
> On Friday, 18 March 2016 15:55:21 UTC-5, webm...@trytha.com  
> wrote:
>>
>> Steps to replicate (3 mins):
>>
>>
>>1. Load Web2py from source off website.  Copy gaehandler.py and 
>>app.yaml to /web2py.  
>>2. In applications/welcome/models/db.py, change the DAL connection to 
>>"db = DAL('google:sql://[$project]:[$instance]/[$database]')"
>>3. python dev_appserver.py --host=0.0.0.0 --mysql_host=localhost 
>>--mysql_port=3306 --mysql_user=root --mysql_password= 
>>/home/www-data/web2py
>>4. Load, then refresh the Welcome app and it crashes because it 
>>thinks it can't access the /databases folder.
>>
>> Solution (1 min):
>>
>>1. Delete /gluon/packages/dal/pydal
>>2. Replace with /gluon/packages/dal/pydal from version 2.12.2 of 
>>web2py.  (http://web2py.com/examples/static/2.12.2/web2py_src.zip)
>>
>> Am I doing something really crazy?  How has nobody run across this in the 
>> six months it's been broken?  Seems like kind of a massive bug.
>>
>

-- 
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: Persist file upload html forms in web2py

2016-03-19 Thread Anthony
Please see response on SO: http://stackoverflow.com/a/36105590/440323


On Saturday, March 19, 2016 at 3:22:57 PM UTC-4, Yogesh Agrawal wrote:
>
> I have developed a web portal using web2py. The portal has a input form 
> that is to be filled by user. There are 5 steps in the form. At the last 
> step there are bunch of file uploads fields. 
>
>
> If a user encounters form validation error after filling the form, he has 
> to again upload the file from upload fields. Because file upload fields get 
> reset after the form validation error. This is acceptable if user has to 
> fill just one form. But it becomes difficult for user when he has to fill 
> hundreds of similar forms to input data.
>
> I want to implement a feature that persist file uploads field even after 
> the form validation error. Is there a way to achieve this using html or php 
> or is there something inbuilt in web2py.
>
>
> Please let me know if anyone has done something like this before.
>

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


[web2py] How do you use web2py app work with phonegap?

2016-03-19 Thread RAGHIB R
Can you explain it stepwise? If possible please send github link of some 
web2py app that you changed to work with phonegap.

-- 
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: IMPORTANT SECURITY ISSUE

2016-03-19 Thread Massimo Di Pierro
yes.

On Thursday, 17 March 2016 18:01:59 UTC-5, Antonio Salazar wrote:
>
> Since this is not a vulnerability, can Examples be simply disabled?
>
> On Tuesday, March 15, 2016 at 10:43:24 AM UTC-6, Massimo Di Pierro wrote:
>>
>> An important security issue has come up.
>>
>> If you use web2py in production with the rocket web server (which you 
>> should not anyway):
>> 1) delete the "examples" app
>> 2) make sure you pages do not expose the {{=response.toolbar}} 
>>
>> Please follow the above guidelines because exposing internal system 
>> status may help attackers gain confidential information about your system.
>> The web2py in trunk will prevent the information leakage by default but 
>> removing "examples" is the safest way.
>>
>> If you use nginx or apache or other wsgi server there is no problem but 
>> you may still want to follow the above rules in production.
>>
>> 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] Adding a new table to web2py with a reference field to an established table and getting error

2016-03-19 Thread Heather Dawe
Hi there,

I have had this error in a couple of scenarios now. I have an established 
and working web2py app and I wish to add a couple of tables to the model. A 
number of fields in these new tables reference fields in established 
tables. I get this error when trying to create the new tables

 Field: invalid field name: field1reference 
table1, use rname for "funny" names

where 'field1' is the name of a field in the new table I am trying to 
create that references table1 (the id field in table1). Given that all I am 
trying to do is add a new table to my model which has a field that 
references an existing table I don't see why this is a problem? I have 
looked into it and searched for the error etc. I have tried to fix it by 
changing to migrate='false' and fake_migrate='true' etc. but this has not 
solved it. Can anyone please advise why I am getting this error and how to 
sort it out?

Many thanks,
Heather

-- 
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: Big Bug: Cloud SQL completely broken? Steps and solution.

2016-03-19 Thread Massimo Di Pierro
I tested this. I am using trunk code with latest github and I cannot 
reproduce. I am pretty sure this is fixed. Make sure you have the latest 
pydal.

On Friday, 18 March 2016 15:55:21 UTC-5, webmas...@trytha.com wrote:
>
> Steps to replicate (3 mins):
>
>
>1. Load Web2py from source off website.  Copy gaehandler.py and 
>app.yaml to /web2py.  
>2. In applications/welcome/models/db.py, change the DAL connection to 
>"db = DAL('google:sql://[$project]:[$instance]/[$database]')"
>3. python dev_appserver.py --host=0.0.0.0 --mysql_host=localhost 
>--mysql_port=3306 --mysql_user=root --mysql_password= 
>/home/www-data/web2py
>4. Load, then refresh the Welcome app and it crashes because it thinks 
>it can't access the /databases folder.
>
> Solution (1 min):
>
>1. Delete /gluon/packages/dal/pydal
>2. Replace with /gluon/packages/dal/pydal from version 2.12.2 of 
>web2py.  (http://web2py.com/examples/static/2.12.2/web2py_src.zip)
>
> Am I doing something really crazy?  How has nobody run across this in the 
> six months it's been broken?  Seems like kind of a massive bug.
>

-- 
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] Persist file upload html forms in web2py

2016-03-19 Thread Yogesh Agrawal
 

I have developed a web portal using web2py. The portal has a input form 
that is to be filled by user. There are 5 steps in the form. At the last 
step there are bunch of file uploads fields. 


If a user encounters form validation error after filling the form, he has 
to again upload the file from upload fields. Because file upload fields get 
reset after the form validation error. This is acceptable if user has to 
fill just one form. But it becomes difficult for user when he has to fill 
hundreds of similar forms to input data.

I want to implement a feature that persist file uploads field even after 
the form validation error. Is there a way to achieve this using html or php 
or is there something inbuilt in web2py.


Please let me know if anyone has done something like this before.

-- 
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] Is this project a good fit for web2py, and if so, what other frameworks will I need?

2016-03-19 Thread John Gall
Hello!

I'm starting a new project I plan to work on over the next six months, and 
I originally planned to use web2py in conjunction with other frameworks to 
accomplish my goal. I've been told that this project is not possible with 
web2py, and I wanted to get an opinion from someone who has worked with it 
before I look into switching technologies. Here is my original post from 
Reddit detailing the scope of my project, and my original question:


I'm in the early phase of a project I hope to spend the next six months 
> working on and I'm trying to find some guidance on what technologies and 
> frameworks I should look into in order to accomplish my goal. To start, I'm 
> an intermediate level Python programmer, but I have no experience working 
> with networked applications, nor do I have any experience with web 
> development. I'll be working on this project with one other person who has 
> a lot of experience with using web2py, so that'll be the web framework 
> we'll be using unless we have a very compelling reason to use something 
> else like Django. That said, I expect to be doing a large majority of the 
> work, so I would like to be familiar with all aspects of this program.
>
> The project I'm working on is a Table-top gaming aid that I can use to 
> manage a game session for a custom built gaming system.
>
>
> Here's a brief list of the requirements I'm looking to implement:
>
>- 
>
>The project is for personal use and won't be something that is 
>publicly available. Thus, security isn't a major concern, and I will only 
>require what is necessary to protect an application of this scope.
>- 
>
>Ideally, this program should be deployed via web. I need a deployment 
>method that is the most accessible. Most of the players will have access 
> to 
>a Smartphone or tablet and I considered making it a mobile app, but I 
> think 
>a web app would also accomplish the goals of the project and would be 
>simpler.
>- 
>
>There should be an authentication process in place so that there are 
>options available for the individual running the game, and each of the 
>players can only view characters that belong to them.
>- 
>
>All of the players and the host will connect to the same session.
>- 
>
>Everything is turn based. Players will need to be notified when it is 
>their turn so that they can take actions, and may only take actions when 
> it 
>is their turn.
>- 
>
>Enemies will be loaded from a database. Player actions will reference 
>their character's stats and their enemy's stats to perform actions. These 
>actions need to update the game state (So if a player damages a particular 
>enemy, that enemy's current health persists for each player's turn until 
> it 
>is removed from the current session.)
>
> --
>
>
> With that said, I am looking to use as few technologies required as 
> possible to accomplish this. UI will mostly be a series of menus, and kept 
> as basic as possible. I've looked around online and there are A LOT of 
> different options, and it's difficult to suss out what would be the most 
> appropriate for what I'm looking to accomplish. I've looked into Tornado, 
> node.js, and HTML5. At this point I think I have information paralysis and 
> I'm looking for someone that has more experience in this field than I do to 
> help me choose what would best help me achieve my design goals. I'm 
> confident once I settle on a technology or framework I can teach myself how 
> to use it.
>
>
> Thank you!
>

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


Re: [web2py] How to preserve order for query results

2016-03-19 Thread mfarees . knysys
Thanks, it worked!
Had to change idx to ids though.

-- 
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 type 'exceptions.AttributeError'

2016-03-19 Thread Dave S
What does your view look like?

What happens when there is no post for the course_id?  Does your select 
give a None or an empty Rows? 

It appears that __getattr__ is expecting a body field, and if you don't 
have one 

(take this as a junior student piping up)

/dps

 Wednesday, March 16, 2016 at 4:27:52 PM UTC-7, Nikhil Rayaprolu wrote:
>
># view
> #show.html
> {{extend 'layout.html'}}
> {{=page.title}}
> [ {{=A('edit', _href=URL('edit', args=request.args))}} ]
> {{=MARKMIN(page.body)}}
> Comments
> {{for post in comments:}}
>   {{=db.auth_user[post.created_by].first_name}} on 
> {{=post.created_on}}
>  says {{=post.body}}
> {{pass}}
> Post a comment
> {{=form}}
> 
> #controller
> #default.py
> def user():
> return dict(form=auth())
> @auth.requires_login()
> def index():
> pages = db().select(db.course.id
> ,db.course.title,db.course.Instructor,orderby=db.course.title)
> return dict(pages=pages)
> @auth.requires_login()
> def createcourse():
>  """creates a new empty wiki page"""
>  form = SQLFORM(db.course).process(next=URL('index'))
>  return dict(form=form)
> def show():
>  """shows a wiki page"""
>  this_page = db.course(request.args(0,cast=int)) or 
> redirect(URL('index'))
>  db.post.course_id.default = this_page.id
>  form = SQLFORM(db.post).process() if auth.user else None
>  pagecomments = db(db.post.course_id==this_page.id).select()
>  return dict(page=this_page, comments=pagecomments, form=form)
> 
> #model
> #db.py
> db = DAL("sqlite://storage.sqlite")
> from gluon.tools import Auth
> auth = Auth(db)
> auth.define_tables(username=True)
> db.define_table('course',
>Field('title', unique=True),
>Field('Instructor','text', unique=True),
>Field('Dateofcoursecreation','datetime'),
> Field('Courseid'),
>format = '%(title)s')
> 
> db.define_table('post',
> Field('course_id'),
> Field('body', 'text'),
> Field('created_on', 'datetime', default=request.now),
> Field('created_by', 'reference auth_user', default=auth.user_id))
>
> #ticket issued
>
> Error ticket for "courseapp"
> Ticket ID
>
> 127.0.0.1.2016-03-16.20-55-17.d72cc1b2-28ab-4aea-be40-a372034830a5
> 
> Version
> web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39
> Python Python 2.7.6: /usr/bin/python (prefix: /usr)
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
>
> 
>
> Traceback (most recent call last):
>   File "/home/nikhil/Downloads/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/home/nikhil/Downloads/web2py/applications/courseapp/views/default/show.html",
>  
> line 79, in 
>   File 
> "/home/nikhil/Downloads/web2py/gluon/packages/dal/pydal/objects.py", line 
> 90, in __getattr__
> raise AttributeError
> AttributeError
>
> Error snapshot help
>
> ()
>
> inspect attributes
> Frames
>
> File /home/nikhil/Downloads/web2py/gluon/restricted.py in restricted 
> at line 227 code arguments variables
>
> File 
> /home/nikhil/Downloads/web2py/applications/courseapp/views/default/show.html 
> in  at line 79 code arguments variables
>
> File /home/nikhil/Downloads/web2py/gluon/packages/dal/pydal/objects.py 
> in __getattr__ at line 90 code arguments variables
> Function argument list
>
> (self= 'Instructor': 'indranil chakrabarty', 'id': 1L}>, k='body')
> Code listing
>
> 85.
> 86.
> 87.
> 88.
> 89.
> 90.
>
> 91.
> 92.
> 93.
> 94.
>
> 
>
>
> def __getattr__(self, k):
> try:
> return self.__getitem__(k)
> except KeyError:
> raise AttributeError
>
>
> def __copy__(self):
> return Row(self)
>
> Variables
> builtinAttributeError 
>
>
> please can any one say me where is the mistake.
>

-- 
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 do you use web2py app work with phonegap?

2016-03-19 Thread eric cuver
thank for information my friend

Le samedi 19 mars 2016 13:05:58 UTC+1, Leonel Câmara a écrit :
>
> I usually just use bootstrap because I'm used to it But really, any mobile 
> first CSS framework is ok. I've used foundation before it's good too, I've 
> also not used anything and just made my own according to the app needs.
>

-- 
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: Couple of questions about improving performance in models

2016-03-19 Thread Lisandro
I will bother with one last related question: *what about callback 
triggers?*
I'm defining them like this:

db.define_table('mytable', Field('field1'), Field('field2'))  # defines the 
table
from myglobals import myfunction  # imports global function
db.mytable._after_update.append(lambda s, r: myfunction(s, r))  # defines 
after update callback trigger

In this case, I guess lazy_tables=True wouldn't make sense, because I'm 
calling db.mytable so it triggers the definition of the table.

Is there a way of specifying callback triggers directly when calling 
define_table?




El jueves, 17 de marzo de 2016, 15:27:22 (UTC-3), Lisandro escribió:
>
> Oh I see! So I can define the virtual/method fields that way, and then it 
> does make sense to keep using lazy_tables. Completely missed that point.
>
> Thank you very much! 
> As always, web2py's community rocks. 
>
>
>
> El jueves, 17 de marzo de 2016, 14:59:35 (UTC-3), Anthony escribió:
>>
>> On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:
>>>
>>> Thank you very much for the quick answer.
>>>
>>> Your first comment made me think about the "lazy_tables" with the 
>>> definition of virtual method fields.
>>> If you say that doing db.tablename the table is no longer lazy, *then 
>>> it wouldn't make sense to use lazy_tables in a particular case where almost 
>>> each table has a virtual method field, am I right?*
>>>
>>> I mean, for example, if this is my model:
>>>
>>> db.define_table('first_table', Field('field1'), Field('field2'))
>>>
>>> db.first_table.field3 = Field.Method(lambda row: 'value for field3')
>>>
>>
>> This won't help with db.auth_user, which is defined automatically (though 
>> you can define it manually yourself if preferred), but you can simply do:
>>
>> db.define_table('first_table',
>> Field('field1'),
>> Field('field2'),
>> Field.Method('Field3', lambda row: 'value for field3'))
>>
>> Note, the first argument of Field.Method() and Field.Virtual() should 
>> always be the field name anyway, even if you are defining them like this:
>>
>> db.mytable.myfield = Field.Method('myfield', ...)
>>
>> There are particular cases where leaving the name out can lead to 
>> problems.
>>
>> 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] how to resend verification email?

2016-03-19 Thread Yibing Liu
Hello everyone, I developed a website with web2py. I have 
set auth.settings.registration_requires_verification = True to verify the 
register's email. However some of the users tell me that they can't receive 
the verification email. They try to re-register with the same email to get 
the verification emailIs, but they get the message"the email has been 
registered". Is there any method to re-send the verification email to the 
user? Thank you.

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


[web2py] Reportlab add image to pdf

2016-03-19 Thread Nico de Groot
You use realpath as if it construct a path to your image file. But you should 
use os.path.join as you did earlier. If you've used web2py upload facilities, 
you need an extra step to get the file from the upload folder, see the web2py 
book for details.

Nico de Groot 

-- 
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: URL parsing in controller

2016-03-19 Thread Jeff Riley
DPS and all,

I have my routes.py set to the application (a).  As far as what is 
request.args(0), that is what is confusing.  That URL is generated by 
smartgrid.  Manage_customers is the controller, so customer should be the 
function but it is not. View is the function.  This is why I am having trouble 
understanding how to grab the customer id and the sheet id.

Thank you,
Jeff Riley

-- 
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: How to insert different grid elements in tab panels?

2016-03-19 Thread Ron Chatterjee
Thank you! that works

On Friday, March 18, 2016 at 9:51:31 AM UTC-4, Massimiliano wrote:
>
> Try to give a each grid a uniq formname:
>
> SQLFORM.grid(db.post, formname=‘grid_post’)
>
> SQLFORM.grid(db.post, formname=‘grid_comments’)
>
> On Wed, Mar 16, 2016 at 1:25 AM, Ron Chatterjee  > wrote:
>
>> Basically, I go to panel one and "view" the grid element. And if I click 
>> on "back" button it takes me to panel2 content even though it says panel1. 
>> And vice versa.
>>
>>
>> On Tuesday, March 15, 2016 at 8:21:59 PM UTC-4, Ron Chatterjee wrote:
>>>
>>> I used the LOAD but seems to be the problem still there. See attached pic
>>>
>>>
>>> My Model
>>>
>>> db.define_table('post',
>>> Field("title", "string", length=128, default=""),
>>> Field("contents", "text", length=512, default=""),
>>> Field("created_on", "date", default=None),
>>> )
>>>  
>>> if not db(db.post).count():
>>> from gluon.contrib.populate import populate
>>> populate(db.post,25)
>>>
>>> db.define_table('comments',
>>> Field("title", "text", length=128, default=""),
>>> Field("contents", "string", length=512, default=""),
>>> Field("created_on", "date", default=None),
>>> )
>>>  
>>> if not db(db.comments).count():
>>> from gluon.contrib.populate import populate
>>> populate(db.comments,25)
>>>
>>>
>>>
>>> Controller:
>>>
>>> def first_action():
>>> grid1 = SQLFORM.grid(db.post)
>>> return dict(grid1 = grid1)
>>>
>>> def second_action():
>>> grid2 = SQLFORM.grid(db.comments)
>>> return dict(grid2 = grid2)
>>>
>>>
>>> def tab_panel():
>>> return locals()
>>>
>>>
>>>
>>> View:
>>>
>>> {{extend 'layout.html'}}
>>>
>>> 
>>>   My Dashboard
>>>   
>>> My 
>>> Projects
>>> My Files
>>> Menu 2
>>> Menu 3
>>>   
>>>
>>>   
>>> 
>>>   {{=LOAD('default','first_action.load',ajax=True)}}
>>> 
>>> 
>>>   
>>>   {{=LOAD('default','second_action.load',ajax=True)}}
>>> 
>>> 
>>>   Menu 2
>>>   Sed ut perspiciatis unde omnis iste natus error sit voluptatem 
>>> accusantium doloremque laudantium, totam rem aperiam.
>>> 
>>> 
>>>   Menu 3
>>>   Eaque ipsa quae ab illo inventore veritatis et quasi architecto 
>>> beatae vitae dicta sunt explicabo.
>>> 
>>>   
>>> 
>>>
>>>
>>>
>>> On Wednesday, March 2, 2016 at 4:24:26 PM UTC-5, Ron Chatterjee wrote:

 Thank you Val. Appreciate the help.

 On Wednesday, March 2, 2016 at 1:51:58 PM UTC-5, Val K wrote:
>
> As I know it's impossible to have 2 "static" (not ajax)  SQLFORM.grids 
> at the same page, because each of them will treat request.args  as its 
> own 
>
> Use {=LOAD(... , ajax=True)} 
>
> And I think  you have to have different controllers to process them or 
> one controller that will return different results depends on "whose 
> requests" - return dict(grid= grid1)  or  return dict(grid= grid2)  not 
> both!
>
>
> On Wednesday, March 2, 2016 at 8:12:49 PM UTC+3, Ron Chatterjee wrote:
>>
>>
>> If I have two independent grid, when I search in one grid, it gets 
>> redirected to the other tab. And I noticed this with other tab panel as 
>> well.  
>>
>>
>>
>> 
>>   
>> My Projects
>> My Payments
>> My Contacts
>>   
>>   
>> 
>>   {{=grid1}}
>>   
>>   
>> {{=grid2}}
>>   
>>   
>> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
>> diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
>> volutpat.
>> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
>> diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
>> volutpat.
>> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
>> diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
>> volutpat.
>>   
>> 
>>
>> 
>> $( "#tabs" ).tabs();
>> 
>>
>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Massimiliano
>

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

[web2py] Re: How do you use web2py app work with phonegap?

2016-03-19 Thread RAGHIB R
Can you please show where you created the REST API? In a different view? 
Can I get any link, how to do that?

On Friday, March 18, 2016 at 8:17:50 PM UTC+5:30, Leonel Câmara wrote:
>
> I usually just create a REST API returning JSON as is very well documented 
> in the book and then just call it from the phonegap/cordova application 
> using ajax (for instance you can include jquery in your phonegap 
> application and it has getJSON which works very well for this). Then I make 
> a regular website for people to use as a backoffice to the application 
> which is just regular web2py. In summary, you don't need to modify anything 
> in particular to make web2py work with cordova.
>

-- 
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: creating a user in auth from shell

2016-03-19 Thread Niphlod
using .insert() over .add() would be a good choice ^_^

On Thursday, March 17, 2016 at 12:52:53 AM UTC+1, Dave S wrote:
>
> My remote host is not running a GUI, so doing appadmin by browsing is 
> inconvenient.  I need to add a user, and I'd like to do that from a script 
> run in the web2py shell "command line (I will be adding this user to a 
> privileged group).  How do I do that?  Something like 
> db.auth_users.add("Forename", "Surname", "maila...@mailserver.usw", 
> REGISTRATIONKEY, ,)
> ?
>
> How do I set the password?
>   
> If I set 
> auth.settings.registration_requires_approval = True
>
> can I do the approval from a similar script?
>
> Thanks.
>
> /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: how to resend verification email?

2016-03-19 Thread Yibing Liu
I have used a commercial smtp service. Is there a way to resend the 
verification email to the users? Thank you.

在 2016年3月17日星期四 UTC+8上午7:31:15,Massimo Di Pierro写道:
>
> The reliability of this depends on the smtp server certificates. using 
> postfix on localhost is very unreliable. Using a commercial service is 
> better
>
> On Wednesday, 16 March 2016 07:41:21 UTC-5, Yibing Liu wrote:
>>
>> Hello everyone, I developed a website with web2py. I have 
>> set auth.settings.registration_requires_verification = True to verify the 
>> register's email. However some of the users tell me that they can't receive 
>> the verification email. They try to re-register with the same email to get 
>> the verification emailIs, but they get the message"the email has been 
>> registered". Is there any method to re-send the verification email to the 
>> user? Thank you.
>>
>

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


[web2py] Reportlab add image to pdf

2016-03-19 Thread Winter Kryz
Hello everyone,
I am trying to generate reports using Reportlab in web2py. I'm working on 
pythonanywhere.com
I am having some problems because I want to insert an image as header into 
the pdf report

this is my report.py 

from reportlab.platypus import *
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch, mm
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import SimpleDocTemplate, Image
from reportlab.lib import colors
from uuid import uuid4
from cgi import escape
import os

def index():
title = "Mi mundo REPORTE PDF"
heading = "MI PRIMER RE"
text = 'bla '* 10
styles = getSampleStyleSheet()
tmpfilename=os.path.join(request.folder,'private',str(uuid4()))
doc = SimpleDocTemplate(tmpfilename)
story = []
logo = "/static/images/logounca.png"
imagen_logo = Image(os.path.realpath(logo),width=400,height=100)
story.append(imagen_logo)
story.append(Paragraph(escape(title),styles["Title"]))
story.append(Paragraph(escape(heading),styles["Heading2"]))
story.append(Paragraph(escape(text),styles["Normal"]))
story.append(Spacer(1,2*inch))
doc.build(story)
data = open(tmpfilename,"rb").read()
os.unlink(tmpfilename)
response.headers['Content-Type']='application/pdf'
return data

My view.html
{{extend 'layout.html'}}
This is my report/index.html
{{=BEAUTIFY(response._vars)}}

When I try to view the pdf, it gives me this error
* Cannot open resource 
"/static/images/logounca.png" fileName='/static/images/logounca.png' 
identity=[ImageReader@0x7fa7f0bf5510 
filename='/static/images/logounca.png']*
I don't know if I am calling the image url wrong or If I uploaded the image 
wrongly. 
I uploaded the image on pythonanywhere.com through the Static section.
If someone can help me with this issue, please

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: Couple of questions about improving performance in models

2016-03-19 Thread Anthony
On Thursday, March 17, 2016 at 1:08:49 PM UTC-4, Lisandro wrote:
>
> Straight to the point:
> I'm using *lazy_tables=True* and *migrate=False*
>
>
> *In my model, I have several Method Fields.*
> Some of them use a function that is declared inside the same model, like 
> this:
>
> db.auth_user.give_me_data = Field.Method(lambda row: _give_me_data(row.
> auth_user))
>
> def _give_me_data(user):
> # calculation and obtention of data
> # return data
>
> So first question: *should I move declaration of _give_me_data function 
> to a module?* 
> Or is it the same because I would have to import it anyway in the model?
> *Just to remind, I'm using lazy_tables=False, so maybe the code isn't 
> really executed until the table is called. I'm not sure about this.*
>

Note, as soon as you do db.auth_user, the table is no longer lazy. Maybe 
not a big deal for this one table.

Probably doesn't matter much where you define the function, though I 
suppose there could be a slight performance benefit to putting it in a 
module (where it will only be defined once instead of on every request).
 

> *Usage of Storage class objects*
> In my models, I create some Storage objects, because it's really useful 
> for setting and retrieving data from those objects. I use them like this:
>
> from gluon.tools import Storage
>
> CONFIG = Storage()
> CONFIG.variable1 = 'value-variable-1'
> CONFIG.variable2 = 'value-variable-2'
>
> I don't put much data inside them, just config variables.
> However, my question is: *should I use other data type to storage those 
> variables?* Or it won't make any difference?
>

Again, probably not a big deal, but you could move that to a module, or 
maybe use AppConfig (which caches the configuration data after the initial 
setup).

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] issue when import from one web2py module into another

2016-03-19 Thread Leonel Câmara
from other_module import function

should work too

-- 
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: session always written if auth.user_groups is accessed

2016-03-19 Thread Anthony

>
> The question is if/how you can address the issue for other users - or at 
> least warn them about it.
>

Not sure. There's some discussion on the developer's list. I agree we 
should at least have a warning in the book.

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] creating a user in auth from shell

2016-03-19 Thread Dave S
My remote host is not running a GUI, so doing appadmin by browsing is 
inconvenient.  I need to add a user, and I'd like to do that from a script 
run in the web2py shell "command line (I will be adding this user to a 
privileged group).  How do I do that?  Something like 
db.auth_users.add("Forename", "Surname", "maila...@mailserver.usw", 
REGISTRATIONKEY, ,)
?

How do I set the password?
  
If I set 
auth.settings.registration_requires_approval = True

can I do the approval from a similar script?

Thanks.

/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: modal not work when upload form field have the data

2016-03-19 Thread Leonel Câmara
Hey stifan, I have a custom made javascript I use to load components in 
modals. It works with file uploads as long as you have jquery.form.js and 
you send it upload_form: true in the options. I usually use it in the 
onclick of buttons to open the modal with the form. Read the comments in 
the code to know how to use it.

function load_in_modal(url, modal_id, options) {
if (typeof options === 'undefined') {
  /* Example Options.   * {title: "Add Image", upload_form: true}   
*/
  options = {};
}

/* * You can remove this if you don't want to deal with file uploads.   
  * If you want to use this, the view/controller using this should * insert 
jquery.form.js on response.files. */
if (Boolean(options.upload_form)) {
$.web2py.trap_form = function (action, target) {
  /* traps any LOADed form */
  $('#' + target + ' form').each(function (i) {
var form = $(this);
if (form.hasClass('no_trap')) {
  return;
}

form.attr('data-w2p_target', target);
var url = form.attr('action');

if ((url === "") || (url === "#")) {
  /* form has no action. Use component url. */
  url = action;
}

if(form.find('.input-file').length>0) {
form.ajaxForm({
url: action,
success: function(data, statusText, xhr) {
jQuery('#'+target).html(xhr.responseText);
$.web2py.trap_form(action,target);
$.web2py.ajax_init();
}
});
}
else {
form.submit(function (e) {
  
$.web2py.disableElement(form.find($.web2py.formInputClickSelector));
  $.web2py.hide_flash();
  $.web2py.ajax_page('post', url, form.serialize(), target, 
form);
  e.preventDefault();
});
}
  });
};
}
/* end of file upload dealing code */


/* Remember to set an id in your modal's body */
$.web2py.component(url, $('#' + modal_id + ' .modal-body').attr('id'));

$('#' + modal_id).modal({show: true});
if (typeof options.title !== undefined) {
$('#' + modal_id + ' .modal-title').text(options.title);
}}

-- 
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: creating a user in auth from shell

2016-03-19 Thread Dave S
On Thursday, March 17, 2016 at 10:54:13 AM UTC-7, Anthony wrote:
>
> new_user = auth.register_bare(email='x...@example.com ', 
> password='1234', ...)
> new_user.update_record(registration_key='') # This approves the 
> registration - can be done later.
> db.commit() # Make sure you explicitly commit db operations when in a 
> script or the shell.
>
> That will handle hashing the password and creating the default user group. 
> Note, it will also allow auth.settings.register_onaccept to run, so if you 
> don't want that, you should temporarily set that to None.
>
> Anthony
>
>

Thank you!

/dps
 

> On Wednesday, March 16, 2016 at 7:52:53 PM UTC-4, Dave S wrote:
>>
>> My remote host is not running a GUI, so doing appadmin by browsing is 
>> inconvenient.  I need to add a user, and I'd like to do that from a script 
>> run in the web2py shell "command line (I will be adding this user to a 
>> privileged group).  How do I do that?  Something like 
>> db.auth_users.add("Forename", "Surname", "maila...@mailserver.usw", 
>> REGISTRATIONKEY, ,)
>> ?
>>
>> How do I set the password?
>>   
>> If I set 
>> auth.settings.registration_requires_approval = True
>>
>> can I do the approval from a similar script?
>>
>> Thanks.
>>
>> /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: How do you use web2py app work with phonegap?

2016-03-19 Thread Leonel Câmara
I usually just use bootstrap because I'm used to it But really, any mobile 
first CSS framework is ok. I've used foundation before it's good too, I've 
also not used anything and just made my own according to the app needs.

-- 
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: URL parsing in controller

2016-03-19 Thread Jeff Riley
Thank you all very much.  This worked.  

args=[request.args(2),request.args(5)]


On Friday, March 18, 2016 at 5:08:15 PM UTC-5, Jeff Riley wrote:
>
> Ah you are totally correct. The controller is default and manage_customers 
> is the function. I am still getting used to these constructs.

-- 
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: session always written if auth.user_groups is accessed

2016-03-19 Thread Alex
thanks! for me that's fine and an easy workaround.

The question is if/how you can address the issue for other users - or at 
least warn them about it. I think experiencing this problem is not that 
unlikely but it goes unnoticed very easily. For a small user base its 
irrelevant (from a performance standpoint) but for an app with many 
requests this could make a difference.

-- 
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: Scheduler as a service RHEL 7

2016-03-19 Thread Michael M
Sorry Dave, I know how that goes :)

If you find a more elegant solution. I'm open.  

-- 
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: Oracle Driver Not Available When web2py run from bash script

2016-03-19 Thread Michael M
CX_Oracle and instantclient are weird about permissions. 

See where they get installed on your system with command "locate" and report 
back the output of "ls -l" in the directory it was found in.

Also run "ps -aux|grep web2py" and see who the user is running it under the 
different methods you explained.

-- 
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 many days does it take you to learn django if you know web2py (and only web2py)?

2016-03-19 Thread rajjmatthur
If you are not comfortable with django ORM you can also use SQLalchemy . 
Use that in web2py first to verify your model. And then you can copy and 
replace in django. Here is a way to replace the django ORM with SQLAlchemy. 

http://lethain.com/replacing-django-s-orm-with-sqlalchemy/

You will be in luck when they have a way to use pydal in django. But for 
now, this may be another option to bridge the gap between two. 



On Wednesday, March 16, 2016 at 8:15:55 AM UTC-4, Bernard Letourmy wrote:
>
> Hello,
> Took me around 2 months working on a new project from scratch to feel 
> nearly as comfortable with django as I was in web2py (after having enjoyed 
> web2py for 2+ years)
> Although prepare to feel quite lot of pain along the way such
> As when you keep repeating yourself with declaring and connecting  routes, 
> controller (sorry view there) and templates till you find your own way to 
> auto generate the relations
> Prepare to cry about batteries missing, such as:
> - default user system with authentication views included, simple default 
> REST api support etc,
> -nice and automatically configured appadmin with dal query, g not only 
> basic CRUD)
> - a scheduler
> - having to always find from where  the hell  you need to import that 
> class  you use every day...
> - having to find it in a manual splitted in chapters without a nice table 
> of content and good index  system  that force you to use Google even when 
> you know it's in the manual.
>
> You''ll also miss the power and clean syntax of pydal. You will see when 
> you will try to do your first join with django orm...
> But ok once accustomed to the silly __ _id field__gte=x notations using 
> keywords argument instead of the clean field object and standard Python 
> Operators of pydal 
> You will enjoy quite  powerful object oriented interface on your models.
> With automatic reverse relation generations, very nice way to extend the 
> default model classes.
> Basically a lot of choices at all stages either inside the framework for 
> different ways to do the same thing or out there when it comes to find a 
> plugin (an app in django) that provides the missing feature.
> These being both advantages and inconvenience, explaining that it will 
> take certainly longer to be fully up and running with django than with 
> web2py
>
> Forgot one thing that's really nice with django:
> the migration system. It's less 'automatic' then web2py's one but more 
> powerful and reliable in my opinion as it allows forward and backwards 
> migration and stores its meta data in the DB instead of the filesystem 
> itself allowing you to easily switch DB backend and migrate them from the 
> same Dev env for ex.
> And one thing less nice
> The core dev community is quite opiniated/ and stuck on the by design 
> limitations...
> With the view/template system that force you to learn a new language with 
> expression being very restricted subset of Python
> And force to develop yourself most of the basic filter needed.
> Then quite a lot of won't fix issues or request for feature some 
> repeatidely asked for 10years
>
> But I do quite like django also :)
>
> Bon courage for your learning
> Bernard 
>
>

-- 
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: Using Scheduler to delete database rows older than a timestamp

2016-03-19 Thread Dave S


On Friday, March 4, 2016 at 11:01:50 AM UTC-8, Dave S wrote:
>
>
>
> On Friday, March 4, 2016 at 3:25:50 AM UTC-8, Niphlod wrote:
>>
>> never ever ever call a queue_task() in a model. models gets executed at 
>> every request. just queue the task in a "protectedinitialsetup()" 
>> controller and use it.
>>
>
> Well, that's why I have the status check, but I like your way of doing it.
>
>
>  
>
>>
>> I have a similar approach for 
>> rebuilding/reinitializing/requeueing/rechecking all tasks
>>
>> in a controller (e.g. default.py)
>>
>> def reinit_sched(protect=None):
>> delete bla bla . do stuff ... bla bla
>> sched.queue_task(foo)
>> sched.queue_task(bar)
>> etc etc etc
>>
>>
>> you can then easily call it with web2py.py -M -S 
>> appname/default/reinit_sched
>>
>> BTW: it's a little easy trick: every function with arguments can't be 
>> called from any request coming in (so it's secured) .. and the -S parameter 
>> can take not only the app name, but also the controller and the function to 
>> execute...
>>  
>>
>
I finally got my code caught up to this.  Took me a couple of tries before 
I realized that I needed the db.commit() after the queue_task() ... duh, 
this is a shell, not a web request.

/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: How to preserve order for query results

2016-03-19 Thread Ron Chatterjee
Wouldn't the sort in numpy will do the same?

http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.sort.html



On Thursday, March 17, 2016 at 7:23:51 AM UTC-4, Leonel Câmara wrote:
>
> You already have an answer but if you're interested in making the DB do 
> the sorting (which may be faster if you have a lot of records) you could do 
> something like this:
>
> ordered = [5,2,3,4,1]
>
> def make_orderby(table, attribute, ordered):
> orderby = 'case'
> for idx, value in enumerate(ordered):
> orderby += '\nwhen %(table)s.%(attribute)s = %(value)s then 
> %(idx)s' % locals()
> else:
> idx += 1
> orderby += '\nelse %(idx)s' % locals()
> orderby += '\nend'
> return orderby
> 
> tests = 
> db(db.test.id.belongs(ordered)).select(orderby=make_orderby('test','id', 
> ordered))
>
>
>
>

-- 
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] custom authentication

2016-03-19 Thread T.R.Rajkumar
I have the username, password, role in legacy SQL server database. In my 
login from I check the credentials against the above database. Now how to 
restrict access to controller functions, since I am not using Auth. 
Pl.guide.

-- 
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: XML object

2016-03-19 Thread Anthony
Please show your exact view code as well as the final rendered HTML.

-- 
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: fighting with the widget

2016-03-19 Thread Pierre
thanks Val K

still there's something unclear:
the book implies that a new widget is just a function and a field 
definition bound to that function like:

def my_string_widget(field, value):
return INPUT(_name=field.name,
 _id="%s_%s" % (field._tablename, field.name),
 _class=field.type,
 _value=value,
 requires=field.requires)

Field('comment', 'string', widget=my_string_widget)

but if you look at the web2py code 
:https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L321
a widget is a class with a static-method in it so my question is :
do I have to define a new widget class like : class myListWidget(StringWidget) ?
or is it enough to define a function as the book says ?

what's perfectly clear (Niphlod) is the need to define a new css class (!= 
w2p_*) for the new widget


-- 
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: Couple of questions about improving performance in models

2016-03-19 Thread Dave S


On Friday, March 18, 2016 at 10:19:40 AM UTC-7, Lisandro wrote:
>
> Anthony, thank you very much for your help.
>
 

> [...]
> I'm tempted to ask one more thing that I'm wondering about:
>
> In my model, I  have several tables (lets say about 8 or 9) that are used 
> to store information about list of options. 
> These tables only have a few records each, and they will never grow.
>
> For example, one table could be "days" (I don't have this table 
> specifically, it's for the example).
> So, let's say the table "days" has a "name" field and a "plural_name" 
> field.
> The table is populated with data only once, at application startup, and 
> remains the same forever: "days" table will only have 7 records, one for 
> each day of the week.
>
> Now, the part that I'm worried about is this: *inside the same model, I 
> store each record in a variable*, like this:
>
> db.define_table('days', Field('name'), Field('plural_name'))
>
> MONDAY = db.days[1]
> TUESDAY = db.days[2]
> WEDNESDAY = db.days[3]
> THURSDAY = db.days[4]
> FRIDAY = db.days[5]
> SATURDAY = db.days[6]
> SUNDAY = db.days[7]
>
> I use that to be able to reference each day from the app code, but I've 
> realised that in this way, the "days" table won't be lazy, because it's 
> called to get the record.
>
> So my question is: *what would be the correct approach for storing that 
> kind of records in variables, without compromising lazy tables?*
>
>
For tables this small, does lazy make a difference?  You're only calling 
the Field constructor twice in this example.

You may have a good reason for having this sort of thing as a table, but if 
you're just wanting a global list, putting an actual list in the globals 
seems reasonable.

/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: How do you use web2py app work with phonegap?

2016-03-19 Thread Leonel Câmara
As I said the book explains how to do it:
http://web2py.com/books/default/chapter/29/10/services#Restful-Web-Services

-- 
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: URL parsing in controller

2016-03-19 Thread webmaster
Maybe something about "args=request.args(2,5)"?

You could try to test this:

args=[request.args(2),request.args(5)]





On Friday, March 18, 2016 at 1:01:51 PM UTC-7, Jeff Riley wrote:
>
> Hello All,
>
> I am pulling my hair out.  I am trying to redirect the view button on a 
> smartgrid.  I can get the button to redirect to the view I want, but I 
> cannot parse the URL correctly to get the correct sheet id.
>
> Here is my controller
>
> @auth.requires_membership('manager')
> def manage_customers():
> if 'new' in request.args:
> if request.args(2) == 'customer':
> redirect(URL('new_customer'))
> elif request.args(4) == 'sheet':
> redirect(URL('new_sheet', args=request.args(2)))
> if 'edit' in request.args:
> if request.args(4) == 'sheet':
> redirect(URL('edit_sheet', args=request.args(2)))
> if 'view' in request.args:
> if request.args(4) == 'sheet':
> redirect(URL('view_sheet', args=request.args(2,5)))
> elif request.args(6) == 'sheet_archive':
> redirect(URL('view_sheet', args=request.args(7)))
> form = SQLFORM.smartgrid(db.customer, linked_tables=['address', 
> 'sheet', 'sheet_archive'],
>  searchable= dict(customer=True, 
> address=False, sheet=False),
>  editable= dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  deletable= dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  create=dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  paginate=20, maxtextlength=60, 
> fields=[db.customer.first_name,
>  db.customer.last_name, db.customer.phone, 
> db.customer.email, db.customer.handed,
>  db.address.address1, db.address.address2, 
> db.address.city, db.address.state_province,
>  db.address.postal_code, db.sheet.title, 
> db.sheet.created_by, db.sheet.created_on,
>  db.sheet_archive.id, db.sheet_archive.title, 
> db.sheet_archive.created_by,
>  db.sheet_archive.created_on],)
> return dict(form=form, request=request)
>
> Here is my URL:
>
>
> http://127.0.0.1:8000/manage_customers/customer/sheet.customer_id/1/edit/sheet/2?_signature=3b4a45778f06aec42421ef503cba968cd633269a
>
>
> I can only get the customer_id and not the sheet #2.  So I am always 
> displaying the first customer record and the first sheet record.  SO LOST.
>
>

-- 
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: URL parsing in controller

2016-03-19 Thread Jeff Riley
Sorry, edit is the function.  This URL does not call view.

-- 
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: Using MySQL in GAE locally (is it actually possible?)

2016-03-19 Thread webmaster
Ok, I went into the web2py_filesystem file that's being created in MySQL by 
GAE.  It shows a bunch of these .table files, but web2py (when run on local 
GAE) is still searching for the folders in the OS's filesystem.  Is this 
just a bug?

On Thursday, March 17, 2016 at 12:59:59 PM UTC-7, webm...@trytha.com wrote:
>
> I've got MySQL working locally in GAE, but since GAE doesn't write to the 
> file system, it can't touch /databases.  Am I doing something wrong?  Has 
> anyone actually gotten GAE working with MySQL locally?  I can't find a 
> single tutorial related to this.  If someone shows me this last step, I can 
> put together a tutorial from fresh OSX install to fully-functional web dev 
> environment with web2py on GAE in a Virtualbox VM (a tutorial web2py 
> desperately needs).  I already have all the steps in an Evernote, just need 
> to figure this last part out.
>
> I even tried putting "folder='/home/www-data/web2py...'" in my DAL 
> connection string, but nothing gets written in the /databases folder still. 
>  GAE does all the MySQL creation and then hits me with a corrupted *.table 
> error the first time I refresh because nothing is written in /databases.
>
> Can I write the databases to memcache or datastore somehow?  How is GAE 
> handling this on the server side without errors?
>

-- 
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 do you use web2py app work with phonegap?

2016-03-19 Thread eric cuver
hi Leonel,

which client (boostrap, jquery mobile, ionic.)  for design with 
phonegap advises you ?


Le vendredi 18 mars 2016 18:41:22 UTC+1, Leonel Câmara a écrit :
>
> I'm sorry but you show fundamental misconceptions about what phonegap 
> does, what web2py does, how they run in the devices and server, and about 
> how they can and should interact.  
>   
> Your questions don't even make sense. I can't help you until you know more 
> about web2py, phonegap, what REST APIs are and how do you access them using 
> javascript.  
>

-- 
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] Djano channels

2016-03-19 Thread Najtsirk
https://blog.heroku.com/archives/2016/3/17/in_deep_with_django_channels_the_future_of_real_time_apps_in_django

Is there anything similar in web2py? 

I read about comet messaging.  How these two compare? 

Thanks,  
Najtsirk

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


[web2py] web2py type 'exceptions.AttributeError'

2016-03-19 Thread Nikhil Rayaprolu
   # view
#show.html
{{extend 'layout.html'}}
{{=page.title}}
[ {{=A('edit', _href=URL('edit', args=request.args))}} ]
{{=MARKMIN(page.body)}}
Comments
{{for post in comments:}}
  {{=db.auth_user[post.created_by].first_name}} on 
{{=post.created_on}}
 says {{=post.body}}
{{pass}}
Post a comment
{{=form}}

#controller
#default.py
def user():
return dict(form=auth())
@auth.requires_login()
def index():
pages = 
db().select(db.course.id,db.course.title,db.course.Instructor,orderby=db.course.title)
return dict(pages=pages)
@auth.requires_login()
def createcourse():
 """creates a new empty wiki page"""
 form = SQLFORM(db.course).process(next=URL('index'))
 return dict(form=form)
def show():
 """shows a wiki page"""
 this_page = db.course(request.args(0,cast=int)) or 
redirect(URL('index'))
 db.post.course_id.default = this_page.id
 form = SQLFORM(db.post).process() if auth.user else None
 pagecomments = db(db.post.course_id==this_page.id).select()
 return dict(page=this_page, comments=pagecomments, form=form)

#model
#db.py
db = DAL("sqlite://storage.sqlite")
from gluon.tools import Auth
auth = Auth(db)
auth.define_tables(username=True)
db.define_table('course',
   Field('title', unique=True),
   Field('Instructor','text', unique=True),
   Field('Dateofcoursecreation','datetime'),
Field('Courseid'),
   format = '%(title)s')

db.define_table('post',
Field('course_id'),
Field('body', 'text'),
Field('created_on', 'datetime', default=request.now),
Field('created_by', 'reference auth_user', default=auth.user_id))

#ticket issued

Error ticket for "courseapp"
Ticket ID

127.0.0.1.2016-03-16.20-55-17.d72cc1b2-28ab-4aea-be40-a372034830a5

Version
web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39
Python Python 2.7.6: /usr/bin/python (prefix: /usr)
Traceback

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



Traceback (most recent call last):
  File "/home/nikhil/Downloads/web2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/home/nikhil/Downloads/web2py/applications/courseapp/views/default/show.html", 
line 79, in 
  File "/home/nikhil/Downloads/web2py/gluon/packages/dal/pydal/objects.py", 
line 90, in __getattr__
raise AttributeError
AttributeError

Error snapshot help

()

inspect attributes
Frames

File /home/nikhil/Downloads/web2py/gluon/restricted.py in restricted at 
line 227 code arguments variables

File 
/home/nikhil/Downloads/web2py/applications/courseapp/views/default/show.html 
in  at line 79 code arguments variables

File /home/nikhil/Downloads/web2py/gluon/packages/dal/pydal/objects.py 
in __getattr__ at line 90 code arguments variables
Function argument list

(self=, k='body')
Code listing

85.
86.
87.
88.
89.
90.

91.
92.
93.
94.




def __getattr__(self, k):
try:
return self.__getitem__(k)
except KeyError:
raise AttributeError


def __copy__(self):
return Row(self)

Variables
builtinAttributeError 


please can any one say me where is the mistake.

-- 
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: web2pyslices unsuable

2016-03-19 Thread webmaster
As a temporary fix while figuring this out, Google has cached pretty much 
every slice.  Just do a google search in the style "site:web2pyslices.com" 
and the tack on whatever search terms you want, then click the little green 
down arrow on Google's search results for the cached version of the site.

On Thursday, March 17, 2016 at 9:04:45 AM UTC-7, zendevel wrote:
>
> Web2pyslices is down and all the content is missing. Is there any owner of 
> the site? It seems like it was hacked or something.  It was been a wealth 
> of knowledge for the community I hate to see it go to pot. I would be 
> willing to host it if needed.
>

-- 
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: Big Bug: Cloud SQL completely broken? Steps and solution.

2016-03-19 Thread webmaster
No rush for me.  I'm satisfied with my temporary fix since I can finally 
get back to actual coding.  Thanks for making such a pleasant framework.

On Saturday, March 19, 2016 at 12:25:02 AM UTC-7, Massimo Di Pierro wrote:
>
> I will get to the bottom of this tomorrow. It is a promise.
>
> On Friday, 18 March 2016 17:42:34 UTC-5, webm...@trytha.com  
> wrote:
>>
>> 2.12.2 is definitely not broken, since that's what I've been using live 
>> on GAE for about six months.  (www.trytha.com)
>>
>> I did the precise steps I outline above while I was preparing the post. 
>>  Not much to it, and it started working again as soon as I replaced the new 
>> /pydal with the old.  I've been beating my head against this for two days. 
>>  I thought it was just a problem I was having deploying locally since I had 
>> gotten things working on GAE last year (I had skipped a *local* GAE 
>> deployment at that time).  This morning I decided to just try my known, 
>> server-side-working app (2.12.2) locally and it worked with no issues. 
>>  That's when I started swapping out directories until I found the offender 
>> was /pydal.  I also tested 2.12.3 and it does *NOT* work.
>>
>> I would really love to be using the latest version.  Hopefully if it's a 
>> mistake on my end, you might have some insight into where I've stepped off 
>> the path.
>>
>> On Friday, March 18, 2016 at 3:28:15 PM UTC-7, Massimo Di Pierro wrote:
>>>
>>> gae on 2.12.2 was broken. It is no broken in current stable and trunk.
>>>
>>> On Friday, 18 March 2016 15:55:21 UTC-5, webm...@trytha.com wrote:

 Steps to replicate (3 mins):


1. Load Web2py from source off website.  Copy gaehandler.py and 
app.yaml to /web2py.  
2. In applications/welcome/models/db.py, change the DAL connection 
to "db = DAL('google:sql://[$project]:[$instance]/[$database]')"
3. python dev_appserver.py --host=0.0.0.0 --mysql_host=localhost 
--mysql_port=3306 --mysql_user=root --mysql_password= 
/home/www-data/web2py
4. Load, then refresh the Welcome app and it crashes because it 
thinks it can't access the /databases folder.

 Solution (1 min):

1. Delete /gluon/packages/dal/pydal
2. Replace with /gluon/packages/dal/pydal from version 2.12.2 of 
web2py.  (http://web2py.com/examples/static/2.12.2/web2py_src.zip)

 Am I doing something really crazy?  How has nobody run across this in 
 the six months it's been broken?  Seems like kind of a massive bug.

>>>

-- 
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: creating a user in auth from shell

2016-03-19 Thread Anthony
new_user = auth.register_bare(email='x...@example.com', password='1234', ...)
new_user.update_record(registration_key='') # This approves the 
registration - can be done later.
db.commit() # Make sure you explicitly commit db operations when in a 
script or the shell.

That will handle hashing the password and creating the default user group. 
Note, it will also allow auth.settings.register_onaccept to run, so if you 
don't want that, you should temporarily set that to None.

Anthony

On Wednesday, March 16, 2016 at 7:52:53 PM UTC-4, Dave S wrote:
>
> My remote host is not running a GUI, so doing appadmin by browsing is 
> inconvenient.  I need to add a user, and I'd like to do that from a script 
> run in the web2py shell "command line (I will be adding this user to a 
> privileged group).  How do I do that?  Something like 
> db.auth_users.add("Forename", "Surname", "maila...@mailserver.usw", 
> REGISTRATIONKEY, ,)
> ?
>
> How do I set the password?
>   
> If I set 
> auth.settings.registration_requires_approval = True
>
> can I do the approval from a similar script?
>
> Thanks.
>
> /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: IMPORTANT SECURITY ISSUE

2016-03-19 Thread Antonio Salazar
Since this is not a vulnerability, can Examples be simply disabled?

On Tuesday, March 15, 2016 at 10:43:24 AM UTC-6, Massimo Di Pierro wrote:
>
> An important security issue has come up.
>
> If you use web2py in production with the rocket web server (which you 
> should not anyway):
> 1) delete the "examples" app
> 2) make sure you pages do not expose the {{=response.toolbar}} 
>
> Please follow the above guidelines because exposing internal system status 
> may help attackers gain confidential information about your system.
> The web2py in trunk will prevent the information leakage by default but 
> removing "examples" is the safest way.
>
> If you use nginx or apache or other wsgi server there is no problem but 
> you may still want to follow the above rules in production.
>
> 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] Re: Couple of questions about improving performance in models

2016-03-19 Thread Anthony
See 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#on_define.

On Thursday, March 17, 2016 at 6:13:35 PM UTC-4, Lisandro wrote:
>
> I will bother with one last related question: *what about callback 
> triggers?*
> I'm defining them like this:
>
> db.define_table('mytable', Field('field1'), Field('field2'))  # defines 
> the table
> from myglobals import myfunction  # imports global function
> db.mytable._after_update.append(lambda s, r: myfunction(s, r))  # defines 
> after update callback trigger
>
> In this case, I guess lazy_tables=True wouldn't make sense, because I'm 
> calling db.mytable so it triggers the definition of the table.
>
> Is there a way of specifying callback triggers directly when calling 
> define_table?
>
>
>
>
> El jueves, 17 de marzo de 2016, 15:27:22 (UTC-3), Lisandro escribió:
>>
>> Oh I see! So I can define the virtual/method fields that way, and then it 
>> does make sense to keep using lazy_tables. Completely missed that point.
>>
>> Thank you very much! 
>> As always, web2py's community rocks. 
>>
>>
>>
>> El jueves, 17 de marzo de 2016, 14:59:35 (UTC-3), Anthony escribió:
>>>
>>> On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:

 Thank you very much for the quick answer.

 Your first comment made me think about the "lazy_tables" with the 
 definition of virtual method fields.
 If you say that doing db.tablename the table is no longer lazy, *then 
 it wouldn't make sense to use lazy_tables in a particular case where 
 almost 
 each table has a virtual method field, am I right?*

 I mean, for example, if this is my model:

 db.define_table('first_table', Field('field1'), Field('field2'))

 db.first_table.field3 = Field.Method(lambda row: 'value for field3')

>>>
>>> This won't help with db.auth_user, which is defined automatically 
>>> (though you can define it manually yourself if preferred), but you can 
>>> simply do:
>>>
>>> db.define_table('first_table',
>>> Field('field1'),
>>> Field('field2'),
>>> Field.Method('Field3', lambda row: 'value for field3'))
>>>
>>> Note, the first argument of Field.Method() and Field.Virtual() should 
>>> always be the field name anyway, even if you are defining them like this:
>>>
>>> db.mytable.myfield = Field.Method('myfield', ...)
>>>
>>> There are particular cases where leaving the name out can lead to 
>>> problems.
>>>
>>> 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: URL parsing in controller

2016-03-19 Thread Jeff Riley
DPS and all,

I have my routes.py set to the application (a).  As far as what is 
requestmaths(0), that is what is confusing.  That URL is generated by 
smartgrid.  Manage_customers is the controller, so customer should be the 
function but it is not. View is the function.  This is why I am having trouble 
understanding how to grab the customer id and the sheet id.

Thank you,
Jeff Riley

-- 
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: Couple of questions about improving performance in models

2016-03-19 Thread Lisandro
Oh I see! So I can define the virtual/method fields that way, and then it 
does make sense to keep using lazy_tables. Completely missed that point.

Thank you very much! 
As always, web2py's community rocks. 



El jueves, 17 de marzo de 2016, 14:59:35 (UTC-3), Anthony escribió:
>
> On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:
>>
>> Thank you very much for the quick answer.
>>
>> Your first comment made me think about the "lazy_tables" with the 
>> definition of virtual method fields.
>> If you say that doing db.tablename the table is no longer lazy, *then it 
>> wouldn't make sense to use lazy_tables in a particular case where almost 
>> each table has a virtual method field, am I right?*
>>
>> I mean, for example, if this is my model:
>>
>> db.define_table('first_table', Field('field1'), Field('field2'))
>>
>> db.first_table.field3 = Field.Method(lambda row: 'value for field3')
>>
>
> This won't help with db.auth_user, which is defined automatically (though 
> you can define it manually yourself if preferred), but you can simply do:
>
> db.define_table('first_table',
> Field('field1'),
> Field('field2'),
> Field.Method('Field3', lambda row: 'value for field3'))
>
> Note, the first argument of Field.Method() and Field.Virtual() should 
> always be the field name anyway, even if you are defining them like this:
>
> db.mytable.myfield = Field.Method('myfield', ...)
>
> There are particular cases where leaving the name out can lead to problems.
>
> 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: How do you use web2py app work with phonegap?

2016-03-19 Thread Leonel Câmara
> So inside the compressed zip folder you upload for phonegap app wrapping, 
you simply put the w2p file of your file inside the zipped folder.

What?! No! Of course not. web2py will reside and run on a regular webserver 
your phonegap application talks to it over the internet. You don't put 
web2py in the apk FFS.

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


[web2py] How can GAE write to the /databases file?? (I know it can't, but what's the workaround?)

2016-03-19 Thread webmaster
So I've got everything running fine locally on a fresh version of my app, 
load it up in dev_appserver.py and it looks fine.  Then I refresh, and now 
GAE can't find any *.table files in /databases.  Because there aren't any, 
since GAE doesn't write to the FS.  So how do I get around this?

-- 
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] is there an easy way to add member to the db.auth_membership?

2016-03-19 Thread Yibing Liu


I want to add member to the db.auth__membership. I have too many users in 
db.auth_user, so it's very hard to add a specified user to the membership. 
Could anyone help me? The following is the screenshot




-- 
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: sqlite database files corrupted?

2016-03-19 Thread Dave S
On Thursday, March 17, 2016 at 12:55:05 PM UTC-7, P Page-McCaw wrote:
>
> I have a pretty simple web2py application that inputs information about 
> academic seminars and then displays the seminar notices on our departmental 
> home page. It is called, creatively, SeminarCalendar. This is hosted by 
> pythonanywhere. It has all of 4 tables. 3 of which have 3 fields or fewer. 
> It gets very little traffic, a big day might be 1000 hits.
> [...] 
>
So I guess I have a bunch of related questions: 
> First, what is the best way to fix this! These tables are small and the 
> included data is not critical, but...
> Second, what on earth did I do to get tables from one app mixed in with 
> tables from another app? I'd like to avoid this in the future! (Very 
> embarrassing to have the Chair look at the page and ask what Error ticket 
> means!)
> Third, as a biologist, not a programmer, should I not be messing around 
> with web2py? If I've missed something really obvious, I think I should go 
> back to my test tubes. It was remarkable how 'easy' it was to set this app 
> up. And what an improvement it was over what the Universities equivalent 
> was.
>

 
For the first 2 questions, it will be helpful if you tell us what OS your 
web2py is running under, and if a network drive (or "share") is involved.

That said, I have never had the problem of files from one application 
interfering with another, but most of my "multiple application" servers are 
really only serving one application except for a few experimental accesses.

For the 3rd question, I'd say that web2py is a better environment for 
beginners than most environments are.  You should be able to manage both 
your test tubes and a simple site. The only way to be safer (in the "I'm 
not a programmer and don't play one on TV" sense) that I know of would be 
to do one of those sites the phone companies seem to be pushing, where you 
don't do much more than paste text and upload pictures.

/dps


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


Re: [web2py] Re: URL parsing in controller

2016-03-19 Thread Jeff Riley
DPS and all,

I have my routes.py set to the application (a).  As far as what is 
requestmaths(0), that is what is confusing.  That URL is generated by 
smartgrid.  Manage_customers is the controller, so customer should be the 
function but it is not. View is the function.  This is why I am having trouble 
understanding how to grab the customer id and the sheet id.

Thank you,
Jeff Riley

> On Mar 18, 2016, at 3:58 PM, Dave S  wrote:
> 
> 
> 
>> On Friday, March 18, 2016 at 1:18:23 PM UTC-7, webm...@trytha.com wrote:
>> Maybe something about "args=request.args(2,5)"?
> 
> He's trying to do a slice, but that would be [2:5], innit?
> 
>  
>> You could try to test this:
>> 
>> args=[request.args(2),request.args(5)]
> 
> shouldn't those '(' and ')' be '[' and ']'  (list indexes)?
> 
> Also, (Jeff) please verify which part of the URL is request.args[0] .  It 
> will be after the app/contoller/function code (and you're using routes.py to 
> set default for the c/f part?);
> I see "sheet" where I count 4, but it should be double-checked.
> 
> /dps
> 
>> 
>> 
>> 
>>> On Friday, March 18, 2016 at 1:01:51 PM UTC-7, Jeff Riley wrote:
>>> Hello All,
>>> 
>>> I am pulling my hair out.  I am trying to redirect the view button on a 
>>> smartgrid.  I can get the button to redirect to the view I want, but I 
>>> cannot parse the URL correctly to get the correct sheet id.
>>> 
>>> Here is my controller
>>> 
>>> @auth.requires_membership('manager')
>>> def manage_customers():
>>> if 'new' in request.args:
>>> if request.args(2) == 'customer':
>>> redirect(URL('new_customer'))
>>> elif request.args(4) == 'sheet':
>>> redirect(URL('new_sheet', args=request.args(2)))
>>> if 'edit' in request.args:
>>> if request.args(4) == 'sheet':
>>> redirect(URL('edit_sheet', args=request.args(2)))
>>> if 'view' in request.args:
>>> if request.args(4) == 'sheet':
>>> redirect(URL('view_sheet', args=request.args(2,5)))
>>> elif request.args(6) == 'sheet_archive':
>>> redirect(URL('view_sheet', args=request.args(7)))
>>> form = SQLFORM.smartgrid(db.customer, linked_tables=['address', 
>>> 'sheet', 'sheet_archive'],
>>>  searchable= dict(customer=True, address=False, 
>>> sheet=False),
>>>  editable= dict(customer=True, address=True, 
>>> sheet=True, sheet_archive=False),
>>>  deletable= dict(customer=True, address=True, 
>>> sheet=True, sheet_archive=False),
>>>  create=dict(customer=True, address=True, 
>>> sheet=True, sheet_archive=False),
>>>  paginate=20, maxtextlength=60, 
>>> fields=[db.customer.first_name,
>>>  db.customer.last_name, db.customer.phone, 
>>> db.customer.email, db.customer.handed,
>>>  db.address.address1, db.address.address2, 
>>> db.address.city, db.address.state_province,
>>>  db.address.postal_code, db.sheet.title, 
>>> db.sheet.created_by, db.sheet.created_on,
>>>  db.sheet_archive.id, db.sheet_archive.title, 
>>> db.sheet_archive.created_by,
>>>  db.sheet_archive.created_on],)
>>> return dict(form=form, request=request)
>>> 
>>> Here is my URL:
>>> http://127.0.0.1:8000/manage_customers/customer/sheet.customer_id/1/edit/sheet/2?_signature=3b4a45778f06aec42421ef503cba968cd633269a
>>> 
>>> 
>>> 
>>> I can only get the customer_id and not the sheet #2.  So I am always 
>>> displaying the first customer record and the first sheet record.  SO LOST.
>>> 
> 
> -- 
> 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/VW9k-9LIEAs/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] Functional programming in web2py...

2016-03-19 Thread António Ramos
Hello i´m a confused guy so bare with me..

I recently discovered elixir language and its so much different mainly
because its a functional programming style.

One of the things i like is the pipe operator.

See here info about it and a way to do it in ruby.

http://www.akitaonrails.com/2016/02/18/elixir-pipe-operator-for-ruby-chainable-methods

Do you find the concept useful or not?

i´d like to learn from your experience...


Regards
António

-- 
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: Couple of questions about improving performance in models

2016-03-19 Thread Lisandro
Anthony, thank you very much for your help.
I've successfully changed the definition of the callback trigger, like this:

db.define_table('mytable',
  Field('myfield'),
  on_define=lambda table: table._after_update.append(lambda s, r: myfunction
(s, r))
)



I'm tempted to ask one more thing that I'm wondering about:

In my model, I  have several tables (lets say about 8 or 9) that are used 
to store information about list of options. 
These tables only have a few records each, and they will never grow.

For example, one table could be "days" (I don't have this table 
specifically, it's for the example).
So, let's say the table "days" has a "name" field and a "plural_name" field.
The table is populated with data only once, at application startup, and 
remains the same forever: "days" table will only have 7 records, one for 
each day of the week.

Now, the part that I'm worried about is this: *inside the same model, I 
store each record in a variable*, like this:

db.define_table('days', Field('name'), Field('plural_name'))

MONDAY = db.days[1]
TUESDAY = db.days[2]
WEDNESDAY = db.days[3]
THURSDAY = db.days[4]
FRIDAY = db.days[5]
SATURDAY = db.days[6]
SUNDAY = db.days[7]

I use that to be able to reference each day from the app code, but I've 
realised that in this way, the "days" table won't be lazy, because it's 
called to get the record.

So my question is: *what would be the correct approach for storing that 
kind of records in variables, without compromising lazy tables?*

I've thouth of an answer myself, but I'm not sure. 
One possible approach would be to define Storage objects instead of 
pointing to the records. 
Because I already know the data of the days table, I can replace the 
previous code with this:

from gluon.tools import Storage

MONDAY = Storage()
MONDAY.id = 1
MONDAY.name = 'monday'
MONDAY.plural_name = 'mondays'


*Would it be better in terms of performance?*
Of course, I wouldn't have methods available at the row level, but I don't 
use them in this case.  



El jueves, 17 de marzo de 2016, 20:17:49 (UTC-3), Anthony escribió:
>
> See 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#on_define
> .
>
> On Thursday, March 17, 2016 at 6:13:35 PM UTC-4, Lisandro wrote:
>>
>> I will bother with one last related question: *what about callback 
>> triggers?*
>> I'm defining them like this:
>>
>> db.define_table('mytable', Field('field1'), Field('field2'))  # defines 
>> the table
>> from myglobals import myfunction  # imports global function
>> db.mytable._after_update.append(lambda s, r: myfunction(s, r))  # 
>> defines after update callback trigger
>>
>> In this case, I guess lazy_tables=True wouldn't make sense, because I'm 
>> calling db.mytable so it triggers the definition of the table.
>>
>> Is there a way of specifying callback triggers directly when calling 
>> define_table?
>>
>>
>>
>>
>> El jueves, 17 de marzo de 2016, 15:27:22 (UTC-3), Lisandro escribió:
>>>
>>> Oh I see! So I can define the virtual/method fields that way, and then 
>>> it does make sense to keep using lazy_tables. Completely missed that point.
>>>
>>> Thank you very much! 
>>> As always, web2py's community rocks. 
>>>
>>>
>>>
>>> El jueves, 17 de marzo de 2016, 14:59:35 (UTC-3), Anthony escribió:

 On Thursday, March 17, 2016 at 1:53:43 PM UTC-4, Lisandro wrote:
>
> Thank you very much for the quick answer.
>
> Your first comment made me think about the "lazy_tables" with the 
> definition of virtual method fields.
> If you say that doing db.tablename the table is no longer lazy, *then 
> it wouldn't make sense to use lazy_tables in a particular case where 
> almost 
> each table has a virtual method field, am I right?*
>
> I mean, for example, if this is my model:
>
> db.define_table('first_table', Field('field1'), Field('field2'))
>
> db.first_table.field3 = Field.Method(lambda row: 'value for field3')
>

 This won't help with db.auth_user, which is defined automatically 
 (though you can define it manually yourself if preferred), but you can 
 simply do:

 db.define_table('first_table',
 Field('field1'),
 Field('field2'),
 Field.Method('Field3', lambda row: 'value for field3'))

 Note, the first argument of Field.Method() and Field.Virtual() should 
 always be the field name anyway, even if you are defining them like this:

 db.mytable.myfield = Field.Method('myfield', ...)

 There are particular cases where leaving the name out can lead to 
 problems.

 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 

[web2py] Re: modal not work when upload form field have the data

2016-03-19 Thread Leonel Câmara
Stifan you didn't try my solution. My solution doesn't use the LOAD helper, 
you need to  invoke it using javascript.

-- 
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: URL parsing in controller

2016-03-19 Thread Anthony
Rather than intercept the built-in view/edit links (which results in an 
unnecessary request due to the redirect), you might also consider removing 
them and instead use the "links" argument to create your own links/buttons 
for those functions.

Anthony

On Friday, March 18, 2016 at 4:01:51 PM UTC-4, Jeff Riley wrote:
>
> Hello All,
>
> I am pulling my hair out.  I am trying to redirect the view button on a 
> smartgrid.  I can get the button to redirect to the view I want, but I 
> cannot parse the URL correctly to get the correct sheet id.
>
> Here is my controller
>
> @auth.requires_membership('manager')
> def manage_customers():
> if 'new' in request.args:
> if request.args(2) == 'customer':
> redirect(URL('new_customer'))
> elif request.args(4) == 'sheet':
> redirect(URL('new_sheet', args=request.args(2)))
> if 'edit' in request.args:
> if request.args(4) == 'sheet':
> redirect(URL('edit_sheet', args=request.args(2)))
> if 'view' in request.args:
> if request.args(4) == 'sheet':
> redirect(URL('view_sheet', args=request.args(2,5)))
> elif request.args(6) == 'sheet_archive':
> redirect(URL('view_sheet', args=request.args(7)))
> form = SQLFORM.smartgrid(db.customer, linked_tables=['address', 
> 'sheet', 'sheet_archive'],
>  searchable= dict(customer=True, 
> address=False, sheet=False),
>  editable= dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  deletable= dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  create=dict(customer=True, address=True, 
> sheet=True, sheet_archive=False),
>  paginate=20, maxtextlength=60, 
> fields=[db.customer.first_name,
>  db.customer.last_name, db.customer.phone, 
> db.customer.email, db.customer.handed,
>  db.address.address1, db.address.address2, 
> db.address.city, db.address.state_province,
>  db.address.postal_code, db.sheet.title, 
> db.sheet.created_by, db.sheet.created_on,
>  db.sheet_archive.id, db.sheet_archive.title, 
> db.sheet_archive.created_by,
>  db.sheet_archive.created_on],)
> return dict(form=form, request=request)
>
> Here is my URL:
>
>
> http://127.0.0.1:8000/manage_customers/customer/sheet.customer_id/1/edit/sheet/2?_signature=3b4a45778f06aec42421ef503cba968cd633269a
>
>
> I can only get the customer_id and not the sheet #2.  So I am always 
> displaying the first customer record and the first sheet record.  SO LOST.
>
>

-- 
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: Big Bug: Cloud SQL completely broken? Steps and solution.

2016-03-19 Thread Massimo Di Pierro
I will get to the bottom of this tomorrow. It is a promise.

On Friday, 18 March 2016 17:42:34 UTC-5, webmas...@trytha.com wrote:
>
> 2.12.2 is definitely not broken, since that's what I've been using live on 
> GAE for about six months.  (www.trytha.com)
>
> I did the precise steps I outline above while I was preparing the post. 
>  Not much to it, and it started working again as soon as I replaced the new 
> /pydal with the old.  I've been beating my head against this for two days. 
>  I thought it was just a problem I was having deploying locally since I had 
> gotten things working on GAE last year (I had skipped a *local* GAE 
> deployment at that time).  This morning I decided to just try my known, 
> server-side-working app (2.12.2) locally and it worked with no issues. 
>  That's when I started swapping out directories until I found the offender 
> was /pydal.  I also tested 2.12.3 and it does *NOT* work.
>
> I would really love to be using the latest version.  Hopefully if it's a 
> mistake on my end, you might have some insight into where I've stepped off 
> the path.
>
> On Friday, March 18, 2016 at 3:28:15 PM UTC-7, Massimo Di Pierro wrote:
>>
>> gae on 2.12.2 was broken. It is no broken in current stable and trunk.
>>
>> On Friday, 18 March 2016 15:55:21 UTC-5, webm...@trytha.com wrote:
>>>
>>> Steps to replicate (3 mins):
>>>
>>>
>>>1. Load Web2py from source off website.  Copy gaehandler.py and 
>>>app.yaml to /web2py.  
>>>2. In applications/welcome/models/db.py, change the DAL connection 
>>>to "db = DAL('google:sql://[$project]:[$instance]/[$database]')"
>>>3. python dev_appserver.py --host=0.0.0.0 --mysql_host=localhost 
>>>--mysql_port=3306 --mysql_user=root --mysql_password= 
>>>/home/www-data/web2py
>>>4. Load, then refresh the Welcome app and it crashes because it 
>>>thinks it can't access the /databases folder.
>>>
>>> Solution (1 min):
>>>
>>>1. Delete /gluon/packages/dal/pydal
>>>2. Replace with /gluon/packages/dal/pydal from version 2.12.2 of 
>>>web2py.  (http://web2py.com/examples/static/2.12.2/web2py_src.zip)
>>>
>>> Am I doing something really crazy?  How has nobody run across this in 
>>> the six months it's been broken?  Seems like kind of a massive bug.
>>>
>>

-- 
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: Adding a new table to web2py with a reference field to an established table and getting error

2016-03-19 Thread Heather Dawe
The two tables I am defining are as follows

db.define_table('Series',
   Field('name'),
   Field('SeriesBy', 'reference DataItem'),
   format='%(name)s')

db.define_table('SeriesReportInstanceIndicatorInstance',
   Field('Series', 'reference Series'),
   Field('ReportInstanceIndicatorInstance' 'reference 
ReportInstanceIndicatorInstance'),
   Field('this_series_name'))

The Series table gets defined fine. The error I get is the following

 Field: invalid field name: 
ReportInstanceIndicatorInstancereference ReportInstanceIndicatorInstance, 
use rname for "funny" names

when I attempt to reference the already established 
ReportInstanceIndicatorInstance table below

db.define_table('ReportInstanceIndicatorInstance',
   Field('ReportInstance', 'reference ReportInstance'),
   Field('IndicatorInstance', 'reference IndicatorInstance'), 
   Field('GroupBy', 'reference DataItem'),
   Field('GroupBy2', 'reference DataItem'),
   Field('title'),
   Field('x_axis_label'),
   Field('y_axis_label'),
   Field('report_data_id'),
   format= '%(title)s')



On Thursday, 17 March 2016 14:30:36 UTC, Anthony wrote:
>
> According to the error, your field name is "field1reference table1", so 
> you probably have an error in the field definition. Please show your model 
> code.
>
> Anthony
>
> On Thursday, March 17, 2016 at 8:28:00 AM UTC-4, Heather Dawe wrote:
>>
>> Hi there,
>>
>> I have had this error in a couple of scenarios now. I have an established 
>> and working web2py app and I wish to add a couple of tables to the model. A 
>> number of fields in these new tables reference fields in established 
>> tables. I get this error when trying to create the new tables
>>
>>  Field: invalid field name: 
>> field1reference table1, use rname for "funny" names
>>
>> where 'field1' is the name of a field in the new table I am trying to 
>> create that references table1 (the id field in table1). Given that all I am 
>> trying to do is add a new table to my model which has a field that 
>> references an existing table I don't see why this is a problem? I have 
>> looked into it and searched for the error etc. I have tried to fix it by 
>> changing to migrate='false' and fake_migrate='true' etc. but this has not 
>> solved it. Can anyone please advise why I am getting this error and how to 
>> sort it out?
>>
>> Many thanks,
>> Heather
>>
>

-- 
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: XML object

2016-03-19 Thread Anthony
Are you inserting it in the view somehow:

{{=XML(...)}}

If so, what are you seeing in the final rendered HTML?

Anthony

On Wednesday, March 16, 2016 at 3:12:04 PM UTC-4, Jerry Liu wrote:
>
>
> Hi, all
>
> I want to use XML object to stop html from being escaped. But the object  
> seems 
> not working on iframe tag.
>
> I override it like this:
>
> XML(text, sanitize=True,
> permitted_tags=['iframe', ...],
> allowed_attributes={'iframe':[...]})
>
>

-- 
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: Couple of questions about improving performance in models

2016-03-19 Thread Lisandro
Thank you very much for the quick answer.

Your first comment made me think about the "lazy_tables" with the 
definition of virtual method fields.
If you say that doing db.tablename the table is no longer lazy, *then it 
wouldn't make sense to use lazy_tables in a particular case where almost 
each table has a virtual method field, am I right?*

I mean, for example, if this is my model:

db.define_table('first_table', Field('field1'), Field('field2'))

db.first_table.field3 = Field.Method(lambda row: 'value for field3')


db.define_table('second_table', Field('field1'), Field('field2'))

db.second_table.field3 = Field.Method(lambda row: 'value for field3')


...then it would make no sense to use lazy_tables=True, because anyway I'm 
calling both tables in the model, right?

If this is the case, is there any alternative to this?

I'm thinking to define a function in a module, the function would take the 
row as an argument and return the value. 
However, it wouldn't be possible to call the function in the "row.method" 
way, but if it improves performance, I will do it that way.

I would appreciate any comment or advise on this, if any.
Thanks again!





El jueves, 17 de marzo de 2016, 14:42:48 (UTC-3), Anthony escribió:
>
> On Thursday, March 17, 2016 at 1:08:49 PM UTC-4, Lisandro wrote:
>>
>> Straight to the point:
>> I'm using *lazy_tables=True* and *migrate=False*
>>
>>
>> *In my model, I have several Method Fields.*
>> Some of them use a function that is declared inside the same model, like 
>> this:
>>
>> db.auth_user.give_me_data = Field.Method(lambda row: _give_me_data(row.
>> auth_user))
>>
>> def _give_me_data(user):
>> # calculation and obtention of data
>> # return data
>>
>> So first question: *should I move declaration of _give_me_data function 
>> to a module?* 
>> Or is it the same because I would have to import it anyway in the model?
>> *Just to remind, I'm using lazy_tables=False, so maybe the code isn't 
>> really executed until the table is called. I'm not sure about this.*
>>
>
> Note, as soon as you do db.auth_user, the table is no longer lazy. Maybe 
> not a big deal for this one table.
>
> Probably doesn't matter much where you define the function, though I 
> suppose there could be a slight performance benefit to putting it in a 
> module (where it will only be defined once instead of on every request).
>  
>
>> *Usage of Storage class objects*
>> In my models, I create some Storage objects, because it's really useful 
>> for setting and retrieving data from those objects. I use them like this:
>>
>> from gluon.tools import Storage
>>
>> CONFIG = Storage()
>> CONFIG.variable1 = 'value-variable-1'
>> CONFIG.variable2 = 'value-variable-2'
>>
>> I don't put much data inside them, just config variables.
>> However, my question is: *should I use other data type to storage those 
>> variables?* Or it won't make any difference?
>>
>
> Again, probably not a big deal, but you could move that to a module, or 
> maybe use AppConfig (which caches the configuration data after the initial 
> setup).
>
> 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] response.render not using the right view

2016-03-19 Thread Jacob Thoennes
I'm using the ajax strategy suggested by mdipierro here
https://groups.google.com/d/msg/web2py/5rIQhH-RD28/Rp54nhJ1j28J

My code looks like this:

In default.py:

def update_stackItems():
stackID = request.args[0]
stack = session.stack_dict[int(stackID[5:])]
return 
response.render(URL('default','update_stackItems.html'),{'stack':stack})

The only relevant line is the return. When this gets sent back to the page 
it renders with the generic view for a dict (so it just shows the contents 
of stack, which at least tells me that that is working), but I want it to 
use update_stackItems.html. It happens no matter how simple I make my view, 
so I know it's not an error inside the view. I've checked that the URL is 
the correct URL for the view I want, why isn't response.render using it?

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


[web2py] Re: Adding a new table to web2py with a reference field to an established table and getting error

2016-03-19 Thread Heather Dawe
Hi Anthony,

Many thanks for this. A complete noobie error - sorry to waste your time 
but I really appreciate your help. It was the error message that threw me!

Best wishes,
Heather

On Thursday, 17 March 2016 15:55:17 UTC, Anthony wrote:
>
> You are missing a comma:
>
> Field('ReportInstanceIndicatorInstance', 'reference 
> ReportInstanceIndicatorInstance')
>
> Python concatenates adjacent string literals delimited by whitespace, so 
> without the comma, Python interprets:
>
> 'ReportInstanceIndicatorInstance' 'reference 
> ReportInstanceIndicatorInstance'
>
> as:
>
> 'ReportInstanceIndicatorInstancereference ReportInstanceIndicatorInstance'
>
> So, it appears you are trying to include a space in the field name rather 
> than specify the field as a reference field.
>
> Anthony
>
> On Thursday, March 17, 2016 at 10:58:43 AM UTC-4, Heather Dawe wrote:
>>
>> The two tables I am defining are as follows
>>
>> db.define_table('Series',
>>Field('name'),
>>Field('SeriesBy', 'reference DataItem'),
>>format='%(name)s')
>>
>> db.define_table('SeriesReportInstanceIndicatorInstance',
>>Field('Series', 'reference Series'),
>>Field('ReportInstanceIndicatorInstance' 'reference 
>> ReportInstanceIndicatorInstance'),
>>Field('this_series_name'))
>>
>> The Series table gets defined fine. The error I get is the following
>>
>>  Field: invalid field name: 
>> ReportInstanceIndicatorInstancereference ReportInstanceIndicatorInstance, 
>> use rname for "funny" names
>>
>> when I attempt to reference the already established 
>> ReportInstanceIndicatorInstance table below
>>
>> db.define_table('ReportInstanceIndicatorInstance',
>>Field('ReportInstance', 'reference ReportInstance'),
>>Field('IndicatorInstance', 'reference IndicatorInstance'), 
>>Field('GroupBy', 'reference DataItem'),
>>Field('GroupBy2', 'reference DataItem'),
>>Field('title'),
>>Field('x_axis_label'),
>>Field('y_axis_label'),
>>Field('report_data_id'),
>>format= '%(title)s')
>>
>>
>>
>> On Thursday, 17 March 2016 14:30:36 UTC, Anthony wrote:
>>>
>>> According to the error, your field name is "field1reference table1", so 
>>> you probably have an error in the field definition. Please show your model 
>>> code.
>>>
>>> Anthony
>>>
>>> On Thursday, March 17, 2016 at 8:28:00 AM UTC-4, Heather Dawe wrote:

 Hi there,

 I have had this error in a couple of scenarios now. I have an 
 established and working web2py app and I wish to add a couple of tables to 
 the model. A number of fields in these new tables reference fields in 
 established tables. I get this error when trying to create the new tables

  Field: invalid field name: 
 field1reference table1, use rname for "funny" names

 where 'field1' is the name of a field in the new table I am trying to 
 create that references table1 (the id field in table1). Given that all I 
 am 
 trying to do is add a new table to my model which has a field that 
 references an existing table I don't see why this is a problem? I have 
 looked into it and searched for the error etc. I have tried to fix it by 
 changing to migrate='false' and fake_migrate='true' etc. but this has not 
 solved it. Can anyone please advise why I am getting this error and how to 
 sort it out?

 Many thanks,
 Heather

>>>

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