Re: [web2py] Re: Nginx + uwsgi file download problem

2012-01-31 Thread Thomas Bellembois

Le 31/01/2012 07:38, nick name a écrit :
Almost surely the same problem discussed in this thread: 
https://groups.google.com/d/msg/web2py/1_b63bhBeQs/sYFbXNJL8D4J



It looks like the problem is with IE8 in this thread ?
Tried to set the content-lenght header but I miss something:

   response.headers = {'Content-disposition:': 'attachment; 
filename=chimitheque_db.tar.gz',
'Content-Length:': 
os.stat('my_filename').st_size/8,

'Content-type:': 'application/gzip'}

The server response is not correct. I run the last 1.99.4 stable version.
I will try with Python 2.7...


Re: [web2py] Re: Nginx + uwsgi file download problem

2012-01-31 Thread nick name
No, the thread started with Ie8 being suspects, but at least from my 
experiments it is a problem in Rocket which can be triggered with any 
browser or even without a browser (e.g. wget/curl instead of a browser)

See e.g. https://github.com/explorigin/Rocket/issues/1#issuecomment-3734231

The reason it works locally for you and not in production is probably 
because you have lower bandwidth to the production machine, triggering 
timeouts.

If changing SOCKET_TIMEOUT to 10 in rocket.py makes the problem go away for 
you (or at least much less frequent), then this is your problem too. 

(This is not really a solution -- it doesn't address the cause, and it 
interferes with timely detection of problems -- but it will let you know if 
you are experiencing the same problem or a different one)


Re: [web2py] Re: Nginx + uwsgi file download problem

2012-01-31 Thread Thomas Bellembois

Le 31/01/2012 09:18, nick name a écrit :
No, the thread started with Ie8 being suspects, but at least from my 
experiments it is a problem in Rocket which can be triggered with any 
browser or even without a browser (e.g. wget/curl instead of a browser)


See e.g. 
https://github.com/explorigin/Rocket/issues/1#issuecomment-3734231


The reason it works locally for you and not in production is probably 
because you have lower bandwidth to the production machine, triggering 
timeouts.


If changing SOCKET_TIMEOUT to 10 in rocket.py makes the problem go 
away for you (or at least much less frequent), then this is your 
problem too.


(This is not really a solution -- it doesn't address the cause, and it 
interferes with timely detection of problems -- but it will let you 
know if you are experiencing the same problem or a different one)
Thanks for the explanation. I have changed the SOCKET_TIMEOUT to 10, 
removed the *.pyc files to be sure, and I have half a success.


I now have a NOT corrupted tar.gz file but with a wrong content. I mean 
that the archive contains a single 2.0GB temporary file (not the real 
size of course, size shown in the unzipping tool) instead of several 
.csv files.


I will install the same environment on my local machine (uwsgi + nginx) 
to see differences.


Thanks,

Thomas


Re: [web2py] Re: Nginx + uwsgi file download problem

2012-01-31 Thread pbreit
If its a big file, need to adjust:

client_max_body_size 100M;


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-31 Thread Ricardo Pedroso
On Tue, Jan 31, 2012 at 3:14 AM, Massimo Di Pierro
 wrote:
> Specifically it waits for the socket timeout of 60 seconds here:
>
> rocket.py line 1063:
>        # Wait until they pull the
> trigger
>        for t in self.threads:
>            if t.isAlive():
>                t.join()
>
> I feel it is ok to have the timeout set to 60secs but not here. I have
> not yet found a way to change the timeout at this point.
> I tried
>
> rocket.py line 1063:
>        # Wait until they pull the
> trigger
>        for t in self.threads:
>            if t.isAlive():
>                t.conn.socket.settimeout(1) #
>                t.join()
>
> but it did not change a thing.

Instead of trying to change the timeout, probably is better to
force the shutdown, something like:

            if t.isAlive():
try:
t.conn.socket.shutdown(socket.SHUT_RDWR)
except socket.error:
pass
            t.join()

But can be wised to ask Tim is opinion about this.

Ricardo


[web2py] auth registration redirect

2012-01-31 Thread Web2Py Freak
Dear All,

How can redirect anyone who register at my website to the profile page


[web2py] Cannont Initial Password Field in Custom Form

2012-01-31 Thread Aris Green
In have been trying to initialize a password field in a custom form using 
SQLFORM.factory, although I cannot initialize password type fields using 
form.vars['passfield'] = 'somevalue'.  I am not using the registration form 
but instead am using a custom form that I want control over.

Setting the default in the Field constructor works, but that is not the way 
I initialize the other fields.  This this a builtin feature of Password 
fields and/or their corresponding form widgets?



[web2py] Newbie Tutorial Confusion

2012-01-31 Thread llanitedave
I just downloaded web2py, and I'm going through the html book for the first 
time.  I'm just getting to the point where I think I can understand the 
web2py approach, and I'm starting to get enthused.

I've gotten as far as the Postback section, and I'm running into problems. 
 The code does not seem to be working as posted, and I'm kind of at a loss.

Using the code below: 









def first():
if request.vars.visitor_name:
session.visitor_name = request.vars.visitor_name
redirect(URL('second'))
return dict()

def second():
return dict()

 "default/first.html" view:







{{extend 'layout.html'}}
What is your name?

  
  


 "default/second.html" view 



{{extend 'layout.html'}}
Hello {{=session.visitor_name or "anonymous"}}


(I first tried it slightly customized, then in frustration I copied and pasted 
verbatem without a change in results), it works as long as I actually input the 
visitor_name.  But if I don't input any value, then it does not display "Hello 
anonymous" as it should.  It just resets back to "first.html".

I went a little further, to the next step down, but I had similar problems 
there.  It doesn't seem to be treating null session data as it should.

So what should I try next?  I'll settle for any hint I can get.

*
*


[web2py] Calling Controller Function from javascript

2012-01-31 Thread Sanjeet Kumar
How to call the Controller function from javascript

Re: [web2py] Calling Controller Function from javascript

2012-01-31 Thread Bruno Rocha

...
ajax('url/to/the/controller/function', [], 'target_element_for_the_return');
...


the ajax function is included in web2py_ajax.js, the second argument is a
list/array ['input'] to be used if you want to send form input values to
the server, you can leave it null with an empty list [].

The last argument is the target element, if the controller returns some
data, the data will be included in that element, or leave it null "" to do
nothing with the return.

In the book there is more examples and details.
http://web2py.com/books/default/chapter/29/11

On Tue, Jan 31, 2012 at 6:14 AM, Sanjeet Kumar wrote:

> How to call the Controller function from javascript




-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Record Versioning

2012-01-31 Thread Johann Spies
The book describe record versioning in the Forms section (SQLFORM and Crud).

How can I get the same when updating/deleting records through queries that
do not use forms?

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Record Versioning

2012-01-31 Thread Bruno Rocha
something like this http://www.web2pyslices.com/slices/take_slice/35

On Tue, Jan 31, 2012 at 10:31 AM, Johann Spies wrote:

> The book describe record versioning in the Forms section (SQLFORM and
> Crud).
>
> How can I get the same when updating/deleting records through queries that
> do not use forms?
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: help with js issue

2012-01-31 Thread Cliff
I have seen the stopping problem on 1.99.4.

Running on Ubuntu 10.04 LTS, Gnome.  No Tk library on the machine, so
I just use 'python web2py.py'
and take the defaults.

Ctrl-C won't stop it and neither will 'Kill -SIGTERM '

The problem occurs after using the application.

On Jan 30, 9:37 am, Ross Peoples  wrote:
> In reference to the cron error, I posted this a couple days ago:
>
> https://groups.google.com/forum/#!searchin/web2py/ross$20peoples$20cr...
>
> Also, I should mention that for the stopping problem: It's not just Mac.
> The previous message with instructions on how to reproduce was done using
> Ubuntu 10.04.


[web2py] CSS on custom form widget.

2012-01-31 Thread David

I have

{{=form.custom.widget.name_on_card }}

which generates

id="no_table_name_on_card" class="string">



How do I add an additional class to the rendered output?

ie: big

id="no_table_name_on_card" class="string big">


Thanks.



Re: [web2py] auth registration redirect

2012-01-31 Thread David

auth.settings.login_next = URL('dashboard',args=['profile'])
auth.settings.register_next = URL('dashboard',args=['profile'])
auth.settings.profile_next = URL('dashboard',args=['profile'])

Its in the docs. For more info.

On 1/31/12 5:37 AM, Web2Py Freak wrote:

Dear All,

How can redirect anyone who register at my website to the profile page




[web2py] Re: auth registration redirect

2012-01-31 Thread Web2Py Freak
i added it to the db.py and its not working and i used this one from
the book and it didnt work two :

auth.settings.register_next = URL('user', args='profile')   


[web2py] Re: CSS on custom form widget.

2012-01-31 Thread Anthony
form.custom.widget.name_on_card['_class'] += ' my-class'

or

form.element(_name='name_on_card')['_class'] += ' my-class'

Anthony

On Tuesday, January 31, 2012 7:46:44 AM UTC-5, David J wrote:
>
> I have
>
> {{=form.custom.widget.name_on_card }}
>
> which generates
>
>  id="no_table_name_on_card" class="string">
>
>
> How do I add an additional class to the rendered output?
>
> ie: big
>
>  id="no_table_name_on_card" class="string big">
>
> Thanks.
>
>

[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Anthony
Note the following line:

if request.vars.visitor_name:


That means it will only store the value in the session and do the redirect 
if "visitor_name" is in request.vars. If you're not submitting a visitor 
name, then that variable will not be in request.vars, and the conditional 
branch in the code will not be executed.

Anthony

On Tuesday, January 31, 2012 1:57:19 AM UTC-5, llanitedave wrote:
>
> I just downloaded web2py, and I'm going through the html book for the 
> first time.  I'm just getting to the point where I think I can understand 
> the web2py approach, and I'm starting to get enthused.
>
> I've gotten as far as the Postback section, and I'm running into problems. 
>  The code does not seem to be working as posted, and I'm kind of at a loss.
>
> Using the code below: 
>
>
>
>
>
>
>
>
>
> def first():
> if request.vars.visitor_name:
> session.visitor_name = request.vars.visitor_name
> redirect(URL('second'))
> return dict()
>
> def second():
> return dict()
>
>  "default/first.html" view:
>
>
>
>
>
>
>
> {{extend 'layout.html'}}
> What is your name?
> 
>   
>   
> 
>
>  "default/second.html" view 
>
>
>
> {{extend 'layout.html'}}
> Hello {{=session.visitor_name or "anonymous"}}
>
>
> (I first tried it slightly customized, then in frustration I copied and 
> pasted verbatem without a change in results), it works as long as I actually 
> input the visitor_name.  But if I don't input any value, then it does not 
> display "Hello anonymous" as it should.  It just resets back to "first.html".
>
> I went a little further, to the next step down, but I had similar problems 
> there.  It doesn't seem to be treating null session data as it should.
>
> So what should I try next?  I'll settle for any hint I can get.
>
> *
> *
>


[web2py] allow reference field to be empty?

2012-01-31 Thread Rick Ree
I've run into a basic problem that I can't seem to figure out:

db.define_table('A', Field('name'), format='%(name)s')
db.define_table(
'B',
Field('number'),
Field('name', db.A,
  requires=IS_EMPTY_OR(IS_IN_DB(db.A,'A.id','%(name)s')))
)

All I want to do is allow db.B.name to be empty. As far as I can tell
the requires= for db.B.name is the accepted way to do this - if I
leave it out, SQLFORM validation will throw an error. But trying to
insert a record into db.B using SQLFORM raises this ticket:

Traceback (most recent call last):
  File "/home/rree/web2py-1.99.4/gluon/restricted.py", line 204, in
restricted
exec ccode in environment
  File "/home/rree/web2py-1.99.4/applications/welcome/controllers/
appadmin.py", line 433, in 
  File "/home/rree/web2py-1.99.4/gluon/globals.py", line 172, in

self._caller = lambda f: f()
  File "/home/rree/web2py-1.99.4/applications/welcome/controllers/
appadmin.py", line 127, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
  File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 862, in
__init__
inp = self.widgets.options.widget(field, default)
  File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 215, in
widget
options = requires[0].options()
  File "/home/rree/web2py-1.99.4/gluon/validators.py", line 2453, in
_options
options = self.other.options()
  File "/home/rree/web2py-1.99.4/gluon/validators.py", line 460, in
options
self.build_set()
  File "/home/rree/web2py-1.99.4/gluon/validators.py", line 443, in
build_set
fields = [self.dbset.db[self.ktable][k] for k in self.fields]
  File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5542, in
__getattr__
return self[key]
  File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5482, in
__getitem__
return dict.__getitem__(self, str(key))
KeyError: 'db'

Am I missing something?

Thanks
-Rick


[web2py] Re: Chunked downloads and corrupt files with Internet Explorer 8 (IE8)

2012-01-31 Thread Massimo Di Pierro
This is very valuable.

In trunk socket timeout is 60 and this resulted in another problem.
Ctrl-C waits for 60 seconds before joining the worker processes.
Perhaps we should increate socket-timeout, catch Ctrl+C and then kill
the process instead of joining the workers.

On Jan 31, 12:16 am, nick name  wrote:
> Ok, the culprit is definitely ignoring exceptions raised in sendall. In my
> humble opinion this is serious enough to be on the 2.0 blocker list.
>
> How to reproduce: you have to have a wsgi worker, that produces output in
> parts (that is, returns a list or yields part as a generator). e.g: use
> web2py's "static" file server (which uses wsgi and does not use the
> FileSystermWorker).
>
>    1. Make sure that there's a large payload produced, and that it is made
>    of a lot of small parts. e.g. put a 10MB file in
>    web2py/applications/welcome/static/file10mb.data (web2py will use 64K parts
>    by default)
>    2. Consume file slowly, e.g. wget --limit=100k
>    http://localhost:8000/welcome/static/file10mb.data; this would take 100
>    seconds to download the whole file even on localhost.
>    3. Let file download for 10 seconds, then pause wget (e.g. suspend it by
>    using Ctrl-Z on linux/osx)
>    4. Wait 20 seconds
>    5. Let it continue (e.g. type 'fg' if you suspended it with ctrl-z)
>    6. Notice that when it reaches the end, wget will complain about missing
>    bytes, reconnect and download the rest of the file (and will be happy with
>    it). However, the file will be corrupt: A block (or many blocks) will be
>    missing from the middle, and the last few blocks will be repeated (by the
>    2nd wget connection; if you disallow wget from resuming, the file will just
>    be shorter).
>
> A better idea where the problem is can be seen from the following ugly
> patch (applied against web2py's "one file" rocket.py)
>
> @@ -1929,6 +1929,9 @@ class WSGIWorker(Worker):
>                  self.conn.sendall(b('%x\r\n%s\r\n' % (len(data), data)))
>              else:
>                  self.conn.sendall(data)
> +        except socket.timeout:
> +            self.closeConnection = True
> +            print 'Exception lost'
>          except socket.error:
>              # But some clients will close the connection before that
>              # resulting in a socket error.
>
> Running the same experiment with the patched rocket.py will show that files
> get corrupted if 'exception lost' is printed to the web2py's terminal.
>
> Discussion: The only way to use sendall() reliably is to immediately
> terminate the connection upon any error (including timeout), as there is no
> way to know how many bytes were sent. (That there is no way to know how
> many bytes were sent is clearly stated in the documentation; the
> implication that it is impossible to reliably recover from this is not).
> However, there are sendall() calls all over rocket.py, and some will result
> in additional sendalls() following a failed sendall(). The worst offender
> seems to be WSGIWorker.write(), but I'm not sure the other sendalls are
> safe either.
>
> Temporary workaround: increase SOCKET_TIMEOUT significantly (default is 1
> second; bump to e.g. 10), and not swallow socket.timeout in
> WSGIWorker.write().
>
> Increasing the chunk size is NOT a helpful, because it only changes the
> number of bytes before the first loss (at a given bandwidth), but from that
> point, the problem is the same.
> cross 
> reference:https://github.com/explorigin/Rocket/issues/1#issuecomment-3734231


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-31 Thread Massimo Di Pierro
I agree. In particular considering this:

https://groups.google.com/group/web2py/browse_thread/thread/d7f6faddb841790b/3ef04bd25c5b81b1#3ef04bd25c5b81b1

On Jan 31, 4:00 am, Ricardo Pedroso  wrote:
> On Tue, Jan 31, 2012 at 3:14 AM, Massimo Di Pierro
>
>
>
>
>
>
>
>
>
>  wrote:
> > Specifically it waits for the socket timeout of 60 seconds here:
>
> > rocket.py line 1063:
> >        # Wait until they pull the
> > trigger
> >        for t in self.threads:
> >            if t.isAlive():
> >                t.join()
>
> > I feel it is ok to have the timeout set to 60secs but not here. I have
> > not yet found a way to change the timeout at this point.
> > I tried
>
> > rocket.py line 1063:
> >        # Wait until they pull the
> > trigger
> >        for t in self.threads:
> >            if t.isAlive():
> >                t.conn.socket.settimeout(1) #
> >                t.join()
>
> > but it did not change a thing.
>
> Instead of trying to change the timeout, probably is better to
> force the shutdown, something like:
>
>             if t.isAlive():
>                 try:
>                     t.conn.socket.shutdown(socket.SHUT_RDWR)
>                 except socket.error:
>                     pass
>                 t.join()
>
> But can be wised to ask Tim is opinion about this.
>
> Ricardo


[web2py] Re: allow reference field to be empty?

2012-01-31 Thread Anthony
Not sure if this is the problem, but it should be:

IS_IN_DB(db, ...)

not

IS_IN_DB(db.A, ...)

Anthony

On Tuesday, January 31, 2012 9:11:48 AM UTC-5, Rick Ree wrote:
>
> I've run into a basic problem that I can't seem to figure out: 
>
> db.define_table('A', Field('name'), format='%(name)s') 
> db.define_table( 
> 'B', 
> Field('number'), 
> Field('name', db.A, 
>   requires=IS_EMPTY_OR(IS_IN_DB(db.A,'A.id','%(name)s'))) 
> ) 
>
> All I want to do is allow db.B.name to be empty. As far as I can tell 
> the requires= for db.B.name is the accepted way to do this - if I 
> leave it out, SQLFORM validation will throw an error. But trying to 
> insert a record into db.B using SQLFORM raises this ticket: 
>
> Traceback (most recent call last): 
>   File "/home/rree/web2py-1.99.4/gluon/restricted.py", line 204, in 
> restricted 
> exec ccode in environment 
>   File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ 
> appadmin.py", line 433, in  
>   File "/home/rree/web2py-1.99.4/gluon/globals.py", line 172, in 
>  
> self._caller = lambda f: f() 
>   File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ 
> appadmin.py", line 127, in insert 
> form = SQLFORM(db[table], ignore_rw=ignore_rw) 
>   File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 862, in 
> __init__ 
> inp = self.widgets.options.widget(field, default) 
>   File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 215, in 
> widget 
> options = requires[0].options() 
>   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 2453, in 
> _options 
> options = self.other.options() 
>   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 460, in 
> options 
> self.build_set() 
>   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 443, in 
> build_set 
> fields = [self.dbset.db[self.ktable][k] for k in self.fields] 
>   File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5542, in 
> __getattr__ 
> return self[key] 
>   File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5482, in 
> __getitem__ 
> return dict.__getitem__(self, str(key)) 
> KeyError: 'db' 
>
> Am I missing something? 
>
> Thanks 
> -Rick



Re: [web2py] Re: CSS on custom form widget.

2012-01-31 Thread David

Thanks.


On 1/31/12 8:42 AM, Anthony wrote:

form.custom.widget.name_on_card['_class'] += ' my-class'

or

form.element(_name='name_on_card')['_class'] += ' my-class'

Anthony

On Tuesday, January 31, 2012 7:46:44 AM UTC-5, David J wrote:

I have

{{=form.custom.widget.name_on_card }}

which generates




How do I add an additional class to the rendered output?

ie: big



Thanks.





[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Hi,

I did the tutorial of the pdf last week (newest pdf of december) and
there is a missing step exactly at this spot of the PDF. (or actually
a "not so clear change which needs to be made to run the tutorial
without any issue"). I didn't know of the google groups at that time
so I didn't post the issue here...

I can't remember exactly how I solved it but if you look at the steps
very precisely you'll find the issue.

Cheers,

On 31 jan, 07:57, llanitedave  wrote:
> I just downloaded web2py, and I'm going through the html book for the first
> time.  I'm just getting to the point where I think I can understand the
> web2py approach, and I'm starting to get enthused.
>
> I've gotten as far as the Postback section, and I'm running into problems.
>  The code does not seem to be working as posted, and I'm kind of at a loss.
>
> Using the code below:
>
> def first():
>     if request.vars.visitor_name:
>         session.visitor_name = request.vars.visitor_name
>         redirect(URL('second'))
>     return dict()
>
> def second():
>     return dict()
>
>  "default/first.html" view:
>
> {{extend 'layout.html'}}
> What is your name?
> 
>   
>   
> 
>
>  "default/second.html" view
>
> {{extend 'layout.html'}}
> Hello {{=session.visitor_name or "anonymous"}}
>
> (I first tried it slightly customized, then in frustration I copied and 
> pasted verbatem without a change in results), it works as long as I actually 
> input the visitor_name.  But if I don't input any value, then it does not 
> display "Hello anonymous" as it should.  It just resets back to "first.html".
>
> I went a little further, to the next step down, but I had similar problems 
> there.  It doesn't seem to be treating null session data as it should.
>
> So what should I try next?  I'll settle for any hint I can get.
>
> *
> *


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Hello again,

I'm pretty sure the first should be like this :



**

def first():
if request.vars.visitor_name:
session.visitor_name = request.vars.visitor_name
redirect(URL('second'))
return dict(form=form)

**

NOTICE THE return dict(form=form), I think it's what is missing at
this step in the book (one page later it's corrected with the
FORM(INPUT()) form creation technic.

I'm kind of a newbie too but I guess without this it's not really
postingback (?)

If it works for you we should try to be sure Massimo gets the error-
reporting (so newbies don't get lost ;-)) to gather some kind of
"erratum".

Cheers,

On 31 jan, 16:33, Benjamin  wrote:
> Hi,
>
> I did the tutorial of the pdf last week (newest pdf of december) and
> there is a missing step exactly at this spot of the PDF. (or actually
> a "not so clear change which needs to be made to run the tutorial
> without any issue"). I didn't know of the google groups at that time
> so I didn't post the issue here...
>
> I can't remember exactly how I solved it but if you look at the steps
> very precisely you'll find the issue.
>
> Cheers,
>
> On 31 jan, 07:57, llanitedave  wrote:
>
>
>
>
>
>
>
> > I just downloaded web2py, and I'm going through the html book for the first
> > time.  I'm just getting to the point where I think I can understand the
> > web2py approach, and I'm starting to get enthused.
>
> > I've gotten as far as the Postback section, and I'm running into problems.
> >  The code does not seem to be working as posted, and I'm kind of at a loss.
>
> > Using the code below:
>
> > def first():
> >     if request.vars.visitor_name:
> >         session.visitor_name = request.vars.visitor_name
> >         redirect(URL('second'))
> >     return dict()
>
> > def second():
> >     return dict()
>
> >  "default/first.html" view:
>
> > {{extend 'layout.html'}}
> > What is your name?
> > 
> >   
> >   
> > 
>
> >  "default/second.html" view
>
> > {{extend 'layout.html'}}
> > Hello {{=session.visitor_name or "anonymous"}}
>
> > (I first tried it slightly customized, then in frustration I copied and 
> > pasted verbatem without a change in results), it works as long as I 
> > actually input the visitor_name.  But if I don't input any value, then it 
> > does not display "Hello anonymous" as it should.  It just resets back to 
> > "first.html".
>
> > I went a little further, to the next step down, but I had similar problems 
> > there.  It doesn't seem to be treating null session data as it should.
>
> > So what should I try next?  I'll settle for any hint I can get.
>
> > *
> > *


[web2py] Re: allow reference field to be empty?

2012-01-31 Thread Rick Ree
Ah, stupid me. Thanks.

On Jan 31, 8:42 am, Anthony  wrote:
> Not sure if this is the problem, but it should be:
>
> IS_IN_DB(db, ...)
>
> not
>
> IS_IN_DB(db.A, ...)
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, January 31, 2012 9:11:48 AM UTC-5, Rick Ree wrote:
>
> > I've run into a basic problem that I can't seem to figure out:
>
> > db.define_table('A', Field('name'), format='%(name)s')
> > db.define_table(
> >     'B',
> >     Field('number'),
> >     Field('name', db.A,
> >           requires=IS_EMPTY_OR(IS_IN_DB(db.A,'A.id','%(name)s')))
> >     )
>
> > All I want to do is allow db.B.name to be empty. As far as I can tell
> > the requires= for db.B.name is the accepted way to do this - if I
> > leave it out, SQLFORM validation will throw an error. But trying to
> > insert a record into db.B using SQLFORM raises this ticket:
>
> > Traceback (most recent call last):
> >   File "/home/rree/web2py-1.99.4/gluon/restricted.py", line 204, in
> > restricted
> >     exec ccode in environment
> >   File "/home/rree/web2py-1.99.4/applications/welcome/controllers/
> > appadmin.py", line 433, in 
> >   File "/home/rree/web2py-1.99.4/gluon/globals.py", line 172, in
> > 
> >     self._caller = lambda f: f()
> >   File "/home/rree/web2py-1.99.4/applications/welcome/controllers/
> > appadmin.py", line 127, in insert
> >     form = SQLFORM(db[table], ignore_rw=ignore_rw)
> >   File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 862, in
> > __init__
> >     inp = self.widgets.options.widget(field, default)
> >   File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 215, in
> > widget
> >     options = requires[0].options()
> >   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 2453, in
> > _options
> >     options = self.other.options()
> >   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 460, in
> > options
> >     self.build_set()
> >   File "/home/rree/web2py-1.99.4/gluon/validators.py", line 443, in
> > build_set
> >     fields = [self.dbset.db[self.ktable][k] for k in self.fields]
> >   File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5542, in
> > __getattr__
> >     return self[key]
> >   File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5482, in
> > __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'db'
>
> > Am I missing something?
>
> > Thanks
> > -Rick


[web2py] Scaling Web2py on GAE

2012-01-31 Thread Sam Bolgert
Hi all,

For my current project I am making an interactive survey application for a 
environment research project. Its currently hosted on GAE.
My problem is my Datastore read operations are through the roof. A few 
users can max the quota in about an hour.

Ive tried switching DAL adapters from gae:datastore to gae:sql but not my 
app just doesn't work. Anyone else have this problem??


[web2py] Help with auth extra fields

2012-01-31 Thread Jarvert
Hi,

I am new to web2py and have been enjoying it immensely.

I have been trying to add extra fields to the db.auth_user. In
particular, I am trying to associate additional profile details
like a "avatar" and other stats to a user...postal code..and so on.

I have tried in the db.py:

auth=Auth(db)
auth.settings.extra_fields[auth.settings.table_user_name]=
[Field('Skype')]
auth.define_tables()


as per http://stackoverflow.com/questions/7121146/web2py-custom-user-profile


The extra fields does not seem to show up when i inspect it through
the appadmin under db.auth_user.
Am I doing this completely wrong?

Could someone please help, thank you!





[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Anthony

>
> I'm pretty sure the first should be like this : 
>
>
>
> ** 
>
> def first(): 
> if request.vars.visitor_name: 
> session.visitor_name = request.vars.visitor_name 
> redirect(URL('second')) 
> return dict(form=form) 
>
> ** 
>
> NOTICE THE return dict(form=form), I think it's what is missing at 
> this step in the book (one page later it's corrected with the 
> FORM(INPUT()) form creation technic. 
>

No, in that particular example, the form is not defined in the controller 
at all. If you do "return dict(form=form)", you will get an error, because 
"form" has not been defined. In this case, the form is defined in the view. 
The first() function simply receives the form post and checks whether 
"visitor_name" is one of the variables in the post -- otherwise, it simply 
returns the first.html view, which includes the empty form.

Anthony
 


[web2py] Re: Scaling Web2py on GAE

2012-01-31 Thread Massimo Di Pierro
You cannot just swith from the datastore to gae:sql. They are
different databases. To use the latter you need to setup an instance
for it. Google has documentation about it.

Anyway, that may solve your problem or make it worse. First of all you
need to identify why you have to many read operations.


massimo

On Jan 31, 9:38 am, Sam Bolgert  wrote:
> Hi all,
>
> For my current project I am making an interactive survey application for a
> environment research project. Its currently hosted on GAE.
> My problem is my Datastore read operations are through the roof. A few
> users can max the quota in about an hour.
>
> Ive tried switching DAL adapters from gae:datastore to gae:sql but not my
> app just doesn't work. Anyone else have this problem??


[web2py] Re: Help with auth extra fields

2012-01-31 Thread Massimo Di Pierro
What if you just do:

auth=Auth(db)
auth.settings.extra_fields['auth_user']= [Field('Skype')]
auth.define_tables()

On Jan 31, 9:55 am, Jarvert  wrote:
> Hi,
>
> I am new to web2py and have been enjoying it immensely.
>
> I have been trying to add extra fields to the db.auth_user. In
> particular, I am trying to associate additional profile details
> like a "avatar" and other stats to a user...postal code..and so on.
>
> I have tried in the db.py:
>
> auth=Auth(db)
> auth.settings.extra_fields[auth.settings.table_user_name]=
> [Field('Skype')]
> auth.define_tables()
>
> as perhttp://stackoverflow.com/questions/7121146/web2py-custom-user-profile
>
> The extra fields does not seem to show up when i inspect it through
> the appadmin under db.auth_user.
> Am I doing this completely wrong?
>
> Could someone please help, thank you!


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Oups you're right.

Now I remember what I didn't understand at this point, and probably
what the OP was expecting.

The book says :

"
Note that if the "second" action is ever called before a visitor name
is set, it will display "Hello anonymous" because session.visitor_name
returns None.
"

What the OP expected (and what I expected last week) was that by using
the form on the "first" url without entering anything and submitting
it it should display "hello anonymous".

However it's not the case and it's not what the book refers to
(whereas it's pretty close, thus the misunderstanding).

BUT, and it's probably what the book tries to say :

If you DIRECTLY try to acces the url "/second" without EVER having
filled the first form with a name, you will get "Hello Anonymous".

Of course you can probably "reproduce" this behavior after having
submitted a name on the first url by clearing your browser's cache/
cookies or trying to access the second url with another browser.

Cheers,


On 31 jan, 17:25, Anthony  wrote:
> > I'm pretty sure the first should be like this :
>
> > **
>
> > def first():
> >     if request.vars.visitor_name:
> >         session.visitor_name = request.vars.visitor_name
> >         redirect(URL('second'))
> >     return dict(form=form)
>
> > **
>
> > NOTICE THE return dict(form=form), I think it's what is missing at
> > this step in the book (one page later it's corrected with the
> > FORM(INPUT()) form creation technic.
>
> No, in that particular example, the form is not defined in the controller
> at all. If you do "return dict(form=form)", you will get an error, because
> "form" has not been defined. In this case, the form is defined in the view.
> The first() function simply receives the form post and checks whether
> "visitor_name" is one of the variables in the post -- otherwise, it simply
> returns the first.html view, which includes the empty form.
>
> Anthony


[web2py] Re: Scaling Web2py on GAE

2012-01-31 Thread Sam Bolgert
Here is my log from the Google App Engine local dev server. I don't
understand where all these "1"s are being printed from and what they
mean. Some of these pages are just static and are not making any
Datastore calls in the controller. Any insight would be helpful. Thank
you.

2012-01-31 18:08:29,591 dal.py:3399] 1
INFO 2012-01-31 18:08:29,612 dal.py:3399] 1
INFO 2012-01-31 18:08:29,633 dal.py:3399] 1
INFO 2012-01-31 18:08:29,661 dal.py:3399] 1
INFO 2012-01-31 18:08:29,684 dal.py:3399] 1
INFO 2012-01-31 18:08:29,710 dal.py:3399] 1
INFO 2012-01-31 18:08:29,740 dal.py:3399] 1
INFO 2012-01-31 18:08:29,767 dal.py:3399] 1
INFO 2012-01-31 18:08:29,809 dal.py:3399] 1
INFO 2012-01-31 18:08:29,848 dal.py:3399] 1
INFO 2012-01-31 18:08:29,875 dal.py:3399] 1
INFO 2012-01-31 18:08:29,912 dal.py:3399] 1
INFO 2012-01-31 18:08:29,942 dal.py:3399] 1
INFO 2012-01-31 18:08:29,992 dal.py:3399] 1
INFO 2012-01-31 18:08:30,039 dal.py:3399] 1
INFO 2012-01-31 18:08:30,069 dal.py:3399] 1
INFO 2012-01-31 18:08:30,130 dal.py:3399] 1
INFO 2012-01-31 18:08:30,158 dal.py:3399] 1
INFO 2012-01-31 18:08:30,295 dal.py:3399] 1
INFO 2012-01-31 18:08:30,326 dal.py:3399] 1
INFO 2012-01-31 18:08:30,373 gaehandler.py:72]  Request:
1106.70ms/893.63ms (real time/cpu time)
INFO 2012-01-31 18:08:30,560 recording.py:372] Saved; key:
__appstats__:009200, part: 98 bytes, full: 392182 bytes, overhead:
0.021 + 0.186; link: http://localhost:8080/_ah/stats/details?time=1328033309266
INFO 2012-01-31 18:08:30,696 dev_appserver.py:2753] "GET /
uwspcommute HTTP/1.1" 200 -
INFO 2012-01-31 18:08:30,746 dev_appserver_index.py:255] Updating /
Users/samb/Documents/Transportation Project/project/web2py/index.yaml
INFO 2012-01-31 18:08:30,843 dev_appserver.py:2753] "GET /
uwspcommute/static/css/south-street/jquery-ui-1.8.16.custom.css HTTP/
1.1" 200 -
INFO 2012-01-31 18:08:30,957 dev_appserver.py:2753] "GET /
uwspcommute/static/css/calendar.css HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,042 dev_appserver.py:2753] "GET /
uwspcommute/static/css/1140.css HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,138 dev_appserver.py:2753] "GET /
uwspcommute/static/css/styles.css HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,224 dev_appserver.py:2753] "GET /
uwspcommute/static/css/lectric.css HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,346 dev_appserver.py:2753] "GET /
uwspcommute/static/js/lectric.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,454 dev_appserver.py:2753] "GET /
uwspcommute/static/js/modernizr-1.7.min.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,586 dev_appserver.py:2753] "GET /
uwspcommute/static/js/jquery-1.7.min.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,711 dev_appserver.py:2753] "GET /
uwspcommute/static/js/jquery-ui-1.8.16.custom.min.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,841 dev_appserver.py:2753] "GET /
uwspcommute/static/js/calendar.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:31,914 dev_appserver.py:2753] "GET /
uwspcommute/static/js/web2py_ajax.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,060 dev_appserver.py:2753] "GET /
uwspcommute/static/js/css3-mediaqueries.js HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,297 dev_appserver.py:2753] "GET /
uwspcommute/static/images/logo.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,451 dev_appserver.py:2753] "GET /
uwspcommute/static/slideshow/image_1.jpg HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,549 dev_appserver.py:2753] "GET /
uwspcommute/static/slideshow/image_2.jpg HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,625 dev_appserver.py:2753] "GET /
uwspcommute/static/slideshow/image_3.jpg HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,703 dev_appserver.py:2753] "GET /
uwspcommute/static/slideshow/image_4.jpg HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,795 dev_appserver.py:2753] "GET /
uwspcommute/static/slideshow/image_5.jpg HTTP/1.1" 200 -
INFO 2012-01-31 18:08:32,917 dev_appserver.py:2753] "GET /
uwspcommute/static/fonts/com4s_m-webfont.woff HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,040 dev_appserver.py:2753] "GET /
uwspcommute/static/fonts/Bevan-webfont.woff HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,149 dev_appserver.py:2753] "GET /
uwspcommute/static/img/slider_right_arrow.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,216 dev_appserver.py:2753] "GET /
uwspcommute/static/img/slider_left_arrow.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,287 dev_appserver.py:2753] "GET /
uwspcommute/static/img/homepage_sidebox_li.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,355 dev_appserver.py:2753] "GET /
uwspcommute/static/images/homepage_bus.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,438 dev_appserver.py:2753] "GET /
uwspcommute/static/images/homepage_carpool.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,505 dev_appserver.py:2753] "GET /
uwspcommute/static/images/homepage_commute.png HTTP/1.1" 200 -
INFO 2012-01-31 18:08:33,576 dev_appserver.py:2753] "GET /
uwspcommute/st

[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread llanitedave
You hit the nail on the head.  So I'm really just misunderstanding the
tutorial.  And of course, looking at the code now it makes sense,
because it only redirects to the second page if there is actually a
value in "visitor_name".  Now I get it.

Thanks, folks.  It's a self-facepalm.  But there will probably be
others, so don't expect this to be my last somewhat clueless question!

Dave

On Jan 31, 9:53 am, Benjamin  wrote:
> Oups you're right.
>
> Now I remember what I didn't understand at this point, and probably
> what the OP was expecting.
>
> The book says :
>
> "
> Note that if the "second" action is ever called before a visitor name
> is set, it will display "Hello anonymous" because session.visitor_name
> returns None.
> "
>
> What the OP expected (and what I expected last week) was that by using
> the form on the "first" url without entering anything and submitting
> it it should display "hello anonymous".
>
> However it's not the case and it's not what the book refers to
> (whereas it's pretty close, thus the misunderstanding).
>
> BUT, and it's probably what the book tries to say :
>
> If you DIRECTLY try to acces the url "/second" without EVER having
> filled the first form with a name, you will get "Hello Anonymous".
>
> Of course you can probably "reproduce" this behavior after having
> submitted a name on the first url by clearing your browser's cache/
> cookies or trying to access the second url with another browser.
>
> Cheers,
>
> On 31 jan, 17:25, Anthony  wrote:
>
>
>
>
>
>
>
> > > I'm pretty sure the first should be like this :
>
> > > **
>
> > > def first():
> > >     if request.vars.visitor_name:
> > >         session.visitor_name = request.vars.visitor_name
> > >         redirect(URL('second'))
> > >     return dict(form=form)
>
> > > **
>
> > > NOTICE THE return dict(form=form), I think it's what is missing at
> > > this step in the book (one page later it's corrected with the
> > > FORM(INPUT()) form creation technic.
>
> > No, in that particular example, the form is not defined in the controller
> > at all. If you do "return dict(form=form)", you will get an error, because
> > "form" has not been defined. In this case, the form is defined in the view.
> > The first() function simply receives the form post and checks whether
> > "visitor_name" is one of the variables in the post -- otherwise, it simply
> > returns the first.html view, which includes the empty form.
>
> > Anthony


[web2py] [OT] e-mail delivery strategies

2012-01-31 Thread Chris May
This is off-topic, but since a fair number of web2py users send e-mail from 
their applications, I thought this post from 37Signals might prove helpful 
to some.

There were nearly 16 million e-mails sent from 37Signals' eight web 
applications in the last seven days. About 99.3% of them were accepted by 
the remote mail server. The link explains how they achieve such a high rate 
of acceptance.

http://37signals.com/svn/posts/3096-behind-the-scenes-giving-away-the-secrets-of-email-delivery
 


[web2py] Re: Scaling Web2py on GAE

2012-01-31 Thread Massimo Di Pierro
I suspect you have tables which use represent to look up the
representation of each record.

for example:

db.define_table('item',
Field('name'),
Field('owner','reference auth_user'))

{{=SQLFORM.grid(db.item)}}

The grid needs to represent each owner. It is a user to will look up
the representation for the user. It needs first name and last name for
it, so it fetches each record.

This is not efficient.

If you could do joins (and on GAE you cannot) you would do a join:

{{=SQLFORM.grid(db.item.owner==db.auth_user.id,fields=[db.item.name,db.auth_user.first_name,db.auth_user.last_name)}}

On GAE the only option is pre-selecting all the users, storing their
name in a dict, caching the dict, redefine the representation of a
owner using the dict.

Massimo

On Jan 31, 12:39 pm, Sam Bolgert  wrote:
> Here is my log from the Google App Engine local dev server. I don't
> understand where all these "1"s are being printed from and what they
> mean. Some of these pages are just static and are not making any
> Datastore calls in the controller. Any insight would be helpful. Thank
> you.
>
> 2012-01-31 18:08:29,591 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,612 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,633 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,661 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,684 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,710 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,740 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,767 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,809 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,848 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,875 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,912 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,942 dal.py:3399] 1
> INFO     2012-01-31 18:08:29,992 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,039 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,069 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,130 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,158 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,295 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,326 dal.py:3399] 1
> INFO     2012-01-31 18:08:30,373 gaehandler.py:72]  Request:
> 1106.70ms/893.63ms (real time/cpu time)
> INFO     2012-01-31 18:08:30,560 recording.py:372] Saved; key:
> __appstats__:009200, part: 98 bytes, full: 392182 bytes, overhead:
> 0.021 + 0.186; link:http://localhost:8080/_ah/stats/details?time=1328033309266
> INFO     2012-01-31 18:08:30,696 dev_appserver.py:2753] "GET /
> uwspcommute HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:30,746 dev_appserver_index.py:255] Updating /
> Users/samb/Documents/Transportation Project/project/web2py/index.yaml
> INFO     2012-01-31 18:08:30,843 dev_appserver.py:2753] "GET /
> uwspcommute/static/css/south-street/jquery-ui-1.8.16.custom.css HTTP/
> 1.1" 200 -
> INFO     2012-01-31 18:08:30,957 dev_appserver.py:2753] "GET /
> uwspcommute/static/css/calendar.css HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,042 dev_appserver.py:2753] "GET /
> uwspcommute/static/css/1140.css HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,138 dev_appserver.py:2753] "GET /
> uwspcommute/static/css/styles.css HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,224 dev_appserver.py:2753] "GET /
> uwspcommute/static/css/lectric.css HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,346 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/lectric.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,454 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/modernizr-1.7.min.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,586 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/jquery-1.7.min.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,711 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/jquery-ui-1.8.16.custom.min.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,841 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/calendar.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:31,914 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/web2py_ajax.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,060 dev_appserver.py:2753] "GET /
> uwspcommute/static/js/css3-mediaqueries.js HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,297 dev_appserver.py:2753] "GET /
> uwspcommute/static/images/logo.png HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,451 dev_appserver.py:2753] "GET /
> uwspcommute/static/slideshow/image_1.jpg HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,549 dev_appserver.py:2753] "GET /
> uwspcommute/static/slideshow/image_2.jpg HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,625 dev_appserver.py:2753] "GET /
> uwspcommute/static/slideshow/image_3.jpg HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,703 dev_appserver.py:2753] "GET /
> uwspcommute/static/slideshow/image_4.jpg HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,795 dev_appserver.py:2753] "GET /
> uwspcommute/static/slideshow/image_5.jpg HTTP/1.1" 200 -
> INFO     2012-01-31 18:08:32,917 dev_appserver.py:2753] "GET /
> uwspcommute/static/fonts/com4s_m-webfont.woff HTTP/1

[web2py] Minify (compress) response HTML

2012-01-31 Thread Kernc
Hi,

Looking to this list for guidance...

The web2py issue #369 (http://code.google.com/p/web2py/issues/detail?
id=369) discusses a possible method of minifying response output HTML
(compressing it as in removing all extraneous whitespace). The issue
was closed with WontFix because "minify feature is now built-into
web2py". I looked through the book, 4th Ed., and the only minifcation
I found (http://web2py.com/books/default/search/29?search=minify) was
that of CSS/JavaScript (response.optimize_css).

In a later issue (http://code.google.com/p/web2py/issues/detail?
id=624), again opened by yours truly, Massimo said, "Will fix the
book. This is already in stable." Yet the only minification I see in
the source tree is for CSS/JS (http://code.google.com/p/web2py/source/
browse/#hg/gluon/contrib/minify).

I'd like to know where's my response.render({...}, minify=True) or how
else am I to use supposedly-existent HTML minification feature.

There is popular demand: 
http://groups.google.com/group/web2py/browse_thread/thread/1cd9856537e9a6db/392f2c8fc6c6ef4b

Thank you!


[web2py] Re: Minify (compress) response HTML

2012-01-31 Thread Massimo Di Pierro
I apologize. My answers were not always informative not correct.

I understood the issue was about minification of css and js which is
included.

As far as the minification of html is concerned. I do not think it
belongs to response.render because there is nothing html specific in
there. If you want to propose the inclusion in contrib of a function
that performs minimification of html, I would not oppose to it.
It could be called with:

from gluon.contrib.htmlminify import minify
retrun minify(response.render(...))

Yet I am not sure this will provide any improvement over gzip http
responses. In fact the gzipping would be performed by the web server
and would result in smaller data and faster processing. It is
different for JS because there the minimization can take advantage
variable name rewriting.

What do other people think?




On Jan 31, 2:23 pm, Kernc  wrote:
> Hi,
>
> Looking to this list for guidance...
>
> The web2py issue #369 (http://code.google.com/p/web2py/issues/detail?
> id=369) discusses a possible method of minifying response output HTML
> (compressing it as in removing all extraneous whitespace). The issue
> was closed with WontFix because "minify feature is now built-into
> web2py". I looked through the book, 4th Ed., and the only minifcation
> I found (http://web2py.com/books/default/search/29?search=minify) was
> that of CSS/JavaScript (response.optimize_css).
>
> In a later issue (http://code.google.com/p/web2py/issues/detail?
> id=624), again opened by yours truly, Massimo said, "Will fix the
> book. This is already in stable." Yet the only minification I see in
> the source tree is for CSS/JS (http://code.google.com/p/web2py/source/
> browse/#hg/gluon/contrib/minify).
>
> I'd like to know where's my response.render({...}, minify=True) or how
> else am I to use supposedly-existent HTML minification feature.
>
> There is popular 
> demand:http://groups.google.com/group/web2py/browse_thread/thread/1cd9856537...
>
> Thank you!


[web2py] updating more than one record.

2012-01-31 Thread Ashraf Mansour
Hi all,

I am looking for an example that updates many records in a table.
( similar to sql update)

It seems that crud.update is handling one record.

I thought about looping (for) and/or executesql.

An example will be perfect.

Regards,

Ashraf


[web2py] Background process scheduler and GAE

2012-01-31 Thread Douglas Ross
Hi,

I know that scheduler is only 6 months old, and it is fantastic, as is
web2py. I have not had this much fun and ease in programming in years.

I do have a questions about whether anyone has implemented it in
web2py on GAE.

How do you start the worker threads in web2py in GAE. Can you do it in
code, or is there a need to start the thread in some sort of GAE
console as you do in the video example.?

Appreciate the help.

Doug


[web2py] Re: Chunked downloads and corrupt files with Internet Explorer 8 (IE8)

2012-01-31 Thread nick name
On Tuesday, January 31, 2012 9:37:54 AM UTC-5, Massimo Di Pierro wrote:
>
> In trunk socket timeout is 60 and this resulted in another problem. 
> Ctrl-C waits for 60 seconds before joining the worker processes. 
> Perhaps we should increate socket-timeout, catch Ctrl+C and then kill 
> the process instead of joining the workers. 
>

Note that rocket.py has two "socket timeout" settings:
1. a constant of 1 second (in web2py trunk and in rocket trunk), which is 
the socket timeout passed down to the python socket library. calling send() 
will raise an exception if not a single byte can be sent within that time. 
calling sendall() will  raise an exception if this time has passed without 
being able to send a single byte (but: if it succeeds in sending 1 byte 
every second, sendall() will never actually time out - a 100K file will 
take more than 24hours!).

2. The timeout passed to the rocket initialization. This is the "monitor" 
timeout, which rocket will use to determine if a connection is stale (or 
otherwise working too slow).

So the 60 seconds that affect Ctrl-C is almost unrelated to the 
SOCKET_TIMEOUT constant in rocket which can be used to see if sendall() is 
indeed the cause of the corruption problem


[web2py] Re: Minify (compress) response HTML

2012-01-31 Thread Anthony
Are you just trying to decrease the network payload? If so, maybe just set 
the server to gzip the content. Once gzipped, minifying will probably only 
provide modest additional benefit, and may not be worth the extra 
processing.

Anthony

On Tuesday, January 31, 2012 3:23:09 PM UTC-5, Kernc wrote:
>
> Hi, 
>
> Looking to this list for guidance... 
>
> The web2py issue #369 (http://code.google.com/p/web2py/issues/detail? 
> id=369 ) discusses 
> a possible method of minifying response output HTML 
> (compressing it as in removing all extraneous whitespace). The issue 
> was closed with WontFix because "minify feature is now built-into 
> web2py". I looked through the book, 4th Ed., and the only minifcation 
> I found (http://web2py.com/books/default/search/29?search=minify) was 
> that of CSS/JavaScript (response.optimize_css). 
>
> In a later issue (http://code.google.com/p/web2py/issues/detail? 
> id=624 ), again 
> opened by yours truly, Massimo said, "Will fix the 
> book. This is already in stable." Yet the only minification I see in 
> the source tree is for CSS/JS (http://code.google.com/p/web2py/source/ 
> browse/#hg/gluon/contrib/minify).
>  
>
>
> I'd like to know where's my response.render({...}, minify=True) or how 
> else am I to use supposedly-existent HTML minification feature. 
>
> There is popular demand: 
> http://groups.google.com/group/web2py/browse_thread/thread/1cd9856537e9a6db/392f2c8fc6c6ef4b
>  
>
> Thank you!



[web2py] Parse HTML from the database?

2012-01-31 Thread HittingSmoke
Sorry if this is a dumb question. I'm working on a very basic blog and I'd 
run into a hurdle which I thought would be very trivial. I've skimmed the 
book looking for an answer but I can't seem to find one. Google searching 
turns up nothing but dozens of unrelated results.

How do I get web2py to parse HTML when pulling fields from the database? In 
my blog the post body field should be rendered as HTML so I can do advanced 
formatting. This is what I'm working with right now 
http://hittingsmoke.com/blog/posts/view/1

I feel like this is simple and I'm just overlooking the obvious. Thanks.


[web2py] Re: Minify (compress) response HTML

2012-01-31 Thread Anthony
On Tuesday, January 31, 2012 3:40:00 PM UTC-5, Massimo Di Pierro wrote:
>
> from gluon.contrib.htmlminify import minify 
> retrun minify(response.render(...)) 
>
> Yet I am not sure this will provide any improvement over gzip http 
> responses. In fact the gzipping would be performed by the web server 
> and would result in smaller data and faster processing. It is 
> different for JS because there the minimization can take advantage 
> variable name rewriting. 
>
> What do other people think?
>

I agree -- I'm not sure minifying HTML will be worthwhile after gzipping. 
But if we do it, your proposed approach seems like the way to go (though it 
might be best if we can find an already tested solution rather than try to 
build our own and possibly get it wrong).

Anthony 


[web2py] Re: Parse HTML from the database?

2012-01-31 Thread Anthony
Content inserted in views is automatically escaped. To avoid that, use 
XML(): http://web2py.com/books/default/chapter/29/5#XML.

Note, this can be very dangerous if you're allowing users to enter 
arbitrary HTML -- in that case, you should at least sanitize the content 
via XML(..., sanitize=True).

Anthony

On Tuesday, January 31, 2012 3:46:37 PM UTC-5, HittingSmoke wrote:
>
> Sorry if this is a dumb question. I'm working on a very basic blog and I'd 
> run into a hurdle which I thought would be very trivial. I've skimmed the 
> book looking for an answer but I can't seem to find one. Google searching 
> turns up nothing but dozens of unrelated results.
>
> How do I get web2py to parse HTML when pulling fields from the database? 
> In my blog the post body field should be rendered as HTML so I can do 
> advanced formatting. This is what I'm working with right now 
> http://hittingsmoke.com/blog/posts/view/1
>
> I feel like this is simple and I'm just overlooking the obvious. Thanks.
>


Re: [web2py] Parse HTML from the database?

2012-01-31 Thread Bruno Rocha
{{=XML(posts.body)}}

On Tue, Jan 31, 2012 at 6:46 PM, HittingSmoke wrote:

> Sorry if this is a dumb question. I'm working on a very basic blog and I'd
> run into a hurdle which I thought would be very trivial. I've skimmed the
> book looking for an answer but I can't seem to find one. Google searching
> turns up nothing but dozens of unrelated results.
>
> How do I get web2py to parse HTML when pulling fields from the database?
> In my blog the post body field should be rendered as HTML so I can do
> advanced formatting. This is what I'm working with right now
> http://hittingsmoke.com/blog/posts/view/1
>
> I feel like this is simple and I'm just overlooking the obvious. Thanks.
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] updating more than one record.

2012-01-31 Thread Bruno Rocha
lets say you have a lot of records with somefield == "anything"

db(db.mytable.somefield == "anything").update(field="something")




On Tue, Jan 31, 2012 at 5:01 PM, Ashraf Mansour wrote:

> Hi all,
>
> I am looking for an example that updates many records in a table.
> ( similar to sql update)
>
> It seems that crud.update is handling one record.
>
> I thought about looping (for) and/or executesql.
>
> An example will be perfect.
>
> Regards,
>
> Ashraf
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: updating more than one record.

2012-01-31 Thread Ashraf Mansour
Thank you for the immediate reply.

my problem is how and where to write the statement in controller and
views ?

Regards,

Ashraf


[web2py] Re: Nesting HTML tables

2012-01-31 Thread Cliff
Try this:

t = TABLE(
(1,2,3),
(4,5,6), # trailing comma
 # a blessing for sloppy coders
)

Reasoning that nesting is allowed, we come to this:
t = TABLE(
(1,2,3),
(4,5,6),
(TABLE(
('one', 'two', 'three'),
('four', 'five', 'six'),
),
'third row, middle',
'third row, right',
),
)


This raises an exception:
((1, _style='border:1px solid black'),2,3),

But this will work:
(TD(1, _style='border:1px solid black'),2,3),


On Jan 29, 6:58 pm, DenesL  wrote:
> Can we see the code?
>
> In the following example no tbody is added to the inner table:
>
> >>> t=TABLE(*[TR(TABLE( *[ TR(*[1,2,3]), TR(*[4,5,6])] )),TR()])
> >>> print t
>
> 123 tr>456 table>
>
> or nicely formatted:
>
> 
>   
>     
>       
>         123
>         456
>       
>     
>   
>   
>   
> 
>
> On Jan 29, 4:10 pm, Tsvi Mostovicz  wrote:
>
>
>
>
>
>
>
> > Hi all,
> > I'm trying to get the following HTML structure using HTML helpers:
>
> > ...
> > ...
> > ...
> > ...
> > 
>
> > AKA nested tables.
> > For some reason when I put the TABLE helper within another TABLE
> > helper, the internal one gets surrounded by tbody, tr and td causing
> > it not to show properly. Does anyone have an idea how to fix this
> > behavior?
>
> > Thanks,
>
> > Tsvi
>
> > Sent from my phone


[web2py] Re: Chunked downloads and corrupt files with Internet Explorer 8 (IE8)

2012-01-31 Thread Massimo Di Pierro
I agree with the fact that there are two timeouts but the one I am
talking about is SOCKET_TIMEOUT.
It is set in --socket-timeout in widget.py and passed to rocket in
line 777 of main.py

rocket.SOCKET_TIMEOUT = socket_timeout

which does change the constant value SOCKET_TIMEOUT=1 to 60.

I am pretty sure decreasing this value fixes this problem on my
machine.

On Jan 31, 2:40 pm, nick name  wrote:
> On Tuesday, January 31, 2012 9:37:54 AM UTC-5, Massimo Di Pierro wrote:
>
> > In trunk socket timeout is 60 and this resulted in another problem.
> > Ctrl-C waits for 60 seconds before joining the worker processes.
> > Perhaps we should increate socket-timeout, catch Ctrl+C and then kill
> > the process instead of joining the workers.
>
> Note that rocket.py has two "socket timeout" settings:
> 1. a constant of 1 second (in web2py trunk and in rocket trunk), which is
> the socket timeout passed down to the python socket library. calling send()
> will raise an exception if not a single byte can be sent within that time.
> calling sendall() will  raise an exception if this time has passed without
> being able to send a single byte (but: if it succeeds in sending 1 byte
> every second, sendall() will never actually time out - a 100K file will
> take more than 24hours!).
>
> 2. The timeout passed to the rocket initialization. This is the "monitor"
> timeout, which rocket will use to determine if a connection is stale (or
> otherwise working too slow).
>
> So the 60 seconds that affect Ctrl-C is almost unrelated to the
> SOCKET_TIMEOUT constant in rocket which can be used to see if sendall() is
> indeed the cause of the corruption problem


[web2py] Ticket Issued: Unrecoverable

2012-01-31 Thread Likit
I have seen several posts about this problem.  I just had the problem
and solved it.  However, none of the several posts I read had the
answer that applied in my case.  I did not read ALL of the posts
mentioning this problem so some of them may have had an applicable
answer.

If you are a linux noob like me you might run into this problem.

The problem is caused by the fact that web2py/wsgi do not have the
privileges to write to the directory that holds you application.  If
you have set up wsgi to run as a daemon as www-data then www-data must
have access to the applications directories.   You should NEVER let
web2py or wsgi (the daemon) be root.  If you did, then anyone who
managed to get into your web2py admin site with your root password
could write arbitrary python code and execute which could do anything
to your server because root has access to everything.  If the daemon
is www-data and you allow www-data GROUP


Re: [web2py] Re: updating more than one record.

2012-01-31 Thread Bruno Rocha
in controller default.py

*def update():
> form = SQLFORM.factory(Field("category",
> requires=IS_IN_SET(["category1", "category2"]), comment="Choose a category
> to update"),
> Field("new_value",
> "double"))
>
>if form.process().accepted:
># all products on that category will be updated to the new value
> informed
>try:
>db(db.products.category ==
> form.vars.category).update(price=form.vars.new_value)
>response.flash = "All products updated!"
>except Exception:
>response.flash = "problems updating..."
> *


On Tue, Jan 31, 2012 at 7:21 PM, Ashraf Mansour wrote:

> Thank you for the immediate reply.
>
> my problem is how and where to write the statement in controller and
> views ?
>
> Regards,
>
> Ashraf
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Ticket Issued: Unrecoverable

2012-01-31 Thread Likit
I have seen several posts about this problem.  I just had the problem
and solved it.  However, none of the several posts I read had the
answer that applied in my case.  I did not read ALL of the posts
mentioning this problem so some of them may have had an applicable
answer.

If you are a linux noob like me you might run into this problem.

The problem is caused by the fact that web2py/wsgi do not have the
privileges to write to the directory that holds your application.  If
you have set up wsgi to run as a daemon as www-data then www-data must
have access to the applications directories.   You should NEVER let
web2py or wsgi (the daemon) be root.  If you did, then anyone who
managed to get into your web2py admin site with your root password
could write arbitrary python code and execute it which could do
anything to your server because root has access to everything.  If the
daemon is www-data and you allow www-data GROUP to have rwx privileges
only in your www directory and your web2py directory--and no other
directories on your server (you may have other apps that need www-data
group privileges such as phpmyadmin) then the worst that can happen is
that www and web2py might be compromised (which is bad enough but
quite contained).

Now, once the wsgi daemon runs as www-data then so does web2py.
Web2py needs rwx privileges on applications.  If you don't give the
www-data group rwx privileges then web2py returns an unrecoverable
ticket--it can't do anything with that application.


[web2py] Default controller function

2012-01-31 Thread Ed Greenberg
I have some html files which I want to render inside the layout.
Something like this:

{{extend 'layout.html'}}

content goes here


All it needs is an empty dict, since it won't look for anything from
the controller to customize it.

I put this file in views/default/content.html

My understanding is that I need a function in controllers/default.py
called content().  Without it, I get "Invalid Function default/
content"

Since I expect more than one file of this nature, I'd prefer not to
create a whole bunch of virtually empty controller functions.   Is
there any way to have a default controller function?

Thanks,
Ed


[web2py] Re: Default controller function

2012-01-31 Thread Massimo Di Pierro
How about this?


{{extend 'layout.html'}}
    
        {{include "default/content.html'}}
    

you do not need a controller function to include a view.

On Jan 31, 4:18 pm, Ed Greenberg  wrote:
> I have some html files which I want to render inside the layout.
> Something like this:
>
> {{extend 'layout.html'}}
>     
>         content goes here
>     
>
> All it needs is an empty dict, since it won't look for anything from
> the controller to customize it.
>
> I put this file in views/default/content.html
>
> My understanding is that I need a function in controllers/default.py
> called content().  Without it, I get "Invalid Function default/
> content"
>
> Since I expect more than one file of this nature, I'd prefer not to
> create a whole bunch of virtually empty controller functions.   Is
> there any way to have a default controller function?
>
> Thanks,
> Ed


[web2py] 2 Questions regarding auth

2012-01-31 Thread Lewis
1.  The book, in chapter 9, describes many methods accessible as part
of the authorization system.

Thus:
The controller above exposes multiple actions:
http://.../[app]/default/user/register
http://.../[app]/default/user/login
http://.../[app]/default/user/logout
http://.../[app]/default/user/profile
http://.../[app]/default/user/change_password
http://.../[app]/default/user/verify_email
http://.../[app]/default/user/retrieve_username
http://.../[app]/default/user/request_reset
http://.../[app]/default/user/reset_password
http://.../[app]/default/user/impersonate
http://.../[app]/default/user/groups
http://.../[app]/default/user/not_authorized_password

This is all really useful.  But, in the text there is no mention of
"the controller above."  Which controller is it?  Indeed, the
scaffolding app only appears to contain a very simple user() function
in default.py.  The auth menu that is enabled in the scaffolding app
only offers access to:
login
register
lost password?

These are the essentials.  But, how do I get to the rest of the
functions?

2.  The book describes a specific way to invoke auth in a model for
the application:

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables()

The welcome app and scaffolding app do indeed provide this.  Somewhere
along the line, I was following some documentation (can't remember
where now...) and I created an app which invokes auth in the model as:
from gluon.tools import *
auth = Auth(jodb)
auth.define_tables()

So, I don't have the hmac key.  How bad is this?  Let me guess:  the
passwords in the auth database are not being encrypted because there
is no encryption key.  When I go look at the raw table, the password
has certainly been hashed.  What key or salt is used when I have
specified (mis-specified, as the case may be) auth as I have?

Thanks.  Trying to use the manual and source code reference as much as
possible but sometimes asking is easier.

- Lewis


Re: [web2py] Re: [w2py-dev] model less apps (a blog example)

2012-01-31 Thread Bruce Wade
Hi Bruno,

I have been looking at your code. How would you override the Auth to not
include first name last name using your class?

IE: How would we do the following using your approach? (BaseAuth)

db.define_table(
auth.settings.table_user_name,
Field('username', length=128, default='000', unique=True),
Field('account_id', db.user_account),
Field('email', length=128, default=''),
Field('password', 'password', length=512, readable=False,
label='Password'),
Field('security', 'password', length=512, readable=False,
label='Security Password'),
Field('registration_key', length=512, writable=False, readable=False,
default=''),
Field('reset_password_key', length=512, writable=False, readable=False,
default=''),
Field('reset_security_key', length=512, writable=False, readable=False,
default=''),
Field('registration_id', length=512, writable=False, readable=False,
default='')
)

custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table
custom_auth_table.password.requires = [IS_STRONG(), CRYPT()]
custom_auth_table.security.requires = [IS_STRONG(), CRYPT()]
custom_auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, custom_auth_table.email)]

auth.settings.table_user = custom_auth_table
auth.define_tables()

--
Regards,
Bruce

On Mon, Jan 30, 2012 at 6:24 AM, Ross Peoples wrote:

> Bruno,
>
> This is a good article. I have done something like this before. My
> approach was a bit different. I was using the singleton pattern, but I
> think it accomplishes the same goal.
>
> I would for example have a module like this:
>
> from gluon import *
>
> class MyModel(object):
> instance = None
>
> def get(db):
> if instance is None:
> instance = MyModel(db)
>
> return instance
>
> def __init__(self, db):
> db.define_table()
>
>
> Then I would still have a db.py for a model, but I would replace the usual
> db.define_table() with this:
>
> from mymodel import MyModel
> MyModel.get(db)
>
> This ensures that the tables only get defined once on the first request
> after starting web2py. I have used this approach on other code that I
> needed to keep alive for other requests.
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: updating more than one record.

2012-01-31 Thread Ashraf Mansour
thanks a lot



[web2py] Re: Parse HTML from the database?

2012-01-31 Thread HittingSmoke
Thanks! At the moment this is just a personal blog that only I'm going to 
be posting on so security isn't an issue. Once I start expanding it out 
feature wise then I'll get more into security. I plan on eventually 
branching it off as a forum app as well so it will be important eventually.


[web2py] Re: Help with auth extra fields

2012-01-31 Thread HittingSmoke
If you're just looking to add fields and not completely redefine your auth 
table this is really simple. From the web2py book:


## after auth = Auth(db)
> auth.settings.extra_fields['auth_user']= [
>   Field('address'),
>   Field('city'),
>   Field('zip'),
>   Field('phone')]
> ## before auth.define_tables(username=True)
>
>
Those fields will show up on registration and on the edit profile page.


[web2py] Re: Any advice on spam control for a comment system?

2012-01-31 Thread monotasker
Thanks Benjamin. That sounds quite simple.


[web2py] Re: Any advice on spam control for a comment system?

2012-01-31 Thread monotasker
Thanks. I think I'll try the honeypot (hidden field) approach and see how 
successful it is.


[web2py] Re: Default controller function

2012-01-31 Thread pbreit
You pretty much need to add both a controller function and a view to add 
static pages like that.

Otherwise, you would need to program some sort of traffic cop to see the 
incoming request and manually render it with a view.

So create a controller content.py with something like this:

def index():
return response.render('content/%s' % request.args(0))

Put your views in views/content

Then a URL like:
http://localhost/content/about

Should map to the view at views/content/about.html


[web2py] Re: [OT] e-mail delivery strategies

2012-01-31 Thread pbreit
In the beginning, I think the service providers are pretty good if you can 
afford it. Some have free tiers and pricing usually starts around 
$10/month. If you're on RackSpace cloud, you get free SendGrid. Postmark, 
Amazon and MailGun are other providers.

[web2py] Re: Help with auth extra fields

2012-01-31 Thread Jarvert


Hi Massimo,
Thank you for the prompt reply.
It wasn't an indentation problem.

I made a silly mistake.
I didn't realize auth.define_tables() was already called in earlier
parts of the default code for db.py!
Once again thank you & the community for developing something so
awesome.





On Feb 1, 1:23 am, Massimo Di Pierro 
wrote:
> What if you just do:
>
> auth=Auth(db)
> auth.settings.extra_fields['auth_user']= [Field('Skype')]
> auth.define_tables()
>
> On Jan 31, 9:55 am, Jarvert  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I am new to web2py and have been enjoying it immensely.
>
> > I have been trying to add extra fields to the db.auth_user. In
> > particular, I am trying to associate additional profile details
> > like a "avatar" and other stats to a user...postal code..and so on.
>
> > I have tried in the db.py:
>
> > auth=Auth(db)
> > auth.settings.extra_fields[auth.settings.table_user_name]=
> > [Field('Skype')]
> > auth.define_tables()
>
> > as perhttp://stackoverflow.com/questions/7121146/web2py-custom-user-profile
>
> > The extra fields does not seem to show up when i inspect it through
> > the appadmin under db.auth_user.
> > Am I doing this completely wrong?
>
> > Could someone please help, thank you!


[web2py] Re: 2 Questions regarding auth

2012-01-31 Thread Anthony

>
> The controller above exposes multiple actions: 
> http://.../[app]/default/user/register 
> http://.../[app]/default/user/login 
> http://.../[app]/default/user/logout 
> http://.../[app]/default/user/profile 
> http://.../[app]/default/user/change_password 
> http://.../[app]/default/user/verify_email 
> http://.../[app]/default/user/retrieve_username 
> http://.../[app]/default/user/request_reset 
> http://.../[app]/default/user/reset_password 
> http://.../[app]/default/user/impersonate 
> http://.../[app]/default/user/groups 
> http://.../[app]/default/user/not_authorized_password 
>
> This is all really useful.  But, in the text there is no mention of 
> "the controller above."  Which controller is it?  Indeed, the 
> scaffolding app only appears to contain a very simple user() function 
> in default.py.
>

The "controller above" is indeed the "simple user() function" in default.py:

def user(): return dict(form=auth())


That controller does in fact expose all the functions listed above. Note, 
in all those URLs, "user" is the function, and the part of the URL after 
"user/" is an arg (i.e., request.args(0)). The function returns 
form=auth(). When auth() is called, it automatically extracts 
request.args(0) to figure out which of the auth functions has been 
requested and proceeds accordingly.
 

> from gluon.tools import * 
> auth = Auth(jodb) 
> auth.define_tables() 
>
> So, I don't have the hmac key.  How bad is this?  Let me guess:  the 
> passwords in the auth database are not being encrypted because there 
> is no encryption key.  When I go look at the raw table, the password 
> has certainly been hashed.  What key or salt is used when I have 
> specified (mis-specified, as the case may be) auth as I have?
>

If you don't specify an hmac key, I believe the CRYPT validator defaults to 
using gluon.utils.simple_hash 
(http://code.google.com/p/web2py/source/browse/gluon/utils.py#26), which is 
a simple md5 hash -- no key involved.

Anthony
 


[web2py] Error thrown using sample code from SQLFORM chapter of web2py book

2012-01-31 Thread monotasker
I'm trying to add a hidden form to a SQLFORM using the sample code on p. 
331 of the 4th edition book (pdf):

form.vars.a = request.vars.a
form = SQLFORM(..., hidden=dict(a='b'))

When I submit the form, though, I get an error because I'm calling the 
variable 'form' before assignment. If I reverse the order of these two 
lines (so that form is declared first) the form doesn't process the hidden 
field. 

My workaround was to write an onvalidation method that adds the hidden form 
during processing. But this feels like a hack. Is this really an error, or 
am I just missing something?


[web2py] Error thrown using sample code from SQLFORM chapter of web2py book

2012-01-31 Thread pbreit
I think the assignment should be in the if form.process().accepted: clause.


[web2py] Re: Default controller function

2012-01-31 Thread Massimo Di Pierro
You can always put the static pages into app/static/

On Jan 31, 6:51 pm, pbreit  wrote:
> You pretty much need to add both a controller function and a view to add
> static pages like that.
>
> Otherwise, you would need to program some sort of traffic cop to see the
> incoming request and manually render it with a view.
>
> So create a controller content.py with something like this:
>
> def index():
>     return response.render('content/%s' % request.args(0))
>
> Put your views in views/content
>
> Then a URL like:http://localhost/content/about
>
> Should map to the view at views/content/about.html


Re: [web2py] Re: [w2py-dev] model less apps (a blog example)

2012-01-31 Thread Bruno Rocha
Hi Bruce,

delete the database if the sample app created one, then replace
modules/datamodel/user.py with this https://gist.github.com/1714979

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: 2 Questions regarding auth

2012-01-31 Thread Lewis
Thanks.

So, would I expand the default form to include buttons to access the
other methods?  Not sure how to expose those...

Guess I am ok on hashing but should probably look at using the key.


Re: [web2py] Re: [w2py-dev] model less apps (a blog example)

2012-01-31 Thread Bruce Wade
Thanks that will do it, I was close to that exact same approach when I was
playing around today.

--
Regards,
Bruce

On Tue, Jan 31, 2012 at 7:54 PM, Bruno Rocha  wrote:

> Hi Bruce,
>
> delete the database if the sample app created one, then replace
> modules/datamodel/user.py with this https://gist.github.com/1714979
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Redbean-like ORM in web2py

2012-01-31 Thread Chnrxn
Thanks Anthony, that's exactly right. In fact, there is even no need
for us to call db.define_table('person') at all with RedBean. It would
look more like dal.insert(, =, ...) and
 gets created automatically if it does not exist.

The best use case IMO is the ability to store/insert variable
dictionaries like request.vars, say, when you want to have some
general debugging/monitoring for different controllers.

Looking at some of the examples from Massimo, it seems that it might
not be too difficult to implement the association manager with some
extra functions, as well as extending the db..insert() function
to support on-the-fly schema extensions. (Of course I'm saying this
from a very high level POV; I don't know how much work it would
actually take.)

On Jan 30, 11:13 pm, Anthony  wrote:
> On Monday, January 30, 2012 9:37:29 AM UTC-5, Massimo Di Pierro wrote:
>
> > You can create schemas on the fly with web2py (web2py will do the
> > alter table).
>
> I think in RedBean you don't have to define the schema at all. With the
> DAL, it would look something like:
>
> db.define_table('person')
> db.person.insert(name='John')
>
> Notice that the 'name' field was never defined before the insert -- the
> insert prompts the creation of the 'name' column in the 'person' table
> (type is inferred based on the data, and altered if necessary based on
> subsequent inserts). So, it enables use of a schema-based RDBMS more like a
> schema-less NoSQL db. This "fluid" mode is recommended in development only,
> after which, you are advised to "freeze" the
> schema:http://redbeanphp.com/manual/freeze. So, it's taking automatic
> migrations a step further and doing automatic (inferred) schema definitions
> as well.
>
> Anthony


[web2py] Re: 2 Questions regarding auth

2012-01-31 Thread Anthony
On Wednesday, February 1, 2012 12:23:54 AM UTC-5, Lewis wrote:
>
> Thanks. 
>
> So, would I expand the default form to include buttons to access the 
> other methods?  Not sure how to expose those...
>

You just have to add links pointing to those URLs (e.g., URL('default', 
'user', args='change_password')). Note, each of those functions is a method 
of the Auth class, so you can also create a special action for any given 
function by directly calling the method. For example:

def register():
return dict(form=auth.register())

Guess I am ok on hashing but should probably look at using the key.


Yes, hmac is recommended and will be more secure.

Anthony 


[web2py] Re: Nesting HTML tables

2012-01-31 Thread tsvim
Well apparently you're correct.
Nesting a table within a table is only possible if the inner table is 
within a td according to the HTML spec. (Not that it doesn't render ok in 
most browsers)
I was copying from some Google result on nested tables.
I managed to get my wanted result by setting a correct colspan on the td 
tag.

Thanks everyone.


[web2py] Re: First chapter that should be useful to some web2py users

2012-01-31 Thread amiroff
Please, keep up the series, very nicely done!

On Jan 24, 8:29 pm, "ma...@rockiger.com" 
wrote:
> Hello,
> the tutorial is making some progress:
>
> Begining with chapter 5, it should be interesting for web2py users, that
> are already familiar with the basics of web2py and want
> to learn about functional testing with selenium.
>
> Some links to start:
> Selenium setup:http://killer-web-development.com/section/4/3
> First tests:http://killer-web-development.com/section/5/1
>
> Again this is very basic, but might be interesting to someone.
>
> Best,
> Marco