[web2py] Re: session.about[0].NodeNav.nodeID!=session.id error.

2012-07-29 Thread Annet
Massimo,

Thanks for your reply.

You should not store rows in session. You can do session.rows = 
> rows.as_list() and this is safer. You would be caching a list of 
> dictionaries instead of a rows object.
>

So,

session.about=db((db.NodeNav.nodeID==session.id)&(db.NodeNav.navID==db.Nav.id)&(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position)

... would become 

session.about=db((db.NodeNav.nodeID==session.id)&(db.NodeNav.navID==db.Nav.id)&(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list()


What would

for a in session.about:
if a.Nav.id==32 and a.NodeNav.frontend:

... become?


Kind regards,

Annet.

-- 





[web2py] Is Vars Bad for SEO?

2012-07-29 Thread Hassan Alnatour
Dear ALL,

I want to change all the page i use args in to vars so i can use args to 
make my urls more descriptive  for SEO , now if i move everything to vars 
is it bad for SEO or what , what do you recommend ?

-- 





[web2py] Import SCV Button

2012-07-29 Thread Hassan Alnatour
Dear ALL, 

How can i make a button that lets the user download a scv file for on of my 
tables ?


best regards,

-- 





[web2py] SQLFORM.factory in a model -- huge performance degradation with db size

2012-07-29 Thread weheh
I've got an SQLFORM.factory inside a model. Very standard stuff:

form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])

The problem is, as I insert users into db.auth_user, the above 
SQLFORM.factory statement takes longer and longer to execute. It begins by 
executing in 0.05 seconds when there are only 3 rows in db.auth_user. 
However, when db.auth_user grows to 10,000 rows, it takes 11.4 seconds to 
do the above assignment. At 100,000 rows it takes over 2 minutes.

Any ideas where the trouble is? The db.mytable does have a user_id field 
that references auth_user:

Field('user_id', db.auth_user,
requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id')),
),

but I don't see how this could affect anything. This is a showstopper for 
me, so any help would be appreciated. Thanks.

-- 





[web2py] Re: is_impersonating() as boolean in menu

2012-07-29 Thread weheh
I haven't traced through all the code carefully, but  is_impersonating() 
returns current.session.auth.impersonator, which is based on a cPickle. So 
you're not getting a boolean, as you might be led to expect from the name 
of the function.


On Sunday, July 29, 2012 1:38:42 PM UTC+8, mweissen wrote:
>
> I am using "impersonate" (great idea!) and I have a menu item which should 
> only appear when somebody is impersonated. I wrote
>
> ('end impersonate', False, URL('endimpersonate'),[],*
> auth.is_impersonating()*)
>
> This did notwork, I had to write
>
> ('end impersonate', False, URL('endimpersonate'),[],*
> auth.is_impersonating()!=None*)
>  
> Why?
> Regards, Martin
>
>

-- 





[web2py] Re: dynamic queries

2012-07-29 Thread dave
instead of using the above I went with the code below, if anyone comes 
across this problem
queries=[]
if arg1 == "xyz": queries.append(db.abc.id > 0)
if arg2 == "abc": queries.append(db.abc.age > 5)
query = reduce(lambda a,b:(a&b),queries)



and you can insert this query into SQLFORM.grid(query)
  

On Saturday, July 28, 2012 11:07:33 PM UTC-7, dave wrote:
>
> I have something like
> qset=db()
> if arg1 == "xyz": qset=qset(db.abc.id > 0)
> if arg2 == "abc": qset=qset(db.abc.age > 5)
> x = qset.select()
> 
>
> now I want to pass x to SQLFORM.grid something like this
> return SQLFORM.grid(x)
> but this does not work because qset.select returns all the rows with all 
> the columns I think, I know that SQLFORM.grid accepts a table or a query so 
> how can I pass x to it?

-- 





[web2py] Re: web2py on appfog

2012-07-29 Thread Massimo Di Pierro
Thanks this is useful information.

On Saturday, 28 July 2012 23:04:06 UTC-5, spiffytech wrote:
>
> Tonight I threw up a copy of my personal site, just to see if AppFog is 
> worth looking into. Perhaps my experience would have been better if I tried 
> during business hours while their live chat support was open, but I don't 
> plan to use AppFog after this experience.
>
> The highlights:
>
>- They advertise unlimited apps, but you're limited by how many apps 
>you can squeeze into the RAM your account gets. Sure, you don't have the 
>hard cap of 10 apps like App Engine (still?) gives you, but "unlimited" 
>isn't really true
>- AppFog's founder wants you to 
> believethey're
>  proving PaaS doesn't have to be slow and expensive, but I found 
>AppFog to be slow, and their pricing 
> gets 
>nutty-expensive very fast
>- Getting my app working at all was a trying experience, and AppFog 
>doesn't offer much in the way of documentation or debug output to help you
>- No sign of a cron system, so you'll be relying on web2py's built-in 
>cron (didn't check if it works there, but I assume so)
>- All apps have a 100MB disk limit, and I don't see a way to buy more. 
>Better hope you're apps don't get very big!
>- You do have a writable filesystem, for what that's worth with the 
>100MB disk use limit. I didn't check whether all instances access the same 
>FS (that's kind of an important way so design the service)
>
> My conclusion: If you want a free place to host something that (really, 
> really) doesn't need to be performant, AppFog is a decent choice because:
>
>- It has a writable filesystem, which sets it apart from App Engine
>- It has MySQL, which sets it apart from App Engine
>- It looks more likely to stick around than some of the other free web 
>host services that I've seen mentioned here
>
> However, to get that free hosting you'll have to put up with terrible 
> performance (or highly variable performance if it magically speeds up by 
> tomorrow morning), poor documentation, and a tricky and opaque setup 
> procedure.
>
> On to doing stuff, and statistics!
>
> First off, I could not find any links on their site instructing me on how 
> to configure a Python app to work on AppFog. I eventually gave up and 
> resorted to Googling for a tutorial, which led me to this 
> sectionin AppFog's docs. Not sure 
> how you are supposed to find that.
>
> That link isn't too helpful, though- it shows how to make a Flask site 
> that works on AppFog, and links to working Bottle and Django sites, but 
> doesn't spell out how to make a generic WSGI site work. To make my simple 
> web2py site work, I had to do the following:
>
> mv wsgihandler.py wsgi.py  # AppFog needs wsgi.py. I tried a symlink 
> instead of a move, but couldn't make AppFog work in that arrangement
> ln -s wsgi.py wsgihandler.py  # This ensures updates to web2py affect 
> your wsgi.py
> gem install af
> af login
> af push   # This gives you an Amazon East app. I can't figure 
> out how to use `af` to deploy to a different infrastructure
>
> I tried creating an app on the Rackspace infrastructure through AppFog's 
> web admin `af update `, but couldn't get my app to start. It 
> didn't start automatically, and `af start  --debug` tells me I 
> don't have the "run" mode available. So no Rackspace for me.
>
> Once I got my app running on AppFog's Amazon EC2 infrastructure (after a 
> number of false starts related to not having wsgi.py) I noticed my app ran 
> very slowly. The front page of my app doesn't really do anything; it could 
> almost be a static HTML file, yet it was unbearably slow on AppFog.
>
> I fired up Apache Benchmark and got some very disappointing results. With 
> a concurrency of 50, run for 30 seconds: 
>
>- 1 instance, 128MB RAM: 139 requests completed, mean average of 10.5 
>seconds to fulfill a request
>- 1 instance, 2GB RAM: 140 requests, 10.8 seconds mean
>- 15 instances, 128MB RAM each: 163 requests, 9.2 seconds mean
>
> For comparison, my site hosted on its usual low-end rackmount server (RHEL 
> 6.2, 3.1GHz quad-core Xeon, 8GB RAM, Apache with mod_wsgi) completed 3061 
> requests with a mean 0.490 seconds per request. Beefier than what AppFog 
> gave me? Sure, but not enough to explain handling 22x the requests, with 
> 1/22nd the response time.
>
> *  The AppFog mean request fulfillment numbers varied by as much as two 
> seconds over the several times I ran the tests. That sort of 
> unpredictability worries me.
>
>
>
> On Thursday, July 26, 2012 9:50:01 PM UTC-4, Joel Carrier wrote:
>>
>> Has anyone tried running web2py on appfog ( www.appfog.com ) and cares 
>> to comment on their experience?
>
>

-- 





[web2py] Re: session.about[0].NodeNav.nodeID!=session.id error.

2012-07-29 Thread Massimo Di Pierro
Should become:

for a in session.about:
if a['Nav']['id ']==32 and a['NodeNav']['frontend']:

On Sunday, 29 July 2012 02:39:03 UTC-5, Annet wrote:
>
> Massimo,
>
> Thanks for your reply.
>
> You should not store rows in session. You can do session.rows = 
>> rows.as_list() and this is safer. You would be caching a list of 
>> dictionaries instead of a rows object.
>>
>
> So,
>
> session.about=db((db.NodeNav.nodeID==session.id)&(db.NodeNav.navID==
> db.Nav.id
> )&(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position)
>
> ... would become 
>
> session.about=db((db.NodeNav.nodeID==session.id)&(db.NodeNav.navID==
> db.Nav.id
> )&(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list()
>
>
> What would
>
> for a in session.about:
> if a.Nav.id==32 and a.NodeNav.frontend:
>
> ... become?
>
>
> Kind regards,
>
> Annet.
>

-- 





[web2py] Re: Import SCV Button

2012-07-29 Thread Massimo Di Pierro
In view:
download all

In controller

def download_all():
import tempfile 
tmp = tempfile.TemporaryFile()
db.export_to_csv_file(tmp)
tmp.seek(0)
return response.stream(tmp)

On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:
>
> Dear ALL, 
>
> How can i make a button that lets the user download a scv file for on of 
> my tables ?
>
>
> best regards,
>

-- 





Re: [web2py] Re: Import SCV Button

2012-07-29 Thread hasan alnator
Thank you a lot massimo  but what is tempfile and how can i give it
a certain  table to import ??


Best Regards,


On Sun, Jul 29, 2012 at 5:14 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> In view:
> download all
>
> In controller
>
> def download_all():
> import tempfile
> tmp = tempfile.TemporaryFile()
> db.export_to_csv_file(tmp)
> tmp.seek(0)
> return response.stream(tmp)
>
> On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:
>>
>> Dear ALL,
>>
>> How can i make a button that lets the user download a scv file for on of
>> my tables ?
>>
>>
>> best regards,
>>
>  --
>
>
>
>

-- 





[web2py] Re: SQLFORM.factory in a model -- huge performance degradation with db size

2012-07-29 Thread Massimo Di Pierro
First of all 

   form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])

should probably be

   form = SQLFORM(db.mytable, record=db.mytable[myindex])

Anyway. The slow down is due to the IS_IN_DB(db, 'auth_user.id') validator. 
Every time you display the form, it will create a new dropdown list with 
all your users. You may want to cache this:


Field('user_id', db.auth_user,
requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id
',cache=(cache.ram,3600))),
),

3600 means the list will be re-built every hour.

On Sunday, 29 July 2012 04:53:25 UTC-5, weheh wrote:
>
> I've got an SQLFORM.factory inside a model. Very standard stuff:
>
> form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])
>
> The problem is, as I insert users into db.auth_user, the above 
> SQLFORM.factory statement takes longer and longer to execute. It begins by 
> executing in 0.05 seconds when there are only 3 rows in db.auth_user. 
> However, when db.auth_user grows to 10,000 rows, it takes 11.4 seconds to 
> do the above assignment. At 100,000 rows it takes over 2 minutes.
>
> Any ideas where the trouble is? The db.mytable does have a user_id field 
> that references auth_user:
>
> Field('user_id', db.auth_user,
> requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id')),
> ),
>
> but I don't see how this could affect anything. This is a showstopper for 
> me, so any help would be appreciated. Thanks.
>

-- 





[web2py] Re: SQLFORM.factory in a model -- huge performance degradation with db size

2012-07-29 Thread Massimo Di Pierro
P.S. An even better approach would be to remove the dropdown

   ...requires=[IS_NULL_OR(IS_IN_DB(db, 'auth_user.id'))] # note [..]

and use an autocomplete widget to allow to search for users.


auth.settings.extra_fields['auth_user']=[Field('fullname',readable=False,writable=False,compute=lambda
 
row: "%s %s" % (row.first_name,row.last_name))]

and

db.mytable.user_id.requires=[IS_NULL_OR(IS_IN_DB(db, 'auth_user.id'))]
db.mytable.user_id.widget=SQLFORM.widgets.autocomplete(request,db.auth_user.fullname,db.auth_user.id,orderby=db.auth_user.fullname)


On Sunday, 29 July 2012 07:19:32 UTC-5, Massimo Di Pierro wrote:
>
> First of all 
>
>form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])
>
> should probably be
>
>form = SQLFORM(db.mytable, record=db.mytable[myindex])
>
> Anyway. The slow down is due to the IS_IN_DB(db, 'auth_user.id') 
> validator. Every time you display the form, it will create a new dropdown 
> list with all your users. You may want to cache this:
>
>
> Field('user_id', db.auth_user,
> requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id
> ',cache=(cache.ram,3600))),
> ),
>
> 3600 means the list will be re-built every hour.
>
> On Sunday, 29 July 2012 04:53:25 UTC-5, weheh wrote:
>>
>> I've got an SQLFORM.factory inside a model. Very standard stuff:
>>
>> form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])
>>
>> The problem is, as I insert users into db.auth_user, the above 
>> SQLFORM.factory statement takes longer and longer to execute. It begins by 
>> executing in 0.05 seconds when there are only 3 rows in db.auth_user. 
>> However, when db.auth_user grows to 10,000 rows, it takes 11.4 seconds to 
>> do the above assignment. At 100,000 rows it takes over 2 minutes.
>>
>> Any ideas where the trouble is? The db.mytable does have a user_id field 
>> that references auth_user:
>>
>> Field('user_id', db.auth_user,
>> requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id')),
>> ),
>>
>> but I don't see how this could affect anything. This is a showstopper for 
>> me, so any help would be appreciated. Thanks.
>>
>

-- 





[web2py] Re: is_impersonating() as boolean in menu

2012-07-29 Thread Massimo Di Pierro
I think this should be considered a bug. Than you check trunk?

On Sunday, 29 July 2012 05:37:51 UTC-5, weheh wrote:
>
> I haven't traced through all the code carefully, but  is_impersonating() 
> returns current.session.auth.impersonator, which is based on a cPickle. So 
> you're not getting a boolean, as you might be led to expect from the name 
> of the function.
>
>
> On Sunday, July 29, 2012 1:38:42 PM UTC+8, mweissen wrote:
>>
>> I am using "impersonate" (great idea!) and I have a menu item which 
>> should only appear when somebody is impersonated. I wrote
>>
>> ('end impersonate', False, URL('endimpersonate'),[],*
>> auth.is_impersonating()*)
>>
>> This did notwork, I had to write
>>
>> ('end impersonate', False, URL('endimpersonate'),[],*
>> auth.is_impersonating()!=None*)
>>  
>> Why?
>> Regards, Martin
>>
>>

-- 





Re: [web2py] Re: Import SCV Button

2012-07-29 Thread Massimo Di Pierro
Sorry. My advice was about downloading all tabes at once.

If you want import one table you could do:

def import_table():
form = SQLFORM.factory(Field('table',requires=IS_IN_SET(db.tables)),
  
 Field('csvfile','upload',uploadfield=False))
form.process()
if form.accepted: 
  try:
  db[form.vars.table].import_from_csv_file(request.vars.csvfile)
  except: form.errors.csvfile = 'invalid file'
return dict(form=form)

On Sunday, 29 July 2012 07:18:02 UTC-5, Hassan Alnatour wrote:
>
> Thank you a lot massimo  but what is tempfile and how can i give it 
> a certain  table to import ??
>
>
> Best Regards,
>
>
> On Sun, Jul 29, 2012 at 5:14 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> In view:
>> download all
>>
>> In controller
>>
>> def download_all():
>> import tempfile 
>> tmp = tempfile.TemporaryFile()
>> db.export_to_csv_file(tmp)
>> tmp.seek(0)
>> return response.stream(tmp)
>>
>> On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:
>>>
>>> Dear ALL, 
>>>
>>> How can i make a button that lets the user download a scv file for on of 
>>> my tables ?
>>>
>>>
>>> best regards,
>>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: SQLFORM.factory in a model -- huge performance degradation with db size [closed]

2012-07-29 Thread weheh
Massimo, thanks for pointing out the obvious to me. I knew it had to be 
something that simple, just couldn't see it. I had decided to use factory 
instead of pure SQLFORM because I'm not going through the usual self-submit 
process. The db is all manipulated via ajax in this case and the form is a 
convenient way to get the widgets I need.

Thanks for the suggestions for the autocomplete widget and cache. Instead, 
since I don't need the reference in my form, I'm just turning it off 
altogether withe readable/writable = False. After making the change, the 
time to build the form dropped to 0.04 sec. Now, that's more like it!

-- 





[web2py] Re: Centos 5 script for Nginx with Uwsgi and Web2py

2012-07-29 Thread Alan Etkin
The fixed peter scrip to install Python 2.7.3 and self-signed certs for ssl 
enabled apps. It retrieves the base architecture also for nginx 
installation. It should be tested although, as I only used its commands 
separately.

-- 



#!/bin/bash

# Script for installing Web2py with Nginx and Uwsgi on Centos 5
# By peter
# Modified by spametki

# It was originally posted in this web2py-users group thread:
# https://groups.google.com/forum/?fromgroups#!topic/web2py/O4c4Jfr18tM

# There are lots of subtleties of ownership, and one has to take care
# when installing python 2.7 not to stop the systems python2.4 from working.

# NOTE: The only thing that should need changing for
# each installation is the $BASEARCH (base architecture) of the machine.
# This is determined by doing uname -i. This is needed for the nginx installation.

# Retrieve base architecture
BASEARCH=$(uname -i)

echo 'Install development tools (it should take a while)'
yum install gcc gdbm-devel readline-devel ncurses-devel zlib-devel \
bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel

echo 'Install python 2.7 without overwriting python 2.4 (no, really, this will take a while too)'

VERSION=2.7.3
cd ~
curl -O http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xvfz Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/opt/python2.7 --with-threads --enable-shared
make

echo 'The altinstall ensures that python2.4 is left okay'
make altinstall
echo "/opt/python2.7/lib">/etc/ld.so.conf.d/opt-python2.7.conf
ldconfig

echo 'Create alias so that python 2.7 can be run with python2.7'
alias -p python2.7="/opt/python2.7/bin/python2.7"
ln -s /opt/python2.7/bin/python2.7 /usr/bin/python2.7

echo 'Install uwsgi'

version=uwsgi-1.2.3
cd ~
curl -O http://projects.unbit.it/downloads/$version.tar.gz
tar -zxvf $version.tar.gz
mkdir /opt/uwsgi-python
cp -R ./$version/* /opt/uwsgi-python/*
cd /opt/uwsgi-python

echo 'build using python 2.7'
python2.7 setup.py build
python2.7 uwsgiconfig.py --build
useradd uwsgi

echo 'Create and own uwsgi log'
# Note this log will need emptying from time to time

touch /var/log/uwsgi.log
chown uwsgi /var/log/uwsgi.log

echo 'Install web2py'

cd /opt
mkdir ./web-apps
cd ./web-apps
curl -O http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip

echo 'Set the ownership for web2py application to uwsgi'
cd /opt/web-apps/web2py
chown -R uwsgi /opt/web-apps/web2py
chmod -R u+rwx ./applications

echo 'Now install nginx'
cd /etc/yum.repos.d
echo "[nginx]">nginx.repo

echo "baseurl=http://nginx.org/packages/centos/5/$BASEARCH/";>>nginx.repo
echo "gpgcheck=0">>nginx.repo
echo "enabled=1">>nginx.repo
yum install nginx

echo "We don't want the defaults, so remove them"
cd /etc/nginx/conf.d
mv default.conf default.conf.o
mv example_ssl.conf example_ssl.conf.o

echo '
The following configuration files are also needed
The options for uwsgi are in the following file.
Other options could be included.
'

echo 'uwsgi_for_nginx.conf'

echo '
[uwsgi]
uuid=uwsgi
pythonpath = /opt/web-apps/web2py
module = wsgihandler
socket=127.0.0.1:9001
harakiri 60
harakiri-verbose
enable-threads
daemonize = /var/log/uwsgi.log
' > /opt/uwsgi-python/uwsgi_for_nginx.conf

chmod 755 /opt/uwsgi-python/uwsgi_for_nginx.conf

echo '
The next configuration file is for nginx, and goes in /etc/nginx/conf.d
It serves the static directory of applications directly. I have not set up
ssl because I access web2py admin by using ssh tunneling and the web2py rocket server.
It should be straightforward to set up the ssl server however.
'

echo 'web2py.conf'

echo '
server {
  listen 80;
  server_name $hostname;
  location ~* /(\w+)/static/ {
root /opt/web-apps/web2py/applications/;
  }
  location / {
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
  }
}

server {
  listen 443;
  server_name $hostname;
  ssl on;
  ssl_certificate /etc/nginx/ssl/web2py.cert;
  ssl_certificate_key /etc/nginx/ssl/web2py.key;
  location / {
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
  }
}
' > /etc/nginx/conf.d/web2py.conf


echo 'Auto-signed ssl certs'
mkdir /etc/nginx/ssl
echo "creating a self signed certificate"
echo "=="
openssl genrsa 1024 > /etc/nginx/ssl/web2py.key
chmod 400 /etc/nginx/ssl/web2py.key
openssl req -new -x509 -nodes -sha1 -days 365 -key /etc/nginx/ssl/web2py.key > /etc/nginx/ssl/web2py.cert
openssl x509 -noout -fingerprint -text < /etc/nginx/ssl/web2py.cert > /etc/nginx/ssl/web2py.info

echo 'uwsgi as service'

echo '
#!/bin/bash

# uwsgi - Use uwsgi to run python and wsgi web apps.
#
# chkconfig: - 85 15
# description: Use uwsgi to run python and wsgi web apps.
# processname: uwsgi

# author: Roman Vasilyev

# Source function library.
. /etc/rc.d/init.d/functions

###
PATH=/opt/uwsgi-python:/sbin:/bin:/usr/sbin:/usr/bin
PYTHONPATH=/home/www-data/web2py
MODULE=wsgihandler
PROG=/opt/uwsgi-python/uwsgi
OWNER=uwsgi

Re: [web2py] Re: Import SCV Button

2012-07-29 Thread Alec Taylor
On Mon, Jul 30, 2012 at 12:11 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Sorry. My advice was about downloading all tabes at once.
>
> If you want import one table you could do:
>
> def import_table():
> form = SQLFORM.factory(Field('table',requires=IS_IN_SET(db.tables)),
>
>  Field('csvfile','upload',uploadfield=False))
> form.process()
> if form.accepted:
>   try:
>
> db[form.vars.table].import_from_csv_file(request.vars.csvfile)
>   except: form.errors.csvfile = 'invalid file'
> return dict(form=form)
>

I tried that on Windows, and the upload field gave an open command, so I
right-clicked "New File->New Text Document" and create "foo.csv".

Selecting it then clicking open then clicking "Submit" gave me the "invalid
file" error.

On Sunday, 29 July 2012 07:18:02 UTC-5, Hassan Alnatour wrote:
>>
>> Thank you a lot massimo  but what is tempfile and how can i give it
>> a certain  table to import ??
>>
>>
>> Best Regards,
>>
>>
>> On Sun, Jul 29, 2012 at 5:14 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> In view:
>>> download all
>>>
>>> In controller
>>>
>>> def download_all():
>>> import tempfile
>>> tmp = tempfile.TemporaryFile()
>>> db.export_to_csv_file(tmp)
>>> tmp.seek(0)
>>> return response.stream(tmp)
>>>
>>> On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:

 Dear ALL,

 How can i make a button that lets the user download a scv file for on
 of my tables ?


 best regards,

>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





[web2py] Re: Centos 5 script for Nginx with Uwsgi and Web2py

2012-07-29 Thread Massimo Di Pierro
In trunk. Kept the previous name. Added Peter's full name.

On Sunday, 29 July 2012 09:26:37 UTC-5, Alan Etkin wrote:
>
> The fixed peter scrip to install Python 2.7.3 and self-signed certs for 
> ssl enabled apps. It retrieves the base architecture also for nginx 
> installation. It should be tested although, as I only used its commands 
> separately.
>
>

-- 





Re: [web2py] Re: Import SCV Button

2012-07-29 Thread Massimo Di Pierro
My bad.

db[form.vars.table].import_from_csv_file(request.vars.csvfile)

should be

db[form.vars.table].import_from_csv_file(request.vars.csvfile.file)

On Sunday, 29 July 2012 10:32:29 UTC-5, Alec Taylor wrote:
>
> On Mon, Jul 30, 2012 at 12:11 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Sorry. My advice was about downloading all tabes at once.
>>
>> If you want import one table you could do:
>>
>> def import_table():
>> form = SQLFORM.factory(Field('table',requires=IS_IN_SET(db.tables)),
>>   
>>  Field('csvfile','upload',uploadfield=False))
>> form.process()
>> if form.accepted: 
>>   try:
>>   
>> db[form.vars.table].import_from_csv_file(request.vars.csvfile)
>>   except: form.errors.csvfile = 'invalid file'
>> return dict(form=form)
>>
>
> I tried that on Windows, and the upload field gave an open command, so I 
> right-clicked "New File->New Text Document" and create "foo.csv".
>
> Selecting it then clicking open then clicking "Submit" gave me the 
> "invalid file" error.
>
> On Sunday, 29 July 2012 07:18:02 UTC-5, Hassan Alnatour wrote:
>>>
>>> Thank you a lot massimo  but what is tempfile and how can i give it 
>>> a certain  table to import ??
>>>
>>>
>>> Best Regards,
>>>
>>>
>>> On Sun, Jul 29, 2012 at 5:14 AM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 In view:
 download all

  In controller

 def download_all():
 import tempfile 
 tmp = tempfile.TemporaryFile()
 db.export_to_csv_file(tmp)
 tmp.seek(0)
 return response.stream(tmp)

 On Sunday, 29 July 2012 03:07:40 UTC-5, Hassan Alnatour wrote:
>
> Dear ALL, 
>
> How can i make a button that lets the user download a scv file for on 
> of my tables ?
>
>
> best regards,
>
  -- 
  
  
  

>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: running scheduler as a windows service or background process

2012-07-29 Thread Massimo Di Pierro
I am thinking it would also be nice to have checkboxes to start the 
scheduler from the tkinter widget.

On Saturday, 28 July 2012 02:35:43 UTC-5, Tim Richardson wrote:
>
>
>
> On Saturday, 28 July 2012 17:26:17 UTC+10, Massimo Di Pierro wrote:
>>
>> Something like this should be included in web2py. What do you think 
>> should be the right place?
>>
>>
>> Well I think a combination of -W and -K should work, in terms of the 
> interface. That is, -W servicename -K appname should install the scheduler 
> as a service. 
>
> I'm sure there are better implementations than my hack.
>  
>

-- 





[web2py] Installing Levenshtein module in controller

2012-07-29 Thread praveen krishna
Hi,
How to import the Levenshtein in controller of web2py actullaý I have 
downloaded the tar.bz2 folder of levenstein from 
http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages 
and used the command import Levenshtein but it dosen't work and even I 
tried by extracting in applications/yourapp/modules and used the command func 
= local_import('func') but this also dosen't work I am getting the error
Ticket ID 

127.0.0.1.2012-07-29.18-29-59.f256a67b-29b3-46da-9272-669cc6577de2
 No module named Levenshtein Version  web2py™ 
(1, 
99, 7, datetime.datetime(2012, 3, 4, 22, 12, 8), 'stable')  Python Python 
2.7.3: /usr/bin/python  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Traceback (most recent call last):
  File "/home/praveen/web2py/web2py/gluon/restricted.py", line 205, in 
restricted
exec ccode in environment
  File 
"/home/praveen/web2py/web2py/applications/tlc2/controllers/plugin_seq.py" 
, line 
7, in 
from Levenshtein import *
  File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 293, in 
__call__
fromlist, level)
  File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 78, in 
__call__
level)
ImportError: No module named Levenshtein

-- 





[web2py] Re: Is Vars Bad for SEO?

2012-07-29 Thread pbreit
Can you give us some examples of your before and after URLs?

In general it shouldn't be a big impact because there are so many variables 
to SEO. It's usually best to construct URLs as makes the most sense for 
your web site. Then you can think about SEO.

-- 





[web2py] Question regarding plugin multiselect ( as a widget ) on a form ...

2012-07-29 Thread Don_X
Hello web2py users ...

This is a question in 2 folds :

I wish to use the multiselect plugin as a widget on a form ( SQLFORM ) as 
opposed to on a crud as demonstrated in the following example  :

http://www.web2py.com/plugins/default/multiselect

However there is one additional detail that I wish to make available - so 
let me elaborate a bit on the issue at hand.

Auth_users need to specify their spoken languages upon registration and 
they can and should be able to select more than 1 or 2  speaking languages !
for example:  in my case, multiple checkboxes ( 4 checkboxes )  to choose 
the spoken languages
1- English ( checkbox )
2- French ( checkbox )
3- Spanish ( checkbox )
4 - Other ( checkbox ) : ( specify ) with a blank input field where the 
user will specify the langage ( or the additional languages separated by a 
comma in the input field ) !

so first : I am unable to use the plugin multiselect on a form as a widget 
... if I can ... how do I set it up as a widget for forms .. instead of 
crud ??

and second : how do I code-ready the 4th option above in my  model, my 
controller to the view for the form ??? ... if in my db.py file, I have 
this defined :



user_lang = ('French','English','Spanish','Other')
>
> db.define.table ( 'auth_user',
> Field('first_name', type='string',
>   label=T('First Name')),
> Field('last_name', type='string',
>   label=T('Last Name')),
> Field('language_spoken','list:string',label=T('I speak'), 
>   requires=IS_IN_SET((1,2,3,4),user_lang, multiple=True)))
>
>
off course, I want the 'Other' value in the user_lang tuple defined to be a 
list of languages defined by the subscriber upon registration ! ..

How do i go about this ??? ... please help ! ... the plugin multiselect 
does not do it for me ! .. i used checkboxes  ... but i get them in one 
single column and it is taking much space on the form ...
 and I cannot get the 4th option as a checkboxe with an input field !

Can someone help me with this so I can make it look good, like  .. may be 
one row ... or possibly 2 rows 2 columns for the 4 checkboxes ??? ... what 
about the input field for the fourth option in the set !!???

thank you.

-- 





Re: [web2py] Installing Levenshtein module in controller

2012-07-29 Thread Jonathan Lundell
On 29 Jul 2012, at 10:22 AM, praveen krishna  wrote:
> How to import the Levenshtein in controller of web2py actullaý I have 
> downloaded the tar.bz2 folder of levenstein from 
> http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages and 
> used the command import Levenshtein but it dosen't work and even I tried by 
> extracting in applications/yourapp/modules and used the command func = 
> local_import('func') but this also dosen't work I am getting the error


Did you build the module?
> Ticket ID
> 
> 127.0.0.1.2012-07-29.18-29-59.f256a67b-29b3-46da-9272-669cc6577de2
> 
>  No module named Levenshtein
> 
> Version
> 
> web2py™   (1, 99, 7, datetime.datetime(2012, 3, 4, 22, 12, 8), 'stable')
> PythonPython 2.7.3: /usr/bin/python
> Traceback
> 
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> Traceback (most recent call last):
>   File "/home/praveen/web2py/web2py/gluon/restricted.py", line 205, in 
> restricted
> exec ccode in environment
>   File 
> "/home/praveen/web2py/web2py/applications/tlc2/controllers/plugin_seq.py", 
> line 7, in 
> from Levenshtein import *
>   File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 293, in 
> __call__
> fromlist, level)
>   File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 78, in 
> __call__
> level)
> ImportError: No module named Levenshtein
> 
> 


-- 





Re: [web2py] Installing Levenshtein module in controller

2012-07-29 Thread praveen krishna
What do u mean by building a module.I don't know how to built a module I
just extracted the folder and stored it in applications/yourapp/modules and
tried to import it.

On Sun, Jul 29, 2012 at 7:52 PM, Jonathan Lundell wrote:

> On 29 Jul 2012, at 10:22 AM, praveen krishna 
> wrote:
>
> How to import the Levenshtein in controller of web2py actullaý I have
> downloaded the tar.bz2 folder of levenstein from
> http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages
> and used the command import Levenshtein but it dosen't work and even I
> tried by extracting in applications/yourapp/modules and used the command func
> = local_import('func') but this also dosen't work I am getting the error
>
>
>
> Did you build the module?
>
> Ticket ID
>
> 127.0.0.1.2012-07-29.18-29-59.f256a67b-29b3-46da-9272-669cc6577de2
>  No module named LevenshteinVersionweb2py™(1,
> 99, 7, datetime.datetime(2012, 3, 4, 22, 12, 8), 'stable')PythonPython
> 2.7.3: /usr/bin/pythonTraceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
>
> Traceback (most recent call last):
>   File "/home/praveen/web2py/web2py/gluon/restricted.py", line 205, in 
> restricted
> exec ccode in environment
>   File 
> "/home/praveen/web2py/web2py/applications/tlc2/controllers/plugin_seq.py" 
> , 
> line 7, in 
> from Levenshtein import *
>   File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 293, in 
> __call__
> fromlist, level)
>   File "/home/praveen/web2py/web2py/gluon/custom_import.py", line 78, in 
> __call__
> level)
> ImportError: No module named Levenshtein
>
>
>
>
>
>  --
>
>
>
>

-- 





Re: [web2py] Installing Levenshtein module in controller

2012-07-29 Thread Jonathan Lundell
On 29 Jul 2012, at 10:56 AM, praveen krishna  wrote:
> What do u mean by building a module.I don't know how to built a module I just 
> extracted the folder and stored it in applications/yourapp/modules and tried 
> to import it.

Levenshtein is written in C, and must be compiled before it can be imported.

python setup.py build

should do the trick. You'll find the result (possibly named Levenshtein.so) in 
the resulting build directory. Put that in site-packages/.

> On Sun, Jul 29, 2012 at 7:52 PM, Jonathan Lundell  wrote:
> On 29 Jul 2012, at 10:22 AM, praveen krishna  
> wrote:
>> How to import the Levenshtein in controller of web2py actullaý I have 
>> downloaded the tar.bz2 folder of levenstein from 
>> http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages 
>> and used the command import Levenshtein but it dosen't work and even I tried 
>> by extracting in applications/yourapp/modules and used the command func = 
>> local_import('func') but this also dosen't work I am getting the error
> 
> 
> Did you build the module?
>> 


-- 





Re: [web2py] Installing Levenshtein module in controller

2012-07-29 Thread praveen krishna
Oh,I haven't done this is this the mistake I have done? but is this
applicable for web2py as well .If so we have run this command in web2py
terminal?
On Sun, Jul 29, 2012 at 7:59 PM, Jonathan Lundell wrote:

> On 29 Jul 2012, at 10:56 AM, praveen krishna 
> wrote:
>
> What do u mean by building a module.I don't know how to built a module I
> just extracted the folder and stored it in applications/yourapp/modules
> and tried to import it.
>
>
> Levenshtein is written in C, and must be compiled before it can be
> imported.
>
> python setup.py build
>
>
> should do the trick. You'll find the result (possibly named
> Levenshtein.so) in the resulting build directory. Put that in
> site-packages/.
>
> On Sun, Jul 29, 2012 at 7:52 PM, Jonathan Lundell 
> wrote:
>
>> On 29 Jul 2012, at 10:22 AM, praveen krishna 
>> wrote:
>>
>> How to import the Levenshtein in controller of web2py actullaý I
>> have downloaded the tar.bz2 folder of levenstein from
>> http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages
>> and used the command import Levenshtein but it dosen't work and even I
>> tried by extracting in applications/yourapp/modules and used the command func
>> = local_import('func') but this also dosen't work I am getting the error
>>
>>
>>
>> Did you build the module?
>>
>>
>>
>
>  --
>
>
>
>

-- 





Re: [web2py] Installing Levenshtein module in controller

2012-07-29 Thread Jonathan Lundell
On 29 Jul 2012, at 11:05 AM, praveen krishna  wrote:
> Oh,I haven't done this is this the mistake I have done? but is this 
> applicable for web2py as well .If so we have run this command in web2py 
> terminal?

No, it has nothing in particular to do with web2py. It's a Python thing. Some 
modules are written in C (for speed) and must be compiled for the architecture 
they're running on. 

You can read more about it here: http://docs.python.org/extending/extending.html



> On Sun, Jul 29, 2012 at 7:59 PM, Jonathan Lundell  wrote:
> On 29 Jul 2012, at 10:56 AM, praveen krishna  
> wrote:
>> What do u mean by building a module.I don't know how to built a module I 
>> just extracted the folder and stored it in applications/yourapp/modules and 
>> tried to import it.
> 
> Levenshtein is written in C, and must be compiled before it can be imported.
> 
> python setup.py build
> 
> should do the trick. You'll find the result (possibly named Levenshtein.so) 
> in the resulting build directory. Put that in site-packages/.
> 
>> On Sun, Jul 29, 2012 at 7:52 PM, Jonathan Lundell  wrote:
>> On 29 Jul 2012, at 10:22 AM, praveen krishna  
>> wrote:
>>> How to import the Levenshtein in controller of web2py actullaý I have 
>>> downloaded the tar.bz2 folder of levenstein from 
>>> http://code.google.com/p/pylevenshtein/ extracted in web2py/site-packages 
>>> and used the command import Levenshtein but it dosen't work and even I 
>>> tried by extracting in applications/yourapp/modules and used the command 
>>> func = local_import('func') but this also dosen't work I am getting the 
>>> error
>> 
>> 
>> Did you build the module?
>>> 


-- 





[web2py] Re: Question regarding plugin multiselect ( as a widget ) on a form ...

2012-07-29 Thread Massimo Di Pierro
Your question is the same as this one:

http://stackoverflow.com/questions/6459974/how-to-add-option-using-multiselect-jquery-plugin

The answer you want is the first one.

I do not have a complete example of integration with web2py. Give it a try 
and if, necessary, I will take a second look.

Anyway, consider the fact you are basically allowing users to type whatever 
they want. You may as well use the default validator.

On Sunday, 29 July 2012 12:51:48 UTC-5, Don_X wrote:
>
> Hello web2py users ...
>
> This is a question in 2 folds :
>
> I wish to use the multiselect plugin as a widget on a form ( SQLFORM ) as 
> opposed to on a crud as demonstrated in the following example  :
>
> http://www.web2py.com/plugins/default/multiselect
>
> However there is one additional detail that I wish to make available - so 
> let me elaborate a bit on the issue at hand.
>
> Auth_users need to specify their spoken languages upon registration and 
> they can and should be able to select more than 1 or 2  speaking languages !
> for example:  in my case, multiple checkboxes ( 4 checkboxes )  to choose 
> the spoken languages
> 1- English ( checkbox )
> 2- French ( checkbox )
> 3- Spanish ( checkbox )
> 4 - Other ( checkbox ) : ( specify ) with a blank input field where the 
> user will specify the langage ( or the additional languages separated by a 
> comma in the input field ) !
>
> so first : I am unable to use the plugin multiselect on a form as a widget 
> ... if I can ... how do I set it up as a widget for forms .. instead of 
> crud ??
>
> and second : how do I code-ready the 4th option above in my  model, my 
> controller to the view for the form ??? ... if in my db.py file, I have 
> this defined :
>
>
>
> user_lang = ('French','English','Spanish','Other')
>>
>> db.define.table ( 'auth_user',
>> Field('first_name', type='string',
>>   label=T('First Name')),
>> Field('last_name', type='string',
>>   label=T('Last Name')),
>> Field('language_spoken','list:string',label=T('I speak'), 
>>   requires=IS_IN_SET((1,2,3,4),user_lang, multiple=True)))
>>
>>
> off course, I want the 'Other' value in the user_lang tuple defined to be 
> a list of languages defined by the subscriber upon registration ! ..
>
> How do i go about this ??? ... please help ! ... the plugin multiselect 
> does not do it for me ! .. i used checkboxes  ... but i get them in one 
> single column and it is taking much space on the form ...
>  and I cannot get the 4th option as a checkboxe with an input field !
>
> Can someone help me with this so I can make it look good, like  .. may be 
> one row ... or possibly 2 rows 2 columns for the 4 checkboxes ??? ... what 
> about the input field for the fourth option in the set !!???
>
> thank you.
>

-- 





[web2py] is it possible to run web2py parallel to php on apache port 80?

2012-07-29 Thread Robin Manoli
Hey,
I'm wondering if it is possible to run web2py on the same port as other 
php-websites run. I have a normally configured LAMP, and I can install the 
required apache mod. Then the question is if a web2py app can run parallel, 
just as different php/html sites do with different domain names, using port 
80?

Thanks for your help

-- 





[web2py] Re: Eclipse and autocomplete

2012-07-29 Thread voyager29
To get eclipse/PyDev to autocomplete web2py code, after some quick trial 
and error here is what worked for me:

Assuming:
the top level eclipse project dir is web2py
your_app is the name of your application inside the web2py/applications 
folder:

In __init__.py of your_app folder:

if 0:
from gluon import *
from gluon.languages import translator as T

In your controllers, say for e.g. in appadmin.py, add this line:

from applications.your_app import *

Now PyDev will recognize and complete things like URL etc. and T. You can 
add more to your_app/__init__.py to introduce more recognition. There may 
be better more standard ways to do this, I'm not a software engineer, still 
learning the tricks of the trade!

Thanks!

On Tuesday, April 3, 2012 7:54:06 PM UTC-7, Rod Watkins wrote:
>
> I know this has been asked before. I don't mean to be an annoyance. I've 
> done the searches are read numerous posts about how to handle this. But the 
> advice conflicts and I've yet to actually fix the problem. 
>
> What is the best way to handle imports for eclipse to get autocomplete to 
> work properly (as well as rid eclipse of all the incorrect error messages?
>
> I rather like having autocomplete functioning since, as a beginner, it 
> helps me discover functionality that I might otherwise miss (besides saving 
> some typing).
>
> Please accept my thanks in advance for any help on this.
>
> Cordially,
> Rod Watkins
>

-- 





[web2py] Re: is it possible to run web2py parallel to php on apache port 80?

2012-07-29 Thread Massimo Di Pierro
Yes but I have not done it. My understanding is that you can use a 
configuration such as described here:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-ubuntu.sh#L80

and within the same virtualhost you map some paths to the php folder


  php_admin_value open_basedir "/home/php/"
  php_admin_value upload_tmp_dir "/tmp"




On Sunday, July 29, 2012 1:18:37 PM UTC-5, Robin Manoli wrote:
>
> Hey,
> I'm wondering if it is possible to run web2py on the same port as other 
> php-websites run. I have a normally configured LAMP, and I can install the 
> required apache mod. Then the question is if a web2py app can run parallel, 
> just as different php/html sites do with different domain names, using port 
> 80?
>
> Thanks for your help
>

-- 





Re: [web2py] Re: InterfaceError

2012-07-29 Thread Elton Pereira de Lima
There solution to this problem?
I'm experiencing the same problem and I find no solution, what is the cause?

Tanks!

Em domingo, 2 de maio de 2010 19h25min42s UTC-3, mdipierro escreveu:
>
> Can you show the complete model and controller? If you want you can 
> email it to me confidentially. 
>
> Massimo 
>
>
> On May 2, 12:54 pm, Necati Demir  wrote: 
> > web2py version: Version 1.77.3 (2010-04-20 02:48:54) 
> > 
> > Here is the traceback from ticket: 
> > 
> > Traceback (most recent call last): 
> > 
> >   File "/home/ndemir/web2py/gluon/restricted.py", line 178, in 
> restricted 
> > 
> > exec ccode in environment 
> > 
> >   File 
> "/home/ndemir/web2py/applications/project1/controllers/default.py" 
> > , line 10, in 
> >  
> > 
> >   File "/home/ndemir/web2py/gluon/globals.py", line 96, in  
> > 
> > self._caller = lambda f: f() 
> > 
> >   File "/home/ndemir/web2py/applications/ 
> > project1 
> > 
> /controllers/default.py"
>  
>
> > , line 6, in 
> > index 
> > 
> > dbOBJECT.url.insert(variable1=request.vars.variable1, 
> > variable2=request.vars.variable2) 
> >   File "/home/ndemir/web2py/gluon/sql.py", line 1926, in insert 
> > 
> > self._db._execute(query) 
> > 
> >   File "/home/ndemir/web2py/gluon/sql.py", line 958, in  
> > 
> > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) 
> > InterfaceError: cursor already closed 
> > 
> > On 2 May 2010 00:59, mdipierro  wrote: 
> > 
> > 
> > 
> > > Can you tell us more? 
> > 
> > > What os? what web2py version? what code? Is there a complete 
> > > traceback? Is the error in a ticket? Can we see the ticket? 
> > 
> > > Massimo 
> > 
> > > On May 1, 3:35 pm, Necati Demir  wrote: 
> > > > Hello, 
> > 
> > > > I get this error with database operations: InterfaceError: cursor 
> > > > already closed 
> > > > I get the same error with mysql and postgresql. 
> > 
> > > > Any suggestions? 
> > 
> > -- 
> > Necati DEMİRhttp://blog.demir.web.trhttp://friendfeed.com/ndemir 
> > ndemir ~ demir.web.tr 
> > --- 
>

-- 





Re: [web2py] Re: Best way to secure insert on remote call?

2012-07-29 Thread Alec Taylor
Actually I've just been fiddling around with this and run into a few
problems.

Would you be able to show me a more complete example?

Thanks,

Alec Taylor

On Sun, Jul 29, 2012 at 12:28 PM, Alec Taylor wrote:

> Thanks, that should do the trick
>
>
> On Sun, Jul 29, 2012 at 12:38 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> URL('rsvp_action',user_signature=True)
>>
>> +
>>
>> @auth.requires_signature()
>> def rsvp_action(): 
>>
>>
>>
>> On Saturday, 28 July 2012 08:50:30 UTC-5, Alec Taylor wrote:
>>>
>>> So I've got a simple  link dropdown on each of my group-event pages,
>>> like so:
>>>
>>>
>>> 
>>> I have a table called `rsvp_list` with reference fields: `event_id` and
>>> `user_id`, and an `rsvp` field requiring `IS_IN_SET(["Yes", "Maybe",
>>> "No"])`.
>>>
>>> One way I can make the above work is by appending the value for
>>> `event_id`, `user_id` and `rsvp` automatically, through global function
>>> calls or a specialised controller utilising `request.args`.
>>>
>>> Unfortunately this means that anyone who has figure out my URL schema
>>> can simply enter the ID of someone else into the URL, forging an RSVP.
>>>
>>> What's a better way of doing this?
>>>
>>> Thanks for all suggestions,
>>>
>>> Alec Taylor
>>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: InterfaceError

2012-07-29 Thread Massimo Di Pierro
The version of web2py that you are running is more than 2 years old. You 
need to upgrade to the latest stable before we can help you. The problem 
may have been solved long ago.

Massimo

On Sunday, 29 July 2012 14:23:18 UTC-5, Elton Pereira de Lima wrote:
>
> There solution to this problem?
> I'm experiencing the same problem and I find no solution, what is the 
> cause?
>
> Tanks!
>
> Em domingo, 2 de maio de 2010 19h25min42s UTC-3, mdipierro escreveu:
>>
>> Can you show the complete model and controller? If you want you can 
>> email it to me confidentially. 
>>
>> Massimo 
>>
>>
>> On May 2, 12:54 pm, Necati Demir  wrote: 
>> > web2py version: Version 1.77.3 (2010-04-20 02:48:54) 
>> > 
>> > Here is the traceback from ticket: 
>> > 
>> > Traceback (most recent call last): 
>> > 
>> >   File "/home/ndemir/web2py/gluon/restricted.py", line 178, in 
>> restricted 
>> > 
>> > exec ccode in environment 
>> > 
>> >   File 
>> "/home/ndemir/web2py/applications/project1/controllers/default.py" 
>> > , line 10, in 
>> >  
>> > 
>> >   File "/home/ndemir/web2py/gluon/globals.py", line 96, in  
>> > 
>> > self._caller = lambda f: f() 
>> > 
>> >   File "/home/ndemir/web2py/applications/ 
>> > project1 
>> > 
>> /controllers/default.py"
>>  
>>
>> > , line 6, in 
>> > index 
>> > 
>> > dbOBJECT.url.insert(variable1=request.vars.variable1, 
>> > variable2=request.vars.variable2) 
>> >   File "/home/ndemir/web2py/gluon/sql.py", line 1926, in insert 
>> > 
>> > self._db._execute(query) 
>> > 
>> >   File "/home/ndemir/web2py/gluon/sql.py", line 958, in  
>> > 
>> > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) 
>> > InterfaceError: cursor already closed 
>> > 
>> > On 2 May 2010 00:59, mdipierro  wrote: 
>> > 
>> > 
>> > 
>> > > Can you tell us more? 
>> > 
>> > > What os? what web2py version? what code? Is there a complete 
>> > > traceback? Is the error in a ticket? Can we see the ticket? 
>> > 
>> > > Massimo 
>> > 
>> > > On May 1, 3:35 pm, Necati Demir  wrote: 
>> > > > Hello, 
>> > 
>> > > > I get this error with database operations: InterfaceError: cursor 
>> > > > already closed 
>> > > > I get the same error with mysql and postgresql. 
>> > 
>> > > > Any suggestions? 
>> > 
>> > -- 
>> > Necati DEMİRhttp://blog.demir.web.trhttp://friendfeed.com/ndemir 
>> > ndemir ~ demir.web.tr 
>> > --- 
>>
>

-- 





[web2py] Re: Question regarding plugin multiselect ( as a widget ) on a form ...

2012-07-29 Thread Don_X
Thank you Massimo .. I am trying it ( with the last multiselect plugin  
version 1.8 )  .. and will update this post with what I got !  ... 


-- 





[web2py] Re: is it possible to run web2py parallel to php on apache port 80?

2012-07-29 Thread Don_X
I have succeeded in doing this on my home ubuntu server by using the info 
on the same link Massimo provided ! ... 

& not too long ago  ... I have tried to do the same thing on a windows 7 ( 
with the real apache server installed with openssl ) .. it did not go as 
smoothly .. on windows 7 .. it does not work as smoothly .. but it works .. 
I get to have phpmyadmin to manage  mysql databases & tables .!! .. I have 
not really resolved the few glitches  left ... I also run in parralel on 
both servers the Yii framework .. so yes you can do it ! 

 .. .. lately .. I only work from  my ubuntu server  12.04 ! .. no glitches 
!



On Sunday, July 29, 2012 3:22:29 PM UTC-4, Massimo Di Pierro wrote:
>
> Yes but I have not done it. My understanding is that you can use a 
> configuration such as described here:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-ubuntu.sh#L80
>
> and within the same virtualhost you map some paths to the php folder
>
> 
>   php_admin_value open_basedir "/home/php/"
>   php_admin_value upload_tmp_dir "/tmp"
> 
>
>
>
> On Sunday, July 29, 2012 1:18:37 PM UTC-5, Robin Manoli wrote:
>>
>> Hey,
>> I'm wondering if it is possible to run web2py on the same port as other 
>> php-websites run. I have a normally configured LAMP, and I can install the 
>> required apache mod. Then the question is if a web2py app can run parallel, 
>> just as different php/html sites do with different domain names, using port 
>> 80?
>>
>> Thanks for your help
>>
>

-- 





Re: [web2py] Re: InterfaceError

2012-07-29 Thread Elton Pereira
I'm using version 2.0.0
Elton Pereira

On Sun, Jul 29, 2012 at 4:39 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The version of web2py that you are running is more than 2 years old. You
> need to upgrade to the latest stable before we can help you. The problem
> may have been solved long ago.
>
> Massimo
>
>
> On Sunday, 29 July 2012 14:23:18 UTC-5, Elton Pereira de Lima wrote:
>>
>> There solution to this problem?
>> I'm experiencing the same problem and I find no solution, what is the
>> cause?
>>
>> Tanks!
>>
>> Em domingo, 2 de maio de 2010 19h25min42s UTC-3, mdipierro escreveu:
>>>
>>> Can you show the complete model and controller? If you want you can
>>> email it to me confidentially.
>>>
>>> Massimo
>>>
>>>
>>> On May 2, 12:54 pm, Necati Demir  wrote:
>>> > web2py version: Version 1.77.3 (2010-04-20 02:48:54)
>>> >
>>> > Here is the traceback from ticket:
>>> >
>>> > Traceback (most recent call last):
>>> >
>>> >   File "/home/ndemir/web2py/gluon/**restricted.py", line 178, in
>>> restricted
>>> >
>>> > exec ccode in environment
>>> >
>>> >   File 
>>> > "/home/ndemir/web2py/**applications/project1/**controllers/default.py"
>>>
>>> > , line
>>> 10, in
>>> > 
>>> >
>>> >   File "/home/ndemir/web2py/gluon/**globals.py", line 96, in 
>>> >
>>> > self._caller = lambda f: f()
>>> >
>>> >   File "/home/ndemir/web2py/**applications/
>>> > project1
>>> > >> default.py>/controllers/**default.py"
>>> > , line 6,
>>> in
>>> > index
>>> >
>>> > dbOBJECT.url.insert(variable1=**request.vars.variable1,
>>> > variable2=request.vars.**variable2)
>>> >   File "/home/ndemir/web2py/gluon/**sql.py", line 1926, in insert
>>> >
>>> > self._db._execute(query)
>>> >
>>> >   File "/home/ndemir/web2py/gluon/**sql.py", line 958, in 
>>> >
>>> > self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
>>> > InterfaceError: cursor already closed
>>> >
>>> > On 2 May 2010 00:59, mdipierro  wrote:
>>> >
>>> >
>>> >
>>> > > Can you tell us more?
>>> >
>>> > > What os? what web2py version? what code? Is there a complete
>>> > > traceback? Is the error in a ticket? Can we see the ticket?
>>> >
>>> > > Massimo
>>> >
>>> > > On May 1, 3:35 pm, Necati Demir  wrote:
>>> > > > Hello,
>>> >
>>> > > > I get this error with database operations: InterfaceError: cursor
>>> > > > already closed
>>> > > > I get the same error with mysql and postgresql.
>>> >
>>> > > > Any suggestions?
>>> >
>>> > --
>>> > Necati DEMİRhttp://blog.demir.web.**trhttp://friendfeed.com/ndemir
>>> > ndemir ~ demir.web.tr
>>> > --**-
>>>
>>  --
>
>
>
>



-- 
Elton Pereira de Lima
Linux System Administrator
Django Developer
-
Seja transparente! Use Software Livre!

Atenção: Este e-mail pode conter anexos no formato ODF (Open Document
Format)/ABNT (extensões odt, ods, odp, odb, odg). Antes de pedir os
anexos em outro formato, você pode instalar gratuita e livremente o
BrOffice (http://www.broffice.org) ou o seguinte Plugin para Microsoft
Office (http://www.sun.com/software/star/odf_plugin/get.jsp).

Você que paga propina, joga lixo no chão, fura fila, sonega impostos,
estaciona em vagas p/ deficientes... *NÃO PODE FALAR MAL DOS POLÍTICOS*!

-- 





[web2py] Link stats through rerouting URL (geoip)

2012-07-29 Thread BlueShadow
Hi,
I like to get information about usage of a link to an outside page. To 
track some advertizing progress^^.
So My idea was to use a URL to my web2pyapplication which redirects to the 
URL I want to get stats about.
I would like to record the day and the number of clicks as well as the 
region(geoip)
so the db tables would be pretty simple like one primary key and URL to 
redirect to in one table.
a second for the results. date, hits region, tracked URL
for recording the links I would use someting like: pageStatistics by Anton 
G. Mueckl
http://www.web2pyslices.com/main/slices/take_slice/27

My problem is I got no idea how to get the region(geoip) information

-- 





[web2py] Running SSH commands and capturing the results (Threading)

2012-07-29 Thread Tito Garrido
Hi Folks!

I'd like to create a web application that will basically send a command to
1000 servers and grab some data using subprocess + ssh like:

*p = sub.Popen(['ssh','-q', 'support@%s'%hostname,
command],stdout=sub.PIPE, stderr=sub.STDOUT)
out = p.stdout.read()
print out # it will be a db insert
p.poll()
rc=p.returncode
print rc # it will be a db insert*

I can't execute all threads at the same time so I would need to pool then
and execute using Queue module.

My first code was:*
class ThreadSSH(threading.Thread):
"""Thread ssh command"""
def __init__(self, queue, name):
threading.Thread.__init__(self)
self.queue = queue
self.name = name

def run(self):
#while not self.queue.empty():
while True:
 #   print 'Starting %s' %self.name
#grabs host from queue
print 'Empty: %s' %self.queue.empty()
print 'Qsize: %s' %self.queue.qsize()
print '%s' %dir(self.queue)
host = self.queue.get()

#core of the thread
time.sleep(10)
print 'Active count: %s' %threading.activeCount()
print "Exiting " + self.name

#signals to queue job is done
self.queue.task_done()

def test():
hosts = ['host1', 'host2', 'host3', 'host4']
# Queue of servers, we will fill it down there
queue = Queue.Queue()
print 'begin: %s' %threading.enumerate()
#spawn a pool of threads, and pass them queue instance
for i in range(20):
t = ThreadSSH(queue, 'test-%s' %i)
t.setDaemon(True)
t.start()
print 'thread generated: %s' %threading.enumerate()

#populate queue with data
for host in hosts:
queue.put(host)
print 'SIZE: %s' %queue.qsize()*


Not sure if this is the right approach for this kind of application but the
problem is that those threads never ends... if I put in another function:
*def threadInfo():
output='enumerate: %s' %['%s Live(%s) Daemon(%s)'
%(t.name,t.isAlive(),t.isDaemon())
for t in threading.enumerate()]
output+='active count: %s' %threading.activeCount()
output+='current thread: %s' %threading.currentThread().name
return output*

I can see that even the thread ending it is showing on enumerate.

Do you guys have another idea or know how to fix this issue?

Thanks in advance,

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] how to increase field value without to affect computed fields

2012-07-29 Thread Vasile Ermicioi
hi,

I have a table with computed fields, and also field with update values (e.g 
updated_on)
I want to increase a field count (number of views) each time an item is 
displayed but without touching other fields

how to do that without raw sql?

-- 





[web2py] Re: SQLFORM.factory in a model -- huge performance degradation with db size [closed]

2012-07-29 Thread howesc
i might also ask if that form is displayed on *every* request.  if not, i 
would recommend moving it from the model file to the controller where it is 
used (or a module if it is used in several controllers).

On Sunday, July 29, 2012 7:25:55 AM UTC-7, weheh wrote:
>
> Massimo, thanks for pointing out the obvious to me. I knew it had to be 
> something that simple, just couldn't see it. I had decided to use factory 
> instead of pure SQLFORM because I'm not going through the usual self-submit 
> process. The db is all manipulated via ajax in this case and the form is a 
> convenient way to get the widgets I need.
>
> Thanks for the suggestions for the autocomplete widget and cache. Instead, 
> since I don't need the reference in my form, I'm just turning it off 
> altogether with readable/writable = False. After making the change, the 
> time to build the form dropped to 0.04 sec. Now, that's more like it!
>
>

-- 





[web2py] Re: Question about Human-readable forms + REST CRUD APIs.

2012-07-29 Thread howesc
i'll add a couple of comments:

 - if you define your models carefully with requires parameters 
(validators) in web2py, the SQLFORM object will use them, and you can 
trigger the use of those validators via your REST API (i forget the exact 
call, but there is something that does validation and insert/update in the 
recent releases of web2py)
 - if you have custom processing logic, you can always put it in modules 
and have your REST and your web form wrappers just call out to those 
modules for processing.

i think you can achieve a high level of code reuse if you plan your code 
carefully.  i assume the same would be true in flask as well.

good luck!

cfh

On Saturday, July 28, 2012 8:32:35 PM UTC-7, Massimo Di Pierro wrote:
>
> This is an excellent point.
>
> The closest we came to what you asked is the crud object. If a page 
> contains a single crud form and if the page is called with the json 
> extension, it reads the form variable from ?json. This allows one to 
> interact with the Crud object (create,read, update, delete) using html and 
> or rest-like approach.
> I say rest-like because it is not really restful. This is because we do 
> not use PUT and DELETE for Crud.
>
> Anyway, we are considering deprecating Crud because nobody used it this 
> way.
>
> The problem is that html forms and rest services are very different. html 
> forms assume a state (for preventing crsf, for checking permissions, etc.) 
> while rest services are not supposed to. One html page (one url) can 
> contain more crud elements while a restful URL deals with only one service 
> at the time. Html pages do not use PUT and DELETE (unless doing ajax) while 
> rest services do. Usually information in html and rest services is filtered 
> differently.
>
> Therefore we have developed different APIs for forms (SQLFORM, FORM) and 
> rest (@request.restful()).
>
> The only way to build a uniform APIs would be to have html forms and pages 
> get all their data via Ajax restful calls. Yet many users do not 
> want functional parts of their web site depending on JavaScript.
>
> In my view there is no simple solution to this problem and it is easier to 
> actually implement html forms and rest services separately. If you have any 
> advice on how to built a better system, I would like to hear your ideas. It 
> could help make web2py better.
>
> massimo
>
>
>
>
>
>
>
> On Saturday, 28 July 2012 21:41:34 UTC-5, Matthew Wood wrote:
>>
>> A quick question about basic CRUD for both humans (basic HTML) and 
>> computers
>> (REST)
>>
>> I'm trying to pick a solid python framework for a project at work.  We 
>> have a
>> lot of situations where we need to expose datbase tables for data CRUD.
>>
>> I'm trying to pick between Flask and Web2py at this time, but I've got a
>> specific need that I'm not sure is solved by either framework.
>>
>> Obviously for human consumption, I'll be using some sort of form-library 
>> that
>> will read the table-schema auto-create the form for me.  (Built in with 
>> Web2py,
>> WTForms + SQL-Alchemy for Flask.)  For the REST interfaces, I'll use a 
>> similar
>> library (Built in with Web2py, flask-rest for flask).
>>
>> What I'd REALLY like, is to have both the REST interfaces and html-forms 
>> use as
>> much of a common code-path as possible.  It's really frustrating when 
>> things
>> like data-validation work differently between one's REST interfaces and 
>> one's
>> html forms.
>>
>> Thusfar, in my investigations with both frameworks, I've felt that both
>> mechanisms appear quite different, and/or I have to do a lot of manual 
>> parsing
>> of XML in the Post/Put REST case.
>>
>> HOWEVER...  I've really only spent a little time investigating either one.
>> It's extremely likely that I'm just completely missing the best way to 
>> solve
>> the issue I'm describing.
>>
>> Can anyone point me to an example that works the way I'm describing?
>>
>> Hopefully, I have asked my question well enough.  :-) I'm feeling horribly
>> inelequent right now.
>>
>

-- 





Re: [web2py] Re: InterfaceError

2012-07-29 Thread Massimo Di Pierro
This thread was opened by Necati who reports to be using 1.77 and we cannot 
support something so old.

I assume you are having the same problem. Can you tell us more about your 
code so that we can reproduce the problem?
This is usually due a non-thread safe use of the db object. For example you 
store something that points to db in cache.ram and then you use it in a 
different request.

On Sunday, 29 July 2012 15:09:25 UTC-5, Elton Pereira de Lima wrote:
>
> I'm using version 2.0.0
> Elton Pereira
>
> On Sun, Jul 29, 2012 at 4:39 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> The version of web2py that you are running is more than 2 years old. You 
>> need to upgrade to the latest stable before we can help you. The problem 
>> may have been solved long ago.
>>
>> Massimo
>>
>>
>> On Sunday, 29 July 2012 14:23:18 UTC-5, Elton Pereira de Lima wrote:
>>>
>>> There solution to this problem?
>>> I'm experiencing the same problem and I find no solution, what is the 
>>> cause?
>>>
>>> Tanks!
>>>
>>> Em domingo, 2 de maio de 2010 19h25min42s UTC-3, mdipierro escreveu:

 Can you show the complete model and controller? If you want you can 
 email it to me confidentially. 

 Massimo 


 On May 2, 12:54 pm, Necati Demir  wrote: 
 > web2py version: Version 1.77.3 (2010-04-20 02:48:54) 
 > 
 > Here is the traceback from ticket: 
 > 
 > Traceback (most recent call last): 
 > 
 >   File "/home/ndemir/web2py/gluon/**restricted.py", line 178, in 
 restricted 
 > 
 > exec ccode in environment 
 > 
 >   File 
 > "/home/ndemir/web2py/**applications/project1/**controllers/default.py" 

 > , line 
 10, in 
 >  
 > 
 >   File "/home/ndemir/web2py/gluon/**globals.py", line 96, in 
  
 > 
 > self._caller = lambda f: f() 
 > 
 >   File "/home/ndemir/web2py/**applications/ 
 > project1 
 > >>> default.py>/controllers/**default.py" 
 > , line 
 6, in 
 > index 
 > 
 > dbOBJECT.url.insert(variable1=**request.vars.variable1, 
 > variable2=request.vars.**variable2) 
 >   File "/home/ndemir/web2py/gluon/**sql.py", line 1926, in insert 
 > 
 > self._db._execute(query) 
 > 
 >   File "/home/ndemir/web2py/gluon/**sql.py", line 958, in  
 > 
 > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) 
 > InterfaceError: cursor already closed 
 > 
 > On 2 May 2010 00:59, mdipierro  wrote: 
 > 
 > 
 > 
 > > Can you tell us more? 
 > 
 > > What os? what web2py version? what code? Is there a complete 
 > > traceback? Is the error in a ticket? Can we see the ticket? 
 > 
 > > Massimo 
 > 
 > > On May 1, 3:35 pm, Necati Demir  wrote: 
 > > > Hello, 
 > 
 > > > I get this error with database operations: InterfaceError: cursor 
 > > > already closed 
 > > > I get the same error with mysql and postgresql. 
 > 
 > > > Any suggestions? 
 > 
 > -- 
 > Necati DEMİRhttp://blog.demir.web.**trhttp://friendfeed.com/ndemir 
 > ndemir ~ demir.web.tr 
 > --**- 

>>>  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
> Elton Pereira de Lima
> Linux System Administrator
> Django Developer
> -
> Seja transparente! Use Software Livre!
>
> Atenção: Este e-mail pode conter anexos no formato ODF (Open Document
> Format)/ABNT (extensões odt, ods, odp, odb, odg). Antes de pedir os
> anexos em outro formato, você pode instalar gratuita e livremente o
> BrOffice (http://www.broffice.org) ou o seguinte Plugin para Microsoft
> Office (http://www.sun.com/software/star/odf_plugin/get.jsp).
>
> Você que paga propina, joga lixo no chão, fura fila, sonega impostos, 
> estaciona em vagas p/ deficientes... *NÃO PODE FALAR MAL DOS POLÍTICOS*!
>
>

-- 





[web2py] Re: how to increase field value without to affect computed fields

2012-07-29 Thread Massimo Di Pierro
have you tried?

db.table.updated_on.update=None # disable it
db(query).update(counter=db.table.counter+1)



On Sunday, 29 July 2012 17:28:35 UTC-5, Vasile Ermicioi wrote:
>
> hi,
>
> I have a table with computed fields, and also field with update values 
> (e.g updated_on)
> I want to increase a field count (number of views) each time an item is 
> displayed but without touching other fields
>
> how to do that without raw sql?
>

-- 





[web2py] SQLForm.grid custom details page

2012-07-29 Thread SeamusSeamus

Hi, 
 I am creating a basic app that allows users to view item in an inventory. 
They are able to see the item list by using the sqlform.grid. Because some 
fields in the database are private and I do not want the viewer to see it, 
I am unable to use the default details page. Because of this, I need to 
set  "details=False" on my grid, and then create a new details.html view, 
and add the following "links" code to my grid:

query = ((db.equipment.isActive=="True"))
fields = [db.equipment.id, db.equipment.category, db.equipment.title, 
db.equipment.price]
*links = [lambda row: A('Details',_href=URL("default","details", 
args=[row.id]))]*
grid = SQLFORM.grid(query=query, 
fields=fields,
editable=False,
deletable=False,
create=False,
user_signature=True,
details=False,
links=links
)


So here is my question. What do I use in the details.html view and 
controller in order to pick and choose what information I want to use? I am 
sure this is a basic question, and so far I have been following the 
tutorial / book, but  I cannot seem to find the page in the tutorial, can 
anyone point me to the right direction or show me some example code?

I only want the "title", "price", "photo", "description" and maybe "date" 
to show in the details.html, and not ALL of the fields in the DB (contains 
private information)

Thank you

-- 





[web2py] Re: SQLFORM.factory in a model -- huge performance degradation with db size [closed]

2012-07-29 Thread weheh
Actually, the form is not displayed on every request and is embedded in a 
function. When I have the time, I will be moving it to modules, not a 
controller. I am basically using the automatic form generation capabilities 
of web2py without the self-submitting capabilities. I override all the form 
actions with on_click events. I originally had this coded as raw html, but 
then decided it would be easier to maintain if I got SQLFORM to do the work 
for me. In the final analysis, it's almost a tie in terms of conciseness. 
What I do like about the SQLFORM approach is that it self-documents exactly 
which table in the DAL is going to get updated.

On Monday, July 30, 2012 6:35:33 AM UTC+8, howesc wrote:
>
> i might also ask if that form is displayed on *every* request.  if not, i 
> would recommend moving it from the model file to the controller where it is 
> used (or a module if it is used in several controllers).
>
> On Sunday, July 29, 2012 7:25:55 AM UTC-7, weheh wrote:
>>
>> Massimo, thanks for pointing out the obvious to me. I knew it had to be 
>> something that simple, just couldn't see it. I had decided to use factory 
>> instead of pure SQLFORM because I'm not going through the usual self-submit 
>> process. The db is all manipulated via ajax in this case and the form is a 
>> convenient way to get the widgets I need.
>>
>> Thanks for the suggestions for the autocomplete widget and cache. 
>> Instead, since I don't need the reference in my form, I'm just turning it 
>> off altogether with readable/writable = False. After making the change, the 
>> time to build the form dropped to 0.04 sec. Now, that's more like it!
>>
>>

-- 





[web2py] Re: Facing problem of settingup web2py project in Eclipse.

2012-07-29 Thread Amit
Does anyone having any idea how to resolve those incorrect errors in 
eclipse?
problem:
I set up web2py project in eclipse and having one project inside 
applications folder but when i opened any file of project all import 
statement are showing in Red underline saying "Unresolved import" for e.g. 
in project's model class db.py , I am using below import statement:

*from gluon.tools import Auth, Crud, Service, PluginManager, prettydate*
and every imports are displaying in red underline saying "Unresolved 
import", but when i deployed this application in web2py server , its 
working fine, so not sure why eclipse is displaying import errors.
Can anybody help me to resolve this problem?

Thanks,
Amit


On Friday, 20 July 2012 10:49:29 UTC+5:30, Amit wrote:
>
> Hi,
> I followed below link to configure Web2py project in eclipse:
>
> http://allisterx.blogspot.in/2009/06/using-web2py-framework-on-eclipse.html
>
> but after setting up when i open my application which is there inside 
> application folder of web2py_src folder, I saw so many errors on the module.
> once i open default.py module, it showing error on import modules which 
> are inside Modules folder(for e.g.: i have userconf.py module inside 
> modules but when i import it in default.controller it giving error saying 
> "Unresolved import:userconf") , similar problem with when i am trying to 
> use function of db.py, its giving error "undefined variable".
>
> can anyone please help me to figure out what wrong i did?
>

-- 





[web2py] Re: Question about Human-readable forms + REST CRUD APIs.

2012-07-29 Thread Anthony

>
>  - if you define your models carefully with requires parameters 
> (validators) in web2py, the SQLFORM object will use them, and you can 
> trigger the use of those validators via your REST API (i forget the exact 
> call, but there is something that does validation and insert/update in the 
> recent releases of web2py)


db.mytable.validate_and_insert(...)
db.mytable.validate_and_update(...)

Those methods will run all the validators defined for the table fields 
before doing the insert/update.

Anthony

-- 





[web2py] Book typo

2012-07-29 Thread Johann Spies
I suppose

res.updated
in the documentation for *validate_and_insert, validate_and_update*
in the book should be

ret.updated

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

-- 





Re: [web2py] SQLForm.grid custom details page

2012-07-29 Thread Johann Spies
On 30 July 2012 05:13, SeamusSeamus  wrote:

>
> I only want the "title", "price", "photo", "description" and maybe "date"
> to show in the details.html, and not ALL of the fields in the DB (contains
> private information)
>
>
In your function 'details' set the fields that you do now want to be
displayed as 'readable=False' .
e.g.

db.sometable.somefield.readable=False

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

--