[web2py] Trouble automatically updating dynamically generated image

2010-11-14 Thread G
Hello,
I am using web2py to monitor and control an instrument. I am
dynamically generating plots using matplotlib following the DNA
application example from SC2009 (http://www.web2py.com/examples/static/
sc/sc_dna_talk.pdf)

I was able to get the basic aspects working based on that example.
However, I want to automatically display new plots as new data is
available. I am using the following code in the view:


var auto_refresh = setInterval(
function()
{
$('#loaddiv').load('statusbox.load');
$('#threshpng').html('<img src="/myapp/default/dataThreshPlot.png">');
}, 5000);

loading...
png loading

The statusbox.load generates a table with some statistics about the
data, and this successfully updates every 5 seconds as desired.
However, the dataThreshPlot never gets refreshed, only the initial
version is displayed. (a timestamp is written to the plot when it is
generated so I can verify this fact).

If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png
the plot is properly generated and displayed each time I refresh the
page.

I have tried adding this code to the dataThreshPlot function in the
controller:

response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S
+", time.gmtime(time.time()+1))

to try to avoid caching, but still no luck.

I also tried making a very simple controller function as follows:

def dataThreshPage():
return dict(threshim= URL(r=request,f=dataThreshPlot))

and view:


and tested that localhost:8000/myapp/default/dataThreshPage  presents
the plot as expected.

I then modified the jquery refresh code to:


var auto_refresh = setInterval(
function()
{
$('#loaddiv').load('statusbox.load');
$('#threshpng').load('/myapp/default/dataThreshPage');
}, 5000);

loading...
png loading

but still no luck.

Any suggestions for how to get these plots to refresh?
Thank you,
G


[web2py] Re: Bug in saving changes to the about page for my application?

2010-11-14 Thread G
I have also encountered a similar problem. I have a View file called
status.load that I could not save changes to. By renaming it to
status.html, I could save changes as usual. It seems like some issue
with file types that are not recognized.

On Nov 14, 3:45 pm, Audra Rudys  wrote:
> I just downloaded Version 1.89.1  source code version of web2py to upgrade
> (I skipped a few versions, in case that matters.)  When I go to the "about"
> screen and click edit, I get an edit window and can type changes, but I
> can't save them.  I clicked the disk icon in the upper left corner, but
> nothing happens (date is not updated, changes are not saved.)  I tried
> CTRL-S, but an explorer window comes up asking me where to save the file.
>  (In CHROME browser the default name of the file is "edit myapplication
> ABOUT.htm"; in Firefox, it saves it as About.htm, so the original text is
> not touched and the timestamp on it is not updated.) I'm running in WinXP.
>  If this is not a bug but user error, please help me figure out how to save
> my changes.
>
> Thanks,
> Audra


[web2py] Re: Trouble automatically updating dynamically generated image

2010-11-16 Thread G
Hello again,
Is anyone else using matplotlib to generate dynamic plots for use with
web2py. Any pointers on a better way to do it that will allow dynamic
refreshing?
Thanks for any help,
G

On Nov 14, 3:42 pm, G  wrote:
> Hello,
> I am using web2py to monitor and control an instrument. I am
> dynamically generating plots using matplotlib following the DNA
> application example from SC2009 (http://www.web2py.com/examples/static/
> sc/sc_dna_talk.pdf)
>
> I was able to get the basic aspects working based on that example.
> However, I want to automatically display new plots as new data is
> available. I am using the following code in the view:
>
> 
> var auto_refresh = setInterval(
> function()
> {
> $('#loaddiv').load('statusbox.load');
> $('#threshpng').html('<img src="/myapp/default/dataThreshPlot.png">');}, 
> 5000);
>
> 
> loading...
> png loading
>
> The statusbox.load generates a table with some statistics about the
> data, and this successfully updates every 5 seconds as desired.
> However, the dataThreshPlot never gets refreshed, only the initial
> version is displayed. (a timestamp is written to the plot when it is
> generated so I can verify this fact).
>
> If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png
> the plot is properly generated and displayed each time I refresh the
> page.
>
> I have tried adding this code to the dataThreshPlot function in the
> controller:
>
> response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S
> +", time.gmtime(time.time()+1))
>
> to try to avoid caching, but still no luck.
>
> I also tried making a very simple controller function as follows:
>
> def dataThreshPage():
>     return dict(threshim= URL(r=request,f=dataThreshPlot))
>
> and view:
> 
>
> and tested that localhost:8000/myapp/default/dataThreshPage  presents
> the plot as expected.
>
> I then modified the jquery refresh code to:
>
> 
> var auto_refresh = setInterval(
> function()
> {
> $('#loaddiv').load('statusbox.load');
> $('#threshpng').load('/myapp/default/dataThreshPage');}, 5000);
>
> 
> loading...
> png loading
>
> but still no luck.
>
> Any suggestions for how to get these plots to refresh?
> Thank you,
> G


[web2py] Re: Trouble automatically updating dynamically generated image

2010-11-16 Thread G
Hello,
I read the slides and checked out the app, and it's great to see more
matplotlib/web2py examples. However, this does not address my use of
web2py for dynamically monitoring a system, which I am having some
trouble with. For example, suppose you wanted to create a "master
view" for your double-slit application, which would present a page
where each time someone ran a new double slit experiment with the
application, the page would update and show some plots from the result
of the double slit. Or perhaps some real-time statistics about all of
the experiments run so far. How would you implement something like
that? The code I posted below seems like it should work for this sort
of real time monitoring, but as I mentioned, I cannot get the images
to dynamically update.

I appreciate any suggestions anyone has.
Thanks,
G

On Nov 16, 10:17 am, mdipierro  wrote:
> I just gave a talk at Supercomputing about it. I will post the app and
> slides later today.
>
> On Nov 16, 10:06 am, G  wrote:
>
> > Hello again,
> > Is anyone else using matplotlib to generate dynamic plots for use with
> > web2py. Any pointers on a better way to do it that will allow dynamic
> > refreshing?
> > Thanks for any help,
> > G
>
> > On Nov 14, 3:42 pm, G  wrote:
>
> > > Hello,
> > > I am using web2py to monitor and control an instrument. I am
> > > dynamically generating plots using matplotlib following the DNA
> > > application example from SC2009 (http://www.web2py.com/examples/static/
> > > sc/sc_dna_talk.pdf)
>
> > > I was able to get the basic aspects working based on that example.
> > > However, I want to automatically display new plots as new data is
> > > available. I am using the following code in the view:
>
> > > 
> > > var auto_refresh = setInterval(
> > > function()
> > > {
> > > $('#loaddiv').load('statusbox.load');
> > > $('#threshpng').html('<img src="/myapp/default/dataThreshPlot.png">');}, 
> > > 5000);
>
> > > 
> > > loading...
> > > png loading
>
> > > The statusbox.load generates a table with some statistics about the
> > > data, and this successfully updates every 5 seconds as desired.
> > > However, the dataThreshPlot never gets refreshed, only the initial
> > > version is displayed. (a timestamp is written to the plot when it is
> > > generated so I can verify this fact).
>
> > > If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png
> > > the plot is properly generated and displayed each time I refresh the
> > > page.
>
> > > I have tried adding this code to the dataThreshPlot function in the
> > > controller:
>
> > > response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S
> > > +", time.gmtime(time.time()+1))
>
> > > to try to avoid caching, but still no luck.
>
> > > I also tried making a very simple controller function as follows:
>
> > > def dataThreshPage():
> > >     return dict(threshim= URL(r=request,f=dataThreshPlot))
>
> > > and view:
> > > 
>
> > > and tested that localhost:8000/myapp/default/dataThreshPage  presents
> > > the plot as expected.
>
> > > I then modified the jquery refresh code to:
>
> > > 
> > > var auto_refresh = setInterval(
> > > function()
> > > {
> > > $('#loaddiv').load('statusbox.load');
> > > $('#threshpng').load('/myapp/default/dataThreshPage');}, 5000);
>
> > > 
> > > loading...
> > > png loading
>
> > > but still no luck.
>
> > > Any suggestions for how to get these plots to refresh?
> > > Thank you,
> > > G
>
>


[web2py] Re: Trouble automatically updating dynamically generated image

2010-11-17 Thread G
Hello,
This looks like an interesting idea, I am interested in using
something like this in the future. For my immediate needs, I don't
mind having the client poll the server at regular intervals (every 10
seconds for example). As a last resort, I am using a  statement, but it seems like there must
be a better way with ajax/jquery load and setInterval.
Thanks for the pointer,
G

On Nov 16, 11:35 pm, dederocks  wrote:
> Hello,
>
> I guess this could be solved by implementing the APE (ajax-push)
> technology mentionned the other day by 
> Michele:http://www.ape-project.org/ajax-push.html.
> I'm working on it to see if this can be used to remotely control a
> webcam and send back pictures in real time.
> BR, André
>
> On 16 nov, 22:19, G  wrote:
>
> > Hello,
> > I read the slides and checked out the app, and it's great to see more
> > matplotlib/web2py examples. However, this does not address my use of
> > web2py for dynamically monitoring a system, which I am having some
> > trouble with. For example, suppose you wanted to create a "master
> > view" for your double-slit application, which would present a page
> > where each time someone ran a new double slit experiment with the
> > application, the page would update and show some plots from the result
> > of the double slit. Or perhaps some real-time statistics about all of
> > the experiments run so far. How would you implement something like
> > that? The code I posted below seems like it should work for this sort
> > of real time monitoring, but as I mentioned, I cannot get the images
> > to dynamically update.
>
> > I appreciate any suggestions anyone has.
> > Thanks,
> > G
>
> > On Nov 16, 10:17 am, mdipierro  wrote:
>
> > > I just gave a talk at Supercomputing about it. I will post the app and
> > > slides later today.
>
> > > On Nov 16, 10:06 am, G  wrote:
>
> > > > Hello again,
> > > > Is anyone else using matplotlib to generate dynamic plots for use with
> > > > web2py. Any pointers on a better way to do it that will allow dynamic
> > > > refreshing?
> > > > Thanks for any help,
> > > > G
>
> > > > On Nov 14, 3:42 pm, G  wrote:
>
> > > > > Hello,
> > > > > I am using web2py to monitor and control an instrument. I am
> > > > > dynamically generating plots using matplotlib following the DNA
> > > > > application example from SC2009 
> > > > > (http://www.web2py.com/examples/static/
> > > > > sc/sc_dna_talk.pdf)
>
> > > > > I was able to get the basic aspects working based on that example.
> > > > > However, I want to automatically display new plots as new data is
> > > > > available. I am using the following code in the view:
>
> > > > > 
> > > > > var auto_refresh = setInterval(
> > > > > function()
> > > > > {
> > > > > $('#loaddiv').load('statusbox.load');
> > > > > $('#threshpng').html('<img 
> > > > > src="/myapp/default/dataThreshPlot.png">');}, 5000);
>
> > > > > 
> > > > > loading...
> > > > > png loading
>
> > > > > The statusbox.load generates a table with some statistics about the
> > > > > data, and this successfully updates every 5 seconds as desired.
> > > > > However, the dataThreshPlot never gets refreshed, only the initial
> > > > > version is displayed. (a timestamp is written to the plot when it is
> > > > > generated so I can verify this fact).
>
> > > > > If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png
> > > > > the plot is properly generated and displayed each time I refresh the
> > > > > page.
>
> > > > > I have tried adding this code to the dataThreshPlot function in the
> > > > > controller:
>
> > > > > response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S
> > > > > +", time.gmtime(time.time()+1))
>
> > > > > to try to avoid caching, but still no luck.
>
> > > > > I also tried making a very simple controller function as follows:
>
> > > > > def dataThreshPage():
> > > > >     return dict(threshim= URL(r=request,f=dataThreshPlot))
>
> > > > > and view:
> > > > > 
>
> > > > > and tested that localhost:8000/myapp/default/dataThreshPage  presents
> > > > > the plot as expected.
>
> > > > > I then modified the jquery refresh code to:
>
> > > > > 
> > > > > var auto_refresh = setInterval(
> > > > > function()
> > > > > {
> > > > > $('#loaddiv').load('statusbox.load');
> > > > > $('#threshpng').load('/myapp/default/dataThreshPage');}, 5000);
>
> > > > > 
> > > > > loading...
> > > > > png loading
>
> > > > > but still no luck.
>
> > > > > Any suggestions for how to get these plots to refresh?
> > > > > Thank you,
> > > > > G
>
>


[web2py] tunneling over ssh causes incomplete page loads with apache

2010-11-22 Thread G
Hello,
I have a strange problem. My server is behind a fire wall so I must
use ssh tunnels to access web2py pages running on it. This works great
with the default webserver included with web2py. To achieve better
performance, I have now installed apache and got web2py working with
it after a few gotchas. Everything works fine on computers behind the
firewall. But now when I view the pages through the ssh tunnel (at
http://localhost:32197 where 32197 is the port that is tunneled
through ssh to the servers port 80), the pages do not seem to load
completely. Refreshing the page repeatedly shows that the page loads
to different points each time. Sometimes the page does load
completely, but most often not. It seems that the various static/.js
and .css files are often what fails to load all the way, though I've
seen the main content also fail to load. Is there perhaps some (very
short) timeout that is causing this somewhere? It would have to be
very short as the page loads only take a fraction of a second. I am
just testing with the basic welcome and admin apps. I have also
forwarded port 443 and find the same behavior there.

Any ideas?
Thanks,
G


[web2py] Re: tunneling over ssh causes incomplete page loads with apache

2010-11-22 Thread G
Interesting, that makes sense. Except why does it seem to work so well
with the built in web2py webserver but not apache. Is there a
configuration setting in apache that would make it act more like the
web2py server in this regard?
Thanks for the response.

On Nov 22, 2:15 pm, Phyo Arkar  wrote:
> Yes thats happen for me too
> seems that it is caused due to ssh tunnel is single connection where web
> request open multiple connections.
>
> Try testing with a page with no external css/js and it will work fine.
>
> There may be work around for ssh-tunnel not doing multiple requests .
>
> On Tue, Nov 23, 2010 at 2:43 AM, G  wrote:
> > Hello,
> > I have a strange problem. My server is behind a fire wall so I must
> > use ssh tunnels to access web2py pages running on it. This works great
> > with the default webserver included with web2py. To achieve better
> > performance, I have now installed apache and got web2py working with
> > it after a few gotchas. Everything works fine on computers behind the
> > firewall. But now when I view the pages through the ssh tunnel (at
> >http://localhost:32197where 32197 is the port that is tunneled
> > through ssh to the servers port 80), the pages do not seem to load
> > completely. Refreshing the page repeatedly shows that the page loads
> > to different points each time. Sometimes the page does load
> > completely, but most often not. It seems that the various static/.js
> > and .css files are often what fails to load all the way, though I've
> > seen the main content also fail to load. Is there perhaps some (very
> > short) timeout that is causing this somewhere? It would have to be
> > very short as the page loads only take a fraction of a second. I am
> > just testing with the basic welcome and admin apps. I have also
> > forwarded port 443 and find the same behavior there.
>
> > Any ideas?
> > Thanks,
> > G
>
>


[web2py] Re: web2py SSL + Apache + mod_wsgi issues on Ubuntu 8.08 VM machine

2010-11-22 Thread G
I ran into a problem with setting up SSL too which turned out to be
caused by an ssl.conf file that was overriding the web2py.conf
settings. I had similar messages in error.log, but as the [warn]
indicates, they do not seem to be fatal errors. The errors I found
were more like File does not exist.

On Nov 22, 4:38 pm, Hybride  wrote:
> Hi everyone,
>
> I have my head wrapped up with trying to set up SSL for web2py. I
> used, at first, the initial one-step deployment available for Ubuntu/
> debian servers. The SSL was the issue then, so I went through the
> entire step-by-step available on the official book. I still can't seem
> to get SSL to work. I use an ubuntu 8.08 virtual machine, apache +
> mod_wsgi.
>
> This is the results of uname: pypy.domain.com 2.6.24-21-xen #1 SMP
> x86_64 GNU/Linux
> I have "Listen 80" and "Listen 443" in my ports.conf
>
> And this is my web2py:
> 
>   ServerNamehttp://147.126.65.92/
>   #WSGIDaemonProcess web2py user=www-data group=www-data \
>         #                       display-name=%{GROUP}
>   WSGIProcessGroup web2py
>   WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
>
>   
>     AllowOverride None
>     Order Allow,Deny
>     Deny from all
>     
>       Allow from all
>     
>   
>
>   AliasMatch ^/([^/]+)/static/(.*) \
>            /home/www-data/web2py/applications/$1/static/$2
>   
>     Order Allow,Deny
>     Allow from all
>   
>
>   
>   Deny from all
>   
>
>   
>   Deny from all
>   
>
>   CustomLog /private/var/log/apache2/access.log common
>   ErrorLog /private/var/log/apache2/error.log
> 
>
> 
>   ServerNamehttp://147.126.65.92/
>   SSLEngine on
>
>   SSLCertificateFile /etc/apache2/ssl/server.crt
>   SSLCertificateKeyFile /etc/apache2/ssl/server.key
>
>   SSLProtocol -all +TLSv1 +SSLv3
>   SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
>
>   WSGIProcessGroup web2py
>
>   WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
>
>   
>     AllowOverride None
>     Order Allow,Deny
>     Deny from all
>     
>       Allow from all
>     
>   
>
>   AliasMatch ^/([^/]+)/static/(.*) \
>         /home/www-data/web2py/applications/$1/static/$2
>
>   
>     Order Allow,Deny
>     Allow from all
>   
>
>   CustomLog /private/var/log/apache2/access.log common
>   ErrorLog /private/var/log/apache2/error.log
>
>   SSLVerifyClient none
>   SSLProxyEngine off
>
>   
>       AddType application/x-x509-ca-cert      .crt
>       AddType application/x-pkcs7-crl         .crl
>   
>
> 
>
> The result of my error.log is:
>
> [Mon Nov 22 18:23:25 2010] [warn] RSA server certificate CommonName
> (CN) `pypy.domain.com' does NOT match server name!?
>
> Whether this is the common name or the IP name. Any and all help
> appreciated.


[web2py] Memory leak with scheduler.py and MySQL

2011-09-04 Thread G
Hello,
I am finding that when I start my scheduler.py workers, they steadily
consume more and more memory at a rate of about 100 KB every 3
seconds. After a day or so, the system grinds as all the memory is
consumed. I suspected the MySQL driver, but I have verified that the
leak occurs with both the pymysql and MySQLdb libaries. The leak seems
slower when using pymysql but I haven't investigated thourougly.

One thing that's different in my application is I use the scheduler
workers to do intensive computations on a remote server and then
return results. To decrease the latency, I have modified the worker
main loop to run every 100 ms. My guess is that one possible reason a
memory leak hasn't been reported before is that the scheduler defaults
to a much slower heartbeat. NOTE: I see the memory leak even when the
workers are not doing anything other than looping, so my computational
code can be ruled out. I have made a simple scheduler that has none of
my tasks, and it still displays the same memory leak.

Before I work on trying to demonstrate the problem with a standalone
example, does anyone have any suggestions of things to check? I am
surprised to find a memory leak since when using pymysql, everything
is in python.

Thanks,
G


[web2py] MySQL lost connection to server

2011-09-12 Thread G
Hi,
After leaving my app running for a while, when I come back to access
it, I get an error in Framework that is from pymysql reporting that
the connection to the server has been lost (because it timed out from
inactivity presumably). If I refresh the page a couple of times, the
error goes away. I assume this is because DAL opens a new connection
after finding that all the available connections have closed. This
provides a poor impression for users.
I have encountered this in non-web based code and so I wrap all of my
database accesses with a function that first trys to ping the
connection by doing a db.commit, and if it fails, reconnects to the
server. Can something like this be added to dal.py? Is there a better
way to handle this?

The exact source of the error is here

File "/home/dl/trunkw2p/web2py/gluon/main.py", line 506, in wsgibase
BaseAdapter.close_all_instances('commit')

and sometimes here:

File "/home/dl/trunkw2p/web2py/gluon/main.py", line 570, in wsgibase
BaseAdapter.close_all_instances('rollback')


Thanks,
G


[web2py] matplotlib image map using web2py

2011-06-28 Thread G
Hello,
I would like to make a clickable image map of a scatter plot in my
web2py application. The scatter plot will be dynamically generated. I
can use the technique that Massimo has shown many times to generate
matplotlib plots in web2py. The trouble is that the technique relies
on a controller that returns a cStringIO stream and simply sets the
headers for the browser to interpret the stream as a PNG image. This
works fine when you just need to generate a plot. But the techniques
for generating the corresponding clickable regions for an image map
require getting the pixel coordinates of the scatter points from the
plot.

Here are some examples of people generating clickable image maps with
matplotlib that I am referring to:
http://hackmap.blogspot.com/2008/06/pylab-matplotlib-imagemap.html
http://www.dalkescientific.com/writings/diary/archive/2005/04/24/interactive_html.html
http://www.pageofguh.org/random/668

And here is one of Massimo's examples of using matplotlib with web2py:
http://www.web2py.com/appliances/default/show/72

I appreciate any suggestions.

Thanks,
G


[web2py] Re: matplotlib image map using web2py

2011-06-29 Thread G
To follow up, if I were to go about this in a brute force manner, by
simply saving the dynamically generated figure to a randomly generated
file and then passing that file to an AREA MAP / IMG tag, where in the
web2py directory structure would be the recommended place to do so? I
suppose using the SQLLITE database might be a natural option. Any
opinions? Are there any examples of doing something like this? I
suppose it's vaguely similar to a photo album application, except the
photos are dynamically created and deleted after use.
Thanks,
G

On Jun 28, 4:50 pm, G  wrote:
> Hello,
> I would like to make a clickable image map of a scatter plot in my
> web2py application. The scatter plot will be dynamically generated. I
> can use the technique that Massimo has shown many times to generate
> matplotlib plots in web2py. The trouble is that the technique relies
> on a controller that returns a cStringIO stream and simply sets the
> headers for the browser to interpret the stream as a PNG image. This
> works fine when you just need to generate a plot. But the techniques
> for generating the corresponding clickable regions for an image map
> require getting the pixel coordinates of the scatter points from the
> plot.
>
> Here are some examples of people generating clickable image maps with
> matplotlib that I am referring 
> to:http://hackmap.blogspot.com/2008/06/pylab-matplotlib-imagemap.htmlhttp://www.dalkescientific.com/writings/diary/archive/2005/04/24/inte...http://www.pageofguh.org/random/668
>
> And here is one of Massimo's examples of using matplotlib with 
> web2py:http://www.web2py.com/appliances/default/show/72
>
> I appreciate any suggestions.
>
> Thanks,
> G


[web2py] Is the classic green and black layout still available?

2011-07-25 Thread G
Hi,
I think the former green and black default layout looks very nice, so
I'd like to use it, but it doesn't seem to be available in the recent
versions, nor on the page to download new layouts. Is this layout
still available somewhere?
Here is an image showing what I mean 
http://web2py.com/book/static/book_images_png/plugin_wiki_crud.png

Thanks,
G


[web2py] Trouble with components

2011-08-03 Thread G
Hello,
I am trying to make a simple component which has a form that contains
just buttons. It seems to work OK when I use LOAD(... ajax=False) and
have only one component on my page. However, I'd like to have multiple
components on one page. When I tried that, still with ajax=False,
everything looks OK, but the form doesn't do anything (that is, the
action that's supposed to happen when a button is pushed never
happens). Similarly, if I set ajax=True, the same problem occurs (no
action).
I then tried setting ajax_trap = True after which when I click a
button in the component, the component disappears and the text
"invalid request" appears. I found this very difficult to debug, but
finally by putting a print statement in the rewrites.py file I found
that the path that was trying to be accessed looks as follows, from
which it's why it is an invalid request:

/devel/default/(,)

What is the correct way to have multiple components with simple
customized forms on a single page?

The simple component I am using has the following function which uses
the generic.load:

def inits():
obs = _getObs()
form = FORM(TABLE(TR(TD(TAG.BUTTON("Reset
Receiver",_type="submit",_name="initRSS", _value="yes")),
TD(TAG.BUTTON("Reset DSP",_type="submit",_name="initDSP",
_value="yes")),
TD(TAG.BUTTON("Auto Level",_type="submit",_name="autoLevel",
_value="yes")),
TD(TAG.BUTTON("Auto Equalize",_type="submit",_name="autoEQ",
_value="yes")
if form.accepts(request.vars,session):
if request.vars.initRSS == 'yes':
print "init RSS"
obs.simpleRSSSetup()
if request.vars.initDSP == 'yes':
print "init DSP"
obs.simpleDSPSetup()
if request.vars.autoLevel == 'yes':
print "autoLevel"
obs.autoLevel()
if request.vars.autoEQ == 'yes':
print "autoEQ"
obs.autoEQ()
return dict(form=form)

I have a second similar component. I include them both in the larger
page as:
{{=LOAD('default','inits.load')}}
{{=LOAD('default','posControl.load')}}

Thank you for any suggestions on how to make this work.
G


[web2py] Re: Trouble with components

2011-08-03 Thread G
I just tried a single component with ajax=True and found that it was
not responding.
Digging more deeply, I am finding that request.vars includes only
_formname="default" and _formkey=. Only with a single
form and ajax=False do I see the expected autoEQ = "yes".

Any idea what's going on?
Thanks,
G

On Aug 3, 9:13 pm, pbreit  wrote:
> I think with ajax=False you're going to run into problems because the end
> result is both of the forms on one page of HTML and the controller might get
> confused on which to handle.
>
> But I would think ajax=True should work. ajax_trap should be unnecessary.
>
> Can you get one form to work by itself with ajax=True?


[web2py] Re: Trouble with components

2011-08-03 Thread G
Hmm, so it sounds like components with multiple buttons are basically
not supported easily. I am writing an application to control a bunch
of scientific equipment. For each piece of equipment I was planning to
make one component to monitor and control it, and then put all these
components on one web page. Most of the controls make sense to
implement as buttons.
Does anyone have a suggestion of a better way to organize such an
application to play better with web2py etc.?
Thanks again,
G

On Aug 3, 10:43 pm, Anthony  wrote:
> Forms in ajax components and non-ajax components with ajax_trap=True are
> submitted via ajax, and the form variables are serialized via the jQuery
> .serialize() method. As explained here (http://api.jquery.com/serialize/),
> the .serialize() method doesn't know what triggered the form submission, so
> it cannot include the values of any submit buttons. For now, here is one
> possible workaround using a hidden 
> field:http://forum.jquery.com/topic/submit-event-serialize-and-submit-butto
> Perhaps we can come up with a more general solution.
>
> Anthony
>
> On Wednesday, August 3, 2011 11:46:09 PM UTC-4, G wrote:
> > Hello,
> > I am trying to make a simple component which has a form that contains
> > just buttons. It seems to work OK when I use LOAD(... ajax=False) and
> > have only one component on my page. However, I'd like to have multiple
> > components on one page. When I tried that, still with ajax=False,
> > everything looks OK, but the form doesn't do anything (that is, the
> > action that's supposed to happen when a button is pushed never
> > happens). Similarly, if I set ajax=True, the same problem occurs (no
> > action).
> > I then tried setting ajax_trap = True after which when I click a
> > button in the component, the component disappears and the text
> > "invalid request" appears. I found this very difficult to debug, but
> > finally by putting a print statement in the rewrites.py file I found
> > that the path that was trying to be accessed looks as follows, from
> > which it's why it is an invalid request:
>
> > /devel/default/(,)
>
> > What is the correct way to have multiple components with simple
> > customized forms on a single page?
>
> > The simple component I am using has the following function which uses
> > the generic.load:
>
> > def inits():
> >     obs = _getObs()
> >     form = FORM(TABLE(TR(TD(TAG.BUTTON("Reset
> > Receiver",_type="submit",_name="initRSS", _value="yes")),
> >         TD(TAG.BUTTON("Reset DSP",_type="submit",_name="initDSP",
> > _value="yes")),
> >         TD(TAG.BUTTON("Auto Level",_type="submit",_name="autoLevel",
> > _value="yes")),
> >         TD(TAG.BUTTON("Auto Equalize",_type="submit",_name="autoEQ",
> > _value="yes")
> >     if form.accepts(request.vars,session):
> >         if request.vars.initRSS == 'yes':
> >             print "init RSS"
> >             obs.simpleRSSSetup()
> >         if request.vars.initDSP == 'yes':
> >             print "init DSP"
> >             obs.simpleDSPSetup()
> >         if request.vars.autoLevel == 'yes':
> >             print "autoLevel"
> >             obs.autoLevel()
> >         if request.vars.autoEQ == 'yes':
> >             print "autoEQ"
> >             obs.autoEQ()
> >     return dict(form=form)
>
> > I have a second similar component. I include them both in the larger
> > page as:
> > {{=LOAD('default','inits.load')}}
> > {{=LOAD('default','posControl.load')}}
>
> > Thank you for any suggestions on how to make this work.
> > G
>
>


[web2py] Re: Trouble with components

2011-08-04 Thread G
I think I found a workable (but slightly annoying) solution: create
several mini-forms that only have the submit button, each with a
different form name. Then I can just use many
if form_blah.accepts(request.vars, session, formname='form_blah'):
clauses. I'd still be interested in knowing if there is a better way.
Another idea I toyed with was using jQuery to connect the .click
action of a button to cause a jQuery.post(URL('myfunction'),
{button_name : "yes"}) to send the button press to myfunction, but I'm
new to jQuery, so didn't put much time into trying it and don't know
if it would work.
Thanks,
G

On Aug 4, 2:23 am, pbreit  wrote:
> Coupla other 
> approaches:http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesn...http://stackoverflow.com/questions/4007942/jquery-serializearray-does...
>
> I'm surprised Jquery doesn't provide better support for this. Seems like a
> common pattern.


[web2py] Re: Trouble with components

2011-08-04 Thread G
Hi Massimo,
Thank you for the suggestions. I have implemented both, but neither
helps with the original problem of having components with multiple
buttons work with ajax=True. My new controller generates several forms
each with just one button and with distinct formnames. It has an if
form.accepts clause for each form to do the required action, and then
returns all the forms to the view to be properly formatted. It seems a
bit clumsy, but also seems to be working.
Thanks again,
G

On Aug 4, 4:36 pm, Massimo Di Pierro 
wrote:
> if you do not need a view and your component only displays the form
> you can just "return form" and pypass the generic view. It will be
> faster. I also suggest you use ajax=True. Always call the component
> directly as a test that it is working.
>
> On Aug 4, 6:33 pm, G  wrote:
>
> > I think I found a workable (but slightly annoying) solution: create
> > several mini-forms that only have the submit button, each with a
> > different form name. Then I can just use many
> > if form_blah.accepts(request.vars, session, formname='form_blah'):
> > clauses. I'd still be interested in knowing if there is a better way.
> > Another idea I toyed with was using jQuery to connect the .click
> > action of a button to cause a jQuery.post(URL('myfunction'),
> > {button_name : "yes"}) to send the button press to myfunction, but I'm
> > new to jQuery, so didn't put much time into trying it and don't know
> > if it would work.
> > Thanks,
> > G
>
> > On Aug 4, 2:23 am, pbreit  wrote:
>
> > > Coupla other 
> > > approaches:http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesn..
>
> > > I'm surprised Jquery doesn't provide better support for this. Seems like a
> > > common pattern.
>
>


[web2py] Re: Trouble with components

2011-08-05 Thread G
Having many small forms is actually working out pretty well, and seems
to be a resonable solution. It was not intuitive to me, but I think
it's just a disconnect between the way I would do things in a GUI
framework versus the way things need to be done for web applications.
By the way, I think it would be helpful to many people to have a
tutorial that approaches web2py (or another framework) from the point
of transitioning from a GUI framework to the web. As it is, the web2py
book seems to assume a lot of familiarity with creating web
applications and less familiarity with Python. I imagine several
people like me are in the opposite situation.
Thanks for the help and the great work,
G

On Aug 5, 3:34 am, Massimo Di Pierro 
wrote:
> I know. They were just regular good practice suggestions. Sorry. Will
> look for a solution.
>
> On Aug 4, 6:44 pm, G  wrote:
>
> > Hi Massimo,
> > Thank you for the suggestions. I have implemented both, but neither
> > helps with the original problem of having components with multiple
> > buttons work with ajax=True. My new controller generates several forms
> > each with just one button and with distinct formnames. It has an if
> > form.accepts clause for each form to do the required action, and then
> > returns all the forms to the view to be properly formatted. It seems a
> > bit clumsy, but also seems to be working.
> > Thanks again,
> > G
>
> > On Aug 4, 4:36 pm, Massimo Di Pierro 
> > wrote:
>
> > > if you do not need a view and your component only displays the form
> > > you can just "return form" and pypass the generic view. It will be
> > > faster. I also suggest you use ajax=True. Always call the component
> > > directly as a test that it is working.
>
> > > On Aug 4, 6:33 pm, G  wrote:
>
> > > > I think I found a workable (but slightly annoying) solution: create
> > > > several mini-forms that only have the submit button, each with a
> > > > different form name. Then I can just use many
> > > > if form_blah.accepts(request.vars, session, formname='form_blah'):
> > > > clauses. I'd still be interested in knowing if there is a better way.
> > > > Another idea I toyed with was using jQuery to connect the .click
> > > > action of a button to cause a jQuery.post(URL('myfunction'),
> > > > {button_name : "yes"}) to send the button press to myfunction, but I'm
> > > > new to jQuery, so didn't put much time into trying it and don't know
> > > > if it would work.
> > > > Thanks,
> > > > G
>
> > > > On Aug 4, 2:23 am, pbreit  wrote:
>
> > > > > Coupla other 
> > > > > approaches:http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesn..
>
> > > > > I'm surprised Jquery doesn't provide better support for this. Seems 
> > > > > like a
> > > > > common pattern.
>
>


[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-10 Thread G
Massimo,
The scheduler.py is just what I needed for my application. The one
problem I have is that in most of my work, the data type I pass around
everywhere is a NumPy array, which I have found cannot be serialized
by SimpleJSON. Numpy has it's own serialization which works very well.
It seems like it might be easiest to extend SimpleJSON to first
serialize a numpy array to a binary string using np.save and then pass
the string to the JSON encoder. Will this work for the binary strings?
The other issue is how to decide on the receiving end if the string
should be passed to np.load.

I appreciate any ideas.
Thanks,
G

On Aug 8, 7:28 am, Massimo Di Pierro 
wrote:
> ## preambole
>
> I have been working on porting django-celery to 
> web2py-celery.http://code.google.com/p/web2py-celery
> There are a few issues to resolve and I am working on it.
>
> Yet I found it to be overkill for most users. It has lots of
> dependencies (for example RabbitMQ) and it is not easy to manage. If
> you do not need a huge number of worker nodes there may be a better
> solution.
>
> So  I added this to trunk:
>
> gluon/scheduler.py
>
> This email is a request for comments as I think this should replace te
> current cron mechanism.
>
> ## What is it?
> It is a lightweight replacement for celery that uses the database
> instead of queues to schedule tasks and uses the default web2py admin
> interface to allow you to schedule tasks. It consists of a single file
> and has no dependencies.
>
> ## How does it work?
>
> For any existing
> app
>
> Create File: app/models/scheduler.py
> ==
> from gluon.scheduler import
> Scheduler
>
> def
> demo1(*args,**vars):
>     print 'you passed args=%s and vars=%s' % (args,
> vars)
>     return
> 'done!'
>
> def
> demo2():
>
> 1/0
>
> scheduler =
> Scheduler(db,dict(demo1=demo1,demo2=demo2))
> =
>
> Create File: app/modules/scheduler.py
> ==
> scheduler.worker_loop()
> =
>
> ## run worker nodes
> with:
> python web2py.py -S app -M -N -R applications/app/modules/
> scheduler.py
>
> ## schedule jobs
> usinghttp://127.0.0.1:8000/scheduler/appadmin/insert/db/task_scheduled
>
> ## monitor scheduled
> jobshttp://127.0.0.1:8000/scheduler/appadmin/select/db?query=db.task_sche...
>
> ## view completed
> jobshttp://127.0.0.1:8000/scheduler/appadmin/select/db?query=db.task_run
>
> Compared to celery it lacks the ability to bind tasks and workers ,
> remotely interrupt tasks and set timeout, yet these features can be
> added easily and I will so eventually.
>
> Please let me know what you think.
>
> Massimo


[web2py] What is the intent of task_scheduled.name?

2011-08-11 Thread G
Hello,
I wonder what the intent of the task_scheduled.name field is in the
new scheduler.py. Specifically, why is it required that it be unique?
I see two disadvantages and no advantage, so I'm wondering what I'm
missing.
The first, and most important, disadvantage is that when
programatically submitting tasks, one must come up with unique names.
This isn't hard (using the time etc.) but seems pointless.

Second, in my application, the user can submit tasks to the server.
I'd like to give the tasks a user friendly name that is displayed when
the user monitors the status of the tasks. I thought the name field
would be ideal for this, but if the user wants to submit two of the
same type of task, the name would conflict unless it has something
appended to it to make it unique. The "something appended" detracts
from the user freindlyness of the field. I could solve this by adding
another table that refrences task_scheduled and holds the user
friendly name.

I'm wondering if the intent is to prevent duplicate task submission,
but it seems more logical to me to allow multiple task submission and
have the user avoid it if necessary rather than making the DB enforce
a rule that requires a workaround to enable multiple task submissions.

Thanks,
G


[web2py] Help with DAL query

2011-08-12 Thread G
Hi,
What is the right way to do the following type of query with DAL,
avoiding the for loop?

ids = db(db.task_run.task_scheduled ==
db.task_scheduled.id)\
(db.task_scheduled.group_name == 'status')\
(db.task_run.start_time
+status_expiration

[web2py] Problem using MySQL with scheduler.py

2011-08-13 Thread G
Hello,
I just tried to use scheduler.py with MySQL instead of SQLite and ran
into this error:

NotSupportedError: (1235, "This version of MySQL doesn't yet support
'LIMIT & IN/ALL/ANY/SOME subquery'")

The MySQL server version is 5.0.77. Searching on the web, it seems
this limitation is common. Is there a way to work around the issue?
The offending SQL looks like this:

UPDATE task_scheduled SET
status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
(task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
(task_scheduled.next_run_time < '2011-08-13 09:33:01')) AND
(((task_scheduled.assigned_worker_name = '') OR
(task_scheduled.assigned_worker_name IS NULL)) OR
(task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
OFFSET 0));

I'm pretty sure this is coming from the massively complex query in
assign_next_task.

Thanks,
G


[web2py] Re: Problem using MySQL with scheduler.py

2011-08-13 Thread G
As a quick workaround, this change in assign_next_task seems to do the
trick:

subselect = db(query).select(
db.task_scheduled.id,limitby=(0,1),
orderby=db.task_scheduled.next_run_time)
for row in subselect:
db(db.task_scheduled.id == row.id).update(
status=RUNNING,
assigned_worker_name=self.worker_name,
last_run_time=datetime.now)

On Aug 13, 11:47 am, Massimo Di Pierro 
wrote:
> I have MySQL, it is full of caveats like this. Can somebody check
> postgresql?
> If this is just a mysql issue, we'll deal with it as an exception and
> find a workaround.
>
> On 13 Ago, 04:56, G  wrote:
>
> > Hello,
> > I just tried to use scheduler.py with MySQL instead of SQLite and ran
> > into this error:
>
> > NotSupportedError: (1235, "This version of MySQL doesn't yet support
> > 'LIMIT & IN/ALL/ANY/SOME subquery'")
>
> > The MySQL server version is 5.0.77. Searching on the web, it seems
> > this limitation is common. Is there a way to work around the issue?
> > The offending SQL looks like this:
>
> > UPDATE task_scheduled SET
> > status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
> > b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
> > (task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
> > WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
> > 'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
> > (task_scheduled.next_run_time < '2011-08-13 09:33:01')) AND
> > (((task_scheduled.assigned_worker_name = '') OR
> > (task_scheduled.assigned_worker_name IS NULL)) OR
> > (task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
> > b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
> > OFFSET 0));
>
> > I'm pretty sure this is coming from the massively complex query in
> > assign_next_task.
>
> > Thanks,
> > G
>
>


[web2py] MySQL query not reflecting actual state of db

2011-08-13 Thread G
Hello,
I am using a loop like this to wait for a scheduled task to complete:

query = schdb.task_scheduled.id == id
query &= ((schdb.task_scheduled.status == 'queued') |
(schdb.task_scheduled.status == 'running'))

while schdb(query).count():
 time.sleep(0.1) #wait for task to run

This worked perfectly when schdb was on SQLite, but now I am using
MySQL so the workers can run on different machines. The loop goes on
forever. If I display the contents of schdb(query).select() in the
loop, I see that it does indeed continuously show the status is
'running'. However, when I look at the database with MysQL Query
Browser, I can see that the task completed normally and updated the
status to 'completed'. I checked to make sure there are no missing
db.commit() statements.

Any ideas what could be causing schdb(query) to not reflect the true
state of the database?

Thanks,
G


[web2py] Re: MySQL query not reflecting actual state of db

2011-08-13 Thread G
Hello again,
It seems that db.commit() is necessary to get the query to reflect the
changed state of the database for some reason.

The simple code at the end of this message illustrates the problem.
Starting two ipython sessions, and running side1() in one, and then
side2() in the other, if the db.commit() line in the side1 loop is
removed, it will loop forever even though the database is actually
updated by side2.

This work around works, but I'd like to understand what's going on.

Thanks,
G


 dbtest.py ===

from gluon import *
import time
db = DAL('mysql://web2py:web2py@localhost:33306/web2py',
   folder = '/home/dl/trunkw2p/web2py/applications/
devel/databases')

db.define_table(
'test',
Field('status',requires=IS_NOT_EMPTY()))

def side1():

id = db.test.insert(status='queued')
db.commit()
query = (db.test.id == id) & ((db.test.status == 'start') |
(db.test.status == 'queued'))
while db(query).count():
print "query", [str(x) for x in db(query).select()]
db.commit()  # !!! Comment out this line and this while loop
will never exit
time.sleep(0.1)
print "done"

def side2():
id = db(db.test.id>0).select().last().id
print "found id",id
time.sleep(5)
db(db.test.id == id).update(status='start')
db.commit()
print "finishing"
time.sleep(5)
db(db.test.id == id).update(status='done')
db.commit()
print "finished"


[web2py] Re: Problem using MySQL with scheduler.py

2011-08-14 Thread G
Hi Massimo,
The new code you offered causes a compaint about bad MySQL syntax.

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near ';))' at line 1")

Changing update to _update, the SQL generated is:

UPDATE task_scheduled SET
status='running',assigned_worker_name='crabby#9d4d2ad8-0d56-4191-
b241-3894ef45a2c2',last_run_time='2011-08-15 00:27:25' WHERE
(task_scheduled.id = (SELECT  task_scheduled.id FROM task_scheduled
WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
'queued')) AND (task_scheduled.group_name IN ('status','main'))) AND
(task_scheduled.next_run_time < '2011-08-15 00:27:25')) AND
(((task_scheduled.assigned_worker_name = '') OR
(task_scheduled.assigned_worker_name IS NULL)) OR
(task_scheduled.assigned_worker_name = 'crabby#9d4d2ad8-0d56-4191-
b241-3894ef45a2c2'))) ORDER BY task_scheduled.next_run_time LIMIT 1
OFFSET 0;));

It looks like the raw command is producing a semicolon at the end.

However, I also tried running the same command directly with MySQL
Query Broswer except without the extra semicolon so the end was:
LIMIT 1 OFFSET 0));

This resulted in an error number 1093: "You can't specify target table
'task_scheduled' for update in FROM clause"

So it looks like this command also run's into a MySQL limitation...

G


On Aug 14, 10:49 pm, Massimo Di Pierro 
wrote:
> Can you help me test if replaceing this:
>
>         subselect = db(query)._select(
>             db.task_scheduled.id,limitby=(0,1),
>             orderby=db.task_scheduled.next_run_time)
>         db(db.task_scheduled.id.belongs(subselect)).update(
>             status=RUNNING,
>             assigned_worker_name=self.worker_name,
>             last_run_time=datetime.now)
>
> with this
>
>         from gluon.dal import raw
>         subselect = db(query)._select(
>             db.task_scheduled.id,limitby=(0,1),
>             orderby=db.task_scheduled.next_run_time)
>         db(db.task_scheduled.id == raw(subselect)).update(
>             status=RUNNING,
>             assigned_worker_name=self.worker_name,
>             last_run_time=datetime.now)
>
> works and fixed the problem with mysql?
>
> On Aug 13, 4:56 am, G  wrote:
>
> > Hello,
> > I just tried to use scheduler.py with MySQL instead of SQLite and ran
> > into this error:
>
> > NotSupportedError: (1235, "This version of MySQL doesn't yet support
> > 'LIMIT & IN/ALL/ANY/SOME subquery'")
>
> > The MySQL server version is 5.0.77. Searching on the web, it seems
> > this limitation is common. Is there a way to work around the issue?
> > The offending SQL looks like this:
>
> > UPDATE task_scheduled SET
> > status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
> > b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
> > (task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
> > WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
> > 'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
> > (task_scheduled.next_run_time < '2011-08-13 09:33:01')) AND
> > (((task_scheduled.assigned_worker_name = '') OR
> > (task_scheduled.assigned_worker_name IS NULL)) OR
> > (task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
> > b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
> > OFFSET 0));
>
> > I'm pretty sure this is coming from the massively complex query in
> > assign_next_task.
>
> > Thanks,
> > G
>
>


[web2py] Re: MySQL query not reflecting actual state of db

2011-08-14 Thread G
What you say makes sense in cases where the databse is being modified
(update/insert/delete, etc). But in this case, the query in the loop
of side1() does not change the database state, it's simply looking for
a change in the database, so I wouldn't think it would require a
db.commit.

On Aug 14, 2:44 pm, Jay  wrote:
> This is required because you are using the DAL outside web2py
> framework,
>
> """
> from gluon import *
> import time
> db = DAL('mysql://web2py:web2p ...
> """
>
> When used like above, you have to call db.commit to complete the
> transaction.
>
> Normally all database insert/updates/deletes are committed at the end
> of each action by the framework.


[web2py] Time intervals with MySQL and DAL

2011-08-23 Thread G
Hello,
I've noticed that the cleanup task in scheduler.py is not working for
me. Looking into it, it appears that the handling of time intervals in
MySQL through DAL is not being done properly.

This code
db(db.task_scheduled.status.belongs(statuses)) \
(db.task_scheduled.last_run_time+60

[web2py] Re: Time intervals with MySQL and DAL

2011-08-24 Thread G
Sorry to repost but I was surprised there were no responses. It seems
like time interval arithmetic must be fairly common for web2py
applications. Has no one else run into a similar problem?
Thanks,
G

On Aug 23, 8:27 am, G  wrote:
> Hello,
> I've noticed that the cleanup task in scheduler.py is not working for
> me. Looking into it, it appears that the handling of time intervals in
> MySQL through DAL is not being done properly.
>
> This code
> db(db.task_scheduled.status.belongs(statuses)) \
> (db.task_scheduled.last_run_time+60
> generates the following sql
>
> SELECT  task_scheduled.id, task_scheduled.name,
> task_scheduled.group_name, task_scheduled.status, task_scheduled.func,
> task_scheduled.args, task_scheduled.vars, task_scheduled.enabled,
> task_scheduled.start_time, task_scheduled.next_run_time,
> task_scheduled.stop_time, task_scheduled.repeats,
> task_scheduled.period, task_scheduled.timeout,
> task_scheduled.times_run, task_scheduled.last_run_time,
> task_scheduled.assigned_worker_name FROM task_scheduled WHERE
> ((task_scheduled.status IN ('completed')) AND
> ((task_scheduled.last_run_time + '60') < '2011-08-23 15:01:38'));
>
> However, if I execute the following in MySQL:
>
> SELECT last_run_time + '60' < '2011-08-23 15:01:38' FROM
> task_scheduled ORDER BY ID DESC LIMIT 1;
>
> I get all zeros and MySQL even provides a warning about incorrect
> DOUBLE value '2011-08-23 15:01:38'
>
> If you do
> SELECT '2011-08-23 15:01:38' + 60;
> you also get this warning and the result is meaningless 2071.
>
> Is this an error in the MySQL adapter for DAL or is the query missing
> something to explicitly tell MySQL to do time interval arithmatic?
>
> Thanks,
> G


[web2py] Understanding Rocket Threads

2011-08-24 Thread G
Hi,
First a little background: My application involves displaying and auto-
refreshing data both in the form of text from .load components and
dynamically generated images. I use JavaScript setInterval calls so
that ideally the refreshes should occur some time after the last
refresh completes. As it turns out, this does not work for the images
because using jQuery to update the .attr with the new img src returns
immediately, not after the image is loaded.
Anyway, the amount of time required to generate these images and text
data can be somewhat random, so I'm finding that my site will work for
a while, but eventually the long duration requests will pile up and
the site becomes unresponsive. Interestingly, the admin interface is
still as responsive as usual. I also notice that killing web2py will
not cause a clean exit, there will still be a thread working furiously
on the queued requests.

Thus it looks like rocket is using only one thread for the requests on
the main page, while the other threads sit idle and ready to service
other pages e.g. the admin interface. I tried to look through the code
of rocket.py to decide if this is indeed the case, but I wasn't able
to conclude one way or another. Since the admin interface is still
responsive, this does not appear to be an issue of the global
interpreter lock.

I found that starting many web2py servers on different ports, and then
directing the refresh calls to use a dedicated server for each data
source alleviated the problem somewhat, further suggesting to me that
only one thread is being used per session/browser/whatever to call it.

I expect to have no more than 2 users at a time for my application, so
I was hoping Rocket would be sufficient for this application. Would I
have better luck with apache or the like? I appreciate any advice on
the matter.

The code I'm using in the view to refresh the data is listed below

Thank you for the help,
G

View: --- default/index.html



{{=LOAD('default','calc3.load')}}



jQuery(window).load(function()
{setCalc1Timeout();setCalc2Timeout();setCalc3Timeout()});

function updateCalc3() {
 
jQuery('#test3').load('{{=URL("default","calc3.load")}}',setCalc3Timeout);
}
function setCalc3Timeout() {
setTimeout(updateCalc3, 2000);
}

function setCalc2Timeout() {
setTimeout(updateCalc2,5000);
}
function updateCalc2() {
d = new Date();
jQuery('#test2').attr('src',"calc2.png"+"?"+d.getTime());
setCalc2Timeout();
}

function setCalc1Timeout() {
setTimeout(updateCalc1,5000);
}
function updateCalc1() {
d = new Date();
jQuery('#test1').attr('src',"calc1.png"+"?"+d.getTime());
setCalc1Timeout();
}




[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread G
I should also mention I'm open to other suggestions to alleviate this
problem. The end goal is to display information (text or image) then
request an update, and when it's ready, display the new text/
information.

G

On Aug 24, 11:39 am, G  wrote:
> Hi,
> First a little background: My application involves displaying and auto-
> refreshing data both in the form of text from .load components and
> dynamically generated images. I use JavaScript setInterval calls so
> that ideally the refreshes should occur some time after the last
> refresh completes. As it turns out, this does not work for the images
> because using jQuery to update the .attr with the new img src returns
> immediately, not after the image is loaded.
> Anyway, the amount of time required to generate these images and text
> data can be somewhat random, so I'm finding that my site will work for
> a while, but eventually the long duration requests will pile up and
> the site becomes unresponsive. Interestingly, the admin interface is
> still as responsive as usual. I also notice that killing web2py will
> not cause a clean exit, there will still be a thread working furiously
> on the queued requests.
>
> Thus it looks like rocket is using only one thread for the requests on
> the main page, while the other threads sit idle and ready to service
> other pages e.g. the admin interface. I tried to look through the code
> of rocket.py to decide if this is indeed the case, but I wasn't able
> to conclude one way or another. Since the admin interface is still
> responsive, this does not appear to be an issue of the global
> interpreter lock.
>
> I found that starting many web2py servers on different ports, and then
> directing the refresh calls to use a dedicated server for each data
> source alleviated the problem somewhat, further suggesting to me that
> only one thread is being used per session/browser/whatever to call it.
>
> I expect to have no more than 2 users at a time for my application, so
> I was hoping Rocket would be sufficient for this application. Would I
> have better luck with apache or the like? I appreciate any advice on
> the matter.
>
> The code I'm using in the view to refresh the data is listed below
>
> Thank you for the help,
> G
>
> View: --- default/index.html
> 
>
> {{=LOAD('default','calc3.load')}}
> 
> 
> 
> jQuery(window).load(function()
> {setCalc1Timeout();setCalc2Timeout();setCalc3Timeout()});
>
> function updateCalc3() {
>
> jQuery('#test3').load('{{=URL("default","calc3.load")}}',setCalc3Timeout);
>     }
> function setCalc3Timeout() {
>     setTimeout(updateCalc3, 2000);
>     }
>
> function setCalc2Timeout() {
>         setTimeout(updateCalc2,5000);
>     }
> function updateCalc2() {
>         d = new Date();
>         jQuery('#test2').attr('src',"calc2.png"+"?"+d.getTime());
>         setCalc2Timeout();
>     }
>
> function setCalc1Timeout() {
>         setTimeout(updateCalc1,5000);
>     }
> function updateCalc1() {
>         d = new Date();
>         jQuery('#test1').attr('src',"calc1.png"+"?"+d.getTime());
>         setCalc1Timeout();
>     }
> 


[web2py] Debugging RestrictedErrors

2011-08-24 Thread G
Hello,
I am occasionally getting errors like the followng:

Traceback (most recent call last):
  File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 194, in
restricted
exec ccode in environment
  File "/home/dl/trunkw2p/web2py/applications/devel/views/default/
blah.html", line 71, in 
d = new Date();
  File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 169, in
__call__
page = run_controller_in(c, f, other_environment)
  File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 452, in
run_controller_in
restricted(code, environment, filename)
  File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 202, in
restricted
raise RestrictedError(layer, code, '', environment)
RestrictedError

A web search shows that when people have asked about RestrictedError
before, the culprit was some sort of bug in web2py. How can I figure
out what's causing the problem? The traceback is unhelpful as the line
in question
d = new Date();
is a line of JavaScript from the view. This problem seems to come and
go, and I can't track it down.

Thanks,
G


[web2py] Re: Debugging RestrictedErrors

2011-08-24 Thread G
Sorry, I meant to mention I'm running from the trunk. I ended up
tracing the problem to an exception in my code, but I still don't
understand why it was presented as such. The exception was in a
controller function that was being accessed as a .load component if
that make any difference.
Thanks,
G

On Aug 24, 9:42 pm, Massimo Di Pierro 
wrote:
> which web2py version?
>
> On Aug 24, 3:59 pm, G  wrote:
>
> > Hello,
> > I am occasionally getting errors like the followng:
>
> > Traceback (most recent call last):
> >   File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 194, in
> > restricted
> >     exec ccode in environment
> >   File "/home/dl/trunkw2p/web2py/applications/devel/views/default/
> > blah.html", line 71, in 
> >     d = new Date();
> >   File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 169, in
> > __call__
> >     page = run_controller_in(c, f, other_environment)
> >   File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 452, in
> > run_controller_in
> >     restricted(code, environment, filename)
> >   File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 202, in
> > restricted
> >     raise RestrictedError(layer, code, '', environment)
> > RestrictedError
>
> > A web search shows that when people have asked about RestrictedError
> > before, the culprit was some sort of bug in web2py. How can I figure
> > out what's causing the problem? The traceback is unhelpful as the line
> > in question
> > d = new Date();
> > is a line of JavaScript from the view. This problem seems to come and
> > go, and I can't track it down.
>
> > Thanks,
> > G
>
>


[web2py] Re: Debugging RestrictedErrors

2011-08-24 Thread G
I didn't specify ajax (didn't need it), so I think it defaults to
ajax=False.

On Aug 24, 2:49 pm, Massimo Di Pierro 
wrote:
> was LOAD(, ajax=True) or LOAD(ajax=False)?
>
> On Aug 24, 4:46 pm, G  wrote:
>
> > Sorry, I meant to mention I'm running from the trunk. I ended up
> > tracing the problem to an exception in my code, but I still don't
> > understand why it was presented as such. The exception was in a
> > controller function that was being accessed as a .load component if
> > that make any difference.
> > Thanks,
> > G
>
> > On Aug 24, 9:42 pm, Massimo Di Pierro 
> > wrote:
>
> > > which web2py version?
>
> > > On Aug 24, 3:59 pm, G  wrote:
>
> > > > Hello,
> > > > I am occasionally getting errors like the followng:
>
> > > > Traceback (most recent call last):
> > > >   File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 194, in
> > > > restricted
> > > >     exec ccode in environment
> > > >   File "/home/dl/trunkw2p/web2py/applications/devel/views/default/
> > > > blah.html", line 71, in 
> > > >     d = new Date();
> > > >   File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 169, in
> > > > __call__
> > > >     page = run_controller_in(c, f, other_environment)
> > > >   File "/home/dl/trunkw2p/web2py/gluon/compileapp.py", line 452, in
> > > > run_controller_in
> > > >     restricted(code, environment, filename)
> > > >   File "/home/dl/trunkw2p/web2py/gluon/restricted.py", line 202, in
> > > > restricted
> > > >     raise RestrictedError(layer, code, '', environment)
> > > > RestrictedError
>
> > > > A web search shows that when people have asked about RestrictedError
> > > > before, the culprit was some sort of bug in web2py. How can I figure
> > > > out what's causing the problem? The traceback is unhelpful as the line
> > > > in question
> > > > d = new Date();
> > > > is a line of JavaScript from the view. This problem seems to come and
> > > > go, and I can't track it down.
>
> > > > Thanks,
> > > > G
>
>


[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread G
Thank you for the suggestion. I made a test application that used no
database accesses (no auth and randomly generated data). It showed the
same behavior, so I do not think it is the culprit. In addition, since
the application is monitor only, the real application only reads from
the database, which I hope would not impose a transaction lock.

G

On Aug 24, 3:20 pm, ron_m  wrote:
> You also need to consider the database type used by the application for the
> model. The SQLite database has a transaction lock which will cause the
> application to look like it is single threaded if the database is held in a
> transaction pending state while the background work is performed.


[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread G
I tried session.forget() but found that forms submitted by ajax in
components don't seem to work without a session, so that won't work in
my case.

I also tried removing the SQLite db, it may have helped some but I'm
still testing.

Thanks again for the suggestions

On Aug 24, 4:18 pm, Michele Comitini 
wrote:
> Try session.forget() and see what happens
>
> mic
>
> 2011/8/25 G :
>
> > Thank you for the suggestion. I made a test application that used no
> > database accesses (no auth and randomly generated data). It showed the
> > same behavior, so I do not think it is the culprit. In addition, since
> > the application is monitor only, the real application only reads from
> > the database, which I hope would not impose a transaction lock.
>
> > G
>
> > On Aug 24, 3:20 pm, ron_m  wrote:
> >> You also need to consider the database type used by the application for the
> >> model. The SQLite database has a transaction lock which will cause the
> >> application to look like it is single threaded if the database is held in a
> >> transaction pending state while the background work is performed.
>
>


[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread G
Hi,
Can you explain this a bit more? Is the idea to call
session.forget(response) in my main controller, but not in the
components that have forms in them? I had previously put the
session.forget() line in the model file so it was always executed.
Thanks

On Aug 25, 11:42 am, Anthony  wrote:
> If you don't explicitly "forget" the session, the session file will lock on
> each request, so subsequent requests will be blocked. Maybe you could forget
> the session on requests that don't need it and just keep it for requests
> that do need it (i.e., form submissions).
>
> Note, to immediately unlock the session file, you need to do
> session.forget(response), not just session.forget().
>
> Anthony
>
> On Thursday, August 25, 2011 2:14:54 PM UTC-4, G wrote:
>
> > I tried session.forget() but found that forms submitted by ajax in
> > components don't seem to work without a session, so that won't work in
> > my case.
>
> > I also tried removing the SQLite db, it may have helped some but I'm
> > still testing.
>
> > Thanks again for the suggestions
>
> > On Aug 24, 4:18 pm, Michele Comitini 
> > wrote:
> > > Try session.forget() and see what happens
>
> > > mic
>
> > > 2011/8/25 G :
>
> > > > Thank you for the suggestion. I made a test application that used no
> > > > database accesses (no auth and randomly generated data). It showed the
> > > > same behavior, so I do not think it is the culprit. In addition, since
> > > > the application is monitor only, the real application only reads from
> > > > the database, which I hope would not impose a transaction lock.
>
> > > > G
>
> > > > On Aug 24, 3:20 pm, ron_m  wrote:
> > > >> You also need to consider the database type used by the application
> > for the
> > > >> model. The SQLite database has a transaction lock which will cause the
>
> > > >> application to look like it is single threaded if the database is held
> > in a
> > > >> transaction pending state while the background work is performed.
>
>


[web2py] appadmin fails on gae

2010-02-19 Thread Carles G
Hi!

I'm deploying a test aplication on GAE and almost everything woks
fine, although I can't access appadmin.

When i try to access through https the application fails and i can see
the following error in the dashboard logs:

In FILE: /base/data/home/apps/professorsecaib/1.339995859017462670/
applications/professors/controllers/appadmin.py

Traceback (most recent call last):
  File "/base/data/home/apps/professorsecaib/1.339995859017462670/
gluon/restricted.py", line 173, in restricted
exec ccode in environment
  File "/base/data/home/apps/professorsecaib/1.339995859017462670/
applications/professors/controllers/appadmin.py:index", line 33, in

  File "/base/data/home/apps/professorsecaib/1.339995859017462670/
gluon/fileutils.py", line 271, in check_credentials
% users.create_login_url(request.env.path_info)
  File "/base/python_lib/versions/1/google/appengine/api/users.py",
line 179, in create_login_url
raise NotAllowedError
NotAllowedError

I searched the list but i couldn't find the answer.

Thanks in advance and sorry for my poor english.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: auth expiring sessions too fast

2010-03-11 Thread Ted G
I'm seeing this behaviour as well (on GAE live but not SDK). In my
case sessions are in memcache not db. Can't pinpoint when it started
but noticed it earlier this week. Haven't updated web2py in quite some
time (I've been running 1.65.11).


On Mar 10, 4:47 pm, Richard  wrote:
> I forgot to mention something crucial - this is for web2py on GAE.
>
> Apparently another user is also experiencing sessions problems on
> GAE:http://groups.google.com/group/web2py/browse_thread/thread/a5699d4788...
>
> On Mar 11, 4:00 am, mdipierro  wrote:
>
>
>
> > I cannot find the problem. I could use some help debugging this. Can
> > people reproduce it?
>
> > On Mar 10, 6:28 am, Richard  wrote:
>
> > > I find my auth sessions are expiring after about 5 minutes. I have
> > > tried setting "auth.settings.expiration = 9" but it seems to
> > > make no difference.
>
> > > I recently upgraded to 1.76.3 and don't remember experiencing this
> > > before - is there a new way to set session expiration length?
>
> > > Richard

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: auth expiring sessions too fast

2010-03-15 Thread Ted G
I guess I have misinterpreted this code from my db.py which was part
of the web2py distro that I uncommented. The comments within the code
stated the sessions would be stored in memcache.



try:
from gluon.contrib.gql import *  # if running on Google App Engine
except:
db = SQLDB('sqlite://storage.db')  # if not, use SQLite or other
DB
else:
db = GQLDB()  # connect to Google BigTable
#session.connect(request, response, db=db)  # and store sessions
there
# or use the following lines to store sessions in Memcache
from gluon.contrib.memdb import MEMDB
from google.appengine.api.memcache import Client
session.connect(request, response, db=MEMDB(Client()))

from gluon.contrib.gae_memcache import MemcacheClient
cache.ram=cache.disk=MemcacheClient(request)


On Mar 11, 11:34 am, mdipierro  wrote:
> How are you doing this? web2py does not provide an API to store
> sessions in memcache. If you have implemented it perhaps we should
> include it in web2py so I can help debug it if there is a problem.
>
> On Mar 11, 12:04 pm, Ted G  wrote:
>
>
>
> > I'm seeing this behaviour as well (on GAE live but not SDK). In my
> > case sessions are in memcache not db. Can't pinpoint when it started
> > but noticed it earlier this week. Haven't updated web2py in quite some
> > time (I've been running 1.65.11).
>
> > On Mar 10, 4:47 pm, Richard  wrote:
>
> > > I forgot to mention something crucial - this is for web2py on GAE.
>
> > > Apparently another user is also experiencing sessions problems on
> > > GAE:http://groups.google.com/group/web2py/browse_thread/thread/a5699d4788...
>
> > > On Mar 11, 4:00 am, mdipierro  wrote:
>
> > > > I cannot find the problem. I could use some help debugging this. Can
> > > > people reproduce it?
>
> > > > On Mar 10, 6:28 am, Richard  wrote:
>
> > > > > I find my auth sessions are expiring after about 5 minutes. I have
> > > > > tried setting "auth.settings.expiration = 9" but it seems to
> > > > > make no difference.
>
> > > > > I recently upgraded to 1.76.3 and don't remember experiencing this
> > > > > before - is there a new way to set session expiration length?
>
> > > > > Richard

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py:23362] Re: Best way to handle rich website?

2009-06-05 Thread Ted G
 You include the line {{=some_db_records}}
> > * You have an {{include}} in the file
>
> > When you hit the URL 'appname/default/index':
>
> > * It is the responsibility of the function index() in the controller
> > file default.py to return an item called 'some_db_records'
> > * The function bar() in controller foo.py is not called
>
> > Is this correct?
>
> > Thanks guys, I just wanted to be sure I interpreted these posts
> > correctly.
>
> > Eddie
>
> > On May 7, 2:57 am, Ted G  wrote:
>
> > > If you do a search onjDivyou will find a few recent threads
> > > discussing this topic (related to the example link provided by
> > > Massimo). I've been heading down this road myself, creating a site
> > > where site pages are simply container based layouts containing re-
> > > useable "applets". The pattern I've found that works so far is as
> > > follows:
>
> > > layout.html - contains common style sheets, javascript and layout
> > > containers common across all pages (eg. Header, Menu, Body, Footer).
> > > Provides  an {{include}} in the body area.
>
> > > mypage.html - contains specific styles, javascript and layout
> > > containers for the body area of a specific page that contains a number
> > > of applets. Basically the "glue" that coordinates the interaction of
> > > the various applets on the page. Within the layout defined in this
> > > page are your applets {{=applet1}} , {{=applet2}}, etc.
>
> > > The controller action for the mypage.html view creates applet1,
> > > applet2, etc. asjDiv'sand returns them to the view via dict
> > > (applet1=applet1, applet2=applet2, ...)
>
> > > The individual applets actions/views may be in the same controller as
> > > mypage or in different controllers. Ideally, yourapplet'sview would
> > > contain only that html specific to thatapplet'slayout so that it is
> > > easily re-used. Since theappletwill be able to utilize the
> > > javascript and css in layout.html and mypage.html you can rely on
> > > those layout pages to provide the CSS styling for theappletso that
> > > it is easier to make site wide style changes later.
>
> > > Making use of a CSS framework can help with consistent site wide
> > > layout. I've used the blueprint css framework successfully with
> > > web2py. CSS frameworks are not for everyone, but for CSS challenged
> > > indviduals like myself, they are a real time saver.
>
> > > Ted
>
> > > On May 6, 3:15 am, Joe  Barnhart  wrote:
>
> > > > I've been pondering the best way to create sites with rich pages that
> > > > contain lots of "applets" or "tasklets".  It seems limiting to have
> > > > the entire page tied to a single Python function.  Maintaining the
> > > > site could be problematic if everything funnels through one
> > > > "controller" function.
>
> > > > Then I wondered about the structure of the layout files.  I like the
> > > > "extend" and "include" functionality.  I imagine I could create a tree
> > > > of html files --- one for eachappletdiv, for example, with
> > > > layout.html at the root.  Perhaps a "news" area and a "calandar" area
> > > > in addition to the main body, for example.
>
> > > > Each functional block could be represented by a file such as
> > > > "news.html" and "calandar.html" included into layout.html.  The
> > > > controller for each would then extend its own html file instead of the
> > > > top-level "layout.html" file.
>
> > > > Is there a still better way to organize a busy site?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23970] Re: web2py 1.62.1 is OUT (New Features List)

2009-06-11 Thread Ted G

Massimo,

With respect to the new file upload remembering the file name. Are
there accompanying methods to get and set the filename after upload of
the file?

In my example, my app is running on GAE, therefore uploaded files are
being stored in the DB. I require the ability for the user to see a
list of their uploaded files, using filenames. Currently I use a
separate field to store the filename of the file when it was
originally uploaded and use that for display purposes (upload field
value still used as the url to the resource). I also allow the user to
change the value of the display filename.

With the new upload field I was hoping my extra filename field would
be redundant and that I could get and set the filename that was being
stored as part of the upload field. Is this possible in the new
implementation, or am I stuck using the extra filename field?

Ted



On May 18, 8:10 am, mdipierro  wrote:
> I fixed a couple of issues posted during the night and reposted
> 1.62.1. Please let me know if you have any problem.
>
> New features:
>
> - There is a new "welcome" scaffoling app that has Authentication,
> Authorization, Crud, Services, and Menu by default.
>
> - There is a new file format for web2py apps (.w2p) it is zips files
> so it is more compact.
>
> - if SQLField(, writable=False, readable=True) thefieldis shown
> readonly in SQLFORMs
>
> - The "design" page has been renamed "edit".
>
> - If youuploada file in an "upload"fieldit now "remembers" the
> original name. The name does not appear in the URL for various
> security reason but it will be used when you try to save the file.
> This is ON by default. Can be disabled but I cannot think any reason
> to.
>
> - There is a new {{=MENU(response.menu)}} helper
>
> - You can disable lazy evaluation of languages T.lazy=False (True by
> default as before)
>
> - Better WingIDE support
>
> - Better Internationalization
>
> BETA FEATURES (they seem to work but need more testing and
> improvements)
>
> - look into admin/models/0.py, there is a variable GAE_APPCFG. If that
> variable points to the correct Google App Engine utility appcfg.py,
> web2py will provide a web based interface to deploy on the Google App
> Engine, linked from admin/default/site
>
> - If you run source and you "easy_install mercurial", each app has its
> own minimalist interface to mercurial and you can commit your changes
> to it.
>
> - There is a new [shell] button in the edit (design) page. When you
> click on it you get an AJAX shell within the app (it sees the
> database). It has some problems with sqlite since it closes the
> database unexpectedly.
>
> Thanks particularly to Alvaro, Douglas, Yair, Tim, Iceberg for all
> their help (I am sure I forgot somebody).
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24020] Re: web2py 1.62.1 is OUT (New Features List)

2009-06-12 Thread Ted G

OK thanks. I'll continue using a dedicated field to allow editing of
the "user-friendly" filename after uploading.

Ted

On Jun 11, 9:40 pm, mdipierro  wrote:
> Currently when you upload a file, the actual file goes in the
> filesystem of "uploadfield" in the database. The filename is
> b16encoded and stored inside the new "internal" filename. It is
> extracted and used by the "download" action to set content
> disposition.
>
> There is no easy way to change this mechanism.
>
> It is possible to set an onvalidation function that replaces
> form.vars.filefieldname.filename before the file is actually loaded.
> You can also define a custom download action.
>
> There is no exposed API to do this since the current mechanism is
> quite complex and I do would not encourage bypassing it.
>
> Massimo
>
> On Jun 11, 8:42 pm, Ted G  wrote:
>
>
>
> > Massimo,
>
> > With respect to the new file upload remembering the file name. Are
> > there accompanying methods to get and set the filename after upload of
> > the file?
>
> > In my example, my app is running on GAE, therefore uploaded files are
> > being stored in the DB. I require the ability for the user to see a
> > list of their uploaded files, using filenames. Currently I use a
> > separate field to store the filename of the file when it was
> > originally uploaded and use that for display purposes (upload field
> > value still used as the url to the resource). I also allow the user to
> > change the value of the display filename.
>
> > With the new upload field I was hoping my extra filename field would
> > be redundant and that I could get and set the filename that was being
> > stored as part of the upload field. Is this possible in the new
> > implementation, or am I stuck using the extra filename field?
>
> > Ted
>
> > On May 18, 8:10 am, mdipierro  wrote:
>
> > > I fixed a couple of issues posted during the night and reposted
> > > 1.62.1. Please let me know if you have any problem.
>
> > > New features:
>
> > > - There is a new "welcome" scaffoling app that has Authentication,
> > > Authorization, Crud, Services, and Menu by default.
>
> > > - There is a new file format for web2py apps (.w2p) it is zips files
> > > so it is more compact.
>
> > > - if SQLField(, writable=False, readable=True) thefieldis shown
> > > readonly in SQLFORMs
>
> > > - The "design" page has been renamed "edit".
>
> > > - If youuploada file in an "upload"fieldit now "remembers" the
> > > original name. The name does not appear in the URL for various
> > > security reason but it will be used when you try to save the file.
> > > This is ON by default. Can be disabled but I cannot think any reason
> > > to.
>
> > > - There is a new {{=MENU(response.menu)}} helper
>
> > > - You can disable lazy evaluation of languages T.lazy=False (True by
> > > default as before)
>
> > > - Better WingIDE support
>
> > > - Better Internationalization
>
> > > BETA FEATURES (they seem to work but need more testing and
> > > improvements)
>
> > > - look into admin/models/0.py, there is a variable GAE_APPCFG. If that
> > > variable points to the correct Google App Engine utility appcfg.py,
> > > web2py will provide a web based interface to deploy on the Google App
> > > Engine, linked from admin/default/site
>
> > > - If you run source and you "easy_install mercurial", each app has its
> > > own minimalist interface to mercurial and you can commit your changes
> > > to it.
>
> > > - There is a new [shell] button in the edit (design) page. When you
> > > click on it you get an AJAX shell within the app (it sees the
> > > database). It has some problems with sqlite since it closes the
> > > database unexpectedly.
>
> > > Thanks particularly to Alvaro, Douglas, Yair, Tim, Iceberg for all
> > > their help (I am sure I forgot somebody).
>
> > > Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24024] Re: jpolite and form submit

2009-06-12 Thread Ted G

I think the "patch" may have been the change I suggested in this
thread dealing with file uploads using forms within a jDiv.

http://groups.google.com/group/web2py/browse_frm/thread/34533d763a5e856f/c6cb190b051a03bc?lnk=gst&q=jdiv+file+upload#c6cb190b051a03bc

Basically the change was to utilize jQuery's ajaxform submission. Note
that although this works, you are restricted to one file upload per
submit.


Ted


On May 22, 2:45 pm, mdipierro  wrote:
> be aware that the code injpolite-web2py will change a lot in the near
> future. I am not sure if it currently handle file uploads for example.
> I remember somebody sending me a patch in that direction some time ago
> but I cannot find it anymore.
>
> Massimo
>
> On May 22, 4:41 pm, mdipierro  wrote:
>
>
>
> > For now what you have to do it
>
> > form=crud.create(db.table)
> > form['_class']='ajaxform1'
>
> > I am thinking on whether this should be the default behavior and who's
> > responsibility is to set this behavior (the form? the frame? the app?)
>
> > On May 22, 4:21 pm, Wes James  wrote:
>
> > > Massimo,
>
> > > is it the form submit and submitting data and getting a form back with
> > > validation what you were indicating in the comments on the ajax panel?
>
> > > Because I can't use a crud form submit and get it to submit data, it just
> > > refreshes the screen it seems.
>
> > > I can get a form with form=crud.create(db.table), but submit no go
>
> > > thx,
>
> > > -wes
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24026] Re: jPolite solved (almost) all our problems

2009-06-12 Thread Ted G

Is the work being done with jPolite meant to replace the work that was
being done with jDiv?

I've been using a modified version of the older jDiv code in my app.
Should I be looking instead to use jPolite?

Ted



On May 19, 12:06 pm, mdipierro  wrote:
> I turnedjpoliteinto a web2py app.
>
> https://www.web2py.com/jpolite
>
> (there is a download link to the w2p file, requires web2py 1.62.1)
>
> The form submission needs more work, perhaps you can help.
>
> When that's fixed we can integrate with Auth and port T3 on this.
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24445] Possible to render view template from db blob/text/string instead of file?

2009-06-18 Thread Ted G

I have an application in which I need to have the view rendered by a
controller be specified using a parameter to that controller.

I believe I could do the following based on what I've dug up in this
forum:

def index():

  try:
response.view='default/' + request.args[0]  # eg.
'indexview2.html'
   except:
response.view='default/index.html'

  return dict(message=T('Hello World'))


Ideally, as I come up with new view templates, I would like to upload
them to the appropriate directory, allowing me to request an alternate
view by simply passing the filename of the new view to this
controller.

The problem is that I am running my application on Google App Engine,
therefore to upload new views I would have to update my application,
which is not practical if I am frequently adding new views.

The ideal solution would be to store the new view in a text or blob
field within a table of the database and then be able to use that text/
blob/string as the input to response.view instead of a file.

Is this at all possible under web2py's current template processing
(processing a view from a blobl/text/string instead of file).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24499] Re: Possible to render view template from db blob/text/string instead of file?

2009-06-19 Thread Ted G

That would be amazing. This will help to enable a very important part
of my app's functionality.

Thank You.



On Jun 18, 8:31 pm, mdipierro  wrote:
> not easy to do now, but easy to add. I will add this to trunk
> tomorrow.
>
> Massimo
>
> On Jun 18, 4:30 pm, Ted G  wrote:
>
>
>
> > I have an application in which I need to have the view rendered by a
> > controller be specified using a parameter to that controller.
>
> > I believe I could do the following based on what I've dug up in this
> > forum:
>
> > def index():
>
> >   try:
> >     response.view='default/' + request.args[0]  # eg.
> > 'indexview2.html'
> >    except:
> >     response.view='default/index.html'
>
> >   return dict(message=T('Hello World'))
>
> > Ideally, as I come up with new view templates, I would like to upload
> > them to the appropriate directory, allowing me to request an alternate
> > view by simply passing the filename of the new view to this
> > controller.
>
> > The problem is that I am running my application on Google App Engine,
> > therefore to upload new views I would have to update my application,
> > which is not practical if I am frequently adding new views.
>
> > The ideal solution would be to store the new view in a text or blob
> > field within a table of the database and then be able to use that text/
> > blob/string as the input to response.view instead of a file.
>
> > Is this at all possible under web2py's current template processing
> > (processing a view from a blobl/text/string instead of file).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24715] Re: Possible to render view template from db blob/text/string instead of file?

2009-06-22 Thread Ted G

Hi Massimo,

I've been watching trunk. Have you had any luck with this?

Ted

On Jun 18, 8:31 pm, mdipierro  wrote:
> not easy to do now, but easy to add. I will add this to trunk
> tomorrow.
>
> Massimo
>
> On Jun 18, 4:30 pm, Ted G  wrote:
>
>
>
> > I have an application in which I need to have the view rendered by a
> > controller be specified using a parameter to that controller.
>
> > I believe I could do the following based on what I've dug up in this
> > forum:
>
> > def index():
>
> >   try:
> >     response.view='default/' + request.args[0]  # eg.
> > 'indexview2.html'
> >    except:
> >     response.view='default/index.html'
>
> >   return dict(message=T('Hello World'))
>
> > Ideally, as I come up with new view templates, I would like to upload
> > them to the appropriate directory, allowing me to request an alternate
> > view by simply passing the filename of the new view to this
> > controller.
>
> > The problem is that I am running my application on Google App Engine,
> > therefore to upload new views I would have to update my application,
> > which is not practical if I am frequently adding new views.
>
> > The ideal solution would be to store the new view in a text or blob
> > field within a table of the database and then be able to use that text/
> > blob/string as the input to response.view instead of a file.
>
> > Is this at all possible under web2py's current template processing
> > (processing a view from a blobl/text/string instead of file).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24895] Re: Possible to render view template from db blob/text/string instead of file?

2009-06-24 Thread Ted G

Massimo,

This works like a charm! Thank you so much.

FYI, I'm using it in the following manner (code simplified for
example):

import StringIO

def show_profile():
  # get the user profile data
  user_profile=db(db.user_profile.id==request.args[0]).select[0]

  # get the view used to show the profile
  display_template=db
(db.profile_view.id==user_profile.display_template).select()[0]
  view_text=StringIO.StringIO(display_template.template_text)

  # get the style used to format the view
  display_style=db
(db.profile_style.id==user_profile.display_style).select()[0]

  return response.render(view_text,dict
(style=display_style.style_text,user_profile=user_profile))


In my application, I'm providing users the ability to select from a
list of different views and styles they can use to display their user
profile. Since I'm running on GAE, it is painful for me to create and
upload new views as part of the app, so with this change, I can now
upload new views into the DB as I create them and they then become an
available option for the user to select (I administer and control this
process to prevent uploading of views that could compromise the system
via the template system). The stylesheets are stored in the DB as
well, separate from the view, so the user can mix and match the style
along with the view to create a custom look to their profile.

Thanks again for the change that makes this possible!

Ted




On Jun 23, 12:29 pm, mdipierro  wrote:
> Uploading to trunk now. Please give it a try:
>
> $ python web2py.py -S welcome>>> import StringIO
> >>> a=StringIO.StringIO('{{for i in range(10):}}{{=i}}{{pass}}')
> >>> response.render(a)
>
> '0123456789'
>
> This means in view you can do
>
> {{=response.render(s)}} and {{=cache.ram('key',lambda: response.render
> (s),5000)}}
> where s is any stream-like object with a read method.
>
> Massimo
>
> On Jun 23, 11:29 am, mdipierro  wrote:
>
>
>
> > This could be a possibility. I will experiment.
>
> > On Jun 23, 6:45 am, AchipA  wrote:
>
> > > Could response.view also be a handle (or maybe response.viewhandle ?).
> > > That way we could throw a (c)StringIO at response view, and StringIO
> > > can wrap db fields, python strings or whatever we want.
>
> > > Note that response.stream already works this way so it would be
> > > perhaps more consequential, too.
>
> > > On Jun 22, 9:03 pm, mdipierro  wrote:
>
> > > > I should be able to di it tomorrow if no major obstacles.
>
> > > > Massimo
>
> > > > On Jun 22, 12:01 pm, Ted G  wrote:
>
> > > > > Hi Massimo,
>
> > > > > I've been watching trunk. Have you had any luck with this?
>
> > > > > Ted
>
> > > > > On Jun 18, 8:31 pm, mdipierro  wrote:
>
> > > > > > not easy to do now, but easy to add. I will add this to trunk
> > > > > > tomorrow.
>
> > > > > > Massimo
>
> > > > > > On Jun 18, 4:30 pm, Ted G  wrote:
>
> > > > > > > I have an application in which I need to have the view rendered 
> > > > > > > by a
> > > > > > > controller be specified using a parameter to that controller.
>
> > > > > > > I believe I could do the following based on what I've dug up in 
> > > > > > > this
> > > > > > > forum:
>
> > > > > > > def index():
>
> > > > > > >   try:
> > > > > > >     response.view='default/' + request.args[0]  # eg.
> > > > > > > 'indexview2.html'
> > > > > > >    except:
> > > > > > >     response.view='default/index.html'
>
> > > > > > >   return dict(message=T('Hello World'))
>
> > > > > > > Ideally, as I come up with new view templates, I would like to 
> > > > > > > upload
> > > > > > > them to the appropriate directory, allowing me to request an 
> > > > > > > alternate
> > > > > > > view by simply passing the filename of the new view to this
> > > > > > > controller.
>
> > > > > > > The problem is that I am running my application on Google App 
> > > > > > > Engine,
> > > > > > > therefore to upload new views I would have to update my 
> > > > > > > application,
> > > > > > > which is not practical if I am frequently adding new views.
>
> > > > > > > The ideal solution would be to store the new view in a text or 
> > > > > > > blob
> > > > > > > field within a table of the database and then be able to use that 
> > > > > > > text/
> > > > > > > blob/string as the input to response.view instead of a file.
>
> > > > > > > Is this at all possible under web2py's current template processing
> > > > > > > (processing a view from a blobl/text/string instead of file).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29670] Best approach to insert records containing upload fields with default files/images.

2009-08-30 Thread Ted G

I'm not sure of the best way to approach this, any suggestions?

I am inserting records into a table that contains an upload field for
an image (which is stored in the table as a blob). The user will be
able to later change this image via a form, and I wish to expose the
field for download, thus the use of the upload field. However, when I
first insert a new record, I want to store a default image in the
upload field as the initial insert is not done via a form.

Currently I am opening a default image stored in an application
directory containing a set of default images and storing that file's
contents in the blob used for the upload field. I am not sure, however
what to do about the filename string that is stored in the upload
field itself (usually generated on form.accepts). Is the function that
generates this value from the filename exposed in a manner that I can
use it to manually generate a value outside of a form.accepts? Or does
it matter what I store in the upload field as a value (eg. Could I use
tablename.fieldname..filename as a unique value (although
this would be not optimal for the DB as I have to do an insert to get
the ID and then an update for the generated filename)?

This code represents what I want to do:

# get the default image
filename = os.path.join(request.folder,'templates','default.png')
file = open(filename)
imageBlob = file.read()
file.close()
# generate a unique value for the upload field
uploadName = generateUploadName('profile','file','default.png')
db.profile.insert(file=uploadName,file_data=imageBlob)

Not sure if generateUploadName() is a call to an already existing
web2py method or one that I need to create myself, and if I create
myself, if it needs to be consistent with with what is normally
generated when using form.accepts.

Suggestions?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29713] Re: web2py compatibility with snow leopard

2009-08-31 Thread Ted G

FYI,

After I upgraded to Snow Leopard web2py appeared to run fine (I am
running it under the GAE SDK).

However, I was running with PIL installed for image manipulation and
this broke. After several unsuccessful attempts to install PIL within
Python 2.6 on Snow Leopard (if anyone comes up with a workable
procedure for this please post, as others on the web appear to be
experiencing problems as well).

The eventual solution was to instruct GAE to use Python2.5 which you
can do by setting the Python path in the Google App Engine Launcher
Preferences.


Ted

On Aug 27, 7:42 am, Wes James  wrote:
> some problems might come from python version:
>
> python -V
> Python 2.6.1
>
> On Wed, Aug 26, 2009 at 8:46 PM, vvk wrote:
>
> > Is web2py compatible withsnow leopardfinal Gold master ( a432 )
> > version ? Any issues there ?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29714] Re: Best approach to insert records containing upload fields with default files/images.

2009-08-31 Thread Ted G

FYI,

As an interim solution I have extracted the filename encoding part of
sql.py and created a stand-alone function to generate a filename from
the table, field and filename. I am using this currently unless
someone informs me that it is a bad idea. At this point the only
problem I see is that if sql.py changes, my function may become out of
sync with the sql.py implementation.

Ideally, it would be nice if the fileEncode was a function provided
for use by the framework as well as sql.py.

So here is the code I am using:

import os
import re
import uuid
import base64
def encodeFilename(filename,tablename,fieldname):
filename = os.path.basename(filename or file.filename)
m = re.compile('\.(?P\w{1,5})$').search(filename)
extension = m and m.group('e') or 'txt'
uuid_key = str(uuid.uuid4()).replace('-', '')[-16:]
encoded_filename = base64.b16encode(filename).lower()
newfilename = '%s.%s.%s.%s' % \
(tablename, fieldname, uuid_key, encoded_filename)
newfilename = newfilename[:122]+'.'+extension
return newfilename

Ted


On Aug 30, 11:59 pm, Ted G  wrote:
> I'm not sure of the best way to approach this, any suggestions?
>
> I am inserting records into a table that contains an upload field for
> an image (which is stored in the table as a blob). The user will be
> able to later change this image via a form, and I wish to expose the
> field for download, thus the use of the upload field. However, when I
> first insert a new record, I want to store a default image in the
> upload field as the initial insert is not done via a form.
>
> Currently I am opening a default image stored in an application
> directory containing a set of default images and storing that file's
> contents in the blob used for the upload field. I am not sure, however
> what to do about the filename string that is stored in the upload
> field itself (usually generated on form.accepts). Is the function that
> generates this value from the filename exposed in a manner that I can
> use it to manually generate a value outside of a form.accepts? Or does
> it matter what I store in the upload field as a value (eg. Could I use
> tablename.fieldname..filename as a unique value (although
> this would be not optimal for the DB as I have to do an insert to get
> the ID and then an update for the generated filename)?
>
> This code represents what I want to do:
>
> # get the default image
> filename = os.path.join(request.folder,'templates','default.png')
> file = open(filename)
> imageBlob = file.read()
> file.close()
> # generate a unique value for the upload field
> uploadName = generateUploadName('profile','file','default.png')
> db.profile.insert(file=uploadName,file_data=imageBlob)
>
> Not sure if generateUploadName() is a call to an already existing
> web2py method or one that I need to create myself, and if I create
> myself, if it needs to be consistent with with what is normally
> generated when using form.accepts.
>
> Suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29812] Re: Anyone have errors running 10.6 Mac OS X and web2py?

2009-09-01 Thread Ted G

In the Google App Engine Launcher Preferences you can set the python
path to 2.5. I had to do this as well after upgrading to Snow Leopard
as PIL would not work Snow Leopard Python2.6



On Sep 1, 1:13 am, cpt1002  wrote:
> Hello,
>
> So I upgraded Mac OS X to 10.6 and I get some errors when I try to run
> web2py. I don't really get it but it still works mostly...anyone see
> this before?
>
> default applications appear to be installed already
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2009
> Version 1.67.0 (2009-08-28 03:11:48)
> Database drivers available: SQLite3, MySQL
> Starting cron...
> please visit:
>        http://127.0.0.1:8000
> starting browser...in 5 seconds
> 2009-09-01 01:12:58.503 osascript[2761:60b] Error loading /Library/
> ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit
> Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/
> Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did
> find:
>         /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/
> Adobe Unit Types: no matching architecture in universal wrapper
> osascript: OpenScripting.framework - scripting addition "/Library/
> ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handler
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:18931] Re: Writing a Book

2009-04-01 Thread g-man

Nice!

One 'role model' you might want to study is Obie Fernandez' "The Rails
Way", which goes deeply into each element of that complex framework...


On Apr 1, 11:28 am, TheDude  wrote:
> (This isn't an April Fool's Joke)
>
> So, I've been writing a book for Web2Py, but recently came towards a
> new direction...we already have a great in-depth book writeen by
> Massimo so I was wondering...
>
> Would you guys be interested in a book for web2py like 250 pages long
> that goes in-depth? Or, a nice little quick start guide :D here's the
> thing, BOTH will be able to teach you the fundamentals that you'll
> need to create 80%+ web applications. One will just tell you how to do
> things, but then link you to the documentation page available on
> web2py.com for more information.
>
> Examples:
> (QuickStart)
> In order to create a table for our database, we'll need to define b> our table.
> code:
> db.define_table('tablename',
> SQLField('fieldname','string', notnull=True)
> SQLField('fieldname2','integer', notnull=True),
> )
>
> Let's say we wanted to have a table reference the "tablename" table.
> db.define_table('table2',
> SQLField('tablename_id', db.tablename),
> SQLField('imafield','boolean'),
> )
>
>  the DAL explantion page for all options>
>
> I think the quick-start guide will really help boost the web2py
> community and get people started on a project. It's similar to the
> Dojo, but a bit different since it'll go more in-depth than the Dojo
> but at the same time you don't have to  learn everything. :) It will
> skip things like "What is MVC?" and "Why Web2Py framework" etc. I
> believe Massimo has already full-filled that information.
>
> The book will be available online (HTML) and PDF as well as a
> published book.
>
> Please let me know if your thoughts.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19304] Re: The official Web2py Book by Massimo....for free?

2009-04-06 Thread g-man

OK, let's look at how the most successful web app framework, Ruby on
Rails did this, so we can learn a little about what works:

1. DHH and 37signals developed Rails using Ruby basically as an in-
house tool to simplify repetitive tasks discovered as a project-
tracking and communication application was created for their own use.

2. Because 37signals is a smart, creative company, they realized that
Rails was useful, and could grow on its own, so publicizing it was a
natural next step, therefore the Pragmatic Programmer book was done
(not free, by the way).

3. Lost of blogs and web-based articles popped up (like on O'Reilly),
which gave how-to instructions for creating a sample app, or solving
specific problems.

4. Videos, like those at peepcode or railscasts, came along, also
increasing the buzz, and teaching people how to do things.

5. More and more books started to be done, creating a self-feeding
trend. Conferences, teaching, and consulting opportunities grew, with
a few 'killer apps' thrown in there for good measure.

6. The Ruby-on-Rails website has an API and some information, but not
a true manual, as far as I remember. The framework is changing fast,
and now the main book is into its 3rd edition in about five years.

So, how many of these things have we done yet? Not too many. True,
web2py is a solid, well-designed framework, but we need many more
blogs, articles, and videos in order to get the word out.

It seems that more and more smart people are looking into web2py,
especially after Pycon, so our momentum is moving in the right
direction.

Massimo has done, and continues to do, a great job of nurturing his
'baby', but we all need to do more in support of growing the web2py
user base, because we all benefit from a larger critical mass of
users.

Where are all the web2py blogs and articles, people?


On Apr 4, 6:19 am, Pystar  wrote:
> I had this weird idea today, in other to bring web2py which IMHO is
> the best python framework out there, i would suggest that the official
> web2py book be made a free download. i give my reasons below:
> 1. Any newbie who wants to try out web2py might not be interested in
> reading the source code, or might find the docs on the web2py site
> sufficient, but if the web2py book is available as a free download,
> this might arouse his/her interest more.
> Just my 2 cents anyway
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19415] global controller?

2009-04-07 Thread g-man

I am learning all the new auth, crud, and mail tools now, and I have
one question:

Does web2py use the 'default' controller as an implicit global
controller across a single application, or is that even possible?

Here is my situation. When I create my:

## default.py controller
def user():
return dict(form = auth())

Then I expose:

## request
application/default/user/login

Which is not as clean in terms of MVC, because I in effect have an
additional (virtual) controller (named 'user') created, which then
calls the function 'login'.

Ideally, I would like:

## request
application/user/login

...to expose the function, which would require treating 'default' as a
global controller, as it were. I tried creating a 'login' controller,
but the request still required an extra term in the request (app/login/
user/login) - not pretty.

I hate to say Rails does something like this with the 'application'
controller, because any code in that file is global to the app.

I guess what I am looking for is web2py to look in the 'default'
controller first if any parsed controller/function candidate can not
be found, and only then raise the error on failure.

That way we can have a simpler request syntax (more RESTful), and the
result would be a good fit in the case of auth, crud, and mail,
because these are usually site-wide administrative functions anyway.

Programming is fun again, thanks to web2py!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19482] Re: common controller function

2009-04-08 Thread g-man

This is similar to my recent post:

http://groups.google.com/group/web2py/browse_thread/thread/b406cafc55fde168#

It seems people like the Rails-type 'application' global controller,
but after thinking a little, I am working out how to get what I want
'the Python way'!

Right now, I am storing functions in the default controller, then
importing from there as needed, until I can work out a more elegant
way to do it.


On Apr 8, 6:30 pm, "alex.k.un...@gmail.com" 
wrote:
> How can I call common private (not exposed) functions from many
> different controllers. I thought that in MVC this was something that
> could be placed in the model if the functions dealt with data. Is it
> possible to have functions that in essence protect the DB from changes
> and are a gate keep to the models so that the controllers only access
> these functions which then talk to the db? Also is it possible to have
> a controller file that is central to all controllers and that they can
> all call the methods of?
> Thanks.
>
> -Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19600] Re: welcome to our friends from Brazil

2009-04-11 Thread g-man

Tudo bem!

On Apr 11, 11:35 am, Álvaro Justen [Turicas] 
wrote:
> Para quem fala Português, entre agora mesmo na lista de usuários
> brasileiros do web2py. :-)
> Participe e chame seus amigos!
>
> ---
>
> I encourage other users to create local lists in yours coutries, like
> web2py-brazil-users. Local lists can save Massimo's time with helping
> users and help bringing new users to web2py. I have plans to create
> presentations and events with (future) users of web2py-users-brazil.
>
> Enjoy!
>
> http://groups.google.com/group/web2py-users-brazil
>
> Thanks, Massimo.
>
> On 4/11/09, mdipierro  wrote:
>
>
>
> >http://groups.google.com/group/web2py-users-brazil
>
> --
>  Álvaro Justen
>  Peta5 - Telecomunicações e Software Livre
>  21 3021-6001 / 9898-0141
>  http://www.peta5.com.br/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19775] Poor performance on GAE

2009-04-14 Thread Ted G

I'm wondering if anyone has tips on where I should start in trying to
track down performance problems running my web2py application on GAE.
Initially I created an application using only the api's supplied by
GAE. This app was very fast in terms of response times.

I've since recreated and updated the app within web2py and have been
frustrated with very poor performance. I experience long delays when
loading pages and in particular, when loading pages that contain small
images (where the image source is using web2py's download() handler to
retrieve an image stored in the db as a web2py upload field).

As mentioned, my previous GAE API version of the app also stored these
same images as blobs in the db, but experienced none of the
performance issues I see under web2py.

Due to the delay experienced loading pages, my first thought, after
reading threads in this group, was that maybe my code was being
recompiled on every request. I updated to 1.61 this morning in the
hope that the GAE cache issue it was addressing would solve my problem
- but running a side to side comparison between a  1.59 version and
1.61 on GAE I did not see any difference.

Any tips on how I can narrow down the source of the performance
problems would be greatly appreciated.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19797] Re: Poor performance on GAE

2009-04-14 Thread Ted G

Thank you for the tips. I'll work through these and determine if I can
find a specific root cause of the performance problem.

I've been testing on a particular page of the application that lists a
number of items along with thumbnail images for those items. The
thumbnails are images placed into an upload field of the item record
and then displayed within the page using the following as the image
src:

{{ =URL(r=request,f='download',args=[channel.image]) }}

The page itself takes a while to initially respond, and then each
thumbnail in turn takes a while to download.

As a test, I replaced the above image src with the following:

/img/channel?id={{ =channel.id }}

and used App.yaml to direct the /img to a request handler using GAE's
native wsgihandler where I perform the following to download the
thumbnail image instead of using the web2py download():

record = channel.get_by_id(int(self.request.get
('id')))
self.response.headers['Content-Type'] = contenttype
(record.image)
self.response.out.write(record.image_data)

While the delay before the page first loads has not changed, the
subsequent display of the thumbnails on the page is now very fast
(which are the only requests now not being handled by web2py).

Not sure what to make of this at this point, but I wanted to first
ensure there was not a GAE or DB issue before digging deeper into what
part of my web2py implementation is slowing things down.

I have not modified the gaehandler.py and as a first step did move
sessions to ram cache instead of db, but have not seen any noticeable
performance increase.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20914] Re: Coooooool!

2009-05-01 Thread Ted G

I'm having a problem using upload fields within forms that are used
within jDiv containers. Testing edit() below by itself provides a form
that I can successfully select and update an image. When I encapsulate
the same edit() within a jDiv, all fields update with the exception of
the upload field, even though form.accepts is successful.

The code below contains the essential elements of what I am doing.
Updating the profile edit form correctly forces a refresh of the other
jDiv that is displaying the profile info, and all fields are updated
correctly when changed, with the exception of the upload field.

Any help with this is appreciated.

P.S. - Despite this hiccup, I am enthusiastic about this addition of
the jDiv container.


db.py model:
--

db.define_table('user_profile',
SQLField('nickname', type='string'),
SQLField('bio', type='text'),
SQLField('owner', db.auth_user, notnull=True, required=True,
writable=False),
SQLField('image', 'upload', uploadfield='image_data'),
SQLField('image_data', type='blob', default='', writable=False)
)


profile.py controller:
-
def index():
# create profile form and profile info containers
profile_form = jDiv('',URL(r=request,f='edit'),_id='1')
user_profile = jDiv('',URL
(r=request,f='profile'),timeout=0.01,_id='2')

return (profile_form = profile_form )

def edit():

user_profile=db(db.user_profile.owner==auth.user.id).select()[0]

form=SQLFORM(db.user_profile, user_profile, deletable=False)

if form.accepts(request.vars,session):
   # refresh profile container
jDiv.set(jDiv.trigger('#target_2','load'))
return dict(form=form,user_profile=user_profile)

def profile():
# first get our profile, if we don't yet
# have one, then create it
try:
profile=db(db.user_profile.owner==auth.user.id).select()[0]
except:
db.user_profile.insert(owner=auth.user.id,nickname='n00by')
profile=db(q_profile).select()[0]
return dict(profile=profile)

index.html view:
-
{{extend 'layout.html'}}

{{=user_profile}}

{{=profile_form}}

profile.html view:
-


{{=auth.user.first_name + " " + auth.user.last_name}}'s Profile
Nickname: {{ =profile.nickname }}
email: {{=auth.user.email}}
{{ =profile.bio }}

edit.html view:
---
Edit profile
{{=form}}




On Apr 6, 12:45 pm, mdipierro  wrote:
> I stole it on the web. Not my artwork. Hope the author does not mind.
>
> Massimo
>
> On Apr 6, 2:37 pm, desfrenes  wrote:
>
> > liking the background :-)
>
> > On 6 avr, 21:34, mdipierro  wrote:
>
> > > This can already be done. Here is a better layout and absolute Divs.
>
> > >http://www.web2py.com/events/default/index
>
> > > On Apr 6, 1:52 pm, ceej  wrote:
>
> > > > I think there should defiantly be a way to specify what div the
> > > > response is loaded in and also the option to load different parts of
> > > > the response in different divs.
>
> > > > On Apr 6, 1:42 pm, desfrenes  wrote:
>
> > > > > ok, I understand.
>
> > > > > On 6 avr, 18:17, mdipierro  wrote:
>
> > > > > > because, as far as I understand, this does something different.
>
> > > > > > the main point is thatjDivcatches the self-submitting forms and
> > > > > > prevents from reloading the entire page. I can use this with 
> > > > > > existing
> > > > > > web2py actions.
>
> > > > > > taconite has a flexible mechanism for allowing one page to embed 
> > > > > > code
> > > > > > into the page (using a new XML based syntax) but I prefer to use the
> > > > > > native publisher/subscriber mechanism in jQuery and let the server
> > > > > > always send the HTML to each component. I am ok with one component
> > > > > > triggering an aciton in a different component (like "load" or 
> > > > > > "flash"
> > > > > > or "slideToggle") but I am not ok with a component editing the 
> > > > > > content
> > > > > > of another component (something that taconite is for). I believe the
> > > > > > latter approach become un-manageble for complex systems.
>
> > > > > > Massimo
>
> > > > > > On Apr 6, 3:54 am, desfrenes  wrote:
>
> > > > > > > Hi,
>
> > > > > > > It's nice but how about using existing plugins for the ajax stuff 
> > > > > > > ?
> > > > > > > jquery.taconite.js and jquery.form.js are great (see page test 
> > > > > > > here:http://www.desfrenes.com/playground/carnet_adresse/)
>
> > > > > > > Taconite plugin:http://malsup.com/jquery/taconite/
>
> > > > > > > Regards,
>
> > > > > > > Mickaël.
>
> > > > > > > On Apr 6, 8:09 am, mdipierro  wrote:
>
> > > > > > > > I just changed the layout
>
> > > > > > > >http://www.web2py.com/events/default/indexhttp://www.web2py.com/examp...
>
> > > > > > > > try:
> > > > > > > > - click on "form"
> > > > > > > > - type a= 2 [enter]
> > > > > > > > - type b= 3 [enter]
>
> > > > > > > > - click on "post a message"
> > > > > > > > - type something and see the "list messages" open up 
>

[web2py:20948] File upload not working when form is in jDiv

2009-05-01 Thread Ted G

I've been trying out the new jDiv container, which works well with the
exception of forms containing upload fields. I thought I would start a
new thread for this, as my previous post (included below), seemed out
of place in the old thread.

Note that in the example code below, I've also tried replacing edit()
with:

def edit():
user_profile=db(db.user_profile.owner==auth.user.id).select()[0]
return crud.update(db.user_profile,user_profile.id)


The above change was order to take SQLForm out of the equation and
stick closer to the examples from the website (using crud). The result
is still the same - the form is always accepted, but only changes to
nickname and bio fields are updated to the database, the upload field
is not updated. Take the crud form out of the jDiv and put it directly
on the index page and it works as it should.



-- Original Post 

I'm having a problem using upload fields within forms that are used
within jDiv containers. Testing edit() below by itself provides a
form
that I can successfully select and update an image. When I
encapsulate
the same edit() within a jDiv, all fields update with the exception
of
the upload field, even though form.accepts is successful.
The code below contains the essential elements of what I am doing.
Updating the profile edit form correctly forces a refresh of the
other
jDiv that is displaying the profile info, and all fields are updated
correctly when changed, with the exception of the upload field.
Any help with this is appreciated.
P.S. - Despite this hiccup, I am enthusiastic about this addition of
the jDiv container.
db.py model:
--
db.define_table('user_profile',
SQLField('nickname', type='string'),
SQLField('bio', type='text'),
SQLField('owner', db.auth_user, notnull=True, required=True,
writable=False),
SQLField('image', 'upload', uploadfield='image_data'),
SQLField('image_data', type='blob', default='', writable=False)
)
profile.py controller:
-
def index():
# create profile form and profile info containers
profile_form = jDiv('',URL(r=request,f='edit'),_id='1')
user_profile = jDiv('',URL
(r=request,f='profile'),timeout=0.01,_id='2')
return (profile_form = profile_form )
def edit():
user_profile=db(db.user_profile.owner==auth.user.id).select()[0]
form=SQLFORM(db.user_profile, user_profile, deletable=False)
if form.accepts(request.vars,session):
   # refresh profile container
jDiv.set(jDiv.trigger('#target_2','load'))
return dict(form=form,user_profile=user_profile)
def profile():
# first get our profile, if we don't yet
# have one, then create it
try:
profile=db(db.user_profile.owner==auth.user.id).select()[0]
except:
db.user_profile.insert(owner=auth.user.id,nickname='n00by')
profile=db(q_profile).select()[0]
return dict(profile=profile)
index.html view:
-
{{extend 'layout.html'}}
{{=user_profile}}

{{=profile_form}}
profile.html view:
-

{{=auth.user.first_name + " " + auth.user.last_name}}'s Profile
Nickname: {{ =profile.nickname }}
email: {{=auth.user.email}}
{{ =profile.bio }}
edit.html view:
---
Edit profile
{{=form}}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20967] Re: File upload not working when form is in jDiv

2009-05-01 Thread Ted G

On a related note:

What is the best way to trigger a Javascript function upon a jDiv load
or form submit within a jDiv? For example:

I have a list of customers shown in jDiv1. User clicks a link for a
given customer and I load customer's update form in jDiv2 (which I
also make visible at that point). When user submits form, I hide
jDiv2, reload jDiv1.

Having the customer link call a Javascript function to show jDiv2 and
call jDivLoad manually with the appropriate callback for the given
customerID works fine. I'm not sure of the best way to have jDiv2's
submit success result in another Javascript function call, where I
reload jDiv1 and hide jDiv2?

I note in the example, that jDiv.set(jDiv.trigger('#target_1','load'))
is used to force a refresh of another div after submitting a form. Can
this mechanism be used instead to call a javascript function? Ideally,
I wouldn't want one jDiv to have to know about the other, I would
prefer to keep my partials loosely coupled and bind their behavior
with one another together through javascript on the client side in
order to facilitate better re-use of those partials.




On May 1, 1:38 pm, Wes James  wrote:
> ceej is also working on an update to jdiv to be out in a few weeks maybe.
> (if he get's time to work on it.)  Maybe he can look at this while doing his
> update :)
>
> -wj
>
> On Fri, May 1, 2009 at 2:13 PM, mdipierro  wrote:
>
> > This may a bug in JS library used to handle jDiv. I will investigate
> > but it will not be solved overnight.
>
> > Massimo
>
> > On May 1, 2:21 pm, Ted G  wrote:
> > > I've been trying out the new jDiv container, which works well with the
> > > exception of forms containing upload fields. I thought I would start a
> > > new thread for this, as my previous post (included below), seemed out
> > > of place in the old thread.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20972] Re: File upload not working when form is in jDiv

2009-05-01 Thread Ted G

That is how I've resorted to for now as well (with the exception of
the file upload part of my form not working as mentioned at start of
this thread).

Your example is a good one and similar to my own. Using your example,
I want to be able to re-use the FormjDiv partial in other pages of the
site. It is hard to re-use FormjDiv when it is coupled to HoursjDiv on
the controller side (as a result of FormjDiv refreshing HoursjDiv).
Ideally, I would want to have FormjDiv trigger a Javascript function,
either a specific named one I provide, or have it always call a
generic function - eg. jDivLoadSuccess(target) that I can implement on
the client side to take action.

In the generic case, the jDiv, upon successful submission would call
jDivLoadSuccess(target) passing its own target_id. I could then use
this to determine what action just took place and what action to take
next. In your example, if this function was called as a result of
target_FormjDiv submitting, then I would call jDivLoad
("target_HoursjDiv", myURL, null) to force a load of HoursJDiv. I
could also then hide FormJDiv, refresh it, and any other actions I
wish to take.

Not being forced to couple jDiv behavior together on the server side,
opens up much better scenarios for customizing interaction between
jDiv's and re-use of those jDiv's.


On May 1, 3:59 pm, Wes James  wrote:
> Right now with my time tracker i have:
>
> FormjDiv
> HoursjDiv
> Last20itemsjDiv
>
> When I submit FormjDiv it goes away (the lower part of the jDiv), but it
> refreshes HoursjDiv on the callback.  At the end of the code for HoursjDiv i
> have it trigger FormjDiv to open it up again with a new form (like click the
> first top button) and also to refresh contents in Last20itemsjDiv.
>
> There's probably a better way to do this, but this works for now.
>
> -wj
>
> On Fri, May 1, 2009 at 4:52 PM, Ted G  wrote:
>
> > On a related note:
>
> > What is the best way to trigger a Javascript function upon a jDiv load
> > or form submit within a jDiv? For example:
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21193] Re: File upload not working when form is in jDiv

2009-05-04 Thread Ted G

After some more digging, it would seem the problem with the file
upload failing may be that multipart forms cannot be submitted via
ajax. Given that file upload is a very common feature of forms, and
that forms are very common implementations of a partial (as shown in
the jDiv demos), not having file upload within a jDiv form would limit
it's usefulness.

jQuery already has an ajax form plugin that can handle file uploads in
ajax forms by using a hidden iframe. Since web2py is already using
jQuery would it make sense to incorporate this plugin as part of the
jDiv functionality for submitting forms? Incorporating this plugin
would also open the door to other form behavior customizations on the
client side such as progress meters, etc, which would also be very
useful.

Ted


On May 1, 4:29 pm, Ted G  wrote:
> That is how I've resorted to for now as well (with the exception of
> the file upload part of my form not working as mentioned at start of
> this thread).
>
> Your example is a good one and similar to my own. Using your example,
> I want to be able to re-use the FormjDiv partial in other pages of the
> site. It is hard to re-use FormjDiv when it is coupled to HoursjDiv on
> the controller side (as a result of FormjDiv refreshing HoursjDiv).
> Ideally, I would want to have FormjDiv trigger a Javascript function,
> either a specific named one I provide, or have it always call a
> generic function - eg. jDivLoadSuccess(target) that I can implement on
> the client side to take action.
>
> In the generic case, thejDiv, upon successful submission would call
> jDivLoadSuccess(target) passing its own target_id. I could then use
> this to determine what action just took place and what action to take
> next. In your example, if this function was called as a result of
> target_FormjDiv submitting, then I would call jDivLoad
> ("target_HoursjDiv", myURL, null) to force a load of HoursJDiv. I
> could also then hide FormJDiv, refresh it, and any other actions I
> wish to take.
>
> Not being forced to couplejDivbehavior together on the server side,
> opens up much better scenarios for customizing interaction betweenjDiv'sand 
> re-use of thosejDiv's.
>
> On May 1, 3:59 pm, Wes James  wrote:
>
> > Right now with my time tracker i have:
>
> > FormjDiv
> > HoursjDiv
> > Last20itemsjDiv
>
> > When I submit FormjDiv it goes away (the lower part of thejDiv), but it
> > refreshes HoursjDiv on the callback.  At the end of the code for HoursjDiv i
> > have it trigger FormjDiv to open it up again with a new form (like click the
> > first top button) and also to refresh contents in Last20itemsjDiv.
>
> > There's probably a better way to do this, but this works for now.
>
> > -wj
>
> > On Fri, May 1, 2009 at 4:52 PM, Ted G  wrote:
>
> > > On a related note:
>
> > > What is the best way to trigger a Javascript function upon ajDivload
> > > or form submit within ajDiv? For example:
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21201] Re: File upload not working when form is in jDiv

2009-05-04 Thread Ted G

A bit more follow up on this topic of taking action after an ajax load
call on the jDiv.

Right now the jDivLoad function in the provided web2py_ajax.html makes
the assumption that the command to be evaluated on completion of the
load will be provided by the web2py host application. As mentioned in
my other response to Wes, while I feel this is definitely a valuable
option for those who wish to control the flow of the client from the
host, in more complex apps where there is re-use of partials among web
pages, it may be preferable to control the flow of the client via
javascript in the client itself in order to have a looser coupling
between jDiv's.

Also, there are many cases where the function you wish to call upon
loading a jDiv is something other than the default provided by
jDivLoad (like auto selecting the first item in a list of items for
showing in another jDiv). Right now, this can be specified by jDiv.set
('command') on the host side prior to completing the request handler,
but, again, this requires that my request handler have knowledge of
the function in the view that will be called.

Since jDivLoad is wrapping up the jquery .ajax call for the
implementation of the load, can we have jDivLoad also accept
parameters for the jQuery .ajax beforeSend, success and complete
options and evaluate those commands along with the custom commands
that might be passed back from the host in the response? This would
allow the client more options for sophisticated behavior.

Ted


On May 1, 3:59 pm, Wes James  wrote:
> Right now with my time tracker i have:
>
> FormjDiv
> HoursjDiv
> Last20itemsjDiv
>
> When I submit FormjDiv it goes away (the lower part of the jDiv), but it
> refreshes HoursjDiv on the callback.  At the end of the code for HoursjDiv i
> have it trigger FormjDiv to open it up again with a new form (like click the
> first top button) and also to refresh contents in Last20itemsjDiv.
>
> There's probably a better way to do this, but this works for now.
>
> -wj
>
> On Fri, May 1, 2009 at 4:52 PM, Ted G  wrote:
>
> > On a related note:
>
> > What is the best way to trigger a Javascript function upon a jDiv load
> > or form submit within a jDiv? For example:
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21218] Re: File upload not working when form is in jDiv

2009-05-05 Thread Ted G

Sure.

jDiv1 = Customer Detail/Form
jDiv2 = Invoice List
jDiv3 = Invoice Detail/Invoice Form

The above jDiv's are partials that are re-used in a number of
different views. jDiv2 is not always used in a view where jDiv3 is
used for example.

One of the views does use all of the above jDivs. In this view the
user may:

A. View/Edit the Customer Detail. This is accomplished using an edit
link with onclick="editCustomer()". editCustomer() calls jDivLoad for
jDiv1, providing the URL to the customer form request handler, thus
replacing the customer detail view with the customer edit form. Upon
submitting the form, jDiv1 is reloaded with the customer detail view,
showing any changes. While the reload can be accomplished by doing a
redirect to the customer detail after form accept, this is not the
behavior always required when this form is used within a jDiv. To
ensure the form can be re-used, I need to either pass additional
parameters to the customer form request handler and take the
appropriate action there after form submit based on what view the form
is being used in, or I can keep the form handler generic, and instead,
using javascript in the view that uses the form, call jDivLoad with
the appropriate URL after successful form submit.

B. When view is first loaded and invoice list jDiv2 is populated, the
first invoice is selected and shown in jDiv3. I could have jDiv2's
request handler force a load of jDiv3 with the first item in the list,
but this means jDiv2 must know about jDiv3 in jDiv2's request handler.
This is not always how jDiv2 is used in a view. Better solution is to
simply use jquery after jDiv2 is loaded, to select the first  in
the invoice list, set it's class to "selected" so that CSS can
highlight it, and then call jDivLoad with the appropriate URL to load
jDiv3. This makes sense as I would re-use that same javascript code
for the onclick event of each invoice item in the list, allowing the
user to select an invoice in the list, highlight it and see it
displayed in jDiv3.

C. Like the customer form, the invoice detail can be edited. When the
user chooses to edit, jDiv3 is reloaded with the form view. When the
form is submitted, jDiv3 is reloaded with the detail view. Again, the
invoice form is not always used in this manner (redirecting back to
the detail view), so it does not make sense to code this behavior in
the request handler for the invoice form. It makes more sense to call
jDivLoad as a result of clicking the edit link from a javascript
function in the view and display the form. Then once the form is
submitted, callback to a javascript function that does a jDivLoad to
reload the invoice detail for display.

So what I'm trying to illustrate in a very long winded way, is that
while there is a way to accomplish the three actions listed above by
using redirection and setting the trigger command for the jDiv in the
request handler, it means that I would have to have code in the
request handlers for each of the different use cases of the jDivs. It
would be preferable to keep the jDiv's generic and not dependent on
one another, and instead use javascript in the view to dictate how the
jDiv's behave with one another.

Which leads me finally, to my previous suggestion:

My understanding is that currently, the only way to have a javascript
function called upon completion of a jDivLoad is to specify that
function by using jDiv.set in the request handler of the URL being
loaded. To keep jDiv's loosely coupled from one another and thus more
re-useable, it would be preferable to have the option to also set the
completion callback when jDivLoad is being called directly from
javascript within the view. Currently jDivLoad only accepts target,
url and params as parameters. It then sets up the beforeSend, success
and complete options of the jquery .ajax call that is used to load the
URL for the jDiv.

Since jDivLoad is encapsulating the behavior of the jQuery .ajax call,
you cannot specify callbacks for beforeSend, success, or complete,
which you would normally use when using jquery .ajax. Ideally, if
jDivLoad extended the behavior of the jQuery .ajax by introducing its
custom behavior, but still allowed you to specify the callbacks, you
would have the option of controlling interaction of the jDivs with one
another completely through javascript without involving the request
handlers.

I hope I've explained this well enough.

Ted

On May 4, 6:37 pm, mdipierro  wrote:
> Can you provide an example? I am not sure this cannot be done already.
>
> On May 4, 4:28 pm, Ted G  wrote:
>
> > A bit more follow up on this topic of taking action after an ajax load
> > call on the jDiv.
>
> > Right now the jDivLoad function in the provided web2py_ajax.html makes
> > the assumption that the command to be evaluated on completion of the
> > load will be provided by the web2py host application. As mentione

[web2py:21256] Re: File upload not working when form is in jDiv

2009-05-05 Thread Ted G

I've modified jDivLoad to incorporate the jQuery form plugin in order
to enable file uploads within forms that are part of a jDiv. I thought
I would post the change below so that whoever is working on jDiv can
incorporate this functionality in a better way than the hack I've done
for my purposes. Note that as per other discussions in this thread,
I've also added callbacks that fire on jDiv load and after successful
ajax form submission. I've done this for my implementation so that I
can specify callbacks when calling jDivLoad from javascript in my
view, instead of relying on setting the callback using jDiv.set in the
request handler.

The important thing is that uploading of files within a jDiv now works
like a charm.

Ted

 Modified jDivLoad 


function jDivLoad(target,callback,params,onLoadCmd,onSubmitCmd) {
  $(target).attr('status','loading').trigger('loading',callback);


$.ajax({'type':'post','url':callback, 'data':params,
'beforeSend':function(xhr){
xhr.setRequestHeader('web2py-jDiv-Name',target) },
'success':function(text){ $(target).html(text); },
'complete':function(xhr,text){
$(document).trigger('set_form_constraints');
$(target +' input[type="submit"]').click(function(){
loc=xhr.getResponseHeader('Location');
if((this.form.action=='' || this.form.action=='.') && 
loc)
this.form.action=loc;
$('form').ajaxSubmit({
'target':target,
'url':loc,
'type':'post',
'success':function(text){ if(onSubmitCmd) eval
(onSubmitCmd) },
});
return false;
});

command=xhr.getResponseHeader('web2py-jDiv-Commands');
if(command) eval(command);
if(onLoadCmd) eval(onLoadCmd);
$(target).attr('status','loaded').trigger('loaded',callback);
 } });
}


On May 4, 1:25 pm, mdipierro  wrote:
> I agree.
>
> On May 4, 2:36 pm, Ted G  wrote:
>
> > After some more digging, it would seem the problem with the file
> > upload failing may be that multipart forms cannot be submitted via
> > ajax. Given that file upload is a very common feature of forms, and
> > that forms are very common implementations of a partial (as shown in
> > the jDiv demos), not having file upload within a jDiv form would limit
> > it's usefulness.
>
> > jQuery already has an ajax form plugin that can handle file uploads in
> > ajax forms by using a hidden iframe. Since web2py is already using
> > jQuery would it make sense to incorporate this plugin as part of the
> > jDiv functionality for submitting forms? Incorporating this plugin
> > would also open the door to other form behavior customizations on the
> > client side such as progress meters, etc, which would also be very
> > useful.
>
> > Ted
>
> > On May 1, 4:29 pm, Ted G  wrote:
>
> > > That is how I've resorted to for now as well (with the exception of
> > > the file upload part of my form not working as mentioned at start of
> > > this thread).
>
> > > Your example is a good one and similar to my own. Using your example,
> > > I want to be able to re-use the FormjDiv partial in other pages of the
> > > site. It is hard to re-use FormjDiv when it is coupled to HoursjDiv on
> > > the controller side (as a result of FormjDiv refreshing HoursjDiv).
> > > Ideally, I would want to have FormjDiv trigger a Javascript function,
> > > either a specific named one I provide, or have it always call a
> > > generic function - eg. jDivLoadSuccess(target) that I can implement on
> > > the client side to take action.
>
> > > In the generic case, thejDiv, upon successful submission would call
> > > jDivLoadSuccess(target) passing its own target_id. I could then use
> > > this to determine what action just took place and what action to take
> > > next. In your example, if this function was called as a result of
> > > target_FormjDiv submitting, then I would call jDivLoad
> > > ("target_HoursjDiv", myURL, null) to force a load of HoursJDiv. I
> > > could also then hide FormJDiv, refresh it, and any other actions I
> > > wish to take.
>
> > > Not being forced to couplejDi

[web2py:21261] Re: Open to suggestions

2009-05-05 Thread Ted G

I've used the same technique you describe in order to create a better
form layout. In my case I did not have as many fields, but I did have
a few text areas, which created a "vertically challenged" form.

Same as your approach, I create a form using SQLFORM as per normal and
pass it to the view with return dict(form=form).

In the view, the form is defined without using {{=form}}. Instead, the
form and all inputs are declared in the view and grouped into
appropriate divs, which are shown/hidden based on clicking tabs to
view different sections of the form.

Just be sure to include the hidden fields required by form.accepts in
your form. You can do this by including:

{{=form.hidden_fields()}}

within the form as well as



if the form is being used to update an existing record.

For the inputs in your form, you can use
value="{{=form.record.yourfieldname}}" as the value of the input field
when updating an existing record. Note that form.record does not exist
if your form is creating a new record, therefore you'll need the
appropriate logic in the view to handle setting the appropriate value
for your input fields.

Not sure if the above is the best strategy, but it is one I have been
using with success.

Ted


On May 5, 10:02 am, JohnMc  wrote:
> Working on another application. One table in the DAL will have about
> 60 Fields in it. Using one long form would work but gets rather bland.
> I would prefer to visually cut it up. I could either capture the data
> in multiple screens for input or use a tabbed interface to capture the
> data. I am leaning toward the tabbed interface.
>
> The one approach I have considered for a tabbed approach is --
>
> Controller:
>
> Build the form using helper functions and pass as to dict()
>
> View :
>
> Set up the tabs, display the form and use jQuery hide(), show()
> functions using onclick actions to display pieces of the form as
> required.
>
> I would be interested if there might be a better technique to consider
> to achieve the same ends.
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21305] Re: Best way to handle rich website?

2009-05-06 Thread Ted G

If you do a search on jDiv you will find a few recent threads
discussing this topic (related to the example link provided by
Massimo). I've been heading down this road myself, creating a site
where site pages are simply container based layouts containing re-
useable "applets". The pattern I've found that works so far is as
follows:

layout.html - contains common style sheets, javascript and layout
containers common across all pages (eg. Header, Menu, Body, Footer).
Provides  an {{include}} in the body area.

mypage.html - contains specific styles, javascript and layout
containers for the body area of a specific page that contains a number
of applets. Basically the "glue" that coordinates the interaction of
the various applets on the page. Within the layout defined in this
page are your applets {{=applet1}} , {{=applet2}}, etc.

The controller action for the mypage.html view creates applet1,
applet2, etc. as jDiv's and returns them to the view via dict
(applet1=applet1, applet2=applet2, ...)

The individual applets actions/views may be in the same controller as
mypage or in different controllers. Ideally, your applet's view would
contain only that html specific to that applet's layout so that it is
easily re-used. Since the applet will be able to utilize the
javascript and css in layout.html and mypage.html you can rely on
those layout pages to provide the CSS styling for the applet so that
it is easier to make site wide style changes later.

Making use of a CSS framework can help with consistent site wide
layout. I've used the blueprint css framework successfully with
web2py. CSS frameworks are not for everyone, but for CSS challenged
indviduals like myself, they are a real time saver.

Ted

On May 6, 3:15 am, Joe  Barnhart  wrote:
> I've been pondering the best way to create sites with rich pages that
> contain lots of "applets" or "tasklets".  It seems limiting to have
> the entire page tied to a single Python function.  Maintaining the
> site could be problematic if everything funnels through one
> "controller" function.
>
> Then I wondered about the structure of the layout files.  I like the
> "extend" and "include" functionality.  I imagine I could create a tree
> of html files --- one for each applet div, for example, with
> layout.html at the root.  Perhaps a "news" area and a "calandar" area
> in addition to the main body, for example.
>
> Each functional block could be represented by a file such as
> "news.html" and "calandar.html" included into layout.html.  The
> controller for each would then extend its own html file instead of the
> top-level "layout.html" file.
>
> Is there a still better way to organize a busy site?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21456] Re: todo & help

2009-05-07 Thread Ted G

With the RSS Examples and 90 second Blog example in FAQ, latest
Twitter examples and GAE hosting (or existing web2py server), it would
seem that all the pieces are there to put together a basic free hosted
web2py blog with the ability to post entries (title + summary) to
twitter and provide an RSS feed (title + story) of that blog. Maybe
adding booleans to each post whether to publish the post to Twitter
and/or RSS for flexibility. Nice showcase of capabilities.

Just a thought.

In terms of seeing tweets or rss in the admin app, I can see how some
might find that useful, but why have yet one more RSS/Twitter client
to look at? Also, using Eclipse as my primary IDE running web2py on
GAE, I can't remember the last time I even looked at the admin
interface.

Ted









On May 7, 9:08 pm, mdipierro  wrote:
> I do not have string feeling about this but, if we swicth to RSS I do
> not want to maintain my own feed. What service should I use?
>
> Massimo
>
> On May 7, 10:31 pm, Yarko Tymciurak  wrote:
>
> > Alvaro -
>
> > Just to be clear - I am not arguing with you; I am just thinking out loud.
>
> > I think an admin interface is not place for _any_ kind of news feeds
>
> > BUT... if Massimo wants to send out his own tweeter/web2py account and use
> > it for brief news, and he is who generates these "tweets", it is ok with me.
>
> > Respectfully,
> > Yarko
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22623] 411 Error from Google App Engine resulting from jDivLoad on Firefox

2009-05-25 Thread Ted G

An FYI for anyone experimenting with jDivLoad ...

If you deploy a web2py app using jDivLoad to Google App Engine (this
does not happen in the SDK), you may receive 411 errors when those
jDiv's attempt to load while using Firefox (this issue is not
necessarily isolated to just GAE).

The jDivLoad function provided in the webpy_ajax.html sample code
utilizes the jQuery .ajax call to post the request. If you do not
provide any data for the jDIvLoad params parameter (which is then
passed as the jQuery .ajax data parameter as null) you will receive
the 411 error from GAE.

To remedy the above situation, you need to ensure that you are not
passing null for the data parameter of the jQuery .ajax function when
performing a post. Add the following line prior to the .ajax call in
jDivLoad to catch this error:

params = params || {};

Ted




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py] Potential site trust abuse with default web2py setting?

2010-11-23 Thread Richard G
Howdy all,

In web2py I've noticed a number of methods in gluon/tools.py that
utilize client input to determine site flow:
if next == DEFAULT:
next = request.get_vars._next \
or request.post_vars._next \
or self.settings.login_next

and subsequent
if next and not next[0] == '/' and next[:4] != 'http':
next = self.url(next.replace('[id]', str(form.vars.id)))
redirect(next)

Methods:
  AUTH: login ,  register,  retieve_username,
reset_password_deprecated, reset_password,
request_reset_password(retrieve_password), change_password, profile,

  CRUD: update, delete

Too me this seems that a malicious individual can abuse the trust of
our site to:
a) trick users into instantiating a CSRF from our site
b) providing information (credentials?) to a phishing site.

I'm sure we can all come up with some simple examples to provide users
links that will redirect to a malicious site upon authentication.
Simple ex: (http://web2py-site/login?_next=http://web2py_site/login)
where the secondary site mimics original and identifies that the
authentication failed, and to reenter id/pw (even though we only get
here after original site auth was success).

Unless I am missing something, the _next flow seems a strange
'default' behaviour for a secure framework.

I'm wondering if the community has input / thoughts on my (perceived?)
_next issue.

Thanks all!!


[web2py] Re: Potential site trust abuse with default web2py setting?

2010-11-23 Thread Richard G
Sorry, I am not saying that a web2py site is susceptible to CSRF. I
meant that a web2py site could be used 'in the process' to perform a
request that match these criteria on another site.

I find it weird to click on a link that is going to a legitimate
web2py site, and loads this legitimate web2py site, but then redirects
to an external site, only after I authenticate. (Based on using
authentication).

Again, a simple example scenario:
ie: I receive a fraudulent email, asking me to update password.. click
on it (yes.. first mistake), it redirects me to a legitimate web2py
site (I think, maybe the email was not fraudulent?), which on this
web2py site after I perform an action, redirects me to another site.

I agree that a few items have to fall in place for this abuse to
occur. But it still seems that at one point in the process, the user
has placed trust in our site, and then our site redirects them
elsewhere.

If the community believes form submission redirection based on the
forms variables is not a threat to our environment (It doesn't present
a tangible risk to our site, but I see it as posing a risk to our
site's trust, and thus our user's trust) then I'll stop arguing :)

Again, thanks!


On Nov 23, 10:57 am, mdipierro  wrote:
> What you suggest is indeed possible but...
>
> This is not an example of CRSF. CRSF is when a malicous site redirects
> the user to a site where the user is already authenticated (a web2py
> site) and forces the user to perform action (for example submit a
> form). web2py prevents this by hiding a formkey in forms.
>
> When you suggest is an example of phishing. For the scam to work the
> victim would have to:
> 1) start from the malicious web site
> 2) login with a url provided by the malicious web site
> 3) provide credentials to a clone of the original web site.
>
> If a user falls for 1,2,3 there are much easier ways to implement this
> scam even if web2py did not provide the next functionality and without
> redirecting at all to the web2py site.
> I do not do believe this kind of phishing can be avoided.
>
> We can have a flag that checks whether _next is on a different domain
> but it would not prevent this type of scam, just this particular
> implementation.
>
> Massimo
>
> On Nov 23, 10:42 am, Richard G  wrote:
>
> > Howdy all,
>
> > In web2py I've noticed a number of methods in gluon/tools.py that
> > utilize client input to determine site flow:
> >         if next == DEFAULT:
> >         next = request.get_vars._next \
> >             or request.post_vars._next \
> >             or self.settings.login_next
>
> > and subsequent
> >     if next and not next[0] == '/' and next[:4] != 'http':
> >         next = self.url(next.replace('[id]', str(form.vars.id)))
> >     redirect(next)
>
> > Methods:
> >   AUTH: login ,  register,  retieve_username,
> > reset_password_deprecated, reset_password,
> > request_reset_password(retrieve_password), change_password, profile,
>
> >   CRUD: update, delete
>
> > Too me this seems that a malicious individual can abuse the trust of
> > our site to:
> > a) trick users into instantiating a CSRF from our site
> > b) providing information (credentials?) to a phishing site.
>
> > I'm sure we can all come up with some simple examples to provide users
> > links that will redirect to a malicious site upon authentication.
> > Simple ex: (http://web2py-site/login?_next=http://web2py_site/login)
> > where the secondary site mimics original and identifies that the
> > authentication failed, and to reenter id/pw (even though we only get
> > here after original site auth was success).
>
> > Unless I am missing something, the _next flow seems a strange
> > 'default' behaviour for a secure framework.
>
> > I'm wondering if the community has input / thoughts on my (perceived?)
> > _next issue.
>
> > Thanks all!!
>
>


[web2py] Re: Syntax for placeholders in executesql

2010-12-01 Thread Richard G
As I understand Web2py passes this off to the database adapter that is
in use (likely psycopg2 in this case).

Psycopg2 accepts arguments in a couple different forms, using the '%s'
as you identify below, as well as named references with '%(name)s'.

There are a few caveats when using query parameters that are specific
to psycopg2. More information (with better explanation then I can
provide) is available at:
http://initd.org/psycopg/docs/usage.html

Hope this helps

On Dec 1, 1:29 am, Chris  wrote:
> Hey all,
>
> I was trying to use executesql with placeholders, based on the
> documentation in source and the mailing list [1]. The syntax on the
> site seems to suggest using question marks, for example:
>
> db.executesql("select * from auth_user where id = ?", [4])
>
> I was banging my head against this for a while until I realized that
> the syntax that works is actually:
>
> db.executesql("select * from auth_user where id = %s", [4])
>
> (not sure if this is in postgres or everywhere in general.) Is this
> correct, and if so can it be added to the documentation?
>
> Thanks!
>
> [1]http://groups.google.com/group/web2py/browse_thread/thread/dd01da67ca...


[web2py] New User - a few simple questions...

2011-01-25 Thread g...@rtplanb.com
I have been enjoying the learning process with web2py, honestly I have
little knowledge of html, css and especially ajax.
I am not far off having a functional website building on the
scaffolding application, however I have a few questions please:


How do I move static files (e.g *.png) into folders (i.e. /static/
images) using admin interface? I can only seem to get them in /static
but want to keep the folders tidy.

I have 2 base.css files in /static and one in /static/css why?

what does web2py_ajax.html do? Why are ajax components required?


There seems to be a space for a logo in layout.html and base.css which
is the best to use?


Not web2py related as such but I have created a favicon.ico of my
own, but it is circular. In gimp/inkscape the background is
transparent but when the favicon appears in my tab within chrome it
has a white background. How do I fix this?


Cheers!
B


[web2py] Re: New User - a few simple questions...

2011-01-26 Thread g...@rtplanb.com
Thank you both for your replies.
I have got the favicon bit working. I read a bit online and exported
the inkscape .svg to .png using export bitmap, rather than Save As
png. It now looks perfect.

> I'm not sure moving files via admin is possible -- you're probably better
> off just doing that via the OS.

I didnt realise that I could access the application files directly!
Now my files are tidy! Thank you.

> The css and js files in the /static/css and /static/js folders are the ones
> used by the current scaffolding app (you can see that they are the
> ones included in the head of 'layout.html'). The files in the root /static
> folder are probably from the older scaffolding app -- they may be there
> because you first downloaded an older version of web2py and later unzipped
> the newer version on top of the old version.

Thank you again! That is exactly what has happened, I have upgraded a
few times. I will delete the unused files.
All the other information was also very useful thank you Anthony.
I have kept the logo file in .css.

One more quick question..
The scaffolding app has a nice menu bar below the logo. Showing 3
menus. 2 of which 'drop down'. How do I edit these lists? I have
managed to edit the rest of th page using the html, css, static files
and the controller. It looks like it has something to do with
superfish java but beyond that im stumped.

Thanks again


[web2py] Re: New User - a few simple questions...

2011-01-27 Thread g...@rtplanb.com

Cheers Anthony, Ill get started on the menu's. Not far from being able
to deploy my first Web2Py website!!!


[web2py] Deployment Confusion

2011-01-29 Thread g...@rtplanb.com
I have been happily designing my business website for a while now.
Web2Py is very easy to use and has been a brilliant way to learn html,
css and a bit of java.

I am getting close to wanting to deploy the first version of m site
but honestly, after reading the deployment section of the web2py book
I find it daunting and confusing.

I have a hosting account and domian with godaddy.com.

Ideally I would like both upload my current website and have my draft
versions all accessible from the admin interface online. Is this
possible?
Is it worth going down the google app engine route? This seems a
little simpler?


Im sorry if I am not making any sense,







[web2py] Re: Deployment Confusion

2011-01-30 Thread g...@rtplanb.com
Thank you for the advice, but as I already have a years domain and
hosting with godaddy I was hoping for some specific advice regarding
setup using that service.
godaddy support suggest that I simply upload all the files from my
web2py application but I asssume this will not give me admin interface
access?
I have really enjoyed using web2py but if the deployment isnt simple I
may have to change to something supported by my hosting provider, like
wordpress, joomla or drupal.


[web2py] Re: Deployment Confusion

2011-01-30 Thread g...@rtplanb.com
Thank you all for your help so far.
I will try your suggestions. I can get SSH access to my host.
It runs Python 2.4.3
and Linux distro is quoted as: Linux
n1nlftpg005.shr.prod.ams1.secureserver.net 2.6.18-194.26.1.el5PAE #1
SMP Tue Nov 9 13:34:42 EST 2010 i686 i686 i386 GNU/Linux


On Jan 30, 4:46 pm, Bruno Rocha  wrote:
> AS I said,I know only two host options where you can simply put the files
> there and everything runs without the need of configuration. ['Google App
> Engine', 'webfaction']
>
> In other shared hosts you need to follow some deployment instruction:
>
> I guess this slice works for 
> godaddyhttp://www.web2pyslices.com/main/slices/take_slice/76
>
> or if you have a VPS you can use deployment script on /scripts folder, or
> follow this slices (deppending on your VM 
> setup)http://web2pyslices.com/main/slices/take_slice/110http://web2pyslices.com/main/slices/take_slice/98
>
> Here in Brazil, we have a shared host (kinghost.com.br) that has 'One Click
> Install for web2py' in control panel, but I dont know any other.
>
> In the bookhttp://web2py.com/book/default/chapter/11you can find
> information needed to setup web2py with wsgi, mod_wsgi and mod_python.
>
> Python web apps (indepent of teh framework you are using) works in a
> different way of PHP or ASP applications.
>
> Do you know exactly what is the setup provided by GoDaddy? Python Version,
> Linux Distro?


[web2py] Re: A Web2py CMS like Joomla ?

2012-10-29 Thread Ivan G
I am new to Python (leaving php) and new to web2py.

I have tried to learn django, but the break of backwards compatibily made I 
leave it quickly,
because was difficult to find expert people with the new versions and 
probably more
backward compatibility breakings, so web2py seems a very good option.

As I have no experience with it, could you explain what are those gaps you 
see to try to
understand how we all of us can try to face the challenge of build 
modules/plugins/whatever
needed to fill those gaps?

A CMS is always a good way to manage information for a site and almost 
always you will need one. Even when are few content pages is always better 
to have it
a module/plugin that lets you have it organized and edit it in a wysiwyg 
way.

 
El lunes, 10 de septiembre de 2012 02:32:37 UTC+2, song escribió:
>
> I'm an old  scientist and engineer. 
> I agree all of the writers in this topic.
> But web2py is products for prgrammer than for end-usesr or 
> application-programmers.
> And there are many end-users and application-programmers and programmers 
> are a few.
> In the  web2py programes there is some gaps for the end-users and 
> application-programmers to use.
> If there are no efforts to eliminate the gaps, all of the works in web2py 
> will be in vain in the future.
> For programmers the efforts to study web2py and to program by python or 
> other languages is same, I think.
>
> So,  We(you and  I ) must have some efforts to overcome the gaps.
>
>
>
> 2012년 5월 25일 금요일 오후 12시 54분 54초 UTC+9, Andrew W 님의 말:
>>
>> There have been numerous posts on a web2py based cms, and I know there 
>> are many solutions out there, at varying stages of development.   They each 
>> have a different focus so it is not a simple question of "which one is 
>> best".  I won't try and mention them by name.
>>
>> However,  A colleague of mine was talking about Joomla and I wanted to be 
>> able to offer some "strategy" on a comparable web2py cms.   Would anyone 
>> care to comment on which of the web2py cms' would be a contender to Joomla 
>> ?  If not now, perhaps with a roadmap for the future.
>>
>> Personally, and I've said it before,  cms functionality is very 
>> important, and I think we should highlight the cms offerings on the web2py 
>> website.  Not necessarily one, but showcase the "best of ...".For 
>> example, look at http://www.zope.org/the-world-of-zope   It mentions 
>> Plone and Silva.  Such a thing would also strenghten the adopton of 
>> web2py.  Are they production ready enough to do that ?
>>
>> Thankyou.
>>
>> Andrew W
>>
>

-- 





[web2py] Problems installing web2py in a virtualenv in Windows 7

2012-11-29 Thread Bernardo G.


I'm new to Python and I'm trying to install web2py in a virtualenv. I'm 
running a 32 bit python 2.7.3 installation on a 64 bit Windows 7.

>From what I read, this should be the process:

   - install virtualenv (done)
   - create the virtualenv (done)
   - install pywin32 in that env (I've read it needs to be installed before 
   the web2py installation)
   - install web2py in that env

First and foremost: is that right? If so, then...

I tried installing pywin32 through

'''easy_install pywin32-218.win32-py2.7.exe'''

It went fine. Then, I checked the virtual environment's site-packages for a 
pywin32 folder and it was there, but I couldn't import it into python 
('''ther's no module pywin32'''). The environment was definitely active (I 
double-checked).

As a test, without using virtualenv, I double-click-installed the pywin32 
binary (downloaded the 32 bit version for python 2.7 -- 
pywin32-218.win32-py2.7.exe) but got an error at the end:

'''close failed in file object destructor:

sys.excepthook is missing

lost sys.stderr'''

I downloaded the file again (could be corrupted), tried installing it again 
but got the same result.

Could anybody guide me or point me to a step-by-step install of pywin32 (if 
necessary) and then web2py for windows 7? I'd really appreciate it.

-- 





[web2py] BELONGS is not supported on GAE?

2012-02-20 Thread Peter G.
I'm trying to obtain a set of rows whose ID values belongs in rows'
fields of another table.

Here's the code:

# Construct a query to fetch all the mootid's from the group
mootGroup =
db(db.moot_groups.gid==groupid)._select(db.moot_groups.mootid)
# Gets moots only if the moot ID exists in the Group query
moots =
db((db.moots.url==request.get_vars.url)&(db.moots.id.belongs(mootGroup))).select(db.moots.ALL)

The error in the admin says this:
File "/base/data/home/apps/356965595645653415/gluon/dal.py", line
3367, in BELONGS
raise SyntaxError, "Not supported"
SyntaxError: Not supported

Thanks!


[web2py] Re: BELONGS is not supported on GAE?

2012-02-21 Thread Peter G.
Hmm, if that's the case, can someone recommend a viable alternative to
perform what I'm trying to do with an operation that works under GAE?

On Feb 20, 11:09 pm, guruyaya  wrote:
> I think inner select belongs are not supported by GAE, but using an
> array, is. Can anyone confirm what I just said (read the code, didn't
> test it).
>
> On 21 פברואר, 08:06, "Peter G."  wrote:
>
>
>
>
>
>
>
> > I'm trying to obtain a set of rows whose ID values belongs in rows'
> > fields of another table.
>
> > Here's the code:
>
> > # Construct a query to fetch all the mootid's from the group
> > mootGroup =
> > db(db.moot_groups.gid==groupid)._select(db.moot_groups.mootid)
> > # Gets moots only if the moot ID exists in the Group query
> > moots =
> > db((db.moots.url==request.get_vars.url)&(db.moots.id.belongs(mootGroup))).s 
> > elect(db.moots.ALL)
>
> > The error in the admin says this:
> > File "/base/data/home/apps/356965595645653415/gluon/dal.py", line
> > 3367, in BELONGS
> >     raise SyntaxError, "Not supported"
> > SyntaxError: Not supported
>
> > Thanks!


[web2py] Re: BELONGS is not supported on GAE?

2012-02-24 Thread Peter G.
BrendanC: Thanks for those resources! I ended up gutting that
functionality for now, but those are some great read :)! The non-
relational database backend requires some "unlearning" of SQL database
practices... New challenge for a new environment.

I also have not gotten a local shell working with GAE; it would be
really helpful for interactive development if it existed!

howesc: I'm using the latest stable version (1.99.4). While your
method works as a work around of sorts, it's far too crippled by GAE's
non-relational nature. I would potentially need dozens of queries in
order to fetch all possible mootGroups since GAE limits IN to only 30
items per query! So I simply had to de-normalize the database and gut
the feature I was working on from before.

Thank you both for your helpful replies, I'll definitely be asking
more questions as I hobble along ;)!


[web2py] " float argument required" occurs when registering a user on GAE SDK

2012-02-25 Thread Peter G.
The full stack trace is as follows:

Traceback (most recent call last):
  File "/home/pyg/Development/capstonemoot/web2py/gluon/
restricted.py", line 204, in restricted
exec ccode in environment
  File "/home/pyg/Development/capstonemoot/web2py/applications/init/
controllers/default.py", line 72, in 
  File "/home/pyg/Development/capstonemoot/web2py/gluon/globals.py",
line 172, in 
self._caller = lambda f: f()
  File "/home/pyg/Development/capstonemoot/web2py/applications/init/
controllers/default.py", line 34, in user
return dict(form=auth())
  File "/home/pyg/Development/capstonemoot/web2py/gluon/tools.py",
line 1141, in __call__
return getattr(self,args[0])()
  File "/home/pyg/Development/capstonemoot/web2py/gluon/tools.py",
line 1938, in register
next = replace_id(next, form)
  File "/home/pyg/Development/capstonemoot/web2py/gluon/tools.py",
line 79, in replace_id
return url % form.vars
TypeError: float argument required

The registration IS successful as their information is stored in the
database and they can log-in afterwards.
The odd thing is that this ONLY occurs on local dev environment using
the latest web2py (1.99.4 stable) and GAE SDK (1.6.2), users can
register perfectly fine on the live version running on GAE.


[web2py] Re: " float argument required" occurs when registering a user on GAE SDK

2012-02-25 Thread Peter G.
Thanks Massimo, I'll update to trunk in that case.


[web2py] Obtaining URL to image blob in GAE

2012-02-25 Thread Peter G.
How would one obtain the URL to a image blob stored on GAE's
datastore? A lot of the threads I've looked at were all for generating
an download output for views, but I need this for the Controller since
I'm returning this as a JSON element.

For example, the auth_user table has a field 'avatar' and another blob
field 'avatar_blob'. Ideally I can simply return a JSON like:
{ "avatar": "http:avatars/username_avatar.gif" }

Where username_avatar.gif would map to the stored blob image for that
user's avatar.


[web2py] Re: Obtaining URL to image blob in GAE

2012-02-29 Thread Peter G.
@Anthony & BrendanC: Thank you both for your code snippets! I've got
it working now :). It's loading the image from a blob field in GAE's
DB.

@howesc: Can you possibly expand on how you modified your code to work
with the blob store? That's something I'm also interested at looking
into (would save lots of instance hours if every avatar lookup wasn't
spinning up the app!). Thanks!


[web2py] Validating Registration fields

2012-03-22 Thread Peter G.
I'm using the auth.settengs.extra_fields to add an extra upload field for 
the user to upload an avatar, how can I add an IS_IMAGE validator to the 
upload field so that the user can't upload random files?

Also, how would I add an IS_ALPHANUMERIC to the built in First name and 
Last name form fields? Right now there are users registering with names 
like "!@#$%^~" and some such...

Thanks!


[web2py] Re: Validating Registration fields

2012-03-27 Thread Peter G.
Thanks for the code snippets Anthony--but a minor caveat I didn't realize 
ahead of time is that the user is free to either upload an image or not. If 
the user does not upload an image, the IS_IMAGE() validators barks at the 
user. Is there a easy way of implementing such a logic: "if a file is 
uploaded, check for IS_IMAGE(), otherwise ignore."?


On Thursday, March 22, 2012 3:38:01 PM UTC-7, Anthony wrote:
>
> On Thursday, March 22, 2012 6:09:25 PM UTC-4, Peter G. wrote:
>>
>> I'm using the auth.settengs.extra_fields to add an extra upload field for 
>> the user to upload an avatar, how can I add an IS_IMAGE validator to the 
>> upload field so that the user can't upload random files?
>
>
> When you define the field, you can do:
>
> Field('avatar', 'upload', requires=IS_IMAGE())
>
> or after the tables have been defined:
>
> db.auth_user.avatar.requires = IS_IMAGE()
>  
>
>>
>> Also, how would I add an IS_ALPHANUMERIC to the built in First name and 
>> Last name form fields? Right now there are users registering with names 
>> like "!@#$%^~" and some such...
>>
>
> After the tables have been defined, you can do:
>
> db.auth_user.first_name.requires.append(IS_ALPHANUMERIC())
>
> That adds the validator to the existing IS_NOT_EMPTY validator.
>
> However, I wouldn't use that validator for names because it doesn't allow 
> valid name characters such as spaces, hyphens, and apostrophes. Anyway, if 
> you prevent fake names with special characters, those users will just 
> create fake names with alphanumeric characters, so either way you don't 
> have a real name.
>
> Anthony
>


[web2py] Re: Validating Registration fields

2012-03-28 Thread Peter G.
Thank you so much! That worked like a charm :). I'm guessing this type of 
construct is valid for other validators as well?

On Tuesday, March 27, 2012 5:57:28 PM UTC-7, Anthony wrote:
>
> Try
>
> IS_EMPTY_OR(IS_IMAGE())
>
>
> Anthony
>
> On Tuesday, March 27, 2012 7:12:45 PM UTC-4, Peter G. wrote:
>>
>> Thanks for the code snippets Anthony--but a minor caveat I didn't realize 
>> ahead of time is that the user is free to either upload an image or not. If 
>> the user does not upload an image, the IS_IMAGE() validators barks at the 
>> user. Is there a easy way of implementing such a logic: "if a file is 
>> uploaded, check for IS_IMAGE(), otherwise ignore."?
>>
>>
>> On Thursday, March 22, 2012 3:38:01 PM UTC-7, Anthony wrote:
>>>
>>> On Thursday, March 22, 2012 6:09:25 PM UTC-4, Peter G. wrote:
>>>>
>>>> I'm using the auth.settengs.extra_fields to add an extra upload field 
>>>> for the user to upload an avatar, how can I add an IS_IMAGE validator to 
>>>> the upload field so that the user can't upload random files?
>>>
>>>
>>> When you define the field, you can do:
>>>
>>> Field('avatar', 'upload', requires=IS_IMAGE())
>>>
>>> or after the tables have been defined:
>>>
>>> db.auth_user.avatar.requires = IS_IMAGE()
>>>  
>>>
>>>>
>>>> Also, how would I add an IS_ALPHANUMERIC to the built in First name and 
>>>> Last name form fields? Right now there are users registering with names 
>>>> like "!@#$%^~" and some such...
>>>>
>>>
>>> After the tables have been defined, you can do:
>>>
>>> db.auth_user.first_name.requires.append(IS_ALPHANUMERIC())
>>>
>>> That adds the validator to the existing IS_NOT_EMPTY validator.
>>>
>>> However, I wouldn't use that validator for names because it doesn't 
>>> allow valid name characters such as spaces, hyphens, and apostrophes. 
>>> Anyway, if you prevent fake names with special characters, those users will 
>>> just create fake names with alphanumeric characters, so either way you 
>>> don't have a real name.
>>>
>>> Anthony
>>>
>>

[web2py] Cannot serve any pages after fresh install of Python2.5

2011-10-06 Thread Peter G.
I had a clean install of Ubuntu 11.04 + Python 2.7.1 running web2py
and it was working fine. Then I installed Python 2.5.6 by source,
tried visiting http://127.0.0.1:8000/ and I get the following errors
via Terminal:
DEBUG_c: Exception (,
AttributeError("'NoneType' object has no attribute
'PARSE_DECLTYPES'",))

This is printed 5 times (I guess it tries the connect 5 times).

In the admin interface through ticket system, I see the following:
TRACEBACK:
Traceback (most recent call last):
  File "/home/pyg/web2py/gluon/restricted.py", line 194, in restricted
exec ccode in environment
  File "/home/pyg/web2py/applications/examples/models/db.py", line 18,
in 
db = DAL('sqlite://storage.sqlite')
  File "/home/pyg/web2py/gluon/dal.py", line 4156, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
'NoneType' object has no attribute 'PARSE_DECLTYPES'

In file: /home/pyg/web2py/applications/examples/models/db.py

I'm completely new to web2py (and still a relative newbie to Linux),
so I'm not exactly sure what the problem could be. Of course, I did a
quick google, but turned up nothing useful. The only thing related to
PARSE_DECLTYPES was another post in this exact usergroup, but it was a
completely different issue.

Thanks for any potential insight anyone can provide :)!


[web2py] Re: Cannot serve any pages after fresh install of Python2.5

2011-10-06 Thread Peter G.
A clean install of Ubuntu, web2py, and/or Python? I did start with a
clean install of both web2py and Python (compiled from source). The
reason I'm "downgrading" (so to speak) to 2.5 is because I'm making an
app that I wish to run on Google App Engine, and GAE runs Python
2.5.2, so I'd like to develop in the same environment so as to not run
into any troubles down the line. I know that Ubuntu 11.04 comes with
2.6 and 2.7, so I had to install 2.5 separately.

The funny thing is, even if I run web2py with Python 2.6 or 2.7 (which
worked flawlessly before), it no longer works, and displays the same
error... Could it be something database related? More specifically,
the error seems to be complaining about a certain db operation. Maybe
it's not Python/web2py related at all?

Thoughts?

On Oct 6, 1:00 pm, pbreit  wrote:
> I'd suggest starting over with a clean install if possible. Is there some
> reason you are installing 2.5? If not, I'd avoid it and use what your server
> comes with.
>
> I use Ubuntu 10.04 which is a "long term support" release and comes with
> Python 2.6. But 11.04 should work fine, too.


[web2py] Re: Cannot serve any pages after fresh install of Python2.5

2011-10-06 Thread Peter G.
I did start with a clean install of both web2py and Python 2.5. The
reason why I'm "downgrading" (so to speak) to 2.5 is because I'm
planning on running my web app on Google App Engine, and GAE runs on
Python 2.5.2.

I know that Ubuntu 11.04 comes pre-installed with 2.6 and 2.7, so I
had to manually compile and install 2.5 from source.

I tried to run a fresh instance of web2py extracted from the zip file
with 2.6 and 2.7 afterwards, and they both failed with the same error,
which leads me to believe perhaps the error is elsewhere and is not
Python/web2py related. Given the context of the errors, could it be at
the database layer? And if so, what would be a good approach to
unearth the underlying problem caused by the db connection?

On Oct 6, 1:00 pm, pbreit  wrote:
> I'd suggest starting over with a clean install if possible. Is there some
> reason you are installing 2.5? If not, I'd avoid it and use what your server
> comes with.
>
> I use Ubuntu 10.04 which is a "long term support" release and comes with
> Python 2.6. But 11.04 should work fine, too.


[web2py] Re: Cannot serve any pages after fresh install of Python2.5

2011-10-07 Thread Peter G.
Thanks for the advice, pbreit and Christopher! I will give a fresh
Ubuntu 10.04 install a spin :)!


[web2py] Re: Specifying Field Focus

2011-10-28 Thread Richard G
You could also use jquery syntax:
$('#item' :input:visible:enabled:first).focus()
 Or if you don't have much info on the page and just want the first visible 
field to have focus you could do:
$("input:visible:enabled:first").focus()

More info on the jquery selectors is at: 
http://docs.jquery.com/DOM/Traversing/Selectors


[web2py] Re: Computed Fields not updating

2011-11-22 Thread Richard G
I have run into the above as well. 

Likely the issue is that on update you are not returning all values that 
the 'compute' field is based upon. 

Ex:
db.define_table('test',
  Field('val1', 'double'),
  Field('val2', 'double'),
  Field('result',
 compute = lambda r: r['val1'] + r['val2'])
)

Now if you have one row selected with values:
id = 1,  val1 = 1,  val2 = 1,  result = 2
in variable currRow

If you do:
> currRow.update_record(val1 = 30)
This will not use the 'compute' function

Instead you need to provide all values the compute is based upon in your 
update... so we should have:
> currRow.update_record(val1 = 30, val2 = currRow.val2)

This will now perform the compute method. 

I don't know if this is by design, but looking in the DAL the issue seems 
to be that the DAL only has the field data you sent to 'update' to play 
with.  (Line 4965 of dal.py [function def_listify(self,fields,update=False) 
]. (web2py v 1.99.2)



  1   2   3   >