[web2py] deployment

2012-02-17 Thread shartha
Please forgive me if this question is naïve. This is my first try to
instal web2py on a Linux host that supports wsgi. My best bet was
to do the same as:

http://web2py.pythonanywhere.com/welcome/default/index

But when I run the echo command, I got an error that the /var/www/
wsgi.py directory does not exist. Does anyone know -- with the
provided detail -- what has possibly gone wrong? Please let me know if
you need more information.

Thanks!


[web2py] Re: turnoff the default datepicker

2012-02-17 Thread Niphlod
it's embedded through web2py_ajax.js, or web2py.js, depending on the 
version




[web2py] Re: jQuery UI multiselect

2012-02-17 Thread Annet
Hi Alan,

Thanks for your replies. They pointed me in the right direction to
solve the multiselect problem. I am left with one small problem.

The form that contains the multiselect also contains an autocomplete
function:

def index():

form=SQLFORM.factory(
Field('word',label='Trefwoord',length=128,requires=\
 
IS_IN_DB(db(db.NetworkKeyword.networkID==session.hubnetworkID),db.NetworkKeyword.word,'%
(word)s',\
zero='Select a value')),
 
Field('locality_args',label='Plaats',length=64,requires=IS_NOT_EMPTY()),separator=False)

return dict(form=form,rows=rows)


def locality_args_autocomplete():
 
rows=db((db.NodeKeyword.word==request.args(0))&(db.NodeKeyword.nodeID==db.Address.nodeID)&
\
(db.Address.locality.like(request.vars.term+'%')))\

.select(db.Address.locality,distinct=True,orderby=db.Address.locality).as_list()
result=[r['locality']for r in rows]
return response.json(result)


 and in the view:



$(function() {
  $("#no_table_locality_args").autocomplete({
source: "{{=URL('hubaddressbook',
'locality_args_autocomplete',args='javascript:$
(select#no_table_word).val();')}}",
minLength: 2
  });
});


... which gives me an invalid path (args) error.


When I set args='software engineer' in the source and
db.NodeKeyword.word=='software engineer' in the
locality_args_autocomplete() function, the code works, however, with
form.vars.word in the view and request.args(0) in the function it
doesn't. Do you know with what code I have to replace 'software
engineer' to get both functions to work.


Kind regards,

Annet.


Re: [web2py] Re: turnoff the default datepicker

2012-02-17 Thread Martin Weissenboeck
I am using 1.99.4
web2py_ajax.js is the answer. I have deleted two lines and now everything
works as expected.

Thank you!

Maybe there should be a more simple way to use AnyTime with own parameters.

2012/2/17 Niphlod 

> it's embedded through web2py_ajax.js, or web2py.js, depending on the
> version
>
>
>


[web2py] Re: jQuery UI multiselect

2012-02-17 Thread Alan Etkin
If the controller function is expecting a form field value, it should
be retrieved with request.vars., where  is the field name
in the form. You can also retrieve the form fields values with
form.vars. after .process() (if the form passes validation)
or .accepts()

Anyway, I don't know how are you sending the arguments, if by a web2py
form or within an ajax request. If the case is the second, you should
make sure the parameters in the url are correct. As the server
receives the requested url, each request argument is separated by a
"/" for GET method.

On 17 feb, 07:33, Annet  wrote:
> Hi Alan,
>
> Thanks for your replies. They pointed me in the right direction to
> solve the multiselect problem. I am left with one small problem.
>
> The form that contains the multiselect also contains an autocomplete
> function:
>
> def index():
>     
>     form=SQLFORM.factory(
>         Field('word',label='Trefwoord',length=128,requires=\
>
> IS_IN_DB(db(db.NetworkKeyword.networkID==session.hubnetworkID),db.NetworkKeyword.word,'%
> (word)s',\
>         zero='Select a value')),
>
> Field('locality_args',label='Plaats',length=64,requires=IS_NOT_EMPTY()),separator=False)
>     
>     return dict(form=form,rows=rows)
>
> def locality_args_autocomplete():
>
> rows=db((db.NodeKeyword.word==request.args(0))&(db.NodeKeyword.nodeID==db.Address.nodeID)&
> \
>     (db.Address.locality.like(request.vars.term+'%')))\
>     
> .select(db.Address.locality,distinct=True,orderby=db.Address.locality).as_list()
>     result=[r['locality']for r in rows]
>     return response.json(result)
>
>  and in the view:
>
> 
> $(function() {
>   $("#no_table_locality_args").autocomplete({
>     source: "{{=URL('hubaddressbook',
> 'locality_args_autocomplete',args='javascript:$
> (select#no_table_word).val();')}}",
>     minLength: 2
>   });});
>
> 
>
> ... which gives me an invalid path (args) error.
>
> When I set args='software engineer' in the source and
> db.NodeKeyword.word=='software engineer' in the
> locality_args_autocomplete() function, the code works, however, with
> form.vars.word in the view and request.args(0) in the function it
> doesn't. Do you know with what code I have to replace 'software
> engineer' to get both functions to work.
>
> Kind regards,
>
> Annet.


[web2py] Re: Forms not working with web2py in Chrome

2012-02-17 Thread Sameh Khalil
I'm running from the source version 1.99.4 from my own python 2.7 
installation, 

Model Code

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

db.define_table('image',
 Field('title', unique=True),
 Field('file', 'upload'),
 format = '$(title)s')

db.define_table('comment',
Field('image_id', db.image),
Field('author'),
Field('email'),
Field('body', 'text'))

db.image.title.requires = IS_NOT_IN_DB(db, db.image.title)
db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
db.comment.author.requires = IS_NOT_EMPTY()
db.comment.email.requires = IS_EMAIL()
db.comment.body.requires = IS_NOT_EMPTY() 

db.comment.image_id.writable = db.comment.image_id.readable = False



[web2py] Re: Forms not working with web2py in Chrome

2012-02-17 Thread Ross Peoples
I don't know if it helps, but I spotted a typo:

Replace the dollar sign in:

'image,
format = '$(title)s'

with

format ='%(title)s'


Re: [web2py] Re: How to Generate the effective report by using web2py

2012-02-17 Thread Ross Peoples
Sanjeet.

I sent some code to Mariano last night. So we will have to wait and see if 
it works for him.


[web2py] Re: Why admin|examples|welcome in hgignore?

2012-02-17 Thread Ross Peoples
I'm not great with regular expressions, but I think it's saying ignore 
everything in the applications folder EXCEPT admin, examples, welcome, and 
__init__. I think that's what the '?!' means.

Re: [web2py] Re: How to Generate the effective report by using web2py

2012-02-17 Thread Sanjeet Kumar
Thanks Ross

On Fri, Feb 17, 2012 at 6:23 PM, Ross Peoples wrote:

> Sanjeet.
>
> I sent some code to Mariano last night. So we will have to wait and see if
> it works for him.
>


Re: [web2py] Re: Why admin|examples|welcome in hgignore?

2012-02-17 Thread Bruce Wade
startswith ^ applications/(is like?!(admin or examples or welcome or
__init__)). endswith anything after the .

On Fri, Feb 17, 2012 at 4:56 AM, Ross Peoples wrote:

> I'm not great with regular expressions, but I think it's saying ignore
> everything in the applications folder EXCEPT admin, examples, welcome, and
> __init__. I think that's what the '?!' means.




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


[web2py] Re: rendering a view

2012-02-17 Thread Wikus van de Merwe
If all what you want to do is to link to individual items from the main 
page, you don't need to use redirect at all. Simply add HTML code to your 
view that would link to /arcticles/show/[id] or /bussiness/show/[id] as 
needed.

{{ for article in articles: }}
  {{=LI(A(article.title, _href=URL("articles", "show", article.id)))}
{{ pass }}


Then implement show function in both controllers starting with:
def show():
  id = request.args[0]



[web2py] Re: validators.py error in

2012-02-17 Thread Alan Etkin
I've updated from hg repository to this version:

Version 1.99.4 (2012-02-14 08:44:22) stable

The mentioned error doesn't reproduce now.

Thank you

On 12 feb, 21:52, Alan Etkin  wrote:
> Thank you Bruce. It is possible to do hg log, it shows the complete
> commit list until the last pulled code (I think), and it supposedly
> includes instances not updated locally, so that method doesn't allow
> me to see what versions I really downloaded. However, the update seems
> to have been found by Carlos already.
>
> On 12 feb, 21:11, Bruce Wade  wrote:
>
>
>
>
>
>
>
> > I know git has "git log" I am sure mercurial has something similar.
>
> > On Sun, Feb 12, 2012 at 2:07 PM, Alan Etkin  wrote:
> > > I don't keep a list of version updates for my local repository (and I
> > > see that it is a good idea for cases like this), but I pull the
> > > repository frequently, about once a week. Is there any way in
> > > mercurial to retrieve something like a command log?
>
> > > On 12 feb, 17:16, Massimo Di Pierro 
> > > wrote:
> > > > Any chance you can tell us which versions broke it?
>
> > > > On Feb 12, 8:30 am, Alan Etkin  wrote:
>
> > > > > I have pulled the last mercurial version and get this new exception in
> > > > > a query. This behavior is new, older versions of web2py don't return
> > > > > this error:
>
> > > > > Note: the app is a wxPython application that queries a PostgreSQL
> > > > > database with web2py and gui2py:
> > >http://code.google.com/p/gestionlibre.gui
>
> > > > > 
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 469, in
> > > > > options
> > > > >     self.options() #
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 469, in
> > > > > options
> > > > >     self.options() #
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 469, in
> > > > > options
> > > > >     self.options() #
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 469, in
> > > > > options
> > > > >     self.options() #
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 469, in
> > > > > options
> > > > >     self.options() #
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 463, in
> > > > > options
> > > > >     self.build_set()
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/validators.py", line 451, in
> > > > > build_set
> > > > >     records = self.dbset.select(*fields, **dd)
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/dal.py", line 7379, in
> > > > > select
> > > > >     return adapter.select(self.query,fields,attributes)
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/dal.py", line 1301, in
> > > > > select
> > > > >     sql = self._select(query, fields, attributes)
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/dal.py", line 1265, in
> > > > > _select
> > > > >     sql_t = ', '.join(alias(t) for t in tablenames)
> > > > >   File "/home/alan/web2py/web2py-hg/gluon/dal.py", line 1265, in
> > > > > 
> > > > >     sql_t = ', '.join(alias(t) for t in tablenames)
> > > > > RuntimeError: maximum recursion depth exceeded while calling a Python
> > > > > object
>
> > > > > Here is a part of the model wich I suppose is relevant
>
> > > > >     # Source Document (transactions records)
> > > > >     db.define_table('operation',
> > > > >         Field('operation_id', 'id', label = T("id")),
> > > > >         Field('code', unique = True, label = T("code")),
> > > > >         Field('description', label = T("description")),
> > > > >         Field('customer_id', 'reference customer', label =
> > > > > T("customer")), # reference
> > > > >         Field('supplier_id', 'reference supplier', label =
> > > > > T("supplier")), # reference
> > > > >         Field('detail', type='string', length=60,
> > > > > comment=T('Observations'), label = T("detail")),
> > > > >         Field('payment_terms_id', 'reference payment_terms',
> > > > > comment=T('Terms of payment'), label = T("payment terms")), #
> > > > > reference
> > > > >         Field('term', type='string', length=50, label = T("term")),
> > > > >         Field('amount', type='double', label = T("amount")),
> > > > >         Field('balance', type='double', label = T("balance")),
> > > > >         Field('posted', type='datetime', default = now, label =
> > > > > T("posted")),
> > > > >         Field('issue', type='datetime', label = T("issue")),
> > > > >         Field('document_id', 'reference document', comment=T('Points
> > > > > to order / invoice / packingslips'), label = T("document")), #
> > > > > reference
> > > > >         Field('branch', label = T("branch")),
> > > > >         Field('number', type='integer', default=0, label =
> > > > > T("number")),
> > > > >         Field('due_date', type='datetime', label = T("due date")),
> > > > >         Field('type', type='string', length=1,
> > > > > requires=IS_IN_SET({'T': 'Stock','S': 'Sales','P': 'Purchases'}),
> > > > > label = T("type")), # reference? types: T: Stock, S: Sa

Re: [web2py] Re: turnoff the default datepicker

2012-02-17 Thread Anthony
On Friday, February 17, 2012 6:23:48 AM UTC-5, mweissen wrote:
>
> I am using 1.99.4
> web2py_ajax.js is the answer. I have deleted two lines and now everything 
> works as expected.
>

This must be an older version of web2py_ajax.js, as the name of the file 
was changed to web2py.js a while back. Also, AnyTime was only included in 
web2py briefly, before we realized the license was not compatible -- now 
we're back to the old datepicker.

Anthony



[web2py] Re: deployment

2012-02-17 Thread Wikus van de Merwe
The directory does not exist. Run "mkdir /var/www" first.


[web2py] Re: adding extra form elements in a

2012-02-17 Thread Anthony

>
> chapter 7.2.8 of the books tells how to add extra form elements to SQLFORM.
> My question: I want to use a SQLFORM.smartgrid. On adding a new record a 
> SQLFORM appears. It is possible to add an extra form element to this form?
>
> Concrete: I want to add a button to activate a datepicker in the line above
>

form = SQLFORM.smartgrid(...)
if request.args and request.args[-2] == 'new':
[code to add button to form]

Anthony


[web2py] Re: Why admin|examples|welcome in hgignore?

2012-02-17 Thread Wikus van de Merwe
The intention is not to track changes in user made applications (different 
than the default ones). ?! is the negative lookahead operator, so the first 
part of the expression will match "applications/" only if it is not 
followed with any of the strings in the brackets. The the second part (.*) 
matches everything, so as long as the first part match, the entire sting 
will match too.


[web2py] jqGrid to SmartGrid - Who's made the switch?

2012-02-17 Thread Willoughby
Hello All,

I've inherited a site running on v1.61.1 and we're looking at 
updating/upgrading things.

Grids are an integral part of the site and was built extensively with 
jgGrid including a search plugin, etc.

SmartGrid seems to be near the point we need it to be to switch things over 
smoothly and I think maintenance would be much easier.
But on the other hand I've gotten to know jqGrid pretty well...so I'm 
definitely hesitant to switch from a devil I know...

I was curious if anyone on the list has 'done the switch' and would kindly 
share any 'gotchas' they've run across in doing so.
Thanks!
-Willoughby


Re: [web2py] jqGrid to SmartGrid - Who's made the switch?

2012-02-17 Thread Jim Steil
I've made the switch, but I was new to web2py and jqgrid when .smartgrid 
came out so it wasn't that tough for me.   Happily, the result was that 
my boilerplate code is now about 10x less than it was with jqgrid.  
.smartgrid isn't perfect, but it works well and was easy to implement.  
And, I'm suspecting it will improve as time goes on without breaking 
backward compatibility.


-Jim

On 2/17/2012 9:04 AM, Willoughby wrote:

Hello All,

I've inherited a site running on v1.61.1 and we're looking at 
updating/upgrading things.


Grids are an integral part of the site and was built extensively with 
jgGrid including a search plugin, etc.


SmartGrid seems to be near the point we need it to be to switch things 
over smoothly and I think maintenance would be much easier.
But on the other hand I've gotten to know jqGrid pretty well...so I'm 
definitely hesitant to switch from a devil I know...


I was curious if anyone on the list has 'done the switch' and would 
kindly share any 'gotchas' they've run across in doing so.

Thanks!
-Willoughby


[web2py] what are these css classes?: w2p_fl w2p_fw w2p_fc

2012-02-17 Thread Yarin
Can someone explain what the following css classes are all about:

w2p_fl
w2p_fw
w2p_fc

I see them in the user form and elsewhere, but there's no
documentation or explanation as to why they are applied.


[web2py] Re: what are these css classes?: w2p_fl w2p_fw w2p_fc

2012-02-17 Thread Anthony

>
> w2p_fl: web2py field label 
> w2p_fw: web2py field widget
> w2p_fc: web2py field comment
>

Each input field in a web2py SQLFORM gets a label, widget, and (optional) 
comment. Those classes are added to the appropriate TD, DIV, or LI elements 
(depending on the formstyle) to make it easy to apply CSS styling and make 
DOM manipulations. They are used in web2py.css to apply some default 
styling.

Anthony



[web2py] Re: rendering a view

2012-02-17 Thread Praveen Bhat
Hello,

Now I am getting the following error:

 when calling URL, function or function name 
required

regards,
Praveen


[web2py] Re: rendering a view

2012-02-17 Thread Niphlod
I recommend fondly that you read 
http://web2py.com/books/default/chapter/29/4#URL. URL() function is very 
important for anyone starting using web2py...
In your case you have to add "article.id" as the only arg.


[web2py] Re: rendering a view

2012-02-17 Thread Anthony
On Friday, February 17, 2012 11:43:04 AM UTC-5, Praveen Bhat wrote:
>
> Hello,
>
> Now I am getting the following error:
>
>  when calling URL, function or function 
> name required
>

See my answer here: http://stackoverflow.com/a/9330047/440323

If you get a syntax error, show your exact code.

Anthony


[web2py] delete_next= and SQLFORM

2012-02-17 Thread Richard
Hello,

When user submit, I redirect him on a read form, but I get in trouble
when for example user has delete a record with update form.

I solve it like this when use SQLFORM() :

if form.accepts(request.vars, session):
session.flash = T('form accepted')
if len(db(db.table1.id ==
form.vars.id).select(db.table1.id)) == 1:
redirect(URL(r=request,
f='read',args=(request.args(0),form.vars.id)))
else:
redirect(URL(r=request,
f='select',args=(request.args(0

But I notice that CRUD has delete_next= option... Could it be add to
SQLFORM somehow? Book seems to be silent on this scenario... Should I
use form.accept().accepted. It has a next methode, but I don't think
it allows to manage conditional redirection...

Thanks

Richard


Re: [web2py] delete_next= and SQLFORM

2012-02-17 Thread Richard Vézina
Also, I don't like the solution I come with since I have to make db
request...

Richard

On Fri, Feb 17, 2012 at 12:43 PM, Richard wrote:

> Hello,
>
> When user submit, I redirect him on a read form, but I get in trouble
> when for example user has delete a record with update form.
>
> I solve it like this when use SQLFORM() :
>
>if form.accepts(request.vars, session):
>session.flash = T('form accepted')
>if len(db(db.table1.id ==
> form.vars.id).select(db.table1.id)) == 1:
>redirect(URL(r=request,
> f='read',args=(request.args(0),form.vars.id)))
>else:
>redirect(URL(r=request,
> f='select',args=(request.args(0
>
> But I notice that CRUD has delete_next= option... Could it be add to
> SQLFORM somehow? Book seems to be silent on this scenario... Should I
> use form.accept().accepted. It has a next methode, but I don't think
> it allows to manage conditional redirection...
>
> Thanks
>
> Richard


[web2py] Re: deployment

2012-02-17 Thread shartha
I am not authorized to make such directory on my server.
In my server, my files should go into the public_html folder that
resides inside my "/home/domainName/public_html". Give that, should I
still make a "/var/www" folder? What is the purpose for the "/var/www"
on pythonanywhere?

On Feb 17, 7:49 am, Wikus van de Merwe 
wrote:
> The directory does not exist. Run "mkdir /var/www" first.


[web2py] Re: rendering a view

2012-02-17 Thread Wikus van de Merwe
Right, my bad, I missed the "args" keyword in the URL call. It should be: 
URL("articles", "show", args=article.id).
For more details see the examples given by Anthony.


Re: [web2py] delete_next= and SQLFORM

2012-02-17 Thread Anthony
You can test if the record was deleted by checking for the 
"delete_this_record" variable:

if form.vars.delete_this_record:

Also, instead of handling the logic after form.accepts(), you could use 
form.process(..., onsuccess=some_function) and have the some_function() 
callback check for the delete and do the redirect.

Anthony

On Friday, February 17, 2012 12:43:37 PM UTC-5, Richard wrote:
>
> Hello, 
>
> When user submit, I redirect him on a read form, but I get in trouble 
> when for example user has delete a record with update form. 
>
> I solve it like this when use SQLFORM() : 
>
> if form.accepts(request.vars, session): 
> session.flash = T('form accepted') 
> if len(db(db.table1.id == 
> form.vars.id).select(db.table1.id)) == 1: 
> redirect(URL(r=request, 
> f='read',args=(request.args(0),form.vars.id))) 
> else: 
> redirect(URL(r=request, 
> f='select',args=(request.args(0 
>
> But I notice that CRUD has delete_next= option... Could it be add to 
> SQLFORM somehow? Book seems to be silent on this scenario... Should I 
> use form.accept().accepted. It has a next methode, but I don't think 
> it allows to manage conditional redirection... 
>
> Thanks 
>
> Richard



Re: [web2py] delete_next= and SQLFORM

2012-02-17 Thread Richard Vézina
Thanks Anthony!

The book is mute about that...

Richard

On Fri, Feb 17, 2012 at 1:27 PM, Anthony  wrote:

> You can test if the record was deleted by checking for the
> "delete_this_record" variable:
>
> if form.vars.delete_this_record:
>
> Also, instead of handling the logic after form.accepts(), you could use
> form.process(..., onsuccess=some_function) and have the some_function()
> callback check for the delete and do the redirect.
>
> Anthony
>
>
> On Friday, February 17, 2012 12:43:37 PM UTC-5, Richard wrote:
>>
>> Hello,
>>
>> When user submit, I redirect him on a read form, but I get in trouble
>> when for example user has delete a record with update form.
>>
>> I solve it like this when use SQLFORM() :
>>
>> if form.accepts(request.vars, session):
>> session.flash = T('form accepted')
>> if len(db(db.table1.id ==
>> form.vars.id).select(db.**table1.id )) == 1:
>> redirect(URL(r=request,
>> f='read',args=(request.args(0)**,form.vars.id)))
>> else:
>> redirect(URL(r=request,
>> f='select',args=(request.args(**0
>>
>> But I notice that CRUD has delete_next= option... Could it be add to
>> SQLFORM somehow? Book seems to be silent on this scenario... Should I
>> use form.accept().accepted. It has a next methode, but I don't think
>> it allows to manage conditional redirection...
>>
>> Thanks
>>
>> Richard
>
>


Re: [web2py] delete_next= and SQLFORM

2012-02-17 Thread Richard Vézina
How to manage session.flash=... with form.process()?

Richard

On Fri, Feb 17, 2012 at 1:31 PM, Richard Vézina  wrote:

> Thanks Anthony!
>
> The book is mute about that...
>
> Richard
>
> On Fri, Feb 17, 2012 at 1:27 PM, Anthony  wrote:
>
>> You can test if the record was deleted by checking for the
>> "delete_this_record" variable:
>>
>> if form.vars.delete_this_record:
>>
>> Also, instead of handling the logic after form.accepts(), you could use
>> form.process(..., onsuccess=some_function) and have the some_function()
>> callback check for the delete and do the redirect.
>>
>> Anthony
>>
>>
>> On Friday, February 17, 2012 12:43:37 PM UTC-5, Richard wrote:
>>>
>>> Hello,
>>>
>>> When user submit, I redirect him on a read form, but I get in trouble
>>> when for example user has delete a record with update form.
>>>
>>> I solve it like this when use SQLFORM() :
>>>
>>> if form.accepts(request.vars, session):
>>> session.flash = T('form accepted')
>>> if len(db(db.table1.id ==
>>> form.vars.id).select(db.**table1.id )) == 1:
>>> redirect(URL(r=request,
>>> f='read',args=(request.args(0)**,form.vars.id)))
>>> else:
>>> redirect(URL(r=request,
>>> f='select',args=(request.args(**0
>>>
>>> But I notice that CRUD has delete_next= option... Could it be add to
>>> SQLFORM somehow? Book seems to be silent on this scenario... Should I
>>> use form.accept().accepted. It has a next methode, but I don't think
>>> it allows to manage conditional redirection...
>>>
>>> Thanks
>>>
>>> Richard
>>
>>
>


Re: [web2py] delete_next= and SQLFORM

2012-02-17 Thread Richard Vézina
Ok, just put it the onssess=func

Richard

On Fri, Feb 17, 2012 at 2:05 PM, Richard Vézina  wrote:

> How to manage session.flash=... with form.process()?
>
> Richard
>
>
> On Fri, Feb 17, 2012 at 1:31 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Thanks Anthony!
>>
>> The book is mute about that...
>>
>> Richard
>>
>> On Fri, Feb 17, 2012 at 1:27 PM, Anthony  wrote:
>>
>>> You can test if the record was deleted by checking for the
>>> "delete_this_record" variable:
>>>
>>> if form.vars.delete_this_record:
>>>
>>> Also, instead of handling the logic after form.accepts(), you could use
>>> form.process(..., onsuccess=some_function) and have the some_function()
>>> callback check for the delete and do the redirect.
>>>
>>> Anthony
>>>
>>>
>>> On Friday, February 17, 2012 12:43:37 PM UTC-5, Richard wrote:

 Hello,

 When user submit, I redirect him on a read form, but I get in trouble
 when for example user has delete a record with update form.

 I solve it like this when use SQLFORM() :

 if form.accepts(request.vars, session):
 session.flash = T('form accepted')
 if len(db(db.table1.id ==
 form.vars.id).select(db.**table1.id )) == 1:
 redirect(URL(r=request,
 f='read',args=(request.args(0)**,form.vars.id)))
 else:
 redirect(URL(r=request,
 f='select',args=(request.args(**0

 But I notice that CRUD has delete_next= option... Could it be add to
 SQLFORM somehow? Book seems to be silent on this scenario... Should I
 use form.accept().accepted. It has a next methode, but I don't think
 it allows to manage conditional redirection...

 Thanks

 Richard
>>>
>>>
>>
>


[web2py] web2py + GAE memory usage

2012-02-17 Thread howesc
Hi all,

I see this in mt GAE logs from time to time:


   1. 2012-02-17 11:35:59.737
   
   Exceeded soft private memory limit with 129.473 MB after servicing 107 
requests total
   
   2. W2012-02-17 11:35:59.737
   
   After handling this request, the process that handled this request was found 
to be using too much memory and was terminated. This is likely to cause a new 
process to be used for the next request to your application. If you see this 
message frequently, you may have a memory leak in your application.
   
   


now i know i have had this problem when i load lots of stuff into memory, 
but it seems that my GAE instances slowly use more and more memory until 
they are killed and restarted by GAE.  Is there anything in particular that 
i should be doing to make sure that my code is not leaking memory?  i 
assume vars and query results get de-allocated after the request is 
serviced right?

thanks!

christian


Re: [web2py] jqGrid to SmartGrid - Who's made the switch?

2012-02-17 Thread Willoughby
Thanks Jim - easier upgrades and lower overhead is definitely an attraction!
I guess my next step is to do some quick prototypes and see.
Thanks for sharing your experience...



[web2py] Re: web2py + GAE memory usage

2012-02-17 Thread Massimo Di Pierro
Can you reproduce this with the welcome app?

On Feb 17, 2:09 pm, howesc  wrote:
> Hi all,
>
> I see this in mt GAE logs from time to time:
>
>    1. 2012-02-17 11:35:59.737
>
>    Exceeded soft private memory limit with 129.473 MB after servicing 107 
> requests total
>
>    2. W2012-02-17 11:35:59.737
>
>    After handling this request, the process that handled this request was 
> found to be using too much memory and was terminated. This is likely to cause 
> a new process to be used for the next request to your application. If you see 
> this message frequently, you may have a memory leak in your application.
>
> now i know i have had this problem when i load lots of stuff into memory,
> but it seems that my GAE instances slowly use more and more memory until
> they are killed and restarted by GAE.  Is there anything in particular that
> i should be doing to make sure that my code is not leaking memory?  i
> assume vars and query results get de-allocated after the request is
> serviced right?
>
> thanks!
>
> christian


[web2py] Need help understanding a line of code

2012-02-17 Thread davidkw
Hi, I'm going through the web2py tutorial and I don't understand part
of this line:

db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')

I understand that this requires that the image ID of the image the
comment is under should be in the database. However, I don't
understand what the '%(title)s' at the end is doing.

Can someone explain that? Thanks.


Re: [web2py] Need help understanding a line of code

2012-02-17 Thread Bruce Wade
title is a field in the image table, when displayed in the form it will
show the title instead of the id in the combo-box

On Fri, Feb 17, 2012 at 4:02 PM, davidkw  wrote:

> Hi, I'm going through the web2py tutorial and I don't understand part
> of this line:
>
> db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
>
> I understand that this requires that the image ID of the image the
> comment is under should be in the database. However, I don't
> understand what the '%(title)s' at the end is doing.
>
> Can someone explain that? Thanks.
>



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


[web2py] Re: Need help understanding a line of code

2012-02-17 Thread Anthony

>
> Hi, I'm going through the web2py tutorial and I don't understand part 
> of this line: 
>
> db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s') 
>
> I understand that this requires that the image ID of the image the 
> comment is under should be in the database. However, I don't 
> understand what the '%(title)s' at the end is doing.


That is Python string formatting syntax -- 
see 
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#string-formatting.
 
It is saying to represent each db.image record with the "title" field 
rather than the "id" field. Each db.image row object acts like a 
dictionary, so when you do:

'%(title)s' % db.image[1]

that will extract the "title" field value from the db.image[1] record. The 
IS_IN_DB validator uses this method to generate options to be shown in 
select widgets in forms. So, even though the validator is checking for 
values of the db.image.id field, the widget in the user interface shows the 
db.image.title values instead.

Note, instead of specifying '%(title)s', you can also specify a function 
(including a lambda function) that takes the db.image row and returns 
whatever representation you want.

Anthony


[web2py] Question about web2py syntax

2012-02-17 Thread davidkw
For the line:

db().select(db.image.ALL, orderby=db.image.title)

Why is there a () after the "db" and before the select? Is db() a
method call of some kind?

Thanks for any clarification.


[web2py] Re: Need help understanding a line of code

2012-02-17 Thread davidkw
Thank you!

On Feb 17, 8:08 pm, Anthony  wrote:
> > Hi, I'm going through the web2py tutorial and I don't understand part
> > of this line:
>
> > db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
>
> > I understand that this requires that the image ID of the image the
> > comment is under should be in the database. However, I don't
> > understand what the '%(title)s' at the end is doing.
>
> That is Python string formatting syntax --
> seehttp://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
> It is saying to represent each db.image record with the "title" field
> rather than the "id" field. Each db.image row object acts like a
> dictionary, so when you do:
>
> '%(title)s' % db.image[1]
>
> that will extract the "title" field value from the db.image[1] record. The
> IS_IN_DB validator uses this method to generate options to be shown in
> select widgets in forms. So, even though the validator is checking for
> values of the db.image.id field, the widget in the user interface shows the
> db.image.title values instead.
>
> Note, instead of specifying '%(title)s', you can also specify a function
> (including a lambda function) that takes the db.image row and returns
> whatever representation you want.
>
> Anthony


[web2py] Re: Question about web2py syntax

2012-02-17 Thread Anthony
db is a DAL object, which is callable. Its __call__ method takes a query 
and returns a Set object, which has a select() method for pulling records 
from the database. So, typically, you would do:

db(query).select(...)

However, you can call db without any query (it defaults to None), in which 
case, the select will simply return all records from the table specified in 
the select() call. So:

db().select(db.image.ALL, orderby=db.image.title) 

returns all records in the db.image table. It is equivalent to:

db(db.image.id > 0).select(db.image.ALL, orderby=db.image.title) 

See http://web2py.com/books/default/chapter/29/6#select.

Anthony


On Friday, February 17, 2012 8:34:54 PM UTC-5, davidkw wrote:
>
> For the line: 
>
> db().select(db.image.ALL, orderby=db.image.title) 
>
> Why is there a () after the "db" and before the select? Is db() a 
> method call of some kind? 
>
> Thanks for any clarification.