Re: [web2py] Re: Dropdown field not being accepted

2011-07-01 Thread Bruno Rocha
Here is a modified version
https://bitbucket.org/rochacbruno/surveycloud

Bug fixes
Auth included
No more cpuckle
Powertables
Smart reports

http://zerp.ly/rochacbruno
Em 30/06/2011 23:59, "pbreit"  escreveu:
> Everything above the "if form.accepts()" is run each time the submit
button
> is pressed.
>
> I can't think of the best way to implement this off-hand. It does seem
like
> you could do it all in one controller.
>
> There's a pretty old survey app which might give you some ideas:
> http://www.web2py.com/appliances/default/show/66


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-01 Thread Bruno Rocha
Db.define_table('foo',Field('a'),Field('b'), Field('ab',unique=True,
compute=lambda r: r.a + r.b))

http://zerp.ly/rochacbruno
Em 30/06/2011 23:04, "Nick Arnett"  escreveu:
> On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett 
wrote:
>
>>
>>
>> On Thu, Jun 30, 2011 at 4:15 PM, Anthony  wrote:
>>
>>> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you
can
>>> limit the records checked to a particular set within the table (see
>>> http://web2py.com/book/default/chapter/07#Database-Validators). However,
>>> I'm not quite sure what you're trying to do here.
>>>
>>> I think what he wants is the equivalent of Django's "unique together",
>> which I'm also trying to figure out. IS_NOT_IN_DB seems to accomplish it,
>> but is that going to create a unique index on the combined fields?
>> Otherwise, it will be expensive to do inserts.
>>
>
> Actually, I don't see how NOT_IN_DB can accomplish this, since it is
> associated with a single field. Do I have to create an extra concatenated
> field and make it unique? Seems silly, given that's what a database unique
> index is.
>
> In other words, for table foo, if I want fields A, B and C to be unique
> together, do I have to do this?
>
> db.define_table('foo', Field('A'), Field('B'), Field('C'),
> Field('ABC_unique', unique=True))
>
> And remember to concat A, B, and C into that last field every time I do an
> insert?
>
> I'm missing something here, since this is so simple elsewhere.
>
> Nick


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-01 Thread Bruno Rocha
>Validators, by the way, are  >enforced at the form level and
> have no direct effect on the db.

There are 3 levels of validation.

Db validadors:
Unique, notnull, expression etc

Dal validators:
Required, compute, default etc

Form & dal validators:
IS_IN_DB etc..

Note the former will be checked in forms and in DAL when used
db.validate_and_insert update_and_insert or Row.validate_and_update_record.


Re: [web2py] looks familiar, could be useful

2011-07-01 Thread Martín Mulone
It's sound familiar to me :O

2011/7/1 Massimo Di Pierro 

> https://github.com/MisterRager/DOMination




-- 
 http://martin.tecnodoc.com.ar


[web2py] How to add user to user_auth table of CAS

2011-07-01 Thread sagar
Hi,

I have situation where ,once I recive Email ids from users i have
autogenerate password and mail to them.

I can insert this info to my local user_auth table.

I can add it in local user_auth table like below

password="password"
db.auth_user.insert(first_name="autotest",last_name="autotest",email="t...@autotest.com",password=CRYPT(auth.settings.hmac_key)
(password)[0])

but to authenticate user i have to insert it into user_auth table of
CAS from my local app.

I am trying but not succeeded yet.


How to do this?

Please help..

Thanks
Sagar



[web2py] Good syntax checker recommendations?

2011-07-01 Thread Cliff
Can anyone recommend a good syntax checker for Web2py?

It would also be good to know how to prevent spurious error messages
caused because the checker can't find all the import statements, etc.


[web2py] OffTopic Google+

2011-07-01 Thread Massimiliano
Anyone interested?
Mail me privately

Ciao
-- 
Massimiliano


[web2py] Upload form using Load

2011-07-01 Thread David J.

I had this working a few weeks ago.

I have an upload form which I load into the page using the LOAD helper.

Right now I get an exception when I try to upload.

Here is the code.

def upload_contacts():
form = FORM(INPUT(_type='file', 
_name='data',requires=[IS_NOT_EMPTY()]), INPUT(_type='submit'))


if form.accepts(request):


contact_list = request.vars.data #I also tried 
form.vars.data.file Exception about data being a string.


...csv processing left out for brevity

I am just trying to access the file at this point.

I followed the example in the book in DAL for uploading CSV data.
http://web2py.com/book/default/chapter/06#CSV-%28one-table-at-a-time%29



[web2py] Re: Janrain login_next

2011-07-01 Thread Massimo Di Pierro
yes.

1) add a field 'completed_registration' to the auth_user table and default to 
False
2) then in a model

if auth.user and not auth.user.completed_registration and not 
URL()==URL('default','user'): redirect('default','user/profile'))



On Jul 1, 2011, at 8:32 AM, DanB wrote:

> fference between a
> new user and an existing user when using something like Janrain?



[web2py] Job - clone website

2011-07-01 Thread gubbanoa
Hi,

I am interested in whether web2py can be used to clone a relatively
simple ecommerce website made in Drupal. I have posted the job on
elance, job number 24934137 and would welcome bids from this user
group. I have specified Django or web2py, but would like to give
web2py a go if I get a good bid. If successful I am looking to expand
functionality (beyond what I think Drupal can do) immediately.

gubbanoa


[web2py] Re: Janrain login_next

2011-07-01 Thread DanB
So, if I have this straight (sorry, very new to web2py, and python) to
implement this in the Welcome App, I would add the following:

To the db.py model (mostly uncommenting):

from gluon.contrib.login_methods.rpx_account import RPXAccount
auth.settings.actions_disabled = \
['register','change_password','request_reset_password']
auth.settings.login_form = RPXAccount(request,
api_key='BLAHBLAHBLAH',
domain='mydomain', url = "http://localhost:8000/%s/default/user/login";
% request.application)
auth.settings.login_next=URL('default/index')

And from there, where would I add the 'if auth.user and not
auth.user.completed_registration...'? To the default controller? db
model?

I'm guessing I would also need to add 'update=True' to the
'completed_registration' field to flag the user as complete once
they've been redirected and submitted full Profile information.

Sorry if I'm being obtuse. Hope I'm making sense. Thanks so much!

On Jul 1, 9:36 am, Massimo Di Pierro 
wrote:
> yes.
>
> 1) add a field 'completed_registration' to the auth_user table and default to 
> False
> 2) then in a model
>
> if auth.user and not auth.user.completed_registration and not 
> URL()==URL('default','user'): redirect('default','user/profile'))
>
> On Jul 1, 2011, at 8:32 AM, DanB wrote:
>
>
>
>
>
>
>
> > fference between a
> > new user and an existing user when using something like Janrain?


Re: [web2py] How to add user to user_auth table of CAS

2011-07-01 Thread sagar nigade
oops thinkig some other way soory...thats simple

it can be encoded using urllib2 and send to cas app..there i can get in
request.vars.i thinks thats the right approach..



On Fri, Jul 1, 2011 at 4:34 PM, sagar  wrote:

> Hi,
>
> I have situation where ,once I recive Email ids from users i have
> autogenerate password and mail to them.
>
> I can insert this info to my local user_auth table.
>
> I can add it in local user_auth table like below
>
> password="password"
> db.auth_user.insert(first_name="autotest",last_name="autotest",email="
> t...@autotest.com",password=CRYPT(auth.settings.hmac_key)
> (password)[0])
>
> but to authenticate user i have to insert it into user_auth table of
> CAS from my local app.
>
> I am trying but not succeeded yet.
>
>
> How to do this?
>
> Please help..
>
> Thanks
> Sagar
>
>


[web2py] Re: Upload form using Load

2011-07-01 Thread Anthony
Assuming you have ajax=True in LOAD(), I think file uploads will not work 
without some special setup. According to the book:
 

**Please note:* Because Ajax post does not support multipart forms, i.e. 
file uploads, upload fields will not work with the LOAD component. You could 
be fooled into thinking it would work because upload fields will function 
normally if POST is done from the individual component's .load view. 
Instead, uploads are done with ajax-compatible 3rd-party widgets and web2py 
manual upload store commands.*

 
Anthony
 

On Friday, July 1, 2011 9:34:33 AM UTC-4, David J wrote:

> I had this working a few weeks ago. 
>
> I have an upload form which I load into the page using the LOAD helper. 
>
> Right now I get an exception when I try to upload. 
>
> Here is the code. 
>
> def upload_contacts():
>  form = FORM(INPUT(_type='file', 
> _name='data',requires=[IS_NOT_EMPTY()]), INPUT(_type='submit')) 
>
>  if form.accepts(request): 
>
>
>  contact_list = request.vars.data #I also tried 
> form.vars.data.file Exception about data being a string. 
>
>  ...csv processing left out for brevity 
>
> I am just trying to access the file at this point. 
>
> I followed the example in the book in DAL for uploading CSV data.
> http://web2py.com/book/default/chapter/06#CSV-%28one-table-at-a-time%29 
>
> 

Re: [web2py] Re: Upload form using Load

2011-07-01 Thread David J.

Got it thanks.

Strange; I am almost certain that I had it working at some point; 
perhaps I am mistaken.


Thanks for the heads up.



On 7/1/11 10:03 AM, Anthony wrote:
Assuming you have ajax=True in LOAD(), I think file uploads will not 
work without some special setup. According to the book:


/*Please note:* Because Ajax post does not support multipart
forms, i.e. file uploads, upload fields will not work with the
LOAD component. You could be fooled into thinking it would work
because upload fields will function normally if POST is done from
the individual component's .load view. Instead, uploads are done
with ajax-compatible 3rd-party widgets and web2py manual upload
store commands./

Anthony

On Friday, July 1, 2011 9:34:33 AM UTC-4, David J wrote:

I had this working a few weeks ago.

I have an upload form which I load into the page using the LOAD
helper.

Right now I get an exception when I try to upload.

Here is the code.

def upload_contacts():
 form = FORM(INPUT(_type='file',
_name='data',requires=[IS_NOT_EMPTY()]), INPUT(_type='submit'))

 if form.accepts(request):


 contact_list = request.vars.data #I also tried
form.vars.data.file Exception about data being a string.

 ...csv processing left out for brevity

I am just trying to access the file at this point.

I followed the example in the book in DAL for uploading CSV data.
http://web2py.com/book/default/chapter/06#CSV-%28one-table-at-a-time%29







[web2py] Forcing SSL/HTTPS

2011-07-01 Thread Ross Peoples
Since I want to make sure that my application is as secure as possible, I 
wanted to force all traffic to use HTTPS. At the bottom of my db.py, I have 
this:

 FORCED SSL #
session.secure()
if not request.is_https:
redirect('https://%s/%s' % (request.env.http_host, request.application))
#

It works great, secures the cookie, and redirects the user to the HTTPS 
version of the site since session.secure() does not do this by itself. There 
is one major problem with this, however, and that is that if I try to run a 
script from cron, the script fails with a gluon.http.HTTP: 303 error due to 
the fact that the script isn't using HTTPS.

So is there a way to tell if a request is from a cron script? Or is there a 
better way to do the forced SSL connections? Thanks.


[web2py] Re: looks familiar, could be useful

2011-07-01 Thread Ross Peoples
a jQuery version of web2py's HTML helpersvery nice. I use jQuery 
heavily, but I rarely ever "create" DOM elements using JavaScript. Either I 
wrap hidden elements for later with "display: none;" or I just replace with 
HTML from an AJAX callback. But if creating DOM elements in JavaScript 
on-the-fly is something that is useful to everyone, then it kind of makes 
sense to do something similar so you have equivalent DOM functionality on 
the client-side as you do on the server-side.

Re: [web2py] Forcing SSL/HTTPS

2011-07-01 Thread Jonathan Lundell
On Jul 1, 2011, at 7:09 AM, Ross Peoples wrote:
> Since I want to make sure that my application is as secure as possible, I 
> wanted to force all traffic to use HTTPS. At the bottom of my db.py, I have 
> this:
> 
>  FORCED SSL #
> session.secure()
> if not request.is_https:
> redirect('https://%s/%s' % (request.env.http_host, request.application))
> #
> 
> It works great, secures the cookie, and redirects the user to the HTTPS 
> version of the site since session.secure() does not do this by itself. There 
> is one major problem with this, however, and that is that if I try to run a 
> script from cron, the script fails with a gluon.http.HTTP: 303 error due to 
> the fact that the script isn't using HTTPS.
> 
> So is there a way to tell if a request is from a cron script? Or is there a 
> better way to do the forced SSL connections? Thanks.

global_settings.cronjob is a boolean indicating just that. I added it a while 
back while cleaning up some aspects of cron handling, so it should be present 
in any of the relatively recent versions.

BTW, you can use URL() in a case like this if you like. Just add scheme='https' 
and URL will do its normal thing, but create an absolute URL as required. The 
rest of its functionality (a/c/f/args?vars and the like) work normally.

[web2py] Re: Job - clone website

2011-07-01 Thread Anthony
You might also contact some of the folks listed on 
http://www.experts4solutions.com/ -- they're all web2py developers.
 
Anthony

On Friday, July 1, 2011 7:08:46 AM UTC-4, gubbanoa wrote:

> Hi, 
>
> I am interested in whether web2py can be used to clone a relatively 
> simple ecommerce website made in Drupal. I have posted the job on 
> elance, job number 24934137 and would welcome bids from this user 
> group. I have specified Django or web2py, but would like to give 
> web2py a go if I get a good bid. If successful I am looking to expand 
> functionality (beyond what I think Drupal can do) immediately. 
>
> gubbanoa



[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread LightOfMooN
Hello, just updated web2py to 1.97.1 and one of my sites crashed with
the same problem:
{{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
too bad

On 1 июл, 01:10, pbreit  wrote:
> Any ideas on this one? Has anyone else had problems with LOAD(ajax=False) in
> trunk? I tried switching it to deepcopy and got same error. I also tried
> putting it in a try/except but could not find anything. Could my request
> have something funky in it?


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread LightOfMooN
def voting_viewlet():
return dict()

works fine

But if I try to check request.vars, it crashes:

def voting_viewlet():
if request.vars.vote:
pass
return dict()

rises an error

On 1 июл, 20:46, LightOfMooN  wrote:
> Hello, just updated web2py to 1.97.1 and one of my sites crashed with
> the same problem:
> {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
> too bad
>
> On 1 июл, 01:10, pbreit  wrote:
>
>
>
>
>
>
>
> > Any ideas on this one? Has anyone else had problems with LOAD(ajax=False) in
> > trunk? I tried switching it to deepcopy and got same error. I also tried
> > putting it in a try/except but could not find anything. Could my request
> > have something funky in it?


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread LightOfMooN
so, request has no vars storage

On 1 июл, 20:53, LightOfMooN  wrote:
> def voting_viewlet():
>     return dict()
>
> works fine
>
> But if I try to check request.vars, it crashes:
>
> def voting_viewlet():
>     if request.vars.vote:
>         pass
>     return dict()
>
> rises an error
>
> On 1 июл, 20:46, LightOfMooN  wrote:
>
>
>
>
>
>
>
> > Hello, just updated web2py to 1.97.1 and one of my sites crashed with
> > the same problem:
> > {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
> > too bad
>
> > On 1 июл, 01:10, pbreit  wrote:
>
> > > Any ideas on this one? Has anyone else had problems with LOAD(ajax=False) 
> > > in
> > > trunk? I tried switching it to deepcopy and got same error. I also tried
> > > putting it in a try/except but could not find anything. Could my request
> > > have something funky in it?


Re: [web2py] Forcing SSL/HTTPS

2011-07-01 Thread Ross Peoples
I just tried the following by running web2py -S app -M -R my_script.py 
(since this is how I run the script from cron):

from gluon.settings import global_settings
print global_settings

The cronjob value seems to always be False and I can't figure out how this 
actually gets set to True. Any ideas?


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread Anthony
That problem has been fixed in trunk, but looks like another problem may 
have been introduced. Try downloading trunk revision d4c2d8d15bb1 -- that 
fixes the request.vars problem, but comes before the copy.copy(request) 
problem was introduced. Actually, maybe you could try the latest revision in 
trunk and see if the copy.copy(request) causes the same problem for you as 
it has for pbreit -- that might help diagnose the problem.
 
Anthony

On Friday, July 1, 2011 10:57:13 AM UTC-4, LightOfMooN wrote:

> so, request has no vars storage 
>
> On 1 июл, 20:53, LightOfMooN  wrote: 
> > def voting_viewlet(): 
> > return dict() 
> > 
> > works fine 
> > 
> > But if I try to check request.vars, it crashes: 
> > 
> > def voting_viewlet(): 
> > if request.vars.vote: 
> > pass 
> > return dict() 
> > 
> > rises an error 
> > 
> > On 1 июл, 20:46, LightOfMooN  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hello, just updated web2py to 1.97.1 and one of my sites crashed with 
> > > the same problem: 
> > > {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}} 
> > > too bad 
> > 
> > > On 1 июл, 01:10, pbreit  wrote: 
> > 
> > > > Any ideas on this one? Has anyone else had problems with 
> LOAD(ajax=False) in 
> > > > trunk? I tried switching it to deepcopy and got same error. I also 
> tried 
> > > > putting it in a try/except but could not find anything. Could my 
> request 
> > > > have something funky in it?



Re: [web2py] Forcing SSL/HTTPS

2011-07-01 Thread Jonathan Lundell
On Jul 1, 2011, at 8:18 AM, Ross Peoples wrote:
> I just tried the following by running web2py -S app -M -R my_script.py (since 
> this is how I run the script from cron):
> 
> from gluon.settings import global_settings
> print global_settings
> 
> The cronjob value seems to always be False and I can't figure out how this 
> actually gets set to True. Any ideas?

web2py-initiated cronjobs add the flag -J (equivalent to --cronjob); that's 
what sets the flag. So if you want to trigger one yourself, set that flag.

Look for 'cronjob' in gluon.widgets.py to get an idea what it's used for.

Re: [web2py] Forcing SSL/HTTPS

2011-07-01 Thread Ross Peoples
I'm calling from external cron, which is why this option is not getting set. 
So all I have to do is add --cronjob to my cron line and it's all set. 
Alternatively, while trying to figure this problem out, I noticed that 
global_settings.cmd_options.shell will return a string if run from the 
shell, or None if run as a web request, so if I didn't want to (or couldn't) 
add --cronjob to my script, then I could replace what I used earlier with 
this:

 FORCED SSL #
from gluon.settings import global_settings
if global_settings.cmd_options.shell:
print 'Running as shell script.'
elif not request.is_https:
session.secure()
redirect('https://%s/%s' % (request.env.http_host, request.application))
#

So I guess it's personal preference as to whether you would want to add 
--cronjob or check global_settings.cmd_options.shell. Thanks for the help!


[web2py] Re: Forcing SSL/HTTPS

2011-07-01 Thread Ross Peoples
Actually, scratch that. When running in Apache,
global_settings.cmd_options is set to None, so I guess you could do
some extra checking there to make sure it initialized, then check the
shell variable, but it's way easier to just add --cronjob and just
check global_settings.cronjob.

And Google Groups is giving me a lot of trouble. This is the 3rd time
I've tried to post this, so I apologize if this shows up several
times.

On Jul 1, 11:46 am, Ross Peoples  wrote:
> I'm calling from external cron, which is why this option is not getting set.
> So all I have to do is add --cronjob to my cron line and it's all set.
> Alternatively, while trying to figure this problem out, I noticed that
> global_settings.cmd_options.shell will return a string if run from the
> shell, or None if run as a web request, so if I didn't want to (or couldn't)
> add --cronjob to my script, then I could replace what I used earlier with
> this:
>
>  FORCED SSL #
> from gluon.settings import global_settings
> if global_settings.cmd_options.shell:
>     print 'Running as shell script.'
> elif not request.is_https:
>     session.secure()    redirect('https://%s/%s' % (request.env.http_host, 
> request.application))
> #
>
> So I guess it's personal preference as to whether you would want to add
> --cronjob or check global_settings.cmd_options.shell. Thanks for the help!


Re: [web2py] Forcing SSL/HTTPS

2011-07-01 Thread Jonathan Lundell
On Jul 1, 2011, at 8:46 AM, Ross Peoples wrote:
> I'm calling from external cron, which is why this option is not getting set. 
> So all I have to do is add --cronjob to my cron line and it's all set. 
> Alternatively, while trying to figure this problem out, I noticed that 
> global_settings.cmd_options.shell will return a string if run from the shell, 
> or None if run as a web request, so if I didn't want to (or couldn't) add 
> --cronjob to my script, then I could replace what I used earlier with this:
> 
>  FORCED SSL #
> from gluon.settings import global_settings
> if global_settings.cmd_options.shell:
> print 'Running as shell script.'
> elif not request.is_https:
> session.secure()
> redirect('https://%s/%s' % (request.env.http_host, request.application))
> #
> 
> So I guess it's personal preference as to whether you would want to add 
> --cronjob or check global_settings.cmd_options.shell. Thanks for the help!

For that particular purpose, it might be, but there are other reasons to want 
to add --cronjob to cron jobs. I don't recall them all, but there were some 
corner cases, such as just after a web2py upgrade, in which the widget.py logic 
was getting confused by cron jobs. The --cronjob flag unambiguously tells it to 
treat it as a cron job, and -S isn't enough to do that.

So: mark cron invocations with --cronjob (or -J); this happens for you when 
web2py is doing it (soft & hard cron), so it's only relevant for external cron. 
This should be in the docs, I suppose, if someone would be so kind as to stick 
it in.

[web2py] SQLFORM.factory tablename doesn't affect submit row

2011-07-01 Thread Massimiliano
>From something like that:

   form = SQLFORM.factory(
Field('mydate', 'date', label='Data carico', requires=IS_DATE()),
table_name='mytable',
_id = 'myform'
)


I got:

[...]
...

[...]

The submit row doesn't take the tablename
Is it normal?

-- 
Massimiliano


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread LightOfMooN
Thx, but I just disabled some components until the new stable version
of webpy :)

On 1 июл, 21:29, Anthony  wrote:
> That problem has been fixed in trunk, but looks like another problem may
> have been introduced. Try downloading trunk revision d4c2d8d15bb1 -- that
> fixes the request.vars problem, but comes before the copy.copy(request)
> problem was introduced. Actually, maybe you could try the latest revision in
> trunk and see if the copy.copy(request) causes the same problem for you as
> it has for pbreit -- that might help diagnose the problem.
>
> Anthony
>
>
>
>
>
>
>
> On Friday, July 1, 2011 10:57:13 AM UTC-4, LightOfMooN wrote:
> > so, request has no vars storage
>
> > On 1 июл, 20:53, LightOfMooN  wrote:
> > > def voting_viewlet():
> > >     return dict()
>
> > > works fine
>
> > > But if I try to check request.vars, it crashes:
>
> > > def voting_viewlet():
> > >     if request.vars.vote:
> > >         pass
> > >     return dict()
>
> > > rises an error
>
> > > On 1 июл, 20:46, LightOfMooN  wrote:
>
> > > > Hello, just updated web2py to 1.97.1 and one of my sites crashed with
> > > > the same problem:
> > > > {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
> > > > too bad
>
> > > > On 1 июл, 01:10, pbreit  wrote:
>
> > > > > Any ideas on this one? Has anyone else had problems with
> > LOAD(ajax=False) in
> > > > > trunk? I tried switching it to deepcopy and got same error. I also
> > tried
> > > > > putting it in a try/except but could not find anything. Could my
> > request
> > > > > have something funky in it?


[web2py] Inline Table Editor.

2011-07-01 Thread David J.

Anyone know of a good jquery inline table editor?

Thanks.

I saw jqGrid; but I was looking for something less complex.

I am really looking for something simple;

Highlight a row; Edit a row; Save the data;

 I dont need sorting or anything like that.


[web2py] GAE discussion on Hacker News

2011-07-01 Thread Matt Gorecki
There is a discussion on Hacker News today about what Python
frameworks are best suited for Google App Engine.
http://news.ycombinator.com/item?id=2715887

Somebody with more technical knowledge than me should answer a few
web2py questions over there.  Specifically this one:
http://news.ycombinator.com/item?id=2718537

Matt


[web2py] web2py hosting

2011-07-01 Thread DenesL
Information collected from actual users of the service.
Comments can belong to several people,
and can be positive (+), negative (-) or other (~).
This post will be updated periodically.


Hosting company: Webfaction
Type of service: latest
 web2py version:
 Python version: 2.4/3.2
   OS & version: Linux 2.6.18
Aprox. cost: 8 dollars/month (depends on plan)
   Geo location: USA

+ great control panel, great support, feature rich,
  many auxiliary services available.
+ I am very happy with them.
- Personally, my experience with webfaction WAS NOT GOOD.
  My web2py websites, often were slow or down.
- recently changed my 20 web2py apps from webfaction.
~ is very nice if you have only one low traffic website.
+ I have a webfaction account with around 3-4 apps at the
  cheapest plan which is really low and it works very well.
  Until now, a great experience with them, almost 2 years.


Hosting company: vps.net
Type of service: vps
 web2py version: they provide ubuntu images, I install web2py myself
 Python version: depends on the ubuntu image
   OS & version: ubuntu
Aprox. cost: $20/month + $5/month for backups
   Geo location: USA + England


Hosting company: IPage
Type of service:
 web2py version: web2py (with CGI)
 Python version:
   OS & version:
Aprox. cost:
   Geo location:

- very poor technical support, VERY slow, I would not recommend it !


Hosting company: linode.com
Type of service:
 web2py version:
 Python version:
   OS & version:
Aprox. cost: $19 512RAM
   Geo location:

+ In 10 minutes you have a web2py app running on Linode
  with Uwsgi and Nginx, just need to use the script that
  comes with web2py as a stack script on Linode.


Hosting company: alwaysdata.com
Type of service: free
 web2py version:
 Python version: 2.6
   OS & version:
Aprox. cost: 9 euros/mo alwaysdata.com/plans/shared
   Geo location: servers are located in France

~ ssh, phpmyadmin



Other hosting companies from web2py powered sites:

123-reg.co.uk
amazonaws.com
dreamhost.com
GAE
gandi.net
godaddy.com
jiffybox.de
prgmr.com
slicehost.net


Re: [web2py] Navigation in Web2py having an active link

2011-07-01 Thread Andrew Evans
hey thanks worked like a dream *cheers



On Wed, Jun 29, 2011 at 10:35 PM, Bruno Rocha  wrote:

> I did this for web2py.com using request.function, I created a function
> tooggle_class which receives request.function and do this job.
>
> here is an example that I use in http://CursoDePython.com.br
>
> The code
> https://gist.github.com/1055688
>
>
>
> On Wed, Jun 29, 2011 at 5:16 PM, ADE  wrote:
>
>> Hello I am trying to figure out how to check if the current page is
>> active in web2py
>>
>> I have my navigation as follows
>>
>>
>>Home
>>What's On> li>
>>About PSTV> li>
>>Blog
>>Episodes> li>
>>Trailers> li>
>>http://shop.pstv.tv";>Shop
>>Contact Us> a>
>>
>>
>> if the current page is active I would like to set  to > class="selected">
>>
>> Any ideas how to do this
>>
>> *cheers
>>
>>
>
>
> --
>
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>
>


[web2py] BUG: I think.

2011-07-01 Thread David J.

I am running latest in trunk.

I have this code being called from a LOAD function;

I see it appends the '.load' to the generated URL

When I think it should be

/campaigns/edit/5435

It returns

/campaigns.load/edit/5435



{{ for n in items:}}

{{= n.campaign_name }}



src="{{= URL('static','images/editButtonSmall.gif') }}" alt="Edit {{= 
n.campaign_name }}" />






[web2py] web2py hosting

2011-07-01 Thread DenesL
Information collected from actual users of the service.
Comments can belong to several people,
and can be positive (+), negative (-) or other (~).
This post will be updated periodically.


Hosting company: Webfaction
Type of service: latest
 web2py version:
 Python version: 2.4/3.2
   OS & version: Linux 2.6.18
Aprox. cost: 8 dollars/month (depends on plan)
   Geo location: USA

+ great control panel, great support, feature rich,
  many auxiliary services available.
+ I am very happy with them.
- Personally, my experience with webfaction WAS NOT GOOD.
  My web2py websites, often were slow or down.
- recently changed my 20 web2py apps from webfaction.
~ is very nice if you have only one low traffic website.
+ I have a webfaction account with around 3-4 apps at the
  cheapest plan which is really low and it works very well.
  Until now, a great experience with them, almost 2 years.


Hosting company: vps.net
Type of service: vps
 web2py version: they provide ubuntu images, I install web2py myself
 Python version: depends on the ubuntu image
   OS & version: ubuntu
Aprox. cost: $20/month + $5/month for backups
   Geo location: USA + England


Hosting company: IPage
Type of service:
 web2py version: web2py (with CGI)
 Python version:
   OS & version:
Aprox. cost:
   Geo location:

- very poor technical support, VERY slow, I would not recommend it !


Hosting company: linode.com
Type of service:
 web2py version:
 Python version:
   OS & version:
Aprox. cost: $19 512RAM
   Geo location:

+ In 10 minutes you have a web2py app running on Linode
  with Uwsgi and Nginx, just need to use the script that
  comes with web2py as a stack script on Linode.


Hosting company: alwaysdata.com
Type of service: free
 web2py version:
 Python version: 2.6
   OS & version:
Aprox. cost: 9 euros/mo alwaysdata.com/plans/shared
   Geo location: servers are located in France

~ ssh, phpmyadmin



Other hosting companies from web2py powered sites:

123-reg.co.uk
amazonaws.com
dreamhost.com
GAE
gandi.net
godaddy.com
jiffybox.de
prgmr.com
slicehost.net


Re: [web2py] web2py hosting

2011-07-01 Thread Martín Mulone
También está dot_cloud cuando yo lo probé en la beta, y web2py corría bien,
ahora salió de la beta no se como andará en costos
https://www.dotcloud.com/pricing/ Si alguien lo prueba avise.

2011/7/1 DenesL 

> Information collected from actual users of the service.
> Comments can belong to several people,
> and can be positive (+), negative (-) or other (~).
> This post will be updated periodically.
>
>
> Hosting company: Webfaction
> Type of service: latest
>  web2py version:
>  Python version: 2.4/3.2
>   OS & version: Linux 2.6.18
>Aprox. cost: 8 dollars/month (depends on plan)
>   Geo location: USA
>
> + great control panel, great support, feature rich,
>  many auxiliary services available.
> + I am very happy with them.
> - Personally, my experience with webfaction WAS NOT GOOD.
>  My web2py websites, often were slow or down.
> - recently changed my 20 web2py apps from webfaction.
> ~ is very nice if you have only one low traffic website.
> + I have a webfaction account with around 3-4 apps at the
>  cheapest plan which is really low and it works very well.
>  Until now, a great experience with them, almost 2 years.
>
>
> Hosting company: vps.net
> Type of service: vps
>  web2py version: they provide ubuntu images, I install web2py myself
>  Python version: depends on the ubuntu image
>   OS & version: ubuntu
>Aprox. cost: $20/month + $5/month for backups
>   Geo location: USA + England
>
>
> Hosting company: IPage
> Type of service:
>  web2py version: web2py (with CGI)
>  Python version:
>   OS & version:
>Aprox. cost:
>   Geo location:
>
> - very poor technical support, VERY slow, I would not recommend it !
>
>
> Hosting company: linode.com
> Type of service:
>  web2py version:
>  Python version:
>   OS & version:
>Aprox. cost: $19 512RAM
>   Geo location:
>
> + In 10 minutes you have a web2py app running on Linode
>  with Uwsgi and Nginx, just need to use the script that
>  comes with web2py as a stack script on Linode.
>
>
> Hosting company: alwaysdata.com
> Type of service: free
>  web2py version:
>  Python version: 2.6
>   OS & version:
>Aprox. cost: 9 euros/mo alwaysdata.com/plans/shared
>   Geo location: servers are located in France
>
> ~ ssh, phpmyadmin
>
>
>
> Other hosting companies from web2py powered sites:
>
> 123-reg.co.uk
> amazonaws.com
> dreamhost.com
> GAE
> gandi.net
> godaddy.com
> jiffybox.de
> prgmr.com
> slicehost.net
>



-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Inline Table Editor.

2011-07-01 Thread Richard Vézina
I think powertable Bruno's plugin integration of Datatables was allowing
inline edition... Look here : http://powertable.blouweb.com/ and there :
http://www.datatables.net/

Good luck.

Richard

On Fri, Jul 1, 2011 at 12:48 PM, David J.  wrote:

> Anyone know of a good jquery inline table editor?
>
> Thanks.
>
> I saw jqGrid; but I was looking for something less complex.
>
> I am really looking for something simple;
>
> Highlight a row; Edit a row; Save the data;
>
>  I dont need sorting or anything like that.
>


[web2py] Re: BUG: I think.

2011-07-01 Thread Anthony
If you don't specify an extension in URL(), I think it will just use the 
extension of the current request, which is .load in this case. Try 
explicitly setting extension=False:
 
{{=URL('default','campaigns',args=['edit',n.id],extension=False)}}
 
 
Anthony
 

On Friday, July 1, 2011 1:24:11 PM UTC-4, David J wrote:

> I am running latest in trunk. 
>
> I have this code being called from a LOAD function; 
>
> I see it appends the '.load' to the generated URL 
>
> When I think it should be 
>
> /campaigns/edit/5435 
>
> It returns 
>
> /campaigns.load/edit/5435 
>
>
> 
> {{ for n in items:}}
> 
> {{= n.campaign_name }}
>  
>
> 
>  src="{{= URL('static','images/editButtonSmall.gif') }}" alt="Edit {{= 
> n.campaign_name }}" /> 
>
>  
>
> 

Re: [web2py] BUG: I think.

2011-07-01 Thread Martín Mulone
you can pass extension=0 to the URL

URL('default','campaigns',**args=['edit',n.id],extension=0)


2011/7/1 David J. 

> I am running latest in trunk.
>
> I have this code being called from a LOAD function;
>
> I see it appends the '.load' to the generated URL
>
> When I think it should be
>
> /campaigns/edit/5435
>
> It returns
>
> /campaigns.load/edit/5435
>
>
> 
> {{ for n in items:}}
> 
> {{= n.campaign_name }}
> 
>
> 
>  src="{{= URL('static','images/**editButtonSmall.gif') }}" alt="Edit {{=
> n.campaign_name }}" />
>
> 
>
>


-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] BUG: I think.

2011-07-01 Thread Jonathan Lundell
On Jul 1, 2011, at 10:45 AM, Martín Mulone wrote:
> you can pass extension=0 to the URL
> 
> URL('default','campaigns',args=['edit',n.id],extension=0)

extension=False would be prettier.

> 
> 
> 2011/7/1 David J. 
> I am running latest in trunk.
> 
> I have this code being called from a LOAD function;
> 
> I see it appends the '.load' to the generated URL
> 
> When I think it should be
> 
> /campaigns/edit/5435
> 
> It returns
> 
> /campaigns.load/edit/5435
> 
> 
> 
> {{ for n in items:}}
> 
> {{= n.campaign_name }}
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
>  http://martin.tecnodoc.com.ar
> 




[web2py] Error in IS_IN_DB: wrong T()

2011-07-01 Thread Martin Weissenboeck
Hi,

using the T() class in IS_IN_SET yields a strange result:
In this environment *T* does not depend on the language choosen by T.force
but *depends only on the language used in the setup of the browser.*
Tested with Google Chrome, Safari

Here are some lines of code to verify:

This is my database model:

db.define_table('my_table',
Field('answer',
requires=IS_IN_SET([('Y',*T('Yes')*), ('N',*T('No')*)]),
widget=SQLFORM.widgets.checkboxes.widget,
default='N',
comment=T('Yes'),
),
)

The controller:

def a():
*T.force('de-de')*
form=SQLFORM(db.my_table, submit_button=T('Submit'))
if form.accepts(request.vars, session):
response.flash='accepted'
return dict(form=form, yes=T('Yes'), no=T('No'), submit=T('Submit'))

And the view:

{{extend 'layout.html'}}
{{=yes}} {{=no}} {{=submit}}
{{=form}}


Of course there are also some language files with translations for "Yes",
"No" and "Submit".
The language choosen in T.force changes the whole website, *but does not
change the words "Yes" and "No" at the right side of the checkboxes*.

Regards. Martin


[web2py] Good syntax checker recommendations?

2011-07-01 Thread pbreit
I just use text mate on a Mac and with syntax highlighting I rarely have syntax 
errors. And I never have import errors (since there's very little importing 
necessary).


Re: [web2py] Good syntax checker recommendations?

2011-07-01 Thread Jonathan Lundell
On Jul 1, 2011, at 11:03 AM, pbreit wrote:
> 
> I just use text mate on a Mac and with syntax highlighting I rarely have 
> syntax errors. And I never have import errors (since there's very little 
> importing necessary).

I've been using pyflakes, mainly because it's trivial to configure and run. The 
downside is that it's sort of stupid about imports, so I have two rules.

1. Never import *. (pyflakes will still work, but it will turn off its import 
checking)

2. For web2py automatic/invisible imports, use:

if False:
from html import URL, whatever
...and so on


Pyflakes does some nice stuff beyond syntax checking, like finding unused or 
uninitialized symbols.

I also use pylint on non-web2py projects. It's more thorough, and harder to 
configure. It could probably be made to work on web2py, but I haven't tried 
very hard.

Re: [web2py] BUG: I think.

2011-07-01 Thread Anthony
And make sure you don't do extension=None -- that's what it's set to by 
default, and in that case, it will just use request.extension, which you 
don't want. You have to explicitly set extension=False (or 0).
 
Anthony

On Friday, July 1, 2011 1:53:27 PM UTC-4, Jonathan Lundell wrote:

>  On Jul 1, 2011, at 10:45 AM, Martín Mulone wrote:
>
> you can pass extension=0 to the URL 
>
> URL('default','campaigns',**args=['edit',n.id],extension=0)
>
>
> extension=False would be prettier.
>
>  
>
> 2011/7/1 David J. 
>
>> I am running latest in trunk.
>>
>> I have this code being called from a LOAD function;
>>
>> I see it appends the '.load' to the generated URL
>>
>> When I think it should be
>>
>> /campaigns/edit/5435
>>
>> It returns
>>
>> /campaigns.load/edit/5435
>>
>>
>> 
>> {{ for n in items:}}
>> 
>> {{= n.campaign_name }}
>> 
>>
>> 
>> > src="{{= URL('static','images/**editButtonSmall.gif') }}" alt="Edit {{= 
>> n.campaign_name }}" />
>>
>> 
>>
>>
>
>
> -- 
>   http://martin.tecnodoc.com.ar
>
>
>
>

Re: [web2py] BUG: I think.

2011-07-01 Thread pbreit
I usually do extension=''

[web2py] counter implementation

2011-07-01 Thread weheh
With web2py, can you increment an integer field, which is used as a
counter, with just 1 call to the db? Regardless, I'm looking for the
most efficient stand-alone syntax for incrementing a field. 1 line is
better than 2.


[web2py] Re: counter implementation

2011-07-01 Thread Massimo Di Pierro
db(db.table.id=-id).update(db.table.field=db.table.field+1)

does not work on GAE

On Jul 1, 3:33 pm, weheh  wrote:
> With web2py, can you increment an integer field, which is used as a
> counter, with just 1 call to the db? Regardless, I'm looking for the
> most efficient stand-alone syntax for incrementing a field. 1 line is
> better than 2.


Re: [web2py] Multiple Domains, Subdomains, and Applications with SSL. Single web2py Instance on Apache

2011-07-01 Thread Ovidio Marinho
Very Goog Tutorial. Congratulations.



   Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
 88269088
   Paraiba-Brasil



2011/7/1 Ross Peoples 

> This post is meant to be informative, as I have been trying to get this
> working on my server for about a week now and I've finally got what I
> wanted. Sorry in advance if this turns out to be really long, but I'm hoping
> that my hard work and research will help someone else in the same situation.
>
> Let's start with a problem statement: How do I run multiple web2py
> applications all using different domains/subdomains AND make those sites
> usable with SSL on Apache? Oh, and while we're at it, how do we keep
> existing PHP sites working? I am using Ubuntu 10.04 as a LAMP server in
> production and want to start hosting multiple web2py sites/applications on
> it as well.
>
> The best recommendation I can make as far as getting web2py installed is to
> follow the documentation:
> http://web2py.com/book/default/chapter/11#Apache-setup
>
> You will want to read the Apache Setup section and the first part of the
> mod_wsgi section where web2py is downloaded, unziped and owned by www-data.
> After that, the Apache config files mentioned are great for simple server
> setups, but we want something more complex, so we will make our own.
>
> First let's go over what we have and what we need:
>
> We have an existing PHP app running on oldapp.com. We have two web2py
> applications that we want to run and we have two domains for them:
> exampleapp.com and anotherexample.com. If you want to run any of these
> sites on SSL, then you need to get certificates for them. If they are simple
> apps, then you can get free 1-year certificates from StartSSL.com. I won't
> go into detail about how to get these certificates or decrypting the private
> keys, as that is a fairly broad topic and the documentation from your chosen
> certificate authority can probably explain it better than I can.
>
> So now we assume you have your SSL certificates, now it's time to configure
> Apache and web2py. First, let's take care of the PHP application. Hopefully
> you will have each PHP site in it's own VirtualHost file, and not called
> 000-default. If it is, then you will need to run the following commands to
> disable the site, rename it, and re-enable it:
>
> sudo a2dissite 000-default
> sudo mv /etc/apache2/sites-available/000-default
> /etc/apache2/sites-available/php-oldapp
> sudo a2ensite php-oldapp
> sudo /etc/init.d/apache2 restart
>
> Check to make sure your PHP site is still working, as we're done with that.
> Next, we need to create a default web2py configuration. So run your
> preferred text editor to create a new default file (I'll use nano here for
> simplicity):
>
> sudo nano /etc/apache2/sites-available/000-default
>
> Now, put the following in your new configuration file:
>
> # This is the default VirtualHost and should be the first VirtualHost
>
> # This is required in order to run SSL web2py sites
> NameVirtualHost *:443
>
>
> # Make this process global so that other VirtualHosts can access it (i.e. SSL 
> sites)
>
> WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP
> }
>
> 
>   WSGIProcessGroup web2py
>   WSGIScriptAlias / /var/repositories/web2py/wsgihandler.py
>
>   
> AllowOverride None
> Order Allow,Deny
> Deny from all
> 
>   Allow from all
> 
>   
>
>   AliasMatch ^/([^/]+)/static/(.*) \
>/var/repositories/web2py/applications/$1/static/$2
>   
> Order Allow,Deny
> Allow from all
>   
>
>   
>   Deny from all
>   
>
>   
>   Deny from all
>   
>
>   CustomLog /var/log/apache2/access.log common
>   ErrorLog //var/log/apache2/error.log
> 
>
> This configuration file will run all of your non-SSL web2py sites. You can
> map domain names to applications with web2py's routes.py file (which we will
> see later) without ever having to touch this Apache configuration file
> again. To test this, enable the site and restart Apache:
>
> sudo a2ensite 000-default
> sudo /etc/init.d/apache2 restart
>
> web2py should be working now, but it may not work the way we want yet, as
> we have not configured its routers.py file yet. Now we need to set up SSL
> for our sites. In order to do this, we need a Apache configuration
> (VirtualHost) file for each domain/application. This is because each domain
> needs its own certificate and it's best to let Apache handle this for us. We
> need to make another file for our SSL-enabled exampleapp:
>
> sudo nano /etc/apache2/sites-available/web2py-exampleapp-ssl
>
> Put the following in the new configuration file:
>
> 
>   ServerName exampleapp.com
>   ServerAlias *.exampleapp.com
>
>   SSLEngine on
>   SSLCertificateFile /var/repositories/web2py/exampleapp.com.crt
>   SSLCertificateKeyFile /var/repositories/web2py/exampleapp.com.key
>
>   WSGIProcessGroup web2py
>   WSGIScriptAlias / /var/repositories/web2py/wsgihandler.py
>
>   
> 

Re: [web2py] Re: counter implementation

2011-07-01 Thread Ovidio Marinho
There is a document that says what can or can not in GAE?



   Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
 88269088
   Paraiba-Brasil



2011/7/1 Massimo Di Pierro 

> db(db.table.id=-id).update(db.table.field=db.table.field+1)
>
> does not work on GAE
>
> On Jul 1, 3:33 pm, weheh  wrote:
> > With web2py, can you increment an integer field, which is used as a
> > counter, with just 1 call to the db? Regardless, I'm looking for the
> > most efficient stand-alone syntax for incrementing a field. 1 line is
> > better than 2.
>


[web2py] Re: counter implementation

2011-07-01 Thread weheh
Thanks, Massimo.

On Jul 1, 4:37 pm, Massimo Di Pierro 
wrote:
> db(db.table.id=-id).update(db.table.field=db.table.field+1)
>
> does not work on GAE
>
> On Jul 1, 3:33 pm, weheh  wrote:
>
>
>
>
>
>
>
> > With web2py, can you increment an integer field, which is used as a
> > counter, with just 1 call to the db? Regardless, I'm looking for the
> > most efficient stand-alone syntax for incrementing a field. 1 line is
> > better than 2.


[web2py] Re: counter implementation

2011-07-01 Thread weheh
Maybe I spoke too soon...

mytab=123
db(db.mytab.id==mytab_id).update(db.mytab.cnt=db.mytab.cnt+1)
  SyntaxError: keyword can't be an expression


[web2py] Re: counter implementation [open]

2011-07-01 Thread weheh


On Jul 1, 5:58 pm, weheh  wrote:
> Maybe I spoke too soon...
>
> mytab=123
> db(db.mytab.id==mytab_id).update(db.mytab.cnt=db.mytab.cnt+1)
>   SyntaxError: keyword can't be an expression


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread Massimo Di Pierro
There are logic problems with ajax=False. Just use ajax=True. I am not
sure ajax=False should be an option al all.

On Jul 1, 11:45 am, LightOfMooN  wrote:
> Thx, but I just disabled some components until the new stable version
> of webpy :)
>
> On 1 июл, 21:29, Anthony  wrote:
>
>
>
>
>
>
>
> > That problem has been fixed in trunk, but looks like another problem may
> > have been introduced. Try downloading trunk revision d4c2d8d15bb1 -- that
> > fixes the request.vars problem, but comes before the copy.copy(request)
> > problem was introduced. Actually, maybe you could try the latest revision in
> > trunk and see if the copy.copy(request) causes the same problem for you as
> > it has for pbreit -- that might help diagnose the problem.
>
> > Anthony
>
> > On Friday, July 1, 2011 10:57:13 AM UTC-4, LightOfMooN wrote:
> > > so, request has no vars storage
>
> > > On 1 июл, 20:53, LightOfMooN  wrote:
> > > > def voting_viewlet():
> > > >     return dict()
>
> > > > works fine
>
> > > > But if I try to check request.vars, it crashes:
>
> > > > def voting_viewlet():
> > > >     if request.vars.vote:
> > > >         pass
> > > >     return dict()
>
> > > > rises an error
>
> > > > On 1 июл, 20:46, LightOfMooN  wrote:
>
> > > > > Hello, just updated web2py to 1.97.1 and one of my sites crashed with
> > > > > the same problem:
> > > > > {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
> > > > > too bad
>
> > > > > On 1 июл, 01:10, pbreit  wrote:
>
> > > > > > Any ideas on this one? Has anyone else had problems with
> > > LOAD(ajax=False) in
> > > > > > trunk? I tried switching it to deepcopy and got same error. I also
> > > tried
> > > > > > putting it in a try/except but could not find anything. Could my
> > > request
> > > > > > have something funky in it?


[web2py] Re: counter implementation [open]

2011-07-01 Thread Massimo Di Pierro
db(db.mytab.id==mytab_id).update(cnt=db.mytab.cnt+1)

On Jul 1, 4:59 pm, weheh  wrote:
> On Jul 1, 5:58 pm, weheh  wrote:
>
>
>
>
>
>
>
> > Maybe I spoke too soon...
>
> > mytab=123
> > db(db.mytab.id==mytab_id).update(db.mytab.cnt=db.mytab.cnt+1)
> >   SyntaxError: keyword can't be an expression


[web2py] Janrain alternative: Google Identity Toolkit

2011-07-01 Thread Plumo
Google is launching their own login service:
https://sites.google.com/site/gitooldocs/home

Has anyone been granted an account for testing yet?


[web2py] Re: counter implementation [almost closed]

2011-07-01 Thread weheh
Thanks, that works now. My head is fuzzy today after all I've been
through. I had tried this:


db.mytab[mytab_id]=dict(cnt=db.mytab.cnt+1)

but that didn't work. Is there a "shortcut" syntax to do this? Just
curious, as the "longcut" is clearly just as short.


[web2py] Re: counter implementation [almost closed]

2011-07-01 Thread Massimo Di Pierro
This is the shortcut

db(db.mytab.id==mytab_id).update(cnt=db.mytab.cnt+1)


because it does it in one SQL statement

Other ways, when they work, are equivalent to

row = db.mytab(mytab_id)
row.update_record(cnt=row.nct+1)

ie.e. two statements.

On Jul 1, 7:59 pm, weheh  wrote:
> Thanks, that works now. My head is fuzzy today after all I've been
> through. I had tried this:
>
>     db.mytab[mytab_id]=dict(cnt=db.mytab.cnt+1)
>
> but that didn't work. Is there a "shortcut" syntax to do this? Just
> curious, as the "longcut" is clearly just as short.


Re: [web2py] Re: counter implementation

2011-07-01 Thread Bruno Rocha
On Fri, Jul 1, 2011 at 6:58 PM, weheh  wrote:

> mytab=123
> db(db.mytab.id==mytab_id).update(db.mytab.cnt=db.mytab.cnt+1)
>  SyntaxError: keyword can't be an expression
>

try with a lambda (I did not tested, but as lambda returns a valuem could
work.

mytab=123
db(db.mytab.id==mytab_id).update(db.mytab.cnt=(lambda x: x+1)(db.mytab.cnt)
)
 SyntaxError: keyword can't be an expression


-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Re: counter implementation

2011-07-01 Thread Bruno Rocha
forget the lambda..
the problem is the key

mytab=123
db(db.mytab.id==mytab_id).update(*cnt*=db.mytab.cnt+1 )
 SyntaxError: keyword can't be an expression


[web2py] counter implementation [closed]

2011-07-01 Thread weheh
Thanks all.


[web2py] Question on menu active rendering

2011-07-01 Thread ron_m
In response.menu each item of the list is a 4 element tuple. The second 
element of tuple can be True or False to represent that item is active. This 
causes teh MENU class in gluon/html.py to attach class="web2py-menu-active" 
to the li tag associated with that menu item.

That class is not represented anywhere in the .css files included with the 
example. I am using the superfish menus form the default welcome 
application.

Here is what I added to my own application css file

.web2py-menu-active {
background-color: #275B90;
}

but it doesn't get picked up by the rendering of the menu. I am thinking 
maybe the superfish menu styling is over riding this or I don't have it 
right somehow. CSS is not one of my stronger areas.

I looked at the example which the web2py.com site actually is and it uses a 
PNG image file with style sheet animation to change the button look for each 
state idle, hover, pressed and active. I saw something from Bruno recently 
as well in another thread. I am still using the superfish menus, if I need 
to replace them I will. It is not that difficult for a user to know where 
they are in the application but it would be nice to show which of the top 
menu items is active with a visual cue.

Thanks
Ron



[web2py] Re: Question on menu active rendering

2011-07-01 Thread ron_m
Oops I found it, simple once you know how. In layout.html do the following

Change
jQuery('ul.sf-menu').superfish();});

To
jQuery('ul.sf-menu').superfish({pathClass: 
'web2py-menu-active'});});

This will allow suckerfish to use the class added to the active menu item by 
the web2py MENU class as a way to highlight the active path. I hope this 
isn't obvious, looked in the archives of the group and the manual.

Ron


[web2py] Re: Error on LOAD() in trunk

2011-07-01 Thread LightOfMooN
ajax=False is very important for me, so, I like 1.96 more than 1.97 :)
I use it at most interactive components, that can be displayed on the
all pages of site.

Just one example:

def voting_viewlet():
if not session.has_key('finished_votings'):
session.finished_votings = {}
if request.vars.get('vote', None):
active_voting =
db((db.voting.id==session['active_voting'])&(db.voting.status=='opened')).select().first()
if active_voting and active_voting.id not in
session.get('finished_votings', []):
answers =
db(db.voting_answers.voting_id==active_voting.id).select()
show_results = False
if active_voting.multi:
answerlist = []
tmp = makelist(request.vars.answer)
for i in tmp:
answerlist.append(int(i))
valide_answers = list(set(get_ids(answers)) &
set(answerlist))
if valide_answers:
 
db(db.voting_answers.id.belongs(valide_answers)).update(count=db.voting_answers.count
+1)
try:
 
session['finished_votings'].append(active_voting.id)
except:
session['finished_votings']=[active_voting.id]
show_results = True
else:
if request.vars.answer:
answer = int(request.vars.answer)
if answer in get_ids(answers):
 
db(db.voting_answers.id==answer).update(count=db.voting_answers.count
+1)
try:
 
session['finished_votings'].append(active_voting.id)
except:
 
session['finished_votings']=[active_voting.id]
show_results = True
if show_results:
voting =
db(db.voting.id==active_voting.id).select().first() or
redirect(URL('default','index'))
answers =
db(db.voting_answers.voting_id==voting.id).select(orderby=~db.voting_answers.count)
count = 0
if answers:
max = answers.first().count
for answer in answers:
count += answer.count
for answer in answers:
if count > 0:
answer.percent =
int(float(answer.count)*100/count)
answer.width = int(float(answer.count)*100/
max)
answer.color = getColor()
else:
answer.percent = 0
answer.width = 0
answer.color = getColor()
return response.render('voting/
voting_viewlet_results.html', dict(voting=voting, answers=answers,
count=count))

votings = db(db.voting.status=='opened').select()
finished_votings = session.get('finished_votings',[])
unfinished_votings = []
for voting in votings:
if voting.id not in finished_votings:
unfinished_votings.append(voting)
if unfinished_votings:
active_voting = unfinished_votings[random.randint(0,
len(unfinished_votings)-1)]
session['active_voting'] = active_voting.id
else:
active_voting = None
session['active_voting'] = None

if active_voting:
answers =
db(db.voting_answers.voting_id==active_voting.id).select(orderby=db.voting_answers.id)
else:
answers = []

return dict(active_voting=active_voting, answers=answers)

On 2 июл, 04:51, Massimo Di Pierro  wrote:
> There are logic problems with ajax=False. Just use ajax=True. I am not
> sure ajax=False should be an option al all.
>
> On Jul 1, 11:45 am, LightOfMooN  wrote:
>
>
>
>
>
>
>
> > Thx, but I just disabled some components until the new stable version
> > of webpy :)
>
> > On 1 июл, 21:29, Anthony  wrote:
>
> > > That problem has been fixed in trunk, but looks like another problem may
> > > have been introduced. Try downloading trunk revision d4c2d8d15bb1 -- that
> > > fixes the request.vars problem, but comes before the copy.copy(request)
> > > problem was introduced. Actually, maybe you could try the latest revision 
> > > in
> > > trunk and see if the copy.copy(request) causes the same problem for you as
> > > it has for pbreit -- that might help diagnose the problem.
>
> > > Anthony
>
> > > On Friday, July 1, 2011 10:57:13 AM UTC-4, LightOfMooN wrote:
> > > > so, request has no vars storage
>
> > > > On 1 июл, 20:53, LightOfMooN  wrote:
> > > > > def voting_viewlet():
> > > > >     return dict()
>
> > > > > works fine
>
> > > > > But if I try to check request.vars, it crashes:
>
> > > > > def voting_viewlet():
> > > > >     if request.vars.vote:
> > > > >         pass
> > > > >     return dict()
>
> > > > > rises an error
>
> > > > > On 1 июл, 20:46, LightOfMooN  wrote:
>
> > > > > > Hello, just updated web2py to 1.97.1 and one of my sites crashed 
> > > > > > with
> > > > > > the same problem:
> > > > > > {{=LOAD('voting', 'voting_viewlet', aj