[web2py] Re: menu.append() more than one argument

2012-06-20 Thread Niphlod
did you know about extend ?

>>> mylist = []
>>> mylist.append(1)
>>> mylist
[1]
>>> mylist.append(2,3)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: append() takes exactly one argument (2 given)
>>> mylist.extend(2,3)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: extend() takes exactly one argument (2 given)
>>> mylist.extend([2,3])
>>> mylist
[1, 2, 3]




On Wednesday, June 20, 2012 8:03:41 AM UTC+2, Annet wrote:
>
> In a controller I have the following menu:
>
> response.site_submenu = []
> if session.vcardsettings:
> response.site_submenu.append(
> ['Logo',request.function=='uploadLogo',URL('uploadLogo')],
> ['Tagline',request.function=='tagline',URL('tagline')],
> ['Note',request.function=='note',URL('note')])
> elif session.sitesettings:
> ...
>
> response.site_submenu.append(['Custom_theme',request.function=='customTheme',URL('customTheme')])
>
> This results in an error because .append() takes one argument not three. 
> Appending each menu item in a separate .append() solves the problem, but I 
> wonder whether there is another way to solve it>
>
> Kind regards,
>
> Annet
>


Re: [web2py] helps for the biginer on web2py

2012-06-20 Thread song
Thanks a lot.
I don't know the css, HTML5 and  lack of web languages and tools makes me 
hard to understand.
Today  I met the programmer and from him I took some  advices.
But for him it is very easy and ..

Thanks ... Anthony and marco mansilla...

Now, I am a starter in web2py after a few days.




2012년 6월 20일 수요일 오전 8시 37분 55초 UTC+9, marco mansilla 님의 말:
>
> the book [1] should be enough, very explicit and easy to understand, 
> plus this list is very helpfull too... 
>
> [1] http://www.web2py.com/book 
>
> > I start to study the web2py system. I understand the models and a 
> > little controllers. 
> > But now it is very difficult for me to understand the complex views 
> > technologies. 
> > Are there more simple and concise ppt or pdf files? 
>


Re: [web2py] Re: Upload the more than 100 MB file

2012-06-20 Thread Sanjeet Roy
Hi Massimo,

I am going to make a web application in which, requires to upload more than 
100 Mb file at a time, please give us the details in web2py is it possible ?

On Sunday, June 17, 2012 4:58:11 AM UTC+5:30, Massimo Di Pierro wrote:
>
> web2py does not load the uploaded file in Ram (unless the the is uploaded 
> to db). The error reported Sanjeet is in fact different. It runs out of 
> memory trying to serialize a helper, after the file has been uploaded 
> completely.
>
> Massimo
>
> On Saturday, 16 June 2012 17:22:14 UTC-5, Khalil KHAMLICHI wrote:
>>
>> A few weeks ago, I had similar problem with uploading big files (starting 
>> from 100Mb), I could never figure out what was the reason ... I could just 
>> understand that web2py loaded the files into memory (for some reason) and 
>> that caused the whole process to crash, that was my analysis but maybe it 
>> was biased by the fact that the server was a virtual machine with I think 
>> 1gig of Ram.
>> Anyway I confirm the existence of a problem with uploads larger than 
>> 100Mb.
>>
>>
>> On Sat, Jun 16, 2012 at 10:45 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> The error you get is not in uploading the file but in trying to display 
>>> something very large. I suspect there is something in your model that is 
>>> causing the problem. Can we see your model?
>>>
>>>
>>>
>>> On Saturday, 16 June 2012 00:15:35 UTC-5, Sanjeet Roy wrote:

 Can i upload the more than 100 mb file using web2py when i tried got 
 the error:-


 Traceback (most recent call last):
   File "/home/tls-sanjeet/Desktop/**web2py/gluon/restricted.py", line 205, 
 in restricted


 exec ccode in environment
   File 
 "/home/tls-sanjeet/Desktop/**web2py/applications/upload_**test/views/appadmin.html"
  
 ,
  line 56, in 


 {{if rows:}}
   File "/home/tls-sanjeet/Desktop/**web2py/gluon/globals.py", line 182, in 
 write


 self.body.write(xmlescape(data**))


   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 114, in 
 xmlescape


 return data.xml()


   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 848, in xml


 (fa, co) = self._xml()


   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 839, in 
 _xml


 self.components])

 MemoryError



>>

Re: [web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-20 Thread Alec Taylor
Okay, finally got around to testing it.

Not getting any pipes.

The right of my navbar is one long string all of the same colour:
"Welcome  Logout"


[web2py] Re: web2py as standalone desktop application

2012-06-20 Thread glomde
I can do it without DB.

But I still have the other issues to solve to make it standalone 
application.
* I do not want login/logout
* User should start standalone exuctable.
  + It should not ask for admin password
  + Server should close when app is not opened anymore

/T


Den onsdagen den 20:e juni 2012 kl. 03:52:14 UTC+2 skrev Massimo Di Pierro:
>
> You cannot store db in session but I do not see why you need a db at all 
> if, in principle, you do not want rersistence.
>
> On Tuesday, 19 June 2012 11:15:12 UTC-5, glomde wrote:
>>
>> I do not really want authetication. The app will be accessed locally but 
>> on network drive.
>> I want to do it as simple as possible for the user.
>>
>> So the user just runs a command from terminal and the app opens i firefox.
>> When he closes the app this will close the app.
>>
>> But can you store a sqlite db in sthe session?
>>
>>
>>
>> Den tisdagen den 19:e juni 2012 kl. 17:51:47 UTC+2 skrev Massimo Di 
>> Pierro:
>>>
>>> If the app is not the network you need authentication. In this case 
>>> youneed a shared persistant databases.
>>>
>>> Why not store everything else in session and do a session cleanup on 
>>> login and logout.
>>>
>>> massimo
>>>
>>>
>>>
>>>
>>> On Tuesday, 19 June 2012 10:04:08 UTC-5, glomde wrote:

 In my case I would like all my data to be lost when the app is closed. 
 But
 I assume one could think that the user saves the data as well.

 The app is not very complicated, but I want to have a GUI interface.
 What the app should do is to read a file that the user chooses.
 This will the generate a DB. From the DB the user can generate 
 reports that are possible to browse and to filter on different values.

 I would like to use web2py instead of a GUI application for several 
 reasons.
 Main reason is to only depend on python. Most python gui bindings you 
 need
 to have the some gui backend installed.

 There will not be concurrent users. But the app will be on the network 
 and
 several user can start the app at the same time.

 I also assume that some user would like to open several files. That is 
 to
 have more that one session open.  But in general I just want the user 
 to open
 the app and easily close it. That is not to explicitly have to shut 
 down the server.


 Den tisdagen den 19:e juni 2012 kl. 16:22:35 UTC+2 skrev Massimo Di 
 Pierro:
>
> Are you saying all your data should be lost when the app is "closed"?
> Can you tell us more about the use case?
> Are you going to have concurrent users at all? Should they share any 
> data?
> Do they need access to admin at all or just appadmin?
>
>
>
>
>
> On Tuesday, 19 June 2012 04:58:24 UTC-5, glomde wrote:
>>
>> Hi,
>>
>> I was thinking of using web2py as standalone desktop application.
>> After some tinkering I realized I needed to resolve some things.
>>
>> What I want
>> * Application should be completely standalone. Each start of 
>> application should have its own DB.
>> * When user starts app, browser should open with the app, without 
>> asking about admin password.
>> * App/Server should shut down when no pages of app is open.
>>
>> So I thought to create a init app as descripted by 
>>
>> http://web2py.com/books/default/chapter/29/14#How-to-distribute-your-applications-as-binaries
>>
>> This solves some parts but I have some more things that need to be 
>> fixed:
>>
>> * How to make so that app starts without asking for admin password.
>> * How to start app on unique port that is not used.
>> * How to have seperate DB for each instance. I thought of using 
>> sqlite in memory to make the instances independent of each other. Would 
>> this work?
>> * I would like a instance to quit when not used anymore. I thought it 
>> would be possible if each page with ajax
>>   requires updates. If no updates asked for X minutes, I would now 
>> that there are no pages open and the server could
>>   shut down. How to implement this?
>>
>>
>> BR,
>>
>> Toni
>>
>>
>>
>>
>>  
>
>

Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-20 Thread Michele Comitini
Alec,

Thanks to you!
You have found a bug either in the book or in the authentication code. 
 web2py changed behavior.
I have to check if a compatibility breach happened somewhere or if that 
code was using some undocumented feature.

mic


Il giorno mercoledì 20 giugno 2012 02:33:36 UTC+2, Alec Taylor ha scritto:
>
> On Wed, Jun 20, 2012 at 7:49 AM, Michele Comitini 
>  wrote: 
> > You don't return a dictionary with the registration_id key in the 
> > get_user() method. 
> > 
> > change the code as follows: 
> > 
> >  return dict(first_name = user['first_name'], last_name = 
> > user['last_name'], username = user['id'], registration_id = 
> > user['id']) 
> > 
> > This is stated in the web2py book as required parameter when using 
> > third party authentication. 
> > 
> > mic 
>
> Thanks, that worked. 
>
> I guess I was reading the wrong book... I got the previous snippet 
> from the "web2py Application Development Cookbook". 
>
> > 2012/6/16 Alec Taylor
> >> Unfortunately I haven't been able to get Facebook login with OAuth2 
> working. 
> >> 
> >> I've created a tiny test-case below with the problem. 
> >> 
> >> The only major changes I have made is to models/db.py with a minor 
> >> function (foobar) in controllers/default.py. 
> >> 
> >> https://gist.github.com/9967cb95fe026890dae7 
> >> 
> >> I have placed the facebook.py file in the modules folder and the 
> >> CLIENT_ID and CLIENT_SECRET in another .py file in my modules 
> >> directory [file starts with `from gluon import *`]. 
> >> 
> >> Please tell me how I can get this to work. 
> >> 
> >> Thanks for all suggestions, 
> >> 
> >> Alec Taylor 
> >> 
> >> FYI: Not showing a ticket because it actually is stuck in an infinite 
> >> loop. However when I take out the `@auth.requires_login()` decorator 
> >> before the `foobar` function the page loads, but "Login" still appears 
> >> in the top-right. 
>


Re: [web2py] Re: Upload the more than 100 MB file

2012-06-20 Thread Massimo Di Pierro
web2py was tested with up to 2G upload and download. It always worked for 
me. Some users have experience some problem using rocket we have been 
investigating. Wort case scenario you can use a different web server.

Moreover the upload is definitively not stored in Ram (unless your app 
does).

On Wednesday, 20 June 2012 04:57:39 UTC-5, Sanjeet Roy wrote:
>
> Hi Massimo,
>
> I am going to make a web application in which, requires to upload more 
> than 100 Mb file at a time, please give us the details in web2py is it 
> possible ?
>
> On Sunday, June 17, 2012 4:58:11 AM UTC+5:30, Massimo Di Pierro wrote:
>>
>> web2py does not load the uploaded file in Ram (unless the the is uploaded 
>> to db). The error reported Sanjeet is in fact different. It runs out of 
>> memory trying to serialize a helper, after the file has been uploaded 
>> completely.
>>
>> Massimo
>>
>> On Saturday, 16 June 2012 17:22:14 UTC-5, Khalil KHAMLICHI wrote:
>>>
>>> A few weeks ago, I had similar problem with uploading big files 
>>> (starting from 100Mb), I could never figure out what was the reason ... I 
>>> could just understand that web2py loaded the files into memory (for some 
>>> reason) and that caused the whole process to crash, that was my analysis 
>>> but maybe it was biased by the fact that the server was a virtual machine 
>>> with I think 1gig of Ram.
>>> Anyway I confirm the existence of a problem with uploads larger than 
>>> 100Mb.
>>>
>>>
>>> On Sat, Jun 16, 2012 at 10:45 PM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 The error you get is not in uploading the file but in trying to display 
 something very large. I suspect there is something in your model that is 
 causing the problem. Can we see your model?



 On Saturday, 16 June 2012 00:15:35 UTC-5, Sanjeet Roy wrote:
>
> Can i upload the more than 100 mb file using web2py when i tried got 
> the error:-
>
>
> Traceback (most recent call last):
>   File "/home/tls-sanjeet/Desktop/**web2py/gluon/restricted.py", line 
> 205, in restricted
>
>
> exec ccode in environment
>   File 
> "/home/tls-sanjeet/Desktop/**web2py/applications/upload_**test/views/appadmin.html"
>  
> ,
>  line 56, in 
>
>
> {{if rows:}}
>   File "/home/tls-sanjeet/Desktop/**web2py/gluon/globals.py", line 182, 
> in write
>
>
> self.body.write(xmlescape(data**))
>
>
>   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 114, in 
> xmlescape
>
>
> return data.xml()
>
>
>   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 848, in 
> xml
>
>
> (fa, co) = self._xml()
>
>
>   File "/home/tls-sanjeet/Desktop/**web2py/gluon/html.py", line 839, in 
> _xml
>
>
> self.components])
>
> MemoryError
>
>
>
>>>

Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-20 Thread Alec Taylor
Glad I could be of help... I'll be following the book pretty closely
so be sure to check your email [or the github issues queue] for
further errata :P

On Wed, Jun 20, 2012 at 10:02 PM, Michele Comitini
 wrote:
> Alec,
>
> Thanks to you!
> You have found a bug either in the book or in the authentication code.
>  web2py changed behavior.
> I have to check if a compatibility breach happened somewhere or if that code
> was using some undocumented feature.
>
> mic
>
>
> Il giorno mercoledì 20 giugno 2012 02:33:36 UTC+2, Alec Taylor ha scritto:
>>
>> On Wed, Jun 20, 2012 at 7:49 AM, Michele Comitini
>>  wrote:
>> > You don't return a dictionary with the registration_id key in the
>> > get_user() method.
>> >
>> > change the code as follows:
>> >
>> >  return dict(first_name = user['first_name'], last_name =
>> > user['last_name'], username = user['id'], registration_id =
>> > user['id'])
>> >
>> > This is stated in the web2py book as required parameter when using
>> > third party authentication.
>> >
>> > mic
>>
>> Thanks, that worked.
>>
>> I guess I was reading the wrong book... I got the previous snippet
>> from the "web2py Application Development Cookbook".
>>
>> > 2012/6/16 Alec Taylor
>> >> Unfortunately I haven't been able to get Facebook login with OAuth2
>> >> working.
>> >>
>> >> I've created a tiny test-case below with the problem.
>> >>
>> >> The only major changes I have made is to models/db.py with a minor
>> >> function (foobar) in controllers/default.py.
>> >>
>> >> https://gist.github.com/9967cb95fe026890dae7
>> >>
>> >> I have placed the facebook.py file in the modules folder and the
>> >> CLIENT_ID and CLIENT_SECRET in another .py file in my modules
>> >> directory [file starts with `from gluon import *`].
>> >>
>> >> Please tell me how I can get this to work.
>> >>
>> >> Thanks for all suggestions,
>> >>
>> >> Alec Taylor
>> >>
>> >> FYI: Not showing a ticket because it actually is stuck in an infinite
>> >> loop. However when I take out the `@auth.requires_login()` decorator
>> >> before the `foobar` function the page loads, but "Login" still appears
>> >> in the top-right.


[web2py] Re: web2py as standalone desktop application

2012-06-20 Thread Massimo Di Pierro


On Wednesday, 20 June 2012 06:56:43 UTC-5, glomde wrote:
>
> I can do it without DB.
>
> But I still have the other issues to solve to make it standalone 
> application. 

* I do not want login/logout
>

comment anything with auth
 

> * User should start standalone exuctable.
>

unzip the windows binary, install your app, zip again.
 

>   + It should not ask for admin password
>

look into applications/admin/models/access.py (delete the file or comment 
lines as required)
 

>   + Server should close when app is not opened anymore
>

Defined not "not open anymore". there is no way to detect the user has 
closed the page in the browser unless you user html5 web sockets 
(web2py/gluon/contrib/comet_messaging.py). The latter solution is a complex 
one. Perhaps you should have a button [close] and the corresponding action 
would call sys.exit().
 

>
> /T
>
>
> Den onsdagen den 20:e juni 2012 kl. 03:52:14 UTC+2 skrev Massimo Di Pierro:
>>
>> You cannot store db in session but I do not see why you need a db at all 
>> if, in principle, you do not want rersistence.
>>
>> On Tuesday, 19 June 2012 11:15:12 UTC-5, glomde wrote:
>>>
>>> I do not really want authetication. The app will be accessed locally but 
>>> on network drive.
>>> I want to do it as simple as possible for the user.
>>>
>>> So the user just runs a command from terminal and the app opens i 
>>> firefox.
>>> When he closes the app this will close the app.
>>>
>>> But can you store a sqlite db in sthe session?
>>>
>>>
>>>
>>> Den tisdagen den 19:e juni 2012 kl. 17:51:47 UTC+2 skrev Massimo Di 
>>> Pierro:

 If the app is not the network you need authentication. In this case 
 youneed a shared persistant databases.

 Why not store everything else in session and do a session cleanup on 
 login and logout.

 massimo




 On Tuesday, 19 June 2012 10:04:08 UTC-5, glomde wrote:
>
> In my case I would like all my data to be lost when the app is closed. 
> But
> I assume one could think that the user saves the data as well.
>
> The app is not very complicated, but I want to have a GUI interface.
> What the app should do is to read a file that the user chooses.
> This will the generate a DB. From the DB the user can generate 
> reports that are possible to browse and to filter on different values.
>
> I would like to use web2py instead of a GUI application for several 
> reasons.
> Main reason is to only depend on python. Most python gui bindings you 
> need
> to have the some gui backend installed.
>
> There will not be concurrent users. But the app will be on the network 
> and
> several user can start the app at the same time.
>
> I also assume that some user would like to open several files. That is 
> to
> have more that one session open.  But in general I just want the user 
> to open
> the app and easily close it. That is not to explicitly have to shut 
> down the server.
>
>
> Den tisdagen den 19:e juni 2012 kl. 16:22:35 UTC+2 skrev Massimo Di 
> Pierro:
>>
>> Are you saying all your data should be lost when the app is "closed"?
>> Can you tell us more about the use case?
>> Are you going to have concurrent users at all? Should they share any 
>> data?
>> Do they need access to admin at all or just appadmin?
>>
>>
>>
>>
>>
>> On Tuesday, 19 June 2012 04:58:24 UTC-5, glomde wrote:
>>>
>>> Hi,
>>>
>>> I was thinking of using web2py as standalone desktop application.
>>> After some tinkering I realized I needed to resolve some things.
>>>
>>> What I want
>>> * Application should be completely standalone. Each start of 
>>> application should have its own DB.
>>> * When user starts app, browser should open with the app, without 
>>> asking about admin password.
>>> * App/Server should shut down when no pages of app is open.
>>>
>>> So I thought to create a init app as descripted by 
>>>
>>> http://web2py.com/books/default/chapter/29/14#How-to-distribute-your-applications-as-binaries
>>>
>>> This solves some parts but I have some more things that need to be 
>>> fixed:
>>>
>>> * How to make so that app starts without asking for admin password.
>>> * How to start app on unique port that is not used.
>>> * How to have seperate DB for each instance. I thought of using 
>>> sqlite in memory to make the instances independent of each other. Would 
>>> this work?
>>> * I would like a instance to quit when not used anymore. I thought 
>>> it would be possible if each page with ajax
>>>   requires updates. If no updates asked for X minutes, I would now 
>>> that there are no pages open and the server could
>>>   shut down. How to implement this?
>>>
>>>
>>> BR,
>>>
>>> Toni
>>>
>>>
>>>
>>>
>

Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-20 Thread Massimo Di Pierro
Can you please open a ticket?

On Wednesday, 20 June 2012 07:02:28 UTC-5, Michele Comitini wrote:
>
> Alec,
>
> Thanks to you!
> You have found a bug either in the book or in the authentication code. 
>  web2py changed behavior.
> I have to check if a compatibility breach happened somewhere or if that 
> code was using some undocumented feature.
>
> mic
>
>
> Il giorno mercoledì 20 giugno 2012 02:33:36 UTC+2, Alec Taylor ha scritto:
>>
>> On Wed, Jun 20, 2012 at 7:49 AM, Michele Comitini 
>>  wrote: 
>> > You don't return a dictionary with the registration_id key in the 
>> > get_user() method. 
>> > 
>> > change the code as follows: 
>> > 
>> >  return dict(first_name = user['first_name'], last_name = 
>> > user['last_name'], username = user['id'], registration_id = 
>> > user['id']) 
>> > 
>> > This is stated in the web2py book as required parameter when using 
>> > third party authentication. 
>> > 
>> > mic 
>>
>> Thanks, that worked. 
>>
>> I guess I was reading the wrong book... I got the previous snippet 
>> from the "web2py Application Development Cookbook". 
>>
>> > 2012/6/16 Alec Taylor
>> >> Unfortunately I haven't been able to get Facebook login with OAuth2 
>> working. 
>> >> 
>> >> I've created a tiny test-case below with the problem. 
>> >> 
>> >> The only major changes I have made is to models/db.py with a minor 
>> >> function (foobar) in controllers/default.py. 
>> >> 
>> >> https://gist.github.com/9967cb95fe026890dae7 
>> >> 
>> >> I have placed the facebook.py file in the modules folder and the 
>> >> CLIENT_ID and CLIENT_SECRET in another .py file in my modules 
>> >> directory [file starts with `from gluon import *`]. 
>> >> 
>> >> Please tell me how I can get this to work. 
>> >> 
>> >> Thanks for all suggestions, 
>> >> 
>> >> Alec Taylor 
>> >> 
>> >> FYI: Not showing a ticket because it actually is stuck in an infinite 
>> >> loop. However when I take out the `@auth.requires_login()` decorator 
>> >> before the `foobar` function the page loads, but "Login" still appears 
>> >> in the top-right. 
>>
>

Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-20 Thread Michele Comitini
I opened an issue here:
https://github.com/mdipierro/web2py-recipes-source/issues/2

mic

2012/6/20 Massimo Di Pierro :
> Can you please open a ticket?
>
>
> On Wednesday, 20 June 2012 07:02:28 UTC-5, Michele Comitini wrote:
>>
>> Alec,
>>
>> Thanks to you!
>> You have found a bug either in the book or in the authentication code.
>>  web2py changed behavior.
>> I have to check if a compatibility breach happened somewhere or if that
>> code was using some undocumented feature.
>>
>> mic
>>
>>
>> Il giorno mercoledì 20 giugno 2012 02:33:36 UTC+2, Alec Taylor ha scritto:
>>>
>>> On Wed, Jun 20, 2012 at 7:49 AM, Michele Comitini
>>>  wrote:
>>> > You don't return a dictionary with the registration_id key in the
>>> > get_user() method.
>>> >
>>> > change the code as follows:
>>> >
>>> >  return dict(first_name = user['first_name'], last_name =
>>> > user['last_name'], username = user['id'], registration_id =
>>> > user['id'])
>>> >
>>> > This is stated in the web2py book as required parameter when using
>>> > third party authentication.
>>> >
>>> > mic
>>>
>>> Thanks, that worked.
>>>
>>> I guess I was reading the wrong book... I got the previous snippet
>>> from the "web2py Application Development Cookbook".
>>>
>>> > 2012/6/16 Alec Taylor
>>> >> Unfortunately I haven't been able to get Facebook login with OAuth2
>>> >> working.
>>> >>
>>> >> I've created a tiny test-case below with the problem.
>>> >>
>>> >> The only major changes I have made is to models/db.py with a minor
>>> >> function (foobar) in controllers/default.py.
>>> >>
>>> >> https://gist.github.com/9967cb95fe026890dae7
>>> >>
>>> >> I have placed the facebook.py file in the modules folder and the
>>> >> CLIENT_ID and CLIENT_SECRET in another .py file in my modules
>>> >> directory [file starts with `from gluon import *`].
>>> >>
>>> >> Please tell me how I can get this to work.
>>> >>
>>> >> Thanks for all suggestions,
>>> >>
>>> >> Alec Taylor
>>> >>
>>> >> FYI: Not showing a ticket because it actually is stuck in an infinite
>>> >> loop. However when I take out the `@auth.requires_login()` decorator
>>> >> before the `foobar` function the page loads, but "Login" still appears
>>> >> in the top-right.


[web2py] Re: helps for the biginer on web2py

2012-06-20 Thread Don_X
When I was starting with python & web2py, the video series made by 
codeschool.org really jump started it all for me ... beside reading the 
book !

I suggest to read  the first 5 chapters of the book to get familiar with 
the basic concepts before watching the videos .. and after watching the 
videos, go through the whole book again ! ... it all came together for me  
.. then practice with some coding example before you start developing your 
own !

here is the video series link on youtube : 
http://www.youtube.com/watch?v=zmSOnKkm8Y0&feature=bf_prev&list=PL5E2E223FE3777851
 





Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-20 Thread Michele Comitini

I think that it can be considered as the example code was using an 
undocumented feature. I.e. the registration_id was not necessary at the 
time.

So it's the example that must be modified.
This the affecting change in web2py tools.py.

-if 'registration_id' in table_user.fields() and \
-'registration_id' in keys:
-username = 'registration_id'
-elif 'username' in table_user.fields():
-username = 'username'
-elif 'email' in table_user.fields():
-username = 'email'
-else:
-raise SyntaxError, "user must have username or email"
-user = self.db(table_user[username] == 
keys[username]).select().first()
+user = None
+checks = []
+# make a guess about who this user is
+for fieldname in ['registration_id','username','email']:
+if fieldname in table_user.fields() and 
keys.get(fieldname,None):
+checks.append(fieldname)
+user = user or table_user(**{fieldname:keys[fieldname]})
+# if we think we found the user but registration_id does not 
match, make new user
+if 'registration_id' in checks and user and user.registration_id 
and user.registration_id!=keys.get('registration_id',None):
+user = None # THINK MORE ABOUT THIS? DO WE TRUST OPENID 
PROVIDER?


Il giorno mercoledì 20 giugno 2012 15:20:55 UTC+2, Michele Comitini ha 
scritto:
>
> I opened an issue here: 
> https://github.com/mdipierro/web2py-recipes-source/issues/2 
>
> mic 
>
> 2012/6/20 Massimo Di Pierro : 
> > Can you please open a ticket? 
> > 
> > 
> > On Wednesday, 20 June 2012 07:02:28 UTC-5, Michele Comitini wrote: 
> >> 
> >> Alec, 
> >> 
> >> Thanks to you! 
> >> You have found a bug either in the book or in the authentication code. 
> >>  web2py changed behavior. 
> >> I have to check if a compatibility breach happened somewhere or if that 
> >> code was using some undocumented feature. 
> >> 
> >> mic 
> >> 
> >> 
> >> Il giorno mercoledì 20 giugno 2012 02:33:36 UTC+2, Alec Taylor ha 
> scritto: 
> >>> 
> >>> On Wed, Jun 20, 2012 at 7:49 AM, Michele Comitini 
> >>>  wrote: 
> >>> > You don't return a dictionary with the registration_id key in the 
> >>> > get_user() method. 
> >>> > 
> >>> > change the code as follows: 
> >>> > 
> >>> >  return dict(first_name = user['first_name'], last_name = 
> >>> > user['last_name'], username = user['id'], registration_id = 
> >>> > user['id']) 
> >>> > 
> >>> > This is stated in the web2py book as required parameter when using 
> >>> > third party authentication. 
> >>> > 
> >>> > mic 
> >>> 
> >>> Thanks, that worked. 
> >>> 
> >>> I guess I was reading the wrong book... I got the previous snippet 
> >>> from the "web2py Application Development Cookbook". 
> >>> 
> >>> > 2012/6/16 Alec Taylor 
> >>> >> Unfortunately I haven't been able to get Facebook login with OAuth2 
> >>> >> working. 
> >>> >> 
> >>> >> I've created a tiny test-case below with the problem. 
> >>> >> 
> >>> >> The only major changes I have made is to models/db.py with a minor 
> >>> >> function (foobar) in controllers/default.py. 
> >>> >> 
> >>> >> https://gist.github.com/9967cb95fe026890dae7 
> >>> >> 
> >>> >> I have placed the facebook.py file in the modules folder and the 
> >>> >> CLIENT_ID and CLIENT_SECRET in another .py file in my modules 
> >>> >> directory [file starts with `from gluon import *`]. 
> >>> >> 
> >>> >> Please tell me how I can get this to work. 
> >>> >> 
> >>> >> Thanks for all suggestions, 
> >>> >> 
> >>> >> Alec Taylor 
> >>> >> 
> >>> >> FYI: Not showing a ticket because it actually is stuck in an 
> infinite 
> >>> >> loop. However when I take out the `@auth.requires_login()` 
> decorator 
> >>> >> before the `foobar` function the page loads, but "Login" still 
> appears 
> >>> >> in the top-right. 
>


[web2py] Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread Don_X
Hello,

In  the model, in the file db.py I used the auth_user table that comes by 
default with web2py and I enriched it a bit the following way :

db.define_table('auth_user',
Field('first_name', type='string',
  label=T('First Name')),
Field('last_name', type='string',
  label=T('Last Name')),
Field('email', type='string',
  label=T('E-mail')),
Field('password', type='password',
  readable=False,
  label=T('Password')),
Field('sex',requires=IS_IN_SET((T('male'),T('female'))),label=T('My Sex 
is')),
Field('usertype',requires=IS_IN_SET((T('player'),T('coach'),T('referee'
),T('Parent, Soccer Fan or Volunteer'),T('League, Club, School or Team 
owner'),T('OTHER (ex: Health,Sponsor,etc)'))),
  label=T('I am a')),
Field('birth_date','date',label=T('Birth Date')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
Field('registration_key',default='',
  writable=False,readable=False),
Field('reset_password_key',default='',
  writable=False,readable=False),
migrate=settings.migrate)


I am using mysql on my local server, it all works ! the problem or issue I 
am having is this :
In the usertype field, I have 6 predefined user types ...  
1) I wanted to user numbers ( like 1, 2, ... 6) internally to shorten the 
various codes I'll be writting when it comes to compare or to decide on the 
actions of that specific usertype !
 (PS. I am thinking that it is somekind of a list so I can refer to 
that field as auth_user.usertype[0 to 5] to identify the specific usertype 
of a subscriber !!!  ... am I on the right track ??? )

2) ***  THIS IS MY MOST IMPORTANT QUESTION ***
Depending on that user type, the associated profile and form to fill out 
that follow will not be the same upon registration !! ...  in other words, 
depending on the usertype chosen by the user, as I am using the form wizard 
recipe, 
the next steps ( and certain fields ) to be shown will not be the same ... 
so ..  I definitely need to create separate table for each user type  
...  what if a specific user type ( such as a club and a league)  actually 
needs its own database instead of a table in my main database ! ??? how do 
I approach this in the model and consequently in the controller to the view 
???
To put it in context : a player or ref or coach is a user, ( simple ) ... 
and most club owners and persons will be the same basic auth_user ! but on 
the other hand ...
  a team is a list of  registered users
  a club is a list of teams and users ( that 
are not teams )
  a league is a list of clubs and users ( that 
are not clubs, like volunteers, workers, etc.. )

Am i approaching this the right way ??? ...

please advise

 thank you

[web2py] Re: Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread Don_X
A league will most definitely needs its own database instead of a table ... 
while a team can have its own table within that league database !!! ... but 
can a database be created on the fly within the app upon registration ??

On Wednesday, 20 June 2012 10:02:27 UTC-4, Don_X wrote:
>
> Hello,
>
> In  the model, in the file db.py I used the auth_user table that comes by 
> default with web2py and I enriched it a bit the following way :
> 
> db.define_table('auth_user',
> Field('first_name', type='string',
>   label=T('First Name')),
> Field('last_name', type='string',
>   label=T('Last Name')),
> Field('email', type='string',
>   label=T('E-mail')),
> Field('password', type='password',
>   readable=False,
>   label=T('Password')),
> Field('sex',requires=IS_IN_SET((T('male'),T('female'))),label=T('My 
> Sex is')),
> Field('usertype',requires=IS_IN_SET((T('player'),T('coach'),T(
> 'referee'),T('Parent, Soccer Fan or Volunteer'),T('League, Club, School 
> or Team owner'),T('OTHER (ex: Health,Sponsor,etc)'))),
>   label=T('I am a')),
> Field('birth_date','date',label=T('Birth Date')),
> Field('created_on','datetime',default=request.now,
>   label=T('Created On'),writable=False,readable=False),
> Field('modified_on','datetime',default=request.now,
>   label=T('Modified On'),writable=False,readable=False,
>   update=request.now),
> Field('registration_key',default='',
>   writable=False,readable=False),
> Field('reset_password_key',default='',
>   writable=False,readable=False),
> migrate=settings.migrate)
>
>
> I am using mysql on my local server, it all works ! the problem or issue I 
> am having is this :
> In the usertype field, I have 6 predefined user types ...  
> 1) I wanted to user numbers ( like 1, 2, ... 6) internally to shorten the 
> various codes I'll be writting when it comes to compare or to decide on the 
> actions of that specific usertype !
>  (PS. I am thinking that it is somekind of a list so I can refer 
> to that field as auth_user.usertype[0 to 5] to identify the specific 
> usertype of a subscriber !!!  ... am I on the right track ??? )
>
> 2) ***  THIS IS MY MOST IMPORTANT QUESTION ***
> Depending on that user type, the associated profile and form to fill out 
> that follow will not be the same upon registration !! ...  in other words, 
> depending on the usertype chosen by the user, as I am using the form wizard 
> recipe, 
> the next steps ( and certain fields ) to be shown will not be the same ... 
> so ..  I definitely need to create separate table for each user type  
> ...  what if a specific user type ( such as a club and a league)  actually 
> needs its own database instead of a table in my main database ! ??? how do 
> I approach this in the model and consequently in the controller to the view 
> ???
> To put it in context : a player or ref or coach is a user, ( simple ) ... 
> and most club owners and persons will be the same basic auth_user ! but on 
> the other hand ...
>   a team is a list of  registered users
>   a club is a list of teams and users ( that 
> are not teams )
>   a league is a list of clubs and users ( that 
> are not clubs, like volunteers, workers, etc.. )
>
> Am i approaching this the right way ??? ...
>
> please advise
>
>  thank you



[web2py] Problemas com Mysql

2012-06-20 Thread Fernando J
I have an error with mysql (about reference):

*"1452, u'Cannot add or update a child row"*

The table is created with

*db.define_table('navbar',
Field("title", "string"),
Field("url", "string", requires=IS_EMPTY_OR(IS_URL())), 
Field("c", label="Controller"),
Field("f", label="Function"), 
Field("args", label="Arguments"), 
Field("sortable", "integer"), 
Field("parent_id","reference navbar"),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
Field('registration_key',default='',
  writable=False,readable=False),
Field('reset_password_key',default='',
  writable=False,readable=False),
Field('registration_id',default='',
  writable=False,readable=False), 
format='%(title)s',
   migrate=False)*

Any suggestion, please?

Thanks in Advance!


[web2py] import_from_csv_file troubles

2012-06-20 Thread joe
I want to import from a csv file, but I want to use the imported data in 
only one of my database tables, not all of them, which is how I have seen 
the examples online.  Here is my code, which does not work:

Model
---
db.define_table(
'upload', 
Field('name'),
Field('email'))

db.upload.name.requires = IS_NOT_EMPTY()
db.upload.email.requires = [IS_EMAIL, IS_NOT_IN_DB(db, 'upload.email')]

Controller
--
def upload():
db.upload.import_from_csv_file('nameTest.csv')
records = 
SQLTABLE(db().select(db.upload.ALL),headers='fieldname:capitalize')
return dict(records=records)


View
--
{{extend 'layout.html'}}


Current data
{{=records}}




I know its basic, but I am just working on getting the feel for things 
before I do a bigger project.


Re: [web2py] import_from_csv_file troubles

2012-06-20 Thread Richard Vézina
Why don't use the appadmin export and import ?

Richard

On Wed, Jun 20, 2012 at 9:55 AM, joe  wrote:

> I want to import from a csv file, but I want to use the imported data in
> only one of my database tables, not all of them, which is how I have seen
> the examples online.  Here is my code, which does not work:
>
> Model
> ---
> db.define_table(
> 'upload',
> Field('name'),
> Field('email'))
>
> db.upload.name.requires = IS_NOT_EMPTY()
> db.upload.email.requires = [IS_EMAIL, IS_NOT_IN_DB(db, 'upload.email')]
>
> Controller
> --
> def upload():
> db.upload.import_from_csv_file('nameTest.csv')
> records =
> SQLTABLE(db().select(db.upload.ALL),headers='fieldname:capitalize')
> return dict(records=records)
>
>
> View
> --
> {{extend 'layout.html'}}
>
>
> Current data
> {{=records}}
>
>
>
>
> I know its basic, but I am just working on getting the feel for things
> before I do a bigger project.
>


[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
You are correct. I am still sort of new to python and i didn't realize that 
.thumbnail was a PIL method. However after i fixed that issue it still 
isn't working at all. Does anyone have a simple script to do thumbnails? 
Maybe one that doesn't involve compute. 

Brandon


On Tuesday, June 19, 2012 5:16:03 PM UTC-6, villas wrote:
>
> I don't understand this line:
>
> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>
> why isn't it this??
>
> img.thumbnail((nx, ny), Image.ANTIALIAS)
>
> Isn't thumbnail a method in PIL?   Maybe I'm missing something?
>
> Regards,
> David
>
>
>

[web2py] Re: import_from_csv_file troubles

2012-06-20 Thread Niphlod
book say this.

db.person.import_from_csv_file(open('test.csv', 'r'))


why do you use a different syntax ?

BTW: you'd need to delete the table first, or you'll append to existent 
records in the database the ones in the csv file.



On Wednesday, June 20, 2012 3:55:26 PM UTC+2, joe wrote:
>
> I want to import from a csv file, but I want to use the imported data in 
> only one of my database tables, not all of them, which is how I have seen 
> the examples online.  Here is my code, which does not work:
>
> Model
> ---
> db.define_table(
> 'upload', 
> Field('name'),
> Field('email'))
>
> db.upload.name.requires = IS_NOT_EMPTY()
> db.upload.email.requires = [IS_EMAIL, IS_NOT_IN_DB(db, 'upload.email')]
>
> Controller
> --
> def upload():
> db.upload.import_from_csv_file('nameTest.csv')
> records = 
> SQLTABLE(db().select(db.upload.ALL),headers='fieldname:capitalize')
> return dict(records=records)
>
>
> View
> --
> {{extend 'layout.html'}}
>
>
> Current data
> {{=records}}
>
>
>
>
> I know its basic, but I am just working on getting the feel for things 
> before I do a bigger project.
>


[web2py] Re: Problemas com Mysql

2012-06-20 Thread Niphlod
The error is when trying to create the table for the first time or 
migrating ?

That 1452 is quite a famous error: when you establish a FK (to the same 
table or to another) if there is only one discordant data, the error pops 
up.

So, if your table has some records in it, and you're migrating it, please 
double check those ids for referential integrity.

On Wednesday, June 20, 2012 4:23:30 PM UTC+2, Fernando J wrote:
>
> I have an error with mysql (about reference):
>
> *"1452, u'Cannot add or update a child row"*
>
> The table is created with
>
> *db.define_table('navbar',
> Field("title", "string"),
> Field("url", "string", requires=IS_EMPTY_OR(IS_URL())), 
> Field("c", label="Controller"),
> Field("f", label="Function"), 
> Field("args", label="Arguments"), 
> Field("sortable", "integer"), 
> Field("parent_id","reference navbar"),
> Field('created_on','datetime',default=request.now,
>   label=T('Created On'),writable=False,readable=False),
> Field('modified_on','datetime',default=request.now,
>   label=T('Modified On'),writable=False,readable=False,
>   update=request.now),
> Field('registration_key',default='',
>   writable=False,readable=False),
> Field('reset_password_key',default='',
>   writable=False,readable=False),
> Field('registration_id',default='',
>   writable=False,readable=False), 
> format='%(title)s',
>migrate=False)*
>
> Any suggestion, please?
>
> Thanks in Advance!
>


Re: [web2py] import_from_csv_file troubles

2012-06-20 Thread joe
The project I will be working on requires all users to import from 
spreadsheets, so thats not really possible.

On Wednesday, June 20, 2012 9:49:57 AM UTC-5, Richard wrote:
>
> Why don't use the appadmin export and import ?
>
> Richard
>
> On Wed, Jun 20, 2012 at 9:55 AM, joe  wrote:
>
>> I want to import from a csv file, but I want to use the imported data in 
>> only one of my database tables, not all of them, which is how I have seen 
>> the examples online.  Here is my code, which does not work:
>>
>> Model
>> ---
>> db.define_table(
>> 'upload', 
>> Field('name'),
>> Field('email'))
>>
>> db.upload.name.requires = IS_NOT_EMPTY()
>> db.upload.email.requires = [IS_EMAIL, IS_NOT_IN_DB(db, 'upload.email')]
>>
>> Controller
>> --
>> def upload():
>> db.upload.import_from_csv_file('nameTest.csv')
>> records = 
>> SQLTABLE(db().select(db.upload.ALL),headers='fieldname:capitalize')
>> return dict(records=records)
>>
>>
>> View
>> --
>> {{extend 'layout.html'}}
>>
>>
>> Current data
>> {{=records}}
>>
>>
>>
>>
>> I know its basic, but I am just working on getting the feel for things 
>> before I do a bigger project.
>>
>
>

[web2py] Re: Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread pbreit
You'll almost certainly want separate tables each for teams, clubs and 
leagues. Then you probably do one of these two choices:

db.define_table('team', Field('name'), Field('members', 'list:reference 
auth_user'))

OR

db.define_table('team', Field('name'))
db.define_table('team_member', Field('auth_user_id', 'reference 
auth_user'), Field('team_id', 'reference team'))



[web2py] Key Error exception: 2 table test-case

2012-06-20 Thread Alec Taylor
I've been able to develop a very simple test-case that highlights my
problem. The error is  'group':

The idea is groups have events, events can only be created by owner of
a group, and owner of a group has to be an authenticated user.

[[Models]]
db.define_table(
'event',
Field('name', requires=IS_NOT_EMPTY()),
Field('description'),
Field('image', requires=IS_IMAGE()), # might expand this to a list
Field('datetime', requires=[IS_NOT_EMPTY(), IS_DATETIME()]),
Field('location'),
Field('group_id', db.group, requires=IS_NOT_EMPTY()),
format='%(name)s'
)

db.define_table(
'group',
Field('name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'group.name')]),
Field('description'),
Field('image', requires=IS_IMAGE()), # will expand this to a list
Field('date_created', requires=[IS_NOT_EMPTY(), IS_DATETIME()]), #
want timestamp actually
Field('tags'),
Field('website', requires=IS_HTTP_URL()),
Field('facebook', requires=IS_HTTP_URL()), # want to force user to
input a facebook.com URL
Field('owner', [IS_NOT_EMPTY(), auth.user]),
format='%(name)s'
)

[[Controller]]
def events():
eventlist = SQLTABLE(db().select(db.event.name, db.event.description))
return dict(eventlist=eventlist)

What am I doing wrong?

Thanks for all information,

Alec Taylor


[web2py] Mysql reserved words in a legacy db

2012-06-20 Thread Rene Dohmen
Hi All,

I use web2py to create a admin interface for an older project with an
existing database in MySQL.
So I extracted the DAL info with an script.

--extracted from current mysql db --
user_db.define_table('users',
Field('user_id', 'id'),
Field('login_name', 'string'),
Field('title', 'string'),
Field('first_name', 'string'),
Field('last_name', 'string'),
Field('birthdate', 'datetime'),
Field('group', user_db.group_names,
requires=IS_IN_DB(user_db,'group_names.group_id','%(group_name)s')),
format='%(first_name)s %(last_name)s')
--
When I try to insert or update stuff web2py serves me a ticket.
Viewing the record is no problem. It even shows the dropdown with
groupnames from the linked_table.

In the documentation on
http://www.web2py.com/examples/static/epydoc/web2py.gluon.reserved_sql_keywords-pysrc.html
it says that "GROUP" is a keyword.
Is there a way to force the DAL to quote the fieldNames in its insert
and update query's? With our previous framework we didn't experience
any problems with a field "group" in a mysql table.
It would be cool if there is a way to loosen the restrictions on
reserved keywords on a per app basis.

Kind Regards

Rene Dohmen


[web2py] Re: Key Error exception: 2 table test-case

2012-06-20 Thread Anthony

>
> db.define_table( 
> 'event', 
> Field('name', requires=IS_NOT_EMPTY()), 
> Field('description'), 
> Field('image', requires=IS_IMAGE()), # might expand this to a list 
> Field('datetime', requires=[IS_NOT_EMPTY(), IS_DATETIME()]), 
> Field('location'), 
> Field('group_id', db.group, requires=IS_NOT_EMPTY()),


db.group hasn't been defined yet, so you are getting a key error. Either 
define the event table after defining the group table, or use the 
alternative syntax for specifying a reference field:

Field('group_id', 'reference group', ...)

Field('owner', [IS_NOT_EMPTY(), auth.user]),


The second argument to Field() should be the type, but looks like you're 
passing a list of validators (and auth.user is not even a validator). You 
probably want something like:

Field('owner', db.auth_user)

Anthony 


Re: [web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-20 Thread Paolo Caruccio
Alec,

please double check that in "views/layout.html" exists this code (note the 
pipe in separators):

{{='auth' in globals() and auth.navbar(separators=(' ',' | 
','')) or ''}} 

You should find it at line 90 in last trunk.


Il giorno mercoledì 20 giugno 2012 12:59:56 UTC+2, Alec Taylor ha scritto:
>
> Okay, finally got around to testing it. 
>
> Not getting any pipes. 
>
> The right of my navbar is one long string all of the same colour: 
> "Welcome  Logout" 
>


[web2py] Error viewing table due to invalid format!

2012-06-20 Thread rahulserver
I changed the web2py ajax.html date format and also used the IS_DATE 
constraint to get the date in dd-mm- format. When I submit the data via 
sqlform, everything is ok.but When I added an extra date element in the 
sqlform and tried to insert it in a table using 
db.mytable.insert(mydate=form.vars.date1), the form gets submitted.But when 
I try to view the table data via admin interface or sqlform.grid, I get 
ticket showing :

'day is out of range for month' .




[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread pbreit
Mine seems to work OK with current trunk:

db.item.image_thumb.compute = lambda r: resize_image(r['image'], (150,130), 
'thumb')

def resize_image(image, size, path, rotate=0):
if image:
try:
img = Image.open('%sstatic/uploads/%s' % (request.folder, 
image))
img = img.convert("RGB")
img.thumbnail(size, Image.ANTIALIAS)
img = img.rotate(rotate)
root, ext = os.path.splitext(image)
filename = '%s_%s%s' %(root, path, ext)
img.save('%sstatic/uploads/%s' % (request.folder, filename))
return filename
except Exception, e:
return e
else:
return None


[web2py] JSON Problem

2012-06-20 Thread Jack315
Hey everyone, I'm sort of new to web2py, and I'm running a program that 
takes submitted form information and displays it as a JSON file using 
JSONP. Instead of displaying the JSON in the browser, it just downloads the 
.json file to my computer. What am I doing incorrectly? 

Here is the code that I am using in my controller:

def get_devices(): 
response.view = 'generic.jsonp'
devices = db().select(db.contacts.ALL)

return dict(devices=devices)

Thank you for any help you can provide.


Re: [web2py] Quoting reserved words in DAL

2012-06-20 Thread Rene Dohmen
I'm having the same problem:
https://groups.google.com/d/msg/web2py/hCsxVaDLfT4/K6UMbG5p5uAJ


On Mon, Jun 18, 2012 at 9:30 AM, Michael Toomim  wrote:

> I just got bit by the reserved-word problem:
> https://groups.google.com/d/msg/web2py/aSPtD_mGXdM/c7et_2l_54wJ
>
> I am trying to port a postgres database to a friend's mysql database, but
> we are stuck because the DAL does not quote identifiers.
>
> This problem has been discussed a fair amount:
> https://groups.google.com/d/msg/web2py/QKktETHk3yo/Mwm3D-JhNmAJ
>
> ...and it seems all we need to do is add some quoting mechanisms to the
> DAL. In postgresql you surround names with "quotes" and in mysql you use
> `backticks`.
>
> Does anyone have ideas for what to do?
>

-- 





Re: [web2py] JSON Problem

2012-06-20 Thread Bruno Rocha
ypu can try:

devices = db().select(db.contacts.ALL).as_list()


[web2py] Re: Mysql reserved words in a legacy db

2012-06-20 Thread Cliff Kachinske
It occurs to me you might try this

Field("'group'"),



On Wednesday, June 20, 2012 2:03:48 PM UTC-4, acidjunk wrote:
>
> Hi All, 
>
> I use web2py to create a admin interface for an older project with an 
> existing database in MySQL. 
> So I extracted the DAL info with an script. 
>
> --extracted from current mysql db -- 
> user_db.define_table('users', 
> Field('user_id', 'id'), 
> Field('login_name', 'string'), 
> Field('title', 'string'), 
> Field('first_name', 'string'), 
> Field('last_name', 'string'), 
> Field('birthdate', 'datetime'), 
> Field('group', user_db.group_names, 
> requires=IS_IN_DB(user_db,'group_names.group_id','%(group_name)s')), 
> format='%(first_name)s %(last_name)s') 
> -- 
> When I try to insert or update stuff web2py serves me a ticket. 
> Viewing the record is no problem. It even shows the dropdown with 
> groupnames from the linked_table. 
>
> In the documentation on 
>
> http://www.web2py.com/examples/static/epydoc/web2py.gluon.reserved_sql_keywords-pysrc.html
>  
> it says that "GROUP" is a keyword. 
> Is there a way to force the DAL to quote the fieldNames in its insert 
> and update query's? With our previous framework we didn't experience 
> any problems with a field "group" in a mysql table. 
> It would be cool if there is a way to loosen the restrictions on 
> reserved keywords on a per app basis. 
>
> Kind Regards 
>
> Rene Dohmen 
>


[web2py] unique field with case insensitivity

2012-06-20 Thread Corey Marques
Howdy,

I'm trying to put together a quick proof of concept to use this framework 
for porting our desktop application to the web.

I ran into an issue where unique fields don't follow our rules. In our 
database the 'nickname' field is unique and "JOE" is the same as "joe".

I did a quick search and couldn't find an elegant solution to this problem. 
I was hoping for something like

Field('nickname', unique_ignore_case=True)

Is there a simple and efficient way to do this? The only solution I was 
able to find involved duplicating the field on the table and saving both 
the field and it's lowercase equivalent.  

Thanks for your time.

Corey.


[web2py] Accessing a database table from controllers

2012-06-20 Thread sasogeek
Hi, I'm new to this group and this is my first question. I was wondering if 
it was possible to access a database table from controllers and update it 
automatically without having to go to /appadmin and manually typing in the 
data? I just made a crawler and I want the links and titles of pages 
collected to be automatically updated to the database table. if you want to 
ask me anything to help you answer me [better], you may ask for it and if I 
do have it, I'll let you know :) thanks



[web2py] Auto-generate PUT and DELETE methods

2012-06-20 Thread Osama Hussain
Using the following code web2py generated all possible patterns for all my 
tables for GET and POST methods:

@request.restful()
def api():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)
return locals()


Is it possible to have patterns generated for PUT and DELETE methods?



[web2py] Re: bootstrap carousel web2py Nightly build

2012-06-20 Thread Paolo Caruccio
@Andrew

Yes. We could change the file, currently named bootswatch.css, to 
automatize bootstrap carousel in web2py, but next time, when we will found 
an incompatibility between bootstrap.min.css and web2py.css, we will have 
to update again bootswatch.css. I don't think that it's good thing - in 
this case - to update frequently a web2py file but it's better submit a big 
patch. We should test all bootstrap's features to correct the eventual 
collisions with web2py.css

@LightDot

Finding every collision between web2py.css and bootstrap.css it's not 
simple and take much time, but the target will be achieved by testing the 
bootstrap's features and by removing the collisions that will be meet. On 
the other hand, it's my opinion that web2py developers didn't want 
"bootstrapize" (what ugly word!) all our loved framework, but only the 
topbar.

Il giorno martedì 19 giugno 2012 21:35:42 UTC+2, Paolo Caruccio ha scritto:
>
> I'm building an app for trying carousel feature and I met the same your 
> issue.
>
> My solution (note style statement):
>
>  style="width:40px;float:none;text-align:center;">›
>
> Maybe you should adapt the width to your necessity.
>
> The inline css style overwrites the ".right" rule in web2py.css
>
>
> Il giorno martedì 19 giugno 2012 19:25:07 UTC+2, dundee ha scritto:
>>
>> Hey all,
>>
>> Anyone trying to use carousel in web2py nightly build?
>> I used it exactly as stated on the bootstrap web site. However, the 
>> controls are not rendered properly and I can only the next button works.
>> The controls are positioned correctly but a big border is around the 
>> controls.
>>
>> 
>> ‹
>> 
>> ›
>>
>>
>> I have attached a screenshot.
>>
>> Thanks.
>>
>

[web2py] Re: Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread Cliff Kachinske
Why do you say this: A league will most definitely needs its own database 
instead of a table ?

I ask because it's probably not true.

On Wednesday, June 20, 2012 10:12:13 AM UTC-4, Don_X wrote:
>
> A league will most definitely needs its own database instead of a table 
> ... while a team can have its own table within that league database !!! ... 
> but can a database be created on the fly within the app upon registration ??
>
> On Wednesday, 20 June 2012 10:02:27 UTC-4, Don_X wrote:
>>
>> Hello,
>>
>> In  the model, in the file db.py I used the auth_user table that comes by 
>> default with web2py and I enriched it a bit the following way :
>> 
>> db.define_table('auth_user',
>> Field('first_name', type='string',
>>   label=T('First Name')),
>> Field('last_name', type='string',
>>   label=T('Last Name')),
>> Field('email', type='string',
>>   label=T('E-mail')),
>> Field('password', type='password',
>>   readable=False,
>>   label=T('Password')),
>> Field('sex',requires=IS_IN_SET((T('male'),T('female'))),label=T('My 
>> Sex is')),
>> Field('usertype',requires=IS_IN_SET((T('player'),T('coach'),T(
>> 'referee'),T('Parent, Soccer Fan or Volunteer'),T('League, Club, School 
>> or Team owner'),T('OTHER (ex: Health,Sponsor,etc)'))),
>>   label=T('I am a')),
>> Field('birth_date','date',label=T('Birth Date')),
>> Field('created_on','datetime',default=request.now,
>>   label=T('Created On'),writable=False,readable=False),
>> Field('modified_on','datetime',default=request.now,
>>   label=T('Modified On'),writable=False,readable=False,
>>   update=request.now),
>> Field('registration_key',default='',
>>   writable=False,readable=False),
>> Field('reset_password_key',default='',
>>   writable=False,readable=False),
>> migrate=settings.migrate)
>>
>>
>> I am using mysql on my local server, it all works ! the problem or issue 
>> I am having is this :
>> In the usertype field, I have 6 predefined user types ...  
>> 1) I wanted to user numbers ( like 1, 2, ... 6) internally to shorten the 
>> various codes I'll be writting when it comes to compare or to decide on the 
>> actions of that specific usertype !
>>  (PS. I am thinking that it is somekind of a list so I can refer 
>> to that field as auth_user.usertype[0 to 5] to identify the specific 
>> usertype of a subscriber !!!  ... am I on the right track ??? )
>>
>> 2) ***  THIS IS MY MOST IMPORTANT QUESTION ***
>> Depending on that user type, the associated profile and form to fill out 
>> that follow will not be the same upon registration !! ...  in other words, 
>> depending on the usertype chosen by the user, as I am using the form wizard 
>> recipe, 
>> the next steps ( and certain fields ) to be shown will not be the same 
>> ... so ..  I definitely need to create separate table for each user type 
>>  ...  what if a specific user type ( such as a club and a league)  
>> actually needs its own database instead of a table in my main database ! 
>> ??? how do I approach this in the model and consequently in the controller 
>> to the view ???
>> To put it in context : a player or ref or coach is a user, ( simple ) ... 
>> and most club owners and persons will be the same basic auth_user ! but on 
>> the other hand ...
>>   a team is a list of  registered users
>>   a club is a list of teams and users ( that 
>> are not teams )
>>   a league is a list of clubs and users ( 
>> that are not clubs, like volunteers, workers, etc.. )
>>
>> Am i approaching this the right way ??? ...
>>
>> please advise
>>
>>  thank you
>
>

[web2py] Re: Accessing a database table from controllers

2012-06-20 Thread villas
For example here is a function in a controller which adds a few records to 
"mytable".  I guess you already know how to define tables.

def myfunction():
...
db.mytable.insert(user_id=4,court_id=5,perm='C',days=10)
db.mytable.insert(user_id=4,court_id=5,perm='V',days=365)
db.mytable.insert(user_id=4,court_id=9,perm='C',days=10)
db.mytable.insert(user_id=4,court_id=9,perm='V',days=365)
...

Try reading the DAL chapter of the book,  it mentions various examples for 
you to follow.
Regards,  David


[web2py] Re: Key Error exception: 2 table test-case

2012-06-20 Thread villas
In addition to what Anthony has said,  please save yourself a whole heap of 
future problems by avoiding SQL reserved words.  Having a table name GROUP 
is going to bite you!  Look at the 'reserved words' section of the book in 
the DAL chapter and do something like this to help you avoid future 
problems in this respect:

db = DAL('sqlite://storage.db',  check_reserved=['postgres', 'mssql'])

Regards,David


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Doug Philips
On Tue, Jun 19, 2012 at 1:33 PM, Anthony  wrote:
> I'm not sure it's feasible or desirable for the DAL to try to normalize
> every last behavior across all database backends. What exactly would you
> have the DAL do differently in this case?

Actually what I'm looking for is in the documentation, not the code,
so I don't know yet if there is anything I want the DAL to do
differently.


> web2py is just using the Python standard library sqlite3 module. According
> to the docs, it looks like it does not default to autocommit mode.

"It looks like" is my problem here! :-)

I'm looking for The Book to tell me what to expect.
If it doesn't tell me, then I don't know if the current behaviour
(once I discover it) will be carried forward to future versions of
Web2py as part of the backwards compatibility promise, or, if the
current behaviour is just a quirk of the current implementation that
might change and which could bite me if I  rely on it.

Can I count on the DAL setting or not setting autocommit mode? How do
I have any way of knowing if changing that "behind the DAL's back"
would break anything or not. Does the DAL even care?

Since the DAL is trying to abstract away details about particular DB
engines so that Web2py users can write code that "doesn't care", it
also needs to say (for each DB Engine) what assumptions it is
making... that is, what matters to it and what doesn't. It's perfectly
fine to say, for each DB Engine, what configurations/settings/etc.
that Web2py 'cares about' and which it doesn't.


> At some point, it might be worth doing some testing to see if you get the
> behavior you want. If you do db.commit() as in the example, I suspect it
> will be fine (assuming traffic levels aren't too high).

Indeed, I'll have to do that anyways.

Thanks,
--Doug


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Anthony

>
> I'm looking for The Book to tell me what to expect. 
> If it doesn't tell me, then I don't know if the current behaviour 
> (once I discover it) will be carried forward to future versions of 
> Web2py as part of the backwards compatibility promise, or, if the 
> current behaviour is just a quirk of the current implementation that 
> might change and which could bite me if I  rely on it.
>

> Can I count on the DAL setting or not setting autocommit mode? How do 
> I have any way of knowing if changing that "behind the DAL's back" 
> would break anything or not. Does the DAL even care? 
>
> Since the DAL is trying to abstract away details about particular DB 
> engines so that Web2py users can write code that "doesn't care", it 
> also needs to say (for each DB Engine) what assumptions it is 
> making... that is, what matters to it and what doesn't. It's perfectly 
> fine to say, for each DB Engine, what configurations/settings/etc. 
> that Web2py 'cares about' and which it doesn't.
>

Can you explain how whether SQLite autocommits or not matters in this case? 
The DAL documentation recommends doing a db.commit() in scripts and 
background tasks like this precisely because it doesn't want to assume any 
autocommitting is happening. Within the context of HTTP requests, web2py 
automatically does a commit at the end of the request. It's not clear the 
documentation needs to say anything else here -- if you follow what the 
documentation currently says, you should be fine.

Anthony



Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Doug Philips
On Tue, Jun 19, 2012 at 3:31 PM, Niphlod  wrote:
> Yep, I don't know exactly the defaults, but I happen to see some major
> differences against various systems with standard python distribution.

Ugh, at least, for the most part, it still all 'just works'. :-/


> Moreover, it's just for this kind of functionality for webapps that could be
> beneficial to update the module, so I can understand a little bit the
> "standardized" api and "different" actual sqlite linked version. For having
> the possibility to avoid this locking one must activate WAL
> (http://www.sqlite.org/draft/wal.html) on the db. Unfortunately WAL needs
> sqlite version > 3.7.0

Yeah, I'm not looking to go quite that far... yet. :-)

> Anyway, as Anthony suggested, writing something and apply "the theory" to
> that code can't replace a sane "test live functionality": every app has its
> kinds of loads, and percentages of writes/reads are absolutely not a
> standard.

Agreed. I just wanted more documentation about the
assumptions/requirements that DAL makes on the underlying database
engine interface.

Thanks
 --Doug


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Doug Philips
On Wed, Jun 20, 2012 at 5:53 PM, Anthony  wrote:
> Can you explain how whether SQLite autocommits or not matters in this case?
> The DAL documentation recommends doing a db.commit() in scripts and
> background tasks like this precisely because it doesn't want to assume any
> autocommitting is happening. Within the context of HTTP requests, web2py
> automatically does a commit at the end of the request. It's not clear the
> documentation needs to say anything else here -- if you follow what the
> documentation currently says, you should be fine.

>From http://www.sqlite.org/lockingv3.html, "7.0 Transaction Control At
The SQL Level":
"The SQL command "BEGIN TRANSACTION" (the TRANSACTION keyword is
optional) is used to take SQLite out of autocommit mode. Note that the
BEGIN command does not acquire any locks on the database. After a
BEGIN command, a SHARED lock will be acquired when the first SELECT
statement is executed."

So, if the DAL takes the DB out of autocommit mode, the "select"
(which is done in the main/outer loop of the server script) will cause
a SHARED lock to be taken, right?
Then, let's say, there are no new records to process, so the server
script goes to sleep and does another select/query on its next trip
around the loop.
So far, just fine, the server script doesn't block, right?
However, if the Web2py application wants to update the DB, it can't,
because the server script now has a potentially long-lived SHARED
lock.
Quoting from the same document, "3.0 Locking":
"SHARED  The database may be read but not written. Any number of
processes can hold SHARED locks at the same time, hence there can be
many simultaneous readers. But no other thread or process is allowed
to write to the database file while one or more SHARED locks are
active."

Sooo Have I misunderstood the SQLite locking description? or
somewhere in the the DAL documentation where it says it'll do a commit
after a select or is it relying on (in the case of SQLIte) the
autocommit to handle that for it?

Thanks!
   --Doug


[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
pbreit,

I just used your script and my first time thumbnails are working again. 
However the are still not computing on update. Do your thumbnails compute 
when updating?

Brandon

On Wednesday, June 20, 2012 1:58:12 PM UTC-6, pbreit wrote:
>
> Mine seems to work OK with current trunk:
>
> db.item.image_thumb.compute = lambda r: resize_image(r['image'], 
> (150,130), 'thumb')
>
> def resize_image(image, size, path, rotate=0):
> if image:
> try:
> img = Image.open('%sstatic/uploads/%s' % (request.folder, 
> image))
> img = img.convert("RGB")
> img.thumbnail(size, Image.ANTIALIAS)
> img = img.rotate(rotate)
> root, ext = os.path.splitext(image)
> filename = '%s_%s%s' %(root, path, ext)
> img.save('%sstatic/uploads/%s' % (request.folder, filename))
> return filename
> except Exception, e:
> return e
> else:
> return None
>


[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread pbreit
Oh, my bad. You're right, looks like not updating. Will dig in more. Sorry 
about that.

[web2py] run from source to access in another computers

2012-06-20 Thread Janath
Hi,

I run web2py from source on windows 7. Machine has a real IP.

But I am unable to access it even in the same machine when I use the real 
IP as the server IP. I need to access the site from other computers. 
Nothing shows up in the screen.

I am not sure there is a fire wall blocking that. How can I check and go 
ahead.

workarounds appreciated!


Janath


Re: [web2py] run from source to access in another computers

2012-06-20 Thread Bruno Rocha
python web2py.py -a password -i 0.0.0.0 -p 8000



*Bruno Cezar Rocha*

http://www.CursoDePython.com.br
[image: Facebook]  [image:
Twitter] [image:
LinkedIn]  [image:
about.me] [image:
Amazon]  [image:
AngelList] [image:
Blog RSS]  [image:
Facebook Page]  [image:
foursquare] [image:
Google Plus]  [image:
pinterest]  [image:
SlideShare] [image:
YouTube] 
 [image: Google Talk] rochacbruno [image: Skype] blouweb
Blog: Generate a thumbnail that fits in a
box
  Get a signature like this.

Click
here.



On Wed, Jun 20, 2012 at 7:46 PM, Janath  wrote:

> Hi,
>
> I run web2py from source on windows 7. Machine has a real IP.
>
> But I am unable to access it even in the same machine when I use the real
> IP as the server IP. I need to access the site from other computers.
> Nothing shows up in the screen.
>
> I am not sure there is a fire wall blocking that. How can I check and go
> ahead.
>
> workarounds appreciated!
>
>
> Janath
>


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Niphlod
You're forgetting another "layer".  DAL leverages on DBAPI implementation 
of sql drivers.
Actually, there is no "begin" transaction on python.
Usually you instantiate a cursor, do operations, try to commit, if 
exception is raised you rollback.

You can do all kind of tests for your background operations just defining a 
simple model and starting two separate web2py's shells (web2py.py -M -S 
youappname). One is representing the app (1), the other is representing the 
daemon (2).

Remember that shell never commits unless told so (yeah, more control over 
it for your tests).
I just tried and seems that I need to correct my previous statement: lock 
occupies the window of time between the db.commit() and the end of the call 
itself.
Try yourself:
 - select table on 1, select table on 2 --> no problems
 - update one row on 1 (without committing), select on 2. no locking, 2 
shows table as it was before the update on 1, so no problems
 - commit on 1, select on 2. No locking, 2 shows the table with updated 
records

A little more complicated: get on an infinite loop inserting 10 rows, 
without committing. while the loop is running on 1, try a loop of 100 
updates to those records, then commit. Occasionally you'll be presented 
with "Database is locked" error.



[web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread howesc
i suspect that in your case PUT and DELETE would look a lot like POST.  not 
sure the exact code for your use case, but i know it's possible to have PUT 
and DELETE methods.

On Wednesday, June 20, 2012 9:30:26 AM UTC-7, Osama Hussain wrote:
>
> Using the following code web2py generated all possible patterns for all my 
> tables for GET and POST methods:
>
> @request.restful()
> def api():
> response.view = 'generic.'+request.extension
> def GET(*args,**vars):
> patterns = 'auto'
> parser = db.parse_as_rest(patterns,args,vars)
> if parser.status == 200:
> return dict(content=parser.response)
> else:
> raise HTTP(parser.status,parser.error)
> def POST(table_name,**vars):
> return db[table_name].validate_and_insert(**vars)
> return locals()
>
>
> Is it possible to have patterns generated for PUT and DELETE methods?
>
>

[web2py] import module fails

2012-06-20 Thread wdtatenh
I'm running version 1.91.6 installed from binary for localhost testing. I'm 
attempting to add some modules to hold utility functions used by other 
controllers but I consistently get an import error.

Suggestions?  

Thanks in advance


-- 





Re: [web2py] import module fails

2012-06-20 Thread Bruno Rocha
Check if you have an empty __init__.py file under all your root folders.

On Wed, Jun 20, 2012 at 8:19 PM, wdtatenh  wrote:

> I'm running version 1.91.6 installed from binary for localhost testing.
> I'm attempting to add some modules to hold utility functions used by other
> controllers but I consistently get an import error.
>
> Suggestions?
>
> Thanks in advance
>
>
>  --
>


[web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread Massimo Di Pierro
You can do

@request.restful()
def api():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)

def PUT(table_name,record_id,**vars):

return db(db[table_name]._id==record_id).update(**vars)

def PUT(table_name,record_id):

return db(db[table_name]._id==record_id).delete()

return locals()


On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>
> Using the following code web2py generated all possible patterns for all my 
> tables for GET and POST methods:
>
> @request.restful()
> def api():
> response.view = 'generic.'+request.extension
> def GET(*args,**vars):
> patterns = 'auto'
> parser = db.parse_as_rest(patterns,args,vars)
> if parser.status == 200:
> return dict(content=parser.response)
> else:
> raise HTTP(parser.status,parser.error)
> def POST(table_name,**vars):
> return db[table_name].validate_and_insert(**vars)
> return locals()
>
>
> Is it possible to have patterns generated for PUT and DELETE methods?
>
>

Re: [web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread Bruno Rocha
How would it be to receive a file upload thought the restful api?

On Wed, Jun 20, 2012 at 8:39 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You can do
>
> @request.restful()
> def api():
> response.view = 'generic.'+request.extension
>
> def GET(*args,**vars):
>
> patterns = 'auto'
> parser = db.parse_as_rest(patterns,args**,vars)
>
> if parser.status == 200:
>
> return dict(content=parser.response)
>
> else:
> raise HTTP(parser.status,parser.erro**r)
>
> def POST(table_name,**vars):
>
> return db[table_name].validate_and_**insert(**vars)
>
> def PUT(table_name,record_id,**vars):
>
> return db(db[table_name]._id==record_id).update(**vars)
>
> def PUT(table_name,record_id):
>
>  return db(db[table_name]._id==record_id).delete()
>
> return locals()
>
>
> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>>
>> Using the following code web2py generated all possible patterns for all
>> my tables for GET and POST methods:
>>
>> @request.restful()
>> def api():
>> response.view = 'generic.'+request.extension
>>
>> def GET(*args,**vars):
>>
>> patterns = 'auto'
>> parser = db.parse_as_rest(patterns,args**,vars)
>>
>> if parser.status == 200:
>>
>> return dict(content=parser.response)
>>
>> else:
>> raise HTTP(parser.status,parser.erro**r)
>>
>> def POST(table_name,**vars):
>>
>> return db[table_name].validate_and_**insert(**vars)
>>
>> return locals()
>>
>>
>> Is it possible to have patterns generated for PUT and DELETE methods?
>>
>>


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-20 Thread Anthony

>
> Sooo Have I misunderstood the SQLite locking description?
>

I believe so. The shared lock does not last forever -- only as long as it 
takes to execute the select. Once the data have been read, the shared lock 
(for that particular select) is released.

Anthony 

-- 





[web2py] Re: JSON Problem

2012-06-20 Thread Anthony
How is the web2py JSONP action being called? What does the client do once 
the response is received?

On Wednesday, June 20, 2012 4:13:38 PM UTC-4, Jack315 wrote:
>
> Hey everyone, I'm sort of new to web2py, and I'm running a program that 
> takes submitted form information and displays it as a JSON file using 
> JSONP. Instead of displaying the JSON in the browser, it just downloads the 
> .json file to my computer. What am I doing incorrectly? 
>
> Here is the code that I am using in my controller:
>
> def get_devices(): 
> response.view = 'generic.jsonp'
> devices = db().select(db.contacts.ALL)
>
> return dict(devices=devices)
>
> Thank you for any help you can provide.
>

-- 





Re: [web2py] Re: Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread Le Don X
Instead of a table within the main database of this webapp !! simply
because, a SRA or a league wants control and rights ...a league will want
more admin features over their own information .. more than clubs do ! ...

In short ... this is a webapp for Canada, somekind of a Full Soccer Sports
social network with a full featured & embeded soccer management online tool
( destined to where ever they call the game Soccer instead of football ..
like North America ( Canada in occurrence) .. starting with Quebec, the
province I live in ) ...

 just within the island of Montreal alone, In Quebec, there are more than
300 teams within one Soccer Regional Association ! ... ( there are 15+ SRAs
in Quebec ) .. a league as I am referring to it, is in fact a soccer
regional association looking over and managing many different leagues ( A,
AA, AAA, schools and local leagues, etc )  in its own territory, and
overseeing the clubs and soccer activities in that same territory ! .. so
the league ( the SRA)   wants more control ! ... to accommodate that ... I
want provide them with the option of creating their own database within the
app and oversee with their own information in it, manage their subjects (
like registration for players, teams, clubs, etc.. manage competitions,
series, calendars  .. etc .. ) .. ! ...

but .. then again ... it is a lot easier for me to keep it all under the
same database ! .. with just a whole bunch of tables  but I may end up
with lots of tables with redundant information
 ...
Imagine for a moment that I end up with all Soccer Regional Associations in
Canada ( heck ! - what about the US )  signing up .. having it all in one
single database could become my biggest concern ...

As for their need to control and to have many rights ... that can be done
within their own tables in the webapp application ... Yes .. it is a lot
easier ! but I have to have the other option available as well ..  .. !!


anyways ... thank you for the thoughts ...  Meanwhile I still have problems
with the wizard forms .. it is not working the way I want ...

Depending on the usertype chosen, the rest of the subscription form is a
bit different ...  so far .. I  am exploring the possibility to have
everyone sign up ( straight up and simple ) .. and only when they get to
their incomplete profile page ...  .. only then .. they will be reminded to
fully complete the remaining forms based on their usertype and then provide
them with their proper page settings and layout ! ( Yes .. each user type
has  different settings ) .. the user page of a club will be different then
a player's page ! .. ( they will look just a little bit the same ! but they
will not be the same, will not have the same menus and choices ! and so on
.. )



2012/6/20 Cliff Kachinske 

> Why do you say this: A league will most definitely needs its own database
> instead of a table ?
>
> I ask because it's probably not true.
>
> On Wednesday, June 20, 2012 10:12:13 AM UTC-4, Don_X wrote:
>>
>> A league will most definitely needs its own database instead of a table
>> ... while a team can have its own table within that league database !!! ...
>> but can a database be created on the fly within the app upon registration ??
>>
>> On Wednesday, 20 June 2012 10:02:27 UTC-4, Don_X wrote:
>>>
>>> Hello,
>>>
>>> In  the model, in the file db.py I used the auth_user table that comes
>>> by default with web2py and I enriched it a bit the following way :
>>> ##**##
>>> db.define_table('auth_user',
>>> Field('first_name', type='string',
>>>   label=T('First Name')),
>>> Field('last_name', type='string',
>>>   label=T('Last Name')),
>>> Field('email', type='string',
>>>   label=T('E-mail')),
>>> Field('password', type='password',
>>>   readable=False,
>>>   label=T('Password')),
>>> Field('sex',requires=IS_IN_SET**((T('male'),T('female'))),labe**l=T('My
>>> Sex is')),
>>> Field('usertype',requires=IS_**IN_SET((T('player'),T('coach')**,T(
>>> 'referee'),T('Parent, Soccer Fan or Volunteer'),T('League, Club, School
>>> or Team owner'),T('OTHER (ex: Health,Sponsor,etc)'))),
>>>   label=T('I am a')),
>>> Field('birth_date','date',labe**l=T('Birth Date')),
>>> Field('created_on','datetime',**default=request.now,
>>>   label=T('Created On'),writable=False,readable=F**alse),
>>> Field('modified_on','datetime'**,default=request.now,
>>>   label=T('Modified On'),writable=False,readable=F**alse,
>>>   update=request.now),
>>> Field('registration_key',defau**lt='',
>>>   writable=False,readable=False)**,
>>> Field('reset_password_key',def**ault='',
>>>   writable=False,readable=False)**,
>>> migrate=settings.migrate)
>>>
>>>
>>> I am using mysql on my local server, it all works ! the problem or issue
>>> I am having is this :
>>> In the usertype field, I have 6 predefined user types ...
>>> 1) I wanted to user numb

Re: [web2py] Re: Question about a complex model & the associated form ( from controller to view )

2012-06-20 Thread pbreit
One database sounds much easier.

It's probably easier to have users sign up first and then figure out what 
type of user they are. Although it wouldn't be that hard to first determine 
what type of user they are and then use a custom registration form 
(http://web2py.com/books/default/chapter/29/7#Custom-forms) and then an 
auth.settings.register_onaccept callback function to update the rest of the 
database 
(http://web2py.com/books/default/chapter/29/9#Settings-and-messages).

-- 





Re: [web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread Massimo Di Pierro
The code I posted would not work... It depends on how it is uploaded.

if you have the code

curl -X POST \
  -H "Content-Type: text/plain" \
  -T 'hello.txt' \
  http://127.0.0.1:8000/app/default/upload1/hello.txt

I think you can do

def upload():
 table =  db.tablename
 record =  db.tablename[request.args(0)].

 
record.update_record(uploadfield=record.store(file=request.body,filename=request.args(1))
 return 'done'




On Wednesday, 20 June 2012 18:43:15 UTC-5, rochacbruno wrote:
>
>
> How would it be to receive a file upload thought the restful api? 
>
> On Wed, Jun 20, 2012 at 8:39 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> You can do
>>
>> @request.restful()
>>
>> def api():
>> response.view = 'generic.'+request.extension
>>
>>
>> def GET(*args,**vars):
>>
>>
>> patterns = 'auto'
>> parser = db.parse_as_rest(patterns,args**,vars)
>>
>>
>> if parser.status == 200:
>>
>>
>> return dict(content=parser.response)
>>
>>
>> else:
>> raise HTTP(parser.status,parser.erro**r)
>>
>>
>> def POST(table_name,**vars):
>>
>>
>> return db[table_name].validate_and_**insert(**vars)
>>
>> def PUT(table_name,record_id,**vars):
>>
>> return db(db[table_name]._id==record_id).update(**vars)
>>
>> def PUT(table_name,record_id):
>>
>>  return db(db[table_name]._id==record_id).delete()
>>
>> return locals()
>>
>>
>> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>>>
>>> Using the following code web2py generated all possible patterns for all 
>>> my tables for GET and POST methods:
>>>
>>> @request.restful()
>>>
>>> def api():
>>> response.view = 'generic.'+request.extension
>>>
>>>
>>> def GET(*args,**vars):
>>>
>>>
>>> patterns = 'auto'
>>> parser = db.parse_as_rest(patterns,args**,vars)
>>>
>>>
>>> if parser.status == 200:
>>>
>>>
>>> return dict(content=parser.response)
>>>
>>>
>>> else:
>>> raise HTTP(parser.status,parser.erro**r)
>>>
>>>
>>> def POST(table_name,**vars):
>>>
>>>
>>> return db[table_name].validate_and_**insert(**vars)
>>>
>>>
>>> return locals()
>>>
>>>
>>> Is it possible to have patterns generated for PUT and DELETE methods?
>>>
>>>
>

-- 





Re: [web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread Bruno Rocha
I am startiing to develop an mobile app for a website using movu.ca (
http://www.menuvegano.com.br), the idea is that the users will be able to
post cook recipes and its pictures via the mobile using the api.

For the mobile app I am using tiggzi.com and it is rest based.

Everything works, but upload not yet.


On Thu, Jun 21, 2012 at 12:42 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The code I posted would not work... It depends on how it is uploaded.
>
> if you have the code
>
> curl -X POST \
>   -H "Content-Type: text/plain" \
>   -T 'hello.txt' \
>   http://127.0.0.1:8000/app/default/upload1/hello.txt
>
> I think you can do
>
> def upload():
>  table =  db.tablename
>  record =  db.tablename[request.args(0)].
>
>  
> record.update_record(uploadfield=record.store(file=request.body,filename=request.args(1))
>  return 'done'
>
>
>
>
> On Wednesday, 20 June 2012 18:43:15 UTC-5, rochacbruno wrote:
>>
>>
>> How would it be to receive a file upload thought the restful api?
>>
>> On Wed, Jun 20, 2012 at 8:39 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> You can do
>>>
>>> @request.restful()
>>>
>>>
>>> def api():
>>> response.view = 'generic.'+request.extension
>>>
>>>
>>>
>>> def GET(*args,**vars):
>>>
>>>
>>>
>>> patterns = 'auto'
>>> parser = db.parse_as_rest(patterns,args,vars)
>>>
>>>
>>>
>>> if parser.status == 200:
>>>
>>>
>>>
>>> return dict(content=parser.response)
>>>
>>>
>>>
>>> else:
>>> raise HTTP(parser.status,parser.error)
>>>
>>>
>>>
>>> def POST(table_name,**vars):
>>>
>>>
>>>
>>> return db[table_name].validate_and_**in**sert(**vars)
>>>
>>> def PUT(table_name,record_id,**var**s):
>>>
>>> return db(db[table_name]._id==record_**id).update(**vars)
>>>
>>> def PUT(table_name,record_id):
>>>
>>>  return db(db[table_name]._id==record_**id).delete()
>>>
>>> return locals()
>>>
>>>
>>> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:

 Using the following code web2py generated all possible patterns for all
 my tables for GET and POST methods:

 @request.restful()


 def api():
 response.view = 'generic.'+request.extension



 def GET(*args,**vars):


 patterns = 'auto'
 parser = db.parse_as_rest(patterns,args,vars)



 if parser.status == 200:



 return dict(content=parser.response)



 else:
 raise HTTP(parser.status,parser.error)



 def POST(table_name,**vars):


 return db[table_name].validate_and_**in**sert(**vars)



 return locals()


 Is it possible to have patterns generated for PUT and DELETE methods?


>>  --
>

-- 





[web2py] Re: JSON Problem

2012-06-20 Thread pbreit
That's how browsers handle the application/jsonp MIME type. If you want to 
see it in your browser, try changing the Content-Type to:

response.headers['Content-Type'] = 'text/plain'

Not sure if the JSONP consumer will process it correctly, though.

-- 





[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
If i am not the only one not having i think it's possible it may be a 
web2py bug. I bet it is only a bug in update fields as i have seem some 
other complaints online. I have filed a bug ticket. Hopefully it is fixed 
soon. I am only a beginner programmer so i still am learning debugging and 
how python and web2py function. I am more than happy to try and help get 
this fixed.

I appreciate the helpfulness of everyone in this group and the web2py devs. 
You guys rock and i am glad i chose web2py over it's alternatives. I never 
got this much help when i was writing php!

Thanks Again,
Brandon

On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>
> Oh, my bad. You're right, looks like not updating. Will dig in more. Sorry 
> about that.

-- 





Re: [web2py] Re: Key Error exception: 2 table test-case

2012-06-20 Thread Alec Taylor
Unfortunately I still haven't gotten it to work.

Now getting an error saying: type 'exceptions.AttributeError'>
'NoneType' object has no attribute 'startswith'

[[Models]]
db.define_table(
'group_of_events',
Field('name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'group_of_events.name')]),
Field('description'),
Field('image', requires=IS_IMAGE()), # will expand this to a list
Field('date_created', requires=[IS_NOT_EMPTY(), IS_DATETIME()]), #
want timestamp actually
Field('tags'),
Field('website', requires=IS_HTTP_URL()),
Field('facebook', requires=IS_HTTP_URL()), # want to force user to
input a facebook.com URL
Field('owner', auth.user, IS_NOT_EMPTY()),
Field('events', 'list:reference event', requires=IS_IN_DB(db,
'event.id')), # How to do?: WHERE group_id=this->group.id
format='%(name)s'
)

db.define_table(
'event',
Field('name', requires=IS_NOT_EMPTY()),
Field('description'),
Field('image', requires=IS_IMAGE()), # might expand this to a list
Field('datetime', requires=[IS_NOT_EMPTY(), IS_DATETIME()]),
Field('location'),
Field('group_id', db.group_of_events, requires=[IS_NOT_EMPTY(),
IS_IN_DB(db, 'group_of_events.id')]),
format='%(name)s'
)

On Thu, Jun 21, 2012 at 4:31 AM, Anthony  wrote:
>> db.define_table(
>>     'event',
>>     Field('name', requires=IS_NOT_EMPTY()),
>>     Field('description'),
>>     Field('image', requires=IS_IMAGE()), # might expand this to a list
>>     Field('datetime', requires=[IS_NOT_EMPTY(), IS_DATETIME()]),
>>     Field('location'),
>>     Field('group_id', db.group, requires=IS_NOT_EMPTY()),
>
>
> db.group hasn't been defined yet, so you are getting a key error. Either
> define the event table after defining the group table, or use the
> alternative syntax for specifying a reference field:
>

And that's why I should never code at 4am! - /me made a very n00b db
design error.

Thanks for pointing it out.

> Field('group_id', 'reference group', ...)
>
>>     Field('owner', [IS_NOT_EMPTY(), auth.user]),
>
>
> The second argument to Field() should be the type, but looks like you're
> passing a list of validators (and auth.user is not even a validator). You
> probably want something like:
>
> Field('owner', db.auth_user)

Yeah, I had it like that but did some last minute refactoring to
reduce the test-case and must've put it out of the brackets.

>
> Anthony

Thanks

On Thu, Jun 21, 2012 at 7:14 AM, villas  wrote:
> In addition to what Anthony has said,  please save yourself a whole heap of
> future problems by avoiding SQL reserved words.  Having a table name GROUP
> is going to bite you!  Look at the 'reserved words' section of the book in
> the DAL chapter and do something like this to help you avoid future problems
> in this respect:
>
> db = DAL('sqlite://storage.db',  check_reserved=['postgres', 'mssql'])
>
> Regards,David

Thanks for the advice... I'll change the name.

-- 





Re: [web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-20 Thread Alec Taylor
Confirmed.

That pipe code is definitely there (just under the "web2py™ " line).

On Thu, Jun 21, 2012 at 5:00 AM, Paolo Caruccio
 wrote:
> Alec,
>
> please double check that in "views/layout.html" exists this code (note the
> pipe in separators):
>
> {{='auth' in globals() and auth.navbar(separators=(' ',' |
> ','')) or ''}}
>
> You should find it at line 90 in last trunk.
>
>
> Il giorno mercoledì 20 giugno 2012 12:59:56 UTC+2, Alec Taylor ha scritto:
>>
>> Okay, finally got around to testing it.
>>
>> Not getting any pipes.
>>
>> The right of my navbar is one long string all of the same colour:
>> "Welcome  Logout"

-- 





Re: [web2py] Re: Upload the more than 100 MB file

2012-06-20 Thread Sanjeet Roy
On Wed, Jun 20, 2012 at 6:37 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> web2py was tested with up to 2G upload and download. It always worked for
> me. Some users have experience some problem using rocket we have been
> investigating. Wort case scenario you can use a different web server.
>
> Moreover the upload is definitively not stored in Ram (unless your app
> does).
>

Thanks Massimo i will try on different web Server.

>
>
> On Wednesday, 20 June 2012 04:57:39 UTC-5, Sanjeet Roy wrote:
>>
>> Hi Massimo,
>>
>> I am going to make a web application in which, requires to upload more
>> than 100 Mb file at a time, please give us the details in web2py is it
>> possible ?
>>
>> On Sunday, June 17, 2012 4:58:11 AM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> web2py does not load the uploaded file in Ram (unless the the is
>>> uploaded to db). The error reported Sanjeet is in fact different. It runs
>>> out of memory trying to serialize a helper, after the file has been
>>> uploaded completely.
>>>
>>> Massimo
>>>
>>> On Saturday, 16 June 2012 17:22:14 UTC-5, Khalil KHAMLICHI wrote:

 A few weeks ago, I had similar problem with uploading big files
 (starting from 100Mb), I could never figure out what was the reason ... I
 could just understand that web2py loaded the files into memory (for some
 reason) and that caused the whole process to crash, that was my analysis
 but maybe it was biased by the fact that the server was a virtual machine
 with I think 1gig of Ram.
 Anyway I confirm the existence of a problem with uploads larger than
 100Mb.


 On Sat, Jun 16, 2012 at 10:45 PM, Massimo Di Pierro <
 massimo.dipie...@gmail.com> wrote:

> The error you get is not in uploading the file but in trying to
> display something very large. I suspect there is something in your model
> that is causing the problem. Can we see your model?
>
>
>
> On Saturday, 16 June 2012 00:15:35 UTC-5, Sanjeet Roy wrote:
>>
>> Can i upload the more than 100 mb file using web2py when i tried got
>> the error:-
>>
>>
>> Traceback (most recent call last):
>>   File "/home/tls-sanjeet/Desktop/**web**2py/gluon/restricted.py", line 
>> 205, in restricted
>>
>>
>>
>> exec ccode in environment
>>   File 
>> "/home/tls-sanjeet/Desktop/**web**2py/applications/upload_**test/**views/appadmin.html"
>>  
>> ,
>>  line 56, in 
>>
>>
>>
>> {{if rows:}}
>>   File "/home/tls-sanjeet/Desktop/**web**2py/gluon/globals.py", line 
>> 182, in write
>>
>>
>>
>> self.body.write(xmlescape(data))
>>
>>
>>
>>   File "/home/tls-sanjeet/Desktop/**web**2py/gluon/html.py", line 114, 
>> in xmlescape
>>
>>
>>
>> return data.xml()
>>
>>
>>
>>   File "/home/tls-sanjeet/Desktop/**web**2py/gluon/html.py", line 848, 
>> in xml
>>
>>
>>
>> (fa, co) = self._xml()
>>
>>
>>
>>   File "/home/tls-sanjeet/Desktop/**web**2py/gluon/html.py", line 839, 
>> in _xml
>>
>>
>>
>> self.components])
>>
>>
>> MemoryError
>>
>>
>>


-- 





Re: [web2py] Re: Key Error exception: 2 table test-case

2012-06-20 Thread Anthony

>
> Unfortunately I still haven't gotten it to work. 
>
> Now getting an error saying: type 'exceptions.AttributeError'> 
> 'NoneType' object has no attribute 'startswith'
>

Traceback? What line is causing that error? 

-- 





[web2py] Re: Auto-generate PUT and DELETE methods

2012-06-20 Thread Osama Hussain
Thanks a LOT! I know we should avoid auto pattern generation but having 
this functionality makes it super easy to rapidly develop a back end so 
that I could focus on my front end and have a prototype shipped in time, 
guess I made the right choice to choose web2py :) 

On Thursday, June 21, 2012 4:39:33 AM UTC+5, Massimo Di Pierro wrote:
>
> You can do
>
> @request.restful()
> def api():
> response.view = 'generic.'+request.extension
> def GET(*args,**vars):
> patterns = 'auto'
> parser = db.parse_as_rest(patterns,args,vars)
> if parser.status == 200:
> return dict(content=parser.response)
> else:
> raise HTTP(parser.status,parser.error)
> def POST(table_name,**vars):
> return db[table_name].validate_and_insert(**vars)
>
> def PUT(table_name,record_id,**vars):
>
> return db(db[table_name]._id==record_id).update(**vars)
>
> def PUT(table_name,record_id):
>
> return db(db[table_name]._id==record_id).delete()
>
> return locals()
>
>
> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>>
>> Using the following code web2py generated all possible patterns for all 
>> my tables for GET and POST methods:
>>
>> @request.restful()
>> def api():
>> response.view = 'generic.'+request.extension
>> def GET(*args,**vars):
>> patterns = 'auto'
>> parser = db.parse_as_rest(patterns,args,vars)
>> if parser.status == 200:
>> return dict(content=parser.response)
>> else:
>> raise HTTP(parser.status,parser.error)
>> def POST(table_name,**vars):
>> return db[table_name].validate_and_insert(**vars)
>> return locals()
>>
>>
>> Is it possible to have patterns generated for PUT and DELETE methods?
>>
>>

-- 





[web2py] Python 3 is catching up to us...

2012-06-20 Thread Jason (spot) Brower
Not a big deal still at this point but wanted to point out:
http://www.noobslab.com/2012/06/ubuntu-1210-quantal-quetzal-alpha-1-is.html
Python 2 will not be in Ubuntu by default anymore.
BR,
Jason

-- 





[web2py] Re: menu.append() more than one argument

2012-06-20 Thread Annet


> did you know about extend?

 
No. I'll give extend a try, thanks for answering my question.

Annet.

-- 





[web2py] Re: menu.append() more than one argument

2012-06-20 Thread Anthony
You can also do:

response.site_submenu += [list, of, items]

Anthony

On Wednesday, June 20, 2012 3:48:46 AM UTC-4, Niphlod wrote:
>
> did you know about extend ?
>
> >>> mylist = []
> >>> mylist.append(1)
> >>> mylist
> [1]
> >>> mylist.append(2,3)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: append() takes exactly one argument (2 given)
> >>> mylist.extend(2,3)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: extend() takes exactly one argument (2 given)
> >>> mylist.extend([2,3])
> >>> mylist
> [1, 2, 3]
>
>
>
>
> On Wednesday, June 20, 2012 8:03:41 AM UTC+2, Annet wrote:
>>
>> In a controller I have the following menu:
>>
>> response.site_submenu = []
>> if session.vcardsettings:
>> response.site_submenu.append(
>> ['Logo',request.function=='uploadLogo',URL('uploadLogo')],
>> ['Tagline',request.function=='tagline',URL('tagline')],
>> ['Note',request.function=='note',URL('note')])
>> elif session.sitesettings:
>> ...
>>
>> response.site_submenu.append(['Custom_theme',request.function=='customTheme',URL('customTheme')])
>>
>> This results in an error because .append() takes one argument not three. 
>> Appending each menu item in a separate .append() solves the problem, but I 
>> wonder whether there is another way to solve it>
>>
>> Kind regards,
>>
>> Annet
>>
>

-- 





Re: [web2py] Re: Key Error exception: 2 table test-case

2012-06-20 Thread Alec Taylor
Here's the full ticket: http://jsfiddle.net/nqMtX/embedded/result/

On Thu, Jun 21, 2012 at 2:21 PM, Anthony  wrote:
>> Unfortunately I still haven't gotten it to work.
>>
>> Now getting an error saying: type 'exceptions.AttributeError'>
>> 'NoneType' object has no attribute 'startswith'
>
>
> Traceback? What line is causing that error?
>
> --

-- 





[web2py] Email form contents after submission

2012-06-20 Thread Omar Ali

I'm making a one-page web-app which has one table.. that accepts 
suggestions (like a feeback thingie)..

I'm using SQLFORM to render the form and accept and it's adding everything 
in the database as expected. But I would like to do an additional step upon 
submission of form.

I want to send an email with the form's contents to an admin's email id 
with a reply to of the person who sent in the suggestion. How can i 
configure this on a windows server.. 

Here's the code so far:

db.py:

db = DAL('sqlite://storage.db')

db.define_table('suggestions',
Field('type', requires=IS_IN_SET(['شكوى', 'مقترح'])),
Field('created_on', 'datetime', default=request.now),
Field('Name', 'string', notnull=True),
Field('Gender', requires=IS_IN_SET(['انثى', 'ذكر'])),
Field('Description', 'text'),
Field('email', requires=IS_EMAIL(error_message='Invalid Email !')),
Field('usercat', requires=IS_IN_SET(['فرد', 'مكتب عقاري'])),
Field('education', requires=IS_IN_SET(['ابتدائي', 'ثانوي', 'دبلوم', 
'جامعي', 'دراسات عليا'])),
Field('homenumber', 'integer'),
Field('mobilenumber', 'integer'),
Field('age', 'integer'),
Field('pobox', 'integer'),
Field('nationality', 'string'),)

default.py

def viewall():
recs = db().select(db.suggestions.ALL, 
orderby=db.suggestions.created_on)
return dict(recs=recs)
  
def index():
   form = 
SQLFORM(db.suggestions,labels={'type':'نوع','created_on':'التاريخ','Name':'الأسم','Gender':'الجنس','Description':'موضوع','email':'E-Mail','usercat':'نوع
 
المتعامل','education':'المؤهل العلمي','homenumber':'هاتف 
منزل','mobilenumber':'هاتف متحرك','age':'العمر','pobox':'صندوق 
بريد','nationality':'الجنسية'},submit_button='إرسل')
   
   if form.process().accepted:
   response.flash = 'تم ألإرسال'
   
   elif form.errors:
   response.flash = 'يرجى ملء كافة الحقول'
   else:
   pass
   return dict(form=form)

default/index.html:

{{extend 'layout.html'}}

إقترحات و شكاوة

{{=form}}

-- 





Re: [web2py] Python 3 is catching up to us...

2012-06-20 Thread Manuele Pesenti

Il 21/06/2012 07:30, Jason (spot) Brower ha scritto:

Not a big deal still at this point but wanted to point out:
http://www.noobslab.com/2012/06/ubuntu-1210-quantal-quetzal-alpha-1-is.html
Python 2 will not be in Ubuntu by default anymore.
BR,
Jason
well I agree but you're in the same situation if you plan to use a 
stable version of some distros such as CentOS for example in which 
python 2.6 is not yet supported :)


M.

--