[web2py] Radbox getting noticed

2011-03-04 Thread pbreit
One thing I've been looking for is a web2py-based service getting written up 
in TechCrunch. Radbox is getting close:
http://www.businessinsider.com/from-a-new-delhi-cubicle-to-the-new-york-tech-meetup-radbox-kicks-ass-takes-names-2011-3


[web2py] Re: DAL new syntax RFC

2011-03-04 Thread Luther Goh Lu Feng
I too like the 'default' syntax much better than the new one. It feels
more readable.

If the following is feasible, will it be a better solution?

Field('name', r=F,w=F)

Field('name', d='value')


On Mar 5, 7:50 am, Massimo Di Pierro 
wrote:
> think of a dot a False. Two does r and w are false, one dot and only w
> is false.
>
> On Mar 4, 4:43 pm, pbreit  wrote:
>
>
>
>
>
>
>
> > I like the "default" functionality since it's still really easy to
> > understand. I'm not sold on the : and . shortcuts.


[web2py] Database change

2011-03-04 Thread darkblue_b
Hi- last night I wanted to change my database name (postgres) and make
a couple of small changes.. So, I exported the six tables or so
to .csv via the admin pages, then dropped my database, made the change
in the DAL connection string, created a new database, and hit go..
  That didnt work.. so I changed the migrate flag to True in db.py,
that was better.
But then when I went to import via the .csv's I had just created, the
imports failed.
  Going directly to postgres and using its \copy function *on the
unmodified .csv files* worked fine.. hmmm
  I then made the changes to the model I wanted, set migrate to True,
and ran again.. this time, one of the changes was to my postgres-VIEW-
as-table, I got a somewhat misleading error msg, btu checking the
postgres logs, quickly found the issue (cant do that with a VIEW) and
fixed it manually..
  All in all, far less straightforward than I had hoped...

  Do the pros here have a sequence for backing up a database and
restoring it, with web2py ?  also, I am curious about how to move from
one data store to another..   thanks in advance  -Brian




Re: [web2py] Re: Error in templating system

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 6:03 PM, villas wrote:
> 
> On Mar 4, 10:22 pm, Thadeus Burgess  wrote:
>> I don't think you should have code included in a {{= block.
> 
> +1  Explicit is better
> 
> {{if abc:}}
>  {{=xyz}}
> {{pass}}
> 
> Yes, there are extra brackets, but no one's going to have a problem
> with that.

That would continue to work regardless.

Right now we have two rules, and it's hard to explain why.

{{=abc
abc = "123}}

...fails. But

{{abc = "123"
=abc}}

... is fine. And so is

{{abc = "123"
=abc
abc = "456"}}

{{pass
=abc
pass}}

is fine. But

{{=abc
pass}}

...is not.

That's a strange set of rules, if you ask me. And confusing, as we've already 
seen, especially since the error message is not helpful.

[web2py] Re: Error in templating system

2011-03-04 Thread villas
On Mar 4, 10:22 pm, Thadeus Burgess  wrote:
> I don't think you should have code included in a {{= block.

+1  Explicit is better

{{if abc:}}
  {{=xyz}}
{{pass}}

Yes, there are extra brackets, but no one's going to have a problem
with that.


[web2py] Re: web2py 1.93.1 is OUT

2011-03-04 Thread Anthony
Excellent! The new wizard plugin download/install seems to be working for me 
now.
 
Anthony

On Friday, March 4, 2011 3:25:28 PM UTC-5, Massimo Di Pierro wrote:

> Lots of changes! 
>
>
> - support for multiple interfaces, thanks Jonathan 
> - upgraded jquery 1.5.1 
> - upgraded simplejson 2.1.3 
> - leaner app.yaml 
> - css3 buttons in welcome 
> - android support (experimental) 
> - Field(':hidden'), Field('.readonly'), Field('name=value') 
> (experimental) 
> - combined expressions print db.data.body.len().sum() 
> - wizard can download plugins automatically from web site 
> - better json serialization (object.custom_json) 
> - better xml serialization (object.custom_xml) 
> - better formstyle support 
> - better comet_messaging.py (needs more testing) 
> - many bug fixes 
>
>
> Thanks to Jonathan in particular for very many patches! 
>
> Massimo



[web2py] Re: web2py 1.93.1 is OUT

2011-03-04 Thread Massimo Di Pierro
oops. Anyway, get 1.93.2 because of a bug in wizard

On Mar 4, 5:37 pm, smg  wrote:
> http://web2py.com/examples/default/changelog- wrong version number
> (typo).


[web2py] Re: DAL new syntax RFC

2011-03-04 Thread Massimo Di Pierro
think of a dot a False. Two does r and w are false, one dot and only w
is false.

On Mar 4, 4:43 pm, pbreit  wrote:
> I like the "default" functionality since it's still really easy to
> understand. I'm not sold on the : and . shortcuts.


[web2py] web2py HL7: where come from "key:descriptions" of some tables?

2011-03-04 Thread Pepe Araya
Hello,

I'm trying to understand the Web2py HL7 App and I don't understand where 
come from the key:descriptions of some tables.

e.g:

"social_history" Table

id: 1
key: 229819007
description: Tobacco use and exposure (observable entity) Not available 
Smoking


is the key arbitrary or is a standard?

Thanks a lot.


[web2py] Re: web2py 1.93.1 is OUT

2011-03-04 Thread smg

http://web2py.com/examples/default/changelog - wrong version number
(typo).


[web2py] Re: [new slice] Flickr API photosets and web2py

2011-03-04 Thread Bruno Rocha
That is my final solution on Flickr Gallery for web2py.

http://serafimnatural.com.br/galeriaflickr/standalone

Now I know I can use better aproches as JSON loads of pictures and other
methods of the API.

When I git it finished, I will pack in a plugin.


Now, I am running in some problems for serving images in
http://serafimnatural.com.br/ It uses Apache+Nginx and I can't get apache to
serve images for me, I tried everything I found on webfaction forum, but
nothing changes. Images are being loaded so slowly, anyone has an idea?


--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] mssql, login problems

2011-03-04 Thread Stef Mientki
hello,


With the DAL I created tables in an MSSQL database, which I can access as long 
as I login as the
same user.

I created the table with a windows login on my own machine, like this
Database_Name = r'mssql://NKCV2'
My_DB = DAL ( Database_Name, folder = folder )

Now I'm on anther machine, I can not use the windows login, so I use a MSSQL 
login
( I found the syntax by trial and error)
*Database_Name = r'mssql://NKCV2;UID=MY_SQL_LOGIN;PWD=MY_PASSWORD'
*My_DB = DAL ( Database_Name, folder = folder )

The login works, I can contact de database,
with the DAL is trying to create new tables (which I'm not allowed, and as far 
as know, I don't need
to because they are already there)
  File "P:\Python26\lib\site-packages\gluon\sql.py", line 1100, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL 
Server]CREATE TABLE
permission denied in database 'NKCV2'. (262) (SQLExecDirectW)")

Could this be caused, by the DAL creating other filenames to store the table 
information ?
Any suggestions to solve this problem ?

thanks,
Stef Mientki



[web2py] Re: potential memory leak???

2011-03-04 Thread ron_m
Depending on the system type the memory doesn't get released. It is rare 
that a malloc implementation calls sbreak with a smaller number than the 
previous call which is what you are looking for. If you have a program that 
consumes say 100 MB to do some initialization and then frees all those 
memory objects the program size does not shrink. However malloc will keep 
track of what is free and reuse it so if the growth goes up to a certain 
level and stays constant after that as you continue to use the application 
then you don't have a leak. A leak is where the memory is not freed but the 
references to it are lost so it keeps going for more memory from the system. 
In that case the memory growth will not hit a levelling off point like your 
application seems to have reached and instead continues to grow and either 
hit system imposed limits or consume all physical memory on the system and 
force swapping.

My web2py application starts at 22 MB of RSS and if I hit every page in a 
test run it grows to 48 MB and I only have configuration data in the 
database so small tables. I can run the server for weeks after that and will 
not see any further growth. If you see behaviour like that while users are 
still using the application you don't have a memory leak.


[web2py] Re: DAL new syntax RFC

2011-03-04 Thread pbreit
I like the "default" functionality since it's still really easy to 
understand. I'm not sold on the : and . shortcuts.

Re: [web2py] Re: Error in templating system

2011-03-04 Thread Thadeus Burgess
I don't think you should have code included in a {{= block.

{{= should ONLY be used to wrap anything in its code block with a
response.write(). Exactly how it does it now.

Doing otherwise is simply bad template design. I consider it a bug if it
ever worked before. Allowing this syntax encourages template writers to do
things in non-standard ways that won't make obvious sense to anybody else
attempting to read their templates. (I currently have to maintain and
re-write some very ugly web2py code in my day job... the previous guys
working severely abused the power of the template system and it has caused
us many issues/headaches because of it).

tl;dr - it is the desired behaviour, update your app code to standards. lets
not complicate web2py further.

--
Thadeus




On Fri, Mar 4, 2011 at 3:21 PM, Jonathan Lundell  wrote:

> On Mar 4, 2011, at 12:54 PM, Massimo Di Pierro wrote:
> >
> > All I meant is that
> >
> > {{=msg
> > pass}}
> >
> > should become:
> >
> > response.write(msg)
> > pass
> >
> > and not
> >
> > response.write(msg
> > pass)
> >
> > since there is no ambiguity.
>
> Right. The question the code has to answer, implicitly, is: exactly what is
> the termination of whatever will be passed to response.write. If the =
> doesn't appear at the beginning of a code block, the answer is: the next
> newline, or the end of the code block, whichever comes first. I think that's
> the right answer. It does mean that:
>
> {{=msg abc
> pass}}
>
> will become:
>
> response.write (msg abc)
> pass
>
> ...but I think that's OK; it's just a "normal" syntax error. It's really
> too complicated to try to parse the argument, since you want things like
>
> {{="abc def"
> pass}}
>
> to work.
>
> I *think* that this will still work:
>
> {{="""string
> on multiple
> lines
> """
> pass}}
>
> ...because the '=' detection comes after the multiline-string escape.
>
>
>
> >
> > On Mar 4, 2:25 pm, Jonathan Lundell  wrote:
> >> On Mar 4, 2011, at 12:19 PM, Massimo Di Pierro wrote:
> >>
> >>
> >>
> >>> I agree that that is what it should do. Please open a ticket about
> >>> this.
> >>
> >> Are you saying (I think) that both cases should terminate on a newline
> (if present)?
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>> On Mar 4, 11:20 am, Jonathan Lundell  wrote:
>  On Mar 4, 2011, at 1:52 AM, szimszon wrote:
> >>
> > web2py™  Version 1.92.1 (2011-02-16 15:04:40)
> > Python Python 2.5.2: /usr/bin/python
> >>
> > Traceback (most recent call last):
> >  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
> > restricted
> >ccode = compile2(code,layer)
> >  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
> > compile2
> >return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> > 'exec')
> >  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
> > integrity/ftp.html", line 123
> >pass
> >   ^
> > SyntaxError: invalid syntax
> >>
> > if msg:
> >response.write('\n', escape=False)
> >response.write(T("Commands executed"))
> >response.write('\n', escape=False)
> >response.write(XML(msg)
> >pass
> >>
> > My template was working until now (I don't know exactly from what
> > web2py version is it bad).
> >>
> > My template was:
> >>
> > {{if msg:}}
> > {{=T("Commands executed")}}
> > {{ =XML(msg)
> > pass
> > try:
> >  dname=request.args[1]
> > except:
> >  dname=0
> > pass
> > editname=T('New')}}
> >>
>  Thadeus might want to chime in here if I have the details wrong (there
> really ought to be a formal reference for template syntax; the tutorial in
> the book is nice, but not complete).
> >>
>  There's a subtle difference in template parsing when =something
> appears at the beginning of an escaped block (where "beginning" ignores
> white space, so =XML above is regarded as being at the beginning of the code
> block).
> >>
>  You probably know already that =something is translated to
> response.write(something). But the question arises, what exactly is
> "something"? That is, where does it end?
> >>
>  And when the '=something' is found at the beginning of a code block,
> 'something' is defined to be *everything until the end of the code block*.
> >>
>  When '=something' is found *embedded* in a code block (not at the
> beginning, ignoring white space), then the end of 'something' is either the
> next newline or the end of the code block, whichever comes first.
> >>
>  So (to shorten up the problem here), you've effectively got this:
> >>
>  {{=msg
>  pass}}
> >>
>  ...which becomes:
> >>
>  response.write(msg
>  pass)
> >>
>  ...and Python is going to object.
> >>
>  On the other hand, if you had written:
> >>
>  {{if xyz:
>  =msg
>  pass}}
> >>
>  The output will be:
> >>
>  if xyz:
>  response.write(msg)
>  pass
> 

Re: [web2py] web2py 1.93.1 is OUT

2011-03-04 Thread pbreit
The hidden/readonly/default stuff was explained here:
https://groups.google.com/d/topic/web2py/4msITKNBNNM/discussion


Re: [web2py] web2py 1.93.1 is OUT

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 1:44 PM, Bruno Rocha wrote:
> Is there some explanation about these?
> 
> - support for multiple interfaces

The --interfaces item on the command line was broken. Now it works. Each 
interface is a colon-delimited string, thus: ip:port or ip:port:cert:key, and 
multiple such strings can be strung together joined with semicolons.

> - android support (experimental)
> - Field(':hidden'), Field('.readonly'), Field('name=value')




[web2py] Re: web2py 1.93.1 is OUT

2011-03-04 Thread pbreit
I will say, the pace and thoughtfulness of improvements is extraordinary. 
Thank you, Massimo, and everyone else.

Re: [web2py] web2py 1.93.1 is OUT

2011-03-04 Thread Bruno Rocha
Is there some explanation about these?

- support for multiple interfaces
- android support (experimental)
- Field(':hidden'), Field('.readonly'), Field('name=value')



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


Re: [web2py] Re: Error in templating system

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 12:54 PM, Massimo Di Pierro wrote:
> 
> All I meant is that
> 
> {{=msg
> pass}}
> 
> should become:
> 
> response.write(msg)
> pass
> 
> and not
> 
> response.write(msg
> pass)
> 
> since there is no ambiguity.

Right. The question the code has to answer, implicitly, is: exactly what is the 
termination of whatever will be passed to response.write. If the = doesn't 
appear at the beginning of a code block, the answer is: the next newline, or 
the end of the code block, whichever comes first. I think that's the right 
answer. It does mean that:

{{=msg abc
pass}}

will become:

response.write (msg abc)
pass

...but I think that's OK; it's just a "normal" syntax error. It's really too 
complicated to try to parse the argument, since you want things like

{{="abc def"
pass}}

to work.

I *think* that this will still work:

{{="""string
on multiple
lines
"""
pass}}

...because the '=' detection comes after the multiline-string escape.



> 
> On Mar 4, 2:25 pm, Jonathan Lundell  wrote:
>> On Mar 4, 2011, at 12:19 PM, Massimo Di Pierro wrote:
>> 
>> 
>> 
>>> I agree that that is what it should do. Please open a ticket about
>>> this.
>> 
>> Are you saying (I think) that both cases should terminate on a newline (if 
>> present)?
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Mar 4, 11:20 am, Jonathan Lundell  wrote:
 On Mar 4, 2011, at 1:52 AM, szimszon wrote:
>> 
> web2py™  Version 1.92.1 (2011-02-16 15:04:40)
> Python Python 2.5.2: /usr/bin/python
>> 
> Traceback (most recent call last):
>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
> restricted
>ccode = compile2(code,layer)
>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
> compile2
>return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> 'exec')
>  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
> integrity/ftp.html", line 123
>pass
>   ^
> SyntaxError: invalid syntax
>> 
> if msg:
>response.write('\n', escape=False)
>response.write(T("Commands executed"))
>response.write('\n', escape=False)
>response.write(XML(msg)
>pass
>> 
> My template was working until now (I don't know exactly from what
> web2py version is it bad).
>> 
> My template was:
>> 
> {{if msg:}}
> {{=T("Commands executed")}}
> {{ =XML(msg)
> pass
> try:
>  dname=request.args[1]
> except:
>  dname=0
> pass
> editname=T('New')}}
>> 
 Thadeus might want to chime in here if I have the details wrong (there 
 really ought to be a formal reference for template syntax; the tutorial in 
 the book is nice, but not complete).
>> 
 There's a subtle difference in template parsing when =something appears at 
 the beginning of an escaped block (where "beginning" ignores white space, 
 so =XML above is regarded as being at the beginning of the code block).
>> 
 You probably know already that =something is translated to 
 response.write(something). But the question arises, what exactly is 
 "something"? That is, where does it end?
>> 
 And when the '=something' is found at the beginning of a code block, 
 'something' is defined to be *everything until the end of the code block*.
>> 
 When '=something' is found *embedded* in a code block (not at the 
 beginning, ignoring white space), then the end of 'something' is either 
 the next newline or the end of the code block, whichever comes first.
>> 
 So (to shorten up the problem here), you've effectively got this:
>> 
 {{=msg
 pass}}
>> 
 ...which becomes:
>> 
 response.write(msg
 pass)
>> 
 ...and Python is going to object.
>> 
 On the other hand, if you had written:
>> 
 {{if xyz:
 =msg
 pass}}
>> 
 The output will be:
>> 
 if xyz:
 response.write(msg)
 pass
>> 
 ...and everybody's happy. Because =msg wasn't the first thing in the code 
 block, only msg gets included in the response.write argument.
>> 
 Is there a good reason for =something to be interpreted two different 
 ways? I'm not sure it's intentional. Thadeus? Massimo?
>> 
> Now I had to modify:
>> 
> {{if msg:}}
> {{=T("Commands executed")}}
> {{ =XML(msg)}}  < -
> {{pass <---
> try:
>  dname=request.args[1]
> except:
>  dname=0
> pass
> editname=T('New')}}




[web2py] Re: Error in templating system

2011-03-04 Thread Massimo Di Pierro
All I meant is that

{{=msg
pass}}

should become:

response.write(msg)
pass

and not

response.write(msg
pass)

since there is no ambiguity.

On Mar 4, 2:25 pm, Jonathan Lundell  wrote:
> On Mar 4, 2011, at 12:19 PM, Massimo Di Pierro wrote:
>
>
>
> > I agree that that is what it should do. Please open a ticket about
> > this.
>
> Are you saying (I think) that both cases should terminate on a newline (if 
> present)?
>
>
>
>
>
>
>
>
>
> > On Mar 4, 11:20 am, Jonathan Lundell  wrote:
> >> On Mar 4, 2011, at 1:52 AM, szimszon wrote:
>
> >>> web2py™  Version 1.92.1 (2011-02-16 15:04:40)
> >>> Python     Python 2.5.2: /usr/bin/python
>
> >>> Traceback (most recent call last):
> >>>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
> >>> restricted
> >>>    ccode = compile2(code,layer)
> >>>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
> >>> compile2
> >>>    return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> >>> 'exec')
> >>>  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
> >>> integrity/ftp.html", line 123
> >>>    pass
> >>>       ^
> >>> SyntaxError: invalid syntax
>
> >>> if msg:
> >>>    response.write('\n', escape=False)
> >>>    response.write(T("Commands executed"))
> >>>    response.write('\n', escape=False)
> >>>    response.write(XML(msg)
> >>>    pass
>
> >>> My template was working until now (I don't know exactly from what
> >>> web2py version is it bad).
>
> >>> My template was:
>
> >>> {{if msg:}}
> >>> {{=T("Commands executed")}}
> >>> {{ =XML(msg)
> >>> pass
> >>> try:
> >>>  dname=request.args[1]
> >>> except:
> >>>  dname=0
> >>> pass
> >>> editname=T('New')}}
>
> >> Thadeus might want to chime in here if I have the details wrong (there 
> >> really ought to be a formal reference for template syntax; the tutorial in 
> >> the book is nice, but not complete).
>
> >> There's a subtle difference in template parsing when =something appears at 
> >> the beginning of an escaped block (where "beginning" ignores white space, 
> >> so =XML above is regarded as being at the beginning of the code block).
>
> >> You probably know already that =something is translated to 
> >> response.write(something). But the question arises, what exactly is 
> >> "something"? That is, where does it end?
>
> >> And when the '=something' is found at the beginning of a code block, 
> >> 'something' is defined to be *everything until the end of the code block*.
>
> >> When '=something' is found *embedded* in a code block (not at the 
> >> beginning, ignoring white space), then the end of 'something' is either 
> >> the next newline or the end of the code block, whichever comes first.
>
> >> So (to shorten up the problem here), you've effectively got this:
>
> >> {{=msg
> >> pass}}
>
> >> ...which becomes:
>
> >> response.write(msg
> >> pass)
>
> >> ...and Python is going to object.
>
> >> On the other hand, if you had written:
>
> >> {{if xyz:
> >> =msg
> >> pass}}
>
> >> The output will be:
>
> >> if xyz:
> >>     response.write(msg)
> >>     pass
>
> >> ...and everybody's happy. Because =msg wasn't the first thing in the code 
> >> block, only msg gets included in the response.write argument.
>
> >> Is there a good reason for =something to be interpreted two different 
> >> ways? I'm not sure it's intentional. Thadeus? Massimo?
>
> >>> Now I had to modify:
>
> >>> {{if msg:}}
> >>> {{=T("Commands executed")}}
> >>> {{ =XML(msg)}}                  < -
> >>> {{pass                 <---
> >>> try:
> >>>  dname=request.args[1]
> >>> except:
> >>>  dname=0
> >>> pass
> >>> editname=T('New')}}


Re: [web2py] From .represent to csv: is this possible?

2011-03-04 Thread Johann Spies
Hallo Richard,

Don't know if it will help :
>
> import csv
> db.export_to_csv_file(open('/home/YOU/Bureau/export_csv_with_represent.csv',
> 'w'),
>represent=True, # this bring your representation into the CSV...
>delimiter='|',
>quotechar='"',
>quoting=csv.QOUTE_NONNUMERIC)
>
>
Thanks.  I did not know about the 'represent=True'  option.

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


Re: [web2py] Re: Error in templating system

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 12:19 PM, Massimo Di Pierro wrote:
> 
> I agree that that is what it should do. Please open a ticket about
> this.

Are you saying (I think) that both cases should terminate on a newline (if 
present)?

> 
> On Mar 4, 11:20 am, Jonathan Lundell  wrote:
>> On Mar 4, 2011, at 1:52 AM, szimszon wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> web2py™  Version 1.92.1 (2011-02-16 15:04:40)
>>> Python Python 2.5.2: /usr/bin/python
>> 
>>> Traceback (most recent call last):
>>>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
>>> restricted
>>>ccode = compile2(code,layer)
>>>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
>>> compile2
>>>return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
>>> 'exec')
>>>  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
>>> integrity/ftp.html", line 123
>>>pass
>>>   ^
>>> SyntaxError: invalid syntax
>> 
>>> if msg:
>>>response.write('\n', escape=False)
>>>response.write(T("Commands executed"))
>>>response.write('\n', escape=False)
>>>response.write(XML(msg)
>>>pass
>> 
>>> My template was working until now (I don't know exactly from what
>>> web2py version is it bad).
>> 
>>> My template was:
>> 
>>> {{if msg:}}
>>> {{=T("Commands executed")}}
>>> {{ =XML(msg)
>>> pass
>>> try:
>>>  dname=request.args[1]
>>> except:
>>>  dname=0
>>> pass
>>> editname=T('New')}}
>> 
>> Thadeus might want to chime in here if I have the details wrong (there 
>> really ought to be a formal reference for template syntax; the tutorial in 
>> the book is nice, but not complete).
>> 
>> There's a subtle difference in template parsing when =something appears at 
>> the beginning of an escaped block (where "beginning" ignores white space, so 
>> =XML above is regarded as being at the beginning of the code block).
>> 
>> You probably know already that =something is translated to 
>> response.write(something). But the question arises, what exactly is 
>> "something"? That is, where does it end?
>> 
>> And when the '=something' is found at the beginning of a code block, 
>> 'something' is defined to be *everything until the end of the code block*.
>> 
>> When '=something' is found *embedded* in a code block (not at the beginning, 
>> ignoring white space), then the end of 'something' is either the next 
>> newline or the end of the code block, whichever comes first.
>> 
>> So (to shorten up the problem here), you've effectively got this:
>> 
>> {{=msg
>> pass}}
>> 
>> ...which becomes:
>> 
>> response.write(msg
>> pass)
>> 
>> ...and Python is going to object.
>> 
>> On the other hand, if you had written:
>> 
>> {{if xyz:
>> =msg
>> pass}}
>> 
>> The output will be:
>> 
>> if xyz:
>> response.write(msg)
>> pass
>> 
>> ...and everybody's happy. Because =msg wasn't the first thing in the code 
>> block, only msg gets included in the response.write argument.
>> 
>> Is there a good reason for =something to be interpreted two different ways? 
>> I'm not sure it's intentional. Thadeus? Massimo?
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Now I had to modify:
>> 
>>> {{if msg:}}
>>> {{=T("Commands executed")}}
>>> {{ =XML(msg)}}  < -
>>> {{pass <---
>>> try:
>>>  dname=request.args[1]
>>> except:
>>>  dname=0
>>> pass
>>> editname=T('New')}}




[web2py] web2py 1.93.1 is OUT

2011-03-04 Thread Massimo Di Pierro
Lots of changes!


- support for multiple interfaces, thanks Jonathan
- upgraded jquery 1.5.1
- upgraded simplejson 2.1.3
- leaner app.yaml
- css3 buttons in welcome
- android support (experimental)
- Field(':hidden'), Field('.readonly'), Field('name=value')
(experimental)
- combined expressions print db.data.body.len().sum()
- wizard can download plugins automatically from web site
- better json serialization (object.custom_json)
- better xml serialization (object.custom_xml)
- better formstyle support
- better comet_messaging.py (needs more testing)
- many bug fixes


Thanks to Jonathan in particular for very many patches!

Massimo


[web2py] Re: Error in templating system

2011-03-04 Thread Massimo Di Pierro
I agree that that is what it should do. Please open a ticket about
this.

On Mar 4, 11:20 am, Jonathan Lundell  wrote:
> On Mar 4, 2011, at 1:52 AM, szimszon wrote:
>
>
>
>
>
>
>
>
>
>
>
> > web2py™  Version 1.92.1 (2011-02-16 15:04:40)
> > Python     Python 2.5.2: /usr/bin/python
>
> > Traceback (most recent call last):
> >  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
> > restricted
> >    ccode = compile2(code,layer)
> >  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
> > compile2
> >    return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> > 'exec')
> >  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
> > integrity/ftp.html", line 123
> >    pass
> >       ^
> > SyntaxError: invalid syntax
>
> > if msg:
> >    response.write('\n', escape=False)
> >    response.write(T("Commands executed"))
> >    response.write('\n', escape=False)
> >    response.write(XML(msg)
> >    pass
>
> > My template was working until now (I don't know exactly from what
> > web2py version is it bad).
>
> > My template was:
>
> > {{if msg:}}
> > {{=T("Commands executed")}}
> > {{ =XML(msg)
> > pass
> > try:
> >  dname=request.args[1]
> > except:
> >  dname=0
> > pass
> > editname=T('New')}}
>
> Thadeus might want to chime in here if I have the details wrong (there really 
> ought to be a formal reference for template syntax; the tutorial in the book 
> is nice, but not complete).
>
> There's a subtle difference in template parsing when =something appears at 
> the beginning of an escaped block (where "beginning" ignores white space, so 
> =XML above is regarded as being at the beginning of the code block).
>
> You probably know already that =something is translated to 
> response.write(something). But the question arises, what exactly is 
> "something"? That is, where does it end?
>
> And when the '=something' is found at the beginning of a code block, 
> 'something' is defined to be *everything until the end of the code block*.
>
> When '=something' is found *embedded* in a code block (not at the beginning, 
> ignoring white space), then the end of 'something' is either the next newline 
> or the end of the code block, whichever comes first.
>
> So (to shorten up the problem here), you've effectively got this:
>
> {{=msg
> pass}}
>
> ...which becomes:
>
> response.write(msg
> pass)
>
> ...and Python is going to object.
>
> On the other hand, if you had written:
>
> {{if xyz:
> =msg
> pass}}
>
> The output will be:
>
> if xyz:
>     response.write(msg)
>     pass
>
> ...and everybody's happy. Because =msg wasn't the first thing in the code 
> block, only msg gets included in the response.write argument.
>
> Is there a good reason for =something to be interpreted two different ways? 
> I'm not sure it's intentional. Thadeus? Massimo?
>
>
>
>
>
>
>
>
>
> > Now I had to modify:
>
> > {{if msg:}}
> > {{=T("Commands executed")}}
> > {{ =XML(msg)}}                  < -
> > {{pass                 <---
> > try:
> >  dname=request.args[1]
> > except:
> >  dname=0
> > pass
> > editname=T('New')}}


[web2py] Re: Multiple forms grouped as one (django formset equivalent) with jquery plugin allowing clients to add and remove forms on the client-side

2011-03-04 Thread Massimo Di Pierro
wait I actually do it before you thank me.. ;-)

On Mar 4, 11:00 am, ChrisT  wrote:
> Wow, a response from the man himself :-)
> I must admit I was secretly hoping for this and that this is another
> reason web2py seems like a better choice to me.
> I have been lurking at discussions for quite some time and I am
> constantly amazed by the amount of responses you give, always with a
> friendly tone.
> A big "Thank You Massimo" is in order, not just for this, but for
> everything you have done. For this great present called "web2py".
>
> ChrisT
>
> On Mar 4, 4:42 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Hello ChrisT,
>
> > it is possible but I am not sure I have seen a recipe posted for this.
> > I will try write one next week and post it, perhaps sooner.
>
> > Massimo
>
> > On Mar 4, 3:30 am, ChrisT  wrote:
>
> > > Hello everyone,
>
> > > I am in the process of evaluating web2py and django to decide which
> > > one I am going to use for a project of mine.
> > > I am new to both frameworks and web frameworks in general (although I
> > > did experiment with Ruby on Rails a while back)
> > > I must say I am learning web2py much faster than Django which has a
> > > much steeper learning curve I think.
> > > For the past few days however I am trying to figure out the best way
> > > to do a (relatively) simple thing with both frameworks that I guess
> > > many people did before me.
> > > I wanted to have multiple forms grouped as one on a sigle page and a
> > > jquery plugin allowing clients to add and remove forms on the client-
> > > side.
> > > This would be very useful in many situations in my application.
> > > One example would be:
> > >    * Creating an invoice (table invoice with fields such as
> > > reference_no , issue_date, customer_name, etc.) with multiple invoice
> > > lines (table invoice_line with fields such as description, amount,
> > > etc.)
> > > So I need to create a single form for the invoice creation and the
> > > client must be able to add or remove from the form as many
> > > invoice_lines as needed each time.
> > > The fact is that I was able to figure the best way to do it in Django
> > > would be using 
> > > formsets:http://docs.djangoproject.com/en/dev/topics/forms/formsets/
> > > and this:http://code.google.com/p/django-dynamic-formset/jQuery
> > > pluging
> > > I am troubled I didn't find anything similar implemented in web2py, I
> > > am sure many people before me did the same thing using both
> > > frameworks. I found some pieces of code here and there that enabled me
> > > to come close to doing it using web2py but I consider my efforts a
> > > hack (and an incomplete one so far :-))
> > > I would like to know your opinions on how this should be done in
> > > web2py or how someone already did this.
> > > Please forgive my ignorance if I am missing the obvious here as I am
> > > new to all this. In fact this is my first post so go easy on me...
>
> > > Regards,
> > > ChrisT


[web2py] Anti-spam form technique

2011-03-04 Thread pbreit
Could Web2py's forms be made to work like this? I know they already include 
a hash to protect against certain form hacking.
http://docs.jquery.com/Tutorials:Safer_Contact_Forms_Without_CAPTCHAs


[web2py] Re: Apache, Wsgi problem

2011-03-04 Thread VP
oops, it looks like that last post was supposed to be for the other
thread ("potential memory leaks").


On Mar 4, 12:28 pm, Jonathan Lundell  wrote:
> On Mar 4, 2011, at 9:46 AM, VP wrote:
>
>
>
> > To be precise, RSS started with about 32MB (with an apache restart)
> > and starts crawling up to 80MB/process with aforementioned testing.
> > And If I remember correctly, it stayed that way over night and did not
> > get released.
>
> > As I said, I will do further testing with this toy example and with my
> > real app and report further findings.
>
> It'd be useful to know whether it's stable at 80MB or it keeps growing.
>
>
>
> > On Mar 4, 11:31 am, VP  wrote:
> >> For some reason I missed the rest of this discussion.   Just a quick follow
> >> up.
>
> >> + I upgraded psycopg2 from 2.0.7 (default in Debian 5) to the latest
> >> version, 2.4.  This manual installation was smoother than I thought.
>
> >> + Result:   preliminary stress tests show that the problem *disappeared*.  
> >> No more WSGI premature script error.
>
>


Re: [web2py] Re: Apache, Wsgi problem

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 9:46 AM, VP wrote:
> 
> To be precise, RSS started with about 32MB (with an apache restart)
> and starts crawling up to 80MB/process with aforementioned testing.
> And If I remember correctly, it stayed that way over night and did not
> get released.
> 
> As I said, I will do further testing with this toy example and with my
> real app and report further findings.

It'd be useful to know whether it's stable at 80MB or it keeps growing. 

> 
> 
> On Mar 4, 11:31 am, VP  wrote:
>> For some reason I missed the rest of this discussion.   Just a quick follow
>> up.
>> 
>> + I upgraded psycopg2 from 2.0.7 (default in Debian 5) to the latest
>> version, 2.4.  This manual installation was smoother than I thought.
>> 
>> + Result:   preliminary stress tests show that the problem *disappeared*.  
>> No more WSGI premature script error.




[web2py] Re: Apache, Wsgi problem

2011-03-04 Thread VP
To be precise, RSS started with about 32MB (with an apache restart)
and starts crawling up to 80MB/process with aforementioned testing.
And If I remember correctly, it stayed that way over night and did not
get released.

As I said, I will do further testing with this toy example and with my
real app and report further findings.


On Mar 4, 11:31 am, VP  wrote:
> For some reason I missed the rest of this discussion.   Just a quick follow
> up.
>
> + I upgraded psycopg2 from 2.0.7 (default in Debian 5) to the latest
> version, 2.4.  This manual installation was smoother than I thought.
>
> + Result:   preliminary stress tests show that the problem *disappeared*.  
> No more WSGI premature script error.


Re: [web2py] Re: Apache, Wsgi problem

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 9:31 AM, VP wrote:
> For some reason I missed the rest of this discussion.   Just a quick follow 
> up.
> 
> + I upgraded psycopg2 from 2.0.7 (default in Debian 5) to the latest version, 
> 2.4.  This manual installation was smoother than I thought.
> 
> + Result:   preliminary stress tests show that the problem *disappeared*.   
> No more WSGI premature script error.

Thanks for the report.

I wonder if it might be worth a warning message if an app actually uses (not 
just imports) psycopg2 and the version is 2.0.7 or earlier. It seems to be 
fairly widespread.

[web2py] Re: potential memory leak???

2011-03-04 Thread VP
RSS is smaller than VSZ, but the behavior appeared to be the same.
The point is that accumulated resources do not seem to get released.

I have made changes (upgraded psycopg2), so I will report on this with
further testing.




On Mar 4, 11:15 am, ron_m  wrote:
> RSS (Resident Set Size) is a closer approximation of actual physical memory
> consumed by a process. VSZ includes shared libraries and anything else
> required to be mapped in to make the process complete but shared libraries
> are not in physical memory more than once for all processes except the
> writeable data area they may contain.
>
> Presuming Linux or UNIX like system and CPython memory allocation ultimately
> comes down to the library function malloc which is layered over the system
> call sbreak. The malloc library call manages allocation of memory to
> whatever is requesting it such as the CPython interpreter but works from a
> pool for performance efficiency. If it runs out of room it calls the system
> using sbreak to get another chunk. It is possible to reduce the size by
> calling sbreak with a smaller size but malloc must be sure the area given
> back is completely free from use by objects. This was typically never done
> in the past. If malloc frees a lot of space then it will just reuse it on
> the next allocation request. I admit I have not dug into the CPython use of
> malloc reading code to see what it does. What I am saying is the numbers
> reported by system utilities can be misleading specifically if sbreak size
> reduction is not exercised.


Re: [web2py] Re: Apache, Wsgi problem

2011-03-04 Thread VP
For some reason I missed the rest of this discussion.   Just a quick follow 
up.

+ I upgraded psycopg2 from 2.0.7 (default in Debian 5) to the latest 
version, 2.4.  This manual installation was smoother than I thought.

+ Result:   preliminary stress tests show that the problem *disappeared*.   
No more WSGI premature script error.


Re: [web2py] Error in templating system

2011-03-04 Thread Jonathan Lundell
On Mar 4, 2011, at 1:52 AM, szimszon wrote:
> 
> web2py™   Version 1.92.1 (2011-02-16 15:04:40)
> PythonPython 2.5.2: /usr/bin/python
> 
> Traceback (most recent call last):
>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
> restricted
>ccode = compile2(code,layer)
>  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
> compile2
>return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> 'exec')
>  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
> integrity/ftp.html", line 123
>pass
>   ^
> SyntaxError: invalid syntax
> 
> if msg:
>response.write('\n', escape=False)
>response.write(T("Commands executed"))
>response.write('\n', escape=False)
>response.write(XML(msg)
>pass
> 
> My template was working until now (I don't know exactly from what
> web2py version is it bad).
> 
> My template was:
> 
> {{if msg:}}
> {{=T("Commands executed")}}
> {{=XML(msg)
> pass
> try:
>  dname=request.args[1]
> except:
>  dname=0
> pass
> editname=T('New')}}

Thadeus might want to chime in here if I have the details wrong (there really 
ought to be a formal reference for template syntax; the tutorial in the book is 
nice, but not complete).

There's a subtle difference in template parsing when =something appears at the 
beginning of an escaped block (where "beginning" ignores white space, so =XML 
above is regarded as being at the beginning of the code block). 

You probably know already that =something is translated to 
response.write(something). But the question arises, what exactly is 
"something"? That is, where does it end?

And when the '=something' is found at the beginning of a code block, 
'something' is defined to be *everything until the end of the code block*.

When '=something' is found *embedded* in a code block (not at the beginning, 
ignoring white space), then the end of 'something' is either the next newline 
or the end of the code block, whichever comes first.

So (to shorten up the problem here), you've effectively got this:

{{=msg
pass}}

...which becomes:

response.write(msg
pass)

...and Python is going to object.

On the other hand, if you had written:

{{if xyz:
=msg
pass}}

The output will be:

if xyz:
response.write(msg)
pass

...and everybody's happy. Because =msg wasn't the first thing in the code 
block, only msg gets included in the response.write argument.

Is there a good reason for =something to be interpreted two different ways? I'm 
not sure it's intentional. Thadeus? Massimo?


> 
> Now I had to modify:
> 
> {{if msg:}}
> {{=T("Commands executed")}}
> {{=XML(msg)}}  < -
> {{pass <---
> try:
>  dname=request.args[1]
> except:
>  dname=0
> pass
> editname=T('New')}}




[web2py] Re: potential memory leak???

2011-03-04 Thread ron_m
RSS (Resident Set Size) is a closer approximation of actual physical memory 
consumed by a process. VSZ includes shared libraries and anything else 
required to be mapped in to make the process complete but shared libraries 
are not in physical memory more than once for all processes except the 
writeable data area they may contain.

Presuming Linux or UNIX like system and CPython memory allocation ultimately 
comes down to the library function malloc which is layered over the system 
call sbreak. The malloc library call manages allocation of memory to 
whatever is requesting it such as the CPython interpreter but works from a 
pool for performance efficiency. If it runs out of room it calls the system 
using sbreak to get another chunk. It is possible to reduce the size by 
calling sbreak with a smaller size but malloc must be sure the area given 
back is completely free from use by objects. This was typically never done 
in the past. If malloc frees a lot of space then it will just reuse it on 
the next allocation request. I admit I have not dug into the CPython use of 
malloc reading code to see what it does. What I am saying is the numbers 
reported by system utilities can be misleading specifically if sbreak size 
reduction is not exercised.


Re: [web2py] powerTable.extrajs question

2011-03-04 Thread Richard Vézina
Hello Bruno,

What do you think of using web2py service JSONRPC?

So we need function to deal with those call from DataTables :

intiDisplayStartDisplay start pointintiDisplayLengthNumber of records to
displayintiColumnsNumber of columns being displayed (useful for getting
individual column search info)stringsSearchGlobal search fieldboolean
bEscapeRegexGlobal search is regex or notbooleanbSortable_*(int)*Indicator
for if a column is flagged as sortable or not on the client-sideboolean
bSearchable_*(int)*Indicator for if a column is flagged as searchable or not
on the client-sidestringsSearch_*(int)*Individual column filterboolean
bEscapeRegex_*(int)*Individual column filter is regex or
notintiSortingColsNumber
of columns to sort onintiSortCol_*(int)*Column being sorted on (you will
need to decode this number for your database)stringsSortDir_*(int)*Direction
to be sorted - "desc" or "asc". *Note that the prefix for this variable is
wrong in 1.5.x where iSortDir_(int)was used)*stringsEchoInformation for
DataTables to use for rendering

Here the reference :
http://www.datatables.net/usage/server-side

I am searching where to start to solve the server side issue of
PowerTable...

Richard




On Tue, Feb 1, 2011 at 8:11 AM, Bruno Rocha  wrote:

> 2011/2/1 Johann Spies 
>
> I hope some time in future people with proper knowledge of javascript like
>> you will be able to combine pagination the way jqgrid from the plugin_wiki
>> does (using limitby in sql-queries) with the other powerfull features to get
>> the best of both sides.
>
>
> datatables.net has a full support to JSON and Xml datasources, with that
> we can do server side processing in the same way jqgrid does, I am planning
> to rewrite some parts of powerTable to implement it.
>
> And I am counting the help of people who knows javascript and web2py, any
> help, suggestion and report is very appreciated.
>
> Thanks
>
> Bruno.
>
>


[web2py] FYI change in book

2011-03-04 Thread DenesL
The following paragraph at the end of section
http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-distinct
has been removed since it no longer applies:

Currently, "limitby" is only partially supported on MSSQL since the
Microsoft database does not provide a mechanism to fetch a subset of
records not starting at 0.


[web2py] pysimplesoap GAE caching

2011-03-04 Thread howesc
Hi all,

I was wondering if anyone has used pysimplesoap client on GAE with any sort 
of caching?  Since the WSDL is not going to change often, I'd love to cache 
my client between requests.  seems like the client itself is un-pickelable. 
 My next thought is to update the SoapClient.wsdl method to be able to cache 
the files in memcache rather than disk so that it will work on GAE.

Thoughts?  opinions?

thanks,

christian


[web2py] Re: One form for multiple tables

2011-03-04 Thread DenesL
Hi Annet,

I believe you want something like this:

def multitable_form_update():
  last=0
  if request.args:
last=request.args[0]
  # retrieve next 2 addresses
  addrs=db(db.cli_addr.id>last).select(limitby=[0,2])
  if addrs:
addr=addrs[0]
curr=addr.id
# set defaults to be shown on form
db.client.name.default=db.client[addr.client].name
db.cli_addr.street.default=addr.street
db.cli_addr.city.default=addr.city
  else: # show EOF msg and loop
session.flash='no more addresses on file'
redirect(URL(request.action))
  # set client to read only
  db.client.name.writable=False
  form=SQLFORM.factory(db.client,db.cli_addr)
  # add link to next
  form[0][-1][1].append(A("Skip to
Next",_href=URL(request.action,args=curr)))
  if form.accepts(request.vars):
# update record and redirect
addr.update_record(**db.cli_addr._filter_fields(form.vars))
session.flash='record updated'
redirect(URL(request.action,args=last))
  return dict(form=form)


On Mar 2, 1:06 pm, annet  wrote:
> This example is taken from the web2py manual.
>
> model:
>
> db.define_table('client',
>      Field('name'))
> db.define_table('address',
>     Field('client',db.client,writable=False,readable=False),
>     Field('street'),Field('city'))
>
> controller:
>
> def register():
>     form=SQLFORM.factory(db.client,db.address)
>     if form.accepts(request.vars):
>         id = db.client.insert(**db.client._filter_fields(form.vars))
>         form.vars.client=id
>         id = db.address.insert(**db.address._filter_fields(form.vars))
>         response.flash='Thanks for filling the form'
>     return dict(form=form)
>
> Is it possible to pre-populate a form like this and then use update
> instead of insert to update the records in the tables?
>
> Kind regards,
>
> Annet.


[web2py] Re: potential memory leak???

2011-03-04 Thread VP
For some reason, I missed the rest of that discussion.  I didn't
upgrade psycopg2.  My VPS has not upgraded to Debian 6 yet (but will
soon).  So, I will wait for a few weeks and then this module will be
upgraded together with Debian 6.  I will report on this later.



On Mar 4, 8:15 am, Anthony  wrote:
> On Friday, March 4, 2011 1:41:13 AM UTC-5, VP wrote:
>
> > Apache configuration: 5 processes, 1 thread   (more than 1 threads
> > will cause WSGI premature script error as previously described).
>
> I thought the WSGI premature script error problem was resolved by upgrading
> psycopg2 to a version greater than 2.0.7, as discussed 
> here:https://groups.google.com/d/topic/web2py/AcCDl5eJnds/discussion. Did you
> upgrade psycopg2, and if so, did that not solve the problem for you (I mean,
> the premature script error problem, not the current memory leak problem)?
>
> Anthony


[web2py] Re: Multiple forms grouped as one (django formset equivalent) with jquery plugin allowing clients to add and remove forms on the client-side

2011-03-04 Thread ChrisT
Wow, a response from the man himself :-)
I must admit I was secretly hoping for this and that this is another
reason web2py seems like a better choice to me.
I have been lurking at discussions for quite some time and I am
constantly amazed by the amount of responses you give, always with a
friendly tone.
A big "Thank You Massimo" is in order, not just for this, but for
everything you have done. For this great present called "web2py".

ChrisT


On Mar 4, 4:42 pm, Massimo Di Pierro 
wrote:
> Hello ChrisT,
>
> it is possible but I am not sure I have seen a recipe posted for this.
> I will try write one next week and post it, perhaps sooner.
>
> Massimo
>
> On Mar 4, 3:30 am, ChrisT  wrote:
>
> > Hello everyone,
>
> > I am in the process of evaluating web2py and django to decide which
> > one I am going to use for a project of mine.
> > I am new to both frameworks and web frameworks in general (although I
> > did experiment with Ruby on Rails a while back)
> > I must say I am learning web2py much faster than Django which has a
> > much steeper learning curve I think.
> > For the past few days however I am trying to figure out the best way
> > to do a (relatively) simple thing with both frameworks that I guess
> > many people did before me.
> > I wanted to have multiple forms grouped as one on a sigle page and a
> > jquery plugin allowing clients to add and remove forms on the client-
> > side.
> > This would be very useful in many situations in my application.
> > One example would be:
> >    * Creating an invoice (table invoice with fields such as
> > reference_no , issue_date, customer_name, etc.) with multiple invoice
> > lines (table invoice_line with fields such as description, amount,
> > etc.)
> > So I need to create a single form for the invoice creation and the
> > client must be able to add or remove from the form as many
> > invoice_lines as needed each time.
> > The fact is that I was able to figure the best way to do it in Django
> > would be using 
> > formsets:http://docs.djangoproject.com/en/dev/topics/forms/formsets/
> > and this:http://code.google.com/p/django-dynamic-formset/jQuery
> > pluging
> > I am troubled I didn't find anything similar implemented in web2py, I
> > am sure many people before me did the same thing using both
> > frameworks. I found some pieces of code here and there that enabled me
> > to come close to doing it using web2py but I consider my efforts a
> > hack (and an incomplete one so far :-))
> > I would like to know your opinions on how this should be done in
> > web2py or how someone already did this.
> > Please forgive my ignorance if I am missing the obvious here as I am
> > new to all this. In fact this is my first post so go easy on me...
>
> > Regards,
> > ChrisT
>
>


[web2py] Re: potential memory leak???

2011-03-04 Thread VP
Massimo:
1. This is with Apache.
2. print db(db.data).select('sum(length(data.body)
+length(data.body1)+length(data.body2)+length(data.body3))')
Answer: 1764948

I am looking at "ps aux" right now.  Under VSZ column, there's 141M.
Resource is still not released since last night.


On Mar 4, 8:27 am, Massimo Di Pierro 
wrote:
> I do not think it is a memory leak.
>
> Please run two tests:
> 1) What do you get with run with the built-in server instead of
> apache?
>
> 2) what is the output of
>
> print db(db.data).select('sum(length(data.body)
> +length(data.body1)+length(data.body2)+length(data.body3))')
>
> I suspect it may be a big numbers you are fetching all your records at
> once.
>
> On Mar 4, 12:41 am, VP  wrote:
>
> > My app has utilized much RAM over time, so I created a simple app to
> > replicate the problem.  This is what I found out.
>
> > First of all, the app:
>
> > ++ Model (database is postgres):
> > db.define_table('data',
> >     Field('body','text',requires=IS_LENGTH(262144)),
> >     Field('body1','text',requires=IS_LENGTH(262144)),
> >     Field('body2','text',requires=IS_LENGTH(262144)),
> >     Field('body3','text',requires=IS_LENGTH(262144)))
>
> > ### I populate the database with about 1500 entries
> > #from gluon.contrib.populate import populate
> > #populate(db.data,100)
>
> > ++ Controller:
> > def index():
> >     return dict( data = db().select(db.data.ALL) )
>
> > ++ View/default/index.html:
> > {{extend 'layout.html'}}
> > {{i=1}}
> > {{ for d in data: }}
> >     {{=i}}. {{=d.body}} {{=d.body1}} {{=d.body2}} {{=d.body3}}.
> >     {{i+=1}}
> > {{ pass }}
>
> > ==
>
> > Apache configuration: 5 processes, 1 thread   (more than 1 threads
> > will cause WSGI premature script error as previously described).
>
> > ==
>
> > Result (this is with 1.92.1; 1.91.6 had same problem)
>
> > A fresh apache restart gives each of 5 processes about 43MB.
>
> > After using ab to stress test with 20 connections, 10 seconds,
> > repeated several times, RAM starts crawling up to about 130MB per
> > process.
>
> > The RAM appears to be stuck there at 130MB/process and not released.
>
> > At this point the RAM per process does not get increased with repeated
> > testing... BUT Apache starts getting this error:
>
> > IOError: failed to write data
> > mod_wsgi (pid=12689): Exception occurred processing WSGI script '/home/
> > vphan/web2py/wsgihandler.py'.
> > <<<
>
> > ==
>
> > This is with the simple app above.  With my real app, RAM keeps
> > getting increased and not released.
>
> > It seems that if I load many rows (each with much data) into memory,
> > we see this problem.
>
> > Does the DAL leak memory?
>
>


Re: [web2py] From .represent to csv: is this possible?

2011-03-04 Thread Richard Vézina
Don't know if it will help :

import csv
db.export_to_csv_file(open('/home/YOU/Bureau/export_csv_with_represent.csv',
'w'),
   represent=True, # this bring your representation into the CSV...
   delimiter='|',
   quotechar='"',
   quoting=csv.QOUTE_NONNUMERIC)

Richard

On Fri, Mar 4, 2011 at 4:09 AM, Johann Spies  wrote:
> I have a generic 'show_data'  function in my controller using the
.represent
> functions in the models to show linked fields correctly.
>
> The clients wants the same now in the csv-downloads from the same data
shown
> by show_data.
>
> There are many tables involved - it might be more than 20 and I do not
want
> to define a separate function or query for each one of them.  I am looking
> for a way to adjust the query if any of those fields contained the
> referenced data in question.
>
> I do not know whether something like the following pseudocode is possible
or
> how to do it:
>
> def csv_query(table):
> refs = []
>  queryfields = db[table].fields()
>  if 'teacher' in queryfields:
> refs.append('teacher')
> index = queryfields('teacher')
> queryfields.remove('teacher')
> queryfields.insert(index-1,teacher.name)
>  if 'school' in queryfields:
> (you get the idea)
>
>  return dict(queryfields=queryfields, refs = refs)
>
> and then use the return value like this:
>
> refs, queyfields = csv_query[table]
> db(build this part of the query from refs eg (db.esp04.teacher ==
> db.teacher.id) & db.esp04.school == db.school.id).select(build this part
of
> the query from queryfields eg(db.esp04.all the fields except 'school' and
> 'teacher' and those two replaced by db.school.name and db.teacher.name) )
>
> Regards
>
> Johann
>
>
> --
>  May grace and peace be yours in abundance through the full knowledge of
God
> and of Jesus our Lord!  His divine power has given us everything we need
for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>


[web2py] DAL new syntax RFC

2011-03-04 Thread Massimo Di Pierro
There are some new features in trunk:

1)

I got tired of writing default='value',readable=False,writable=False
etc.

So:

Field(':name') is the same as
Field('name',readable=False,writable=False)
Field('.name') is the same as
Field('name',readable=True,writable=False)
Field('name=value') is the same as Field('name',default='value')

and combinations:

Field(':name=value') is the same as
Field('name',default='value',readable=True,writable=False)

notice

Field('name=') is the same as Field('name',default='')

2)

db(db.table).select((db.table.field.length()+5).sum())

note operators length(), +5, sum() can be combined in more ways than
before.









[web2py] Re: Error in templating system

2011-03-04 Thread villas
The code you posted was clearly badly formed.  You need to correct it
first.

The 'pass' function should always look like this: {{pass}}

If something only works in a strange, undocumented way, it is likely
to be broken in the future. This is nothing to do with backwards
compatibility, it is simply working as per the documentation.


On Mar 4, 10:42 am, szimszon  wrote:
> Don't know could be but
>
> The interpreter which checks the syntax about all the pass-es are in
> right place give me the syntax error. What I try to say that first I
> visit the page the msg is None so the "if" branch isn't executed at
> all.
>
> If I just byte compile the app I have the same syntax error message.
> And if I close the =XML(msg) with }} and open before pass everything
> is right. :(
>
> On márc. 4, 11:26, pbreit  wrote:
>
> > Oh, ok, I see, sorry about that. So it somehow dropped the closing ) after 
> > =XML(msg).
> > Could your msg have any special characters in it? I see some UTF-8 related
> > diffs in the code for html.py recently.
>
>


[web2py] Re: no json - cont.

2011-03-04 Thread villas
As an aside,  I would mention that my experience of naming primary
keys anything other than 'id' is that it will always trip you up. In
the end I refactored all my codebase to use 'id' across delphi, php
and web2py. Glad I did.  IMO it is better to do it sooner than
later.
Regards, D


[web2py] Re: Multiple forms grouped as one (django formset equivalent) with jquery plugin allowing clients to add and remove forms on the client-side

2011-03-04 Thread Massimo Di Pierro
Hello ChrisT,

it is possible but I am not sure I have seen a recipe posted for this.
I will try write one next week and post it, perhaps sooner.

Massimo



On Mar 4, 3:30 am, ChrisT  wrote:
> Hello everyone,
>
> I am in the process of evaluating web2py and django to decide which
> one I am going to use for a project of mine.
> I am new to both frameworks and web frameworks in general (although I
> did experiment with Ruby on Rails a while back)
> I must say I am learning web2py much faster than Django which has a
> much steeper learning curve I think.
> For the past few days however I am trying to figure out the best way
> to do a (relatively) simple thing with both frameworks that I guess
> many people did before me.
> I wanted to have multiple forms grouped as one on a sigle page and a
> jquery plugin allowing clients to add and remove forms on the client-
> side.
> This would be very useful in many situations in my application.
> One example would be:
>    * Creating an invoice (table invoice with fields such as
> reference_no , issue_date, customer_name, etc.) with multiple invoice
> lines (table invoice_line with fields such as description, amount,
> etc.)
> So I need to create a single form for the invoice creation and the
> client must be able to add or remove from the form as many
> invoice_lines as needed each time.
> The fact is that I was able to figure the best way to do it in Django
> would be using 
> formsets:http://docs.djangoproject.com/en/dev/topics/forms/formsets/
> and this:http://code.google.com/p/django-dynamic-formset/jQuery
> pluging
> I am troubled I didn't find anything similar implemented in web2py, I
> am sure many people before me did the same thing using both
> frameworks. I found some pieces of code here and there that enabled me
> to come close to doing it using web2py but I consider my efforts a
> hack (and an incomplete one so far :-))
> I would like to know your opinions on how this should be done in
> web2py or how someone already did this.
> Please forgive my ignorance if I am missing the obvious here as I am
> new to all this. In fact this is my first post so go easy on me...
>
> Regards,
> ChrisT


[web2py] Re: Bug in MySQLAdapter

2011-03-04 Thread Massimo Di Pierro
fixed in trunk. Please check! thank you.

On Mar 4, 2:32 am, Milan Melena  wrote:
> I found bug in MySQLAdapter (repository version):
>
>       1.1 --- a/gluon/dal.py    Thu Mar 03 23:20:20 2011 -0600
>      1.2 +++ b/gluon/dal.py     Fri Mar 04 09:25:00 2011 +0100
>      1.3 @@ -1470,11 +1470,11 @@
>      1.4          charset = m.group('charset') or 'utf8'
>      1.5          driver_args.update(dict(db=db,
>      1.6
> user=credential_decoder(user),
>      1.7 -
> password=credential_decoder(password),
>      1.8 +
> passwd=credential_decoder(password),
>      1.9                                     host=host,
>     1.10                                     port=port,
>     1.11                                     charset=charset))
>     1.12 -        def connect(dbpath=dbpath,driver_args=driver_args):
>     1.13 +        def connect(driver_args=driver_args):
>     1.14              return self.driver.connect(**driver_args)
>     1.15          self.pool_connection(connect)
>     1.16          self.cursor = self.connection.cursor()
>
> Best regards
> Milan Melena


[web2py] Re: Weird self submitting forms all checkbox is checked after submit

2011-03-04 Thread Massimo Di Pierro
Which web2py version? I cannnot reproduce it? If latest, can you post
some code to reproduce it?

On Mar 4, 6:12 am, szimszon  wrote:
> If I Submit form data which contains checkbox (boolean) field I got
> back the form with all checkbox selected...
>
> The database operation is ok. Just the returning form is displayed
> with all checkbox checked...


[web2py] Re: mysql dal.py boolean field

2011-03-04 Thread Massimo Di Pierro
should be fixed in trunk. The problem is corrupted data anyway.

Massimo

On Mar 4, 4:34 am, szimszon  wrote:
> I had a mysql table with boolean field but there was some rows with
> empty fields than I got that:
>
> Traceback (most recent call last):
> File "applications/serveradmin/compiled/controllers_integrity_ftp.py",
> line 191, in ftp
> File "/usr/local/web2py/gluon/dal.py", line 4605, in select return
> self.db._adapter.select(self.query,fields,attributes)
> File "/usr/local/web2py/gluon/dal.py", line 1027, in select return
> self.parse(rows,self._colnames)
> File "/usr/local/web2py/gluon/dal.py", line 1225, in parse if value ==
> True or str(value)[0].lower() == 't':
>  IndexError: string index out of range
>
> +-+---+--+-+-+
> +
> | Field       | Type          | Null | Key | Default | Extra
> |
> +-+---+--+-+-+
> +
> | User        | varchar(128)  | NO   | UNI |         |
> |
> | status      | enum('0','1') | NO   |     | 0       |
> |
>
> It's an outer DB I just connect to it (migrate=False). After I put a
> value to all the status field everything is working OK.


[web2py] Re: potential memory leak???

2011-03-04 Thread Massimo Di Pierro
I do not think it is a memory leak.

Please run two tests:
1) What do you get with run with the built-in server instead of
apache?

2) what is the output of

print db(db.data).select('sum(length(data.body)
+length(data.body1)+length(data.body2)+length(data.body3))')

I suspect it may be a big numbers you are fetching all your records at
once.

On Mar 4, 12:41 am, VP  wrote:
> My app has utilized much RAM over time, so I created a simple app to
> replicate the problem.  This is what I found out.
>
> First of all, the app:
>
> ++ Model (database is postgres):
> db.define_table('data',
>     Field('body','text',requires=IS_LENGTH(262144)),
>     Field('body1','text',requires=IS_LENGTH(262144)),
>     Field('body2','text',requires=IS_LENGTH(262144)),
>     Field('body3','text',requires=IS_LENGTH(262144)))
>
> ### I populate the database with about 1500 entries
> #from gluon.contrib.populate import populate
> #populate(db.data,100)
>
> ++ Controller:
> def index():
>     return dict( data = db().select(db.data.ALL) )
>
> ++ View/default/index.html:
> {{extend 'layout.html'}}
> {{i=1}}
> {{ for d in data: }}
>     {{=i}}. {{=d.body}} {{=d.body1}} {{=d.body2}} {{=d.body3}}.
>     {{i+=1}}
> {{ pass }}
>
> ==
>
> Apache configuration: 5 processes, 1 thread   (more than 1 threads
> will cause WSGI premature script error as previously described).
>
> ==
>
> Result (this is with 1.92.1; 1.91.6 had same problem)
>
> A fresh apache restart gives each of 5 processes about 43MB.
>
> After using ab to stress test with 20 connections, 10 seconds,
> repeated several times, RAM starts crawling up to about 130MB per
> process.
>
> The RAM appears to be stuck there at 130MB/process and not released.
>
> At this point the RAM per process does not get increased with repeated
> testing... BUT Apache starts getting this error:
>
>
>
> IOError: failed to write data
> mod_wsgi (pid=12689): Exception occurred processing WSGI script '/home/
> vphan/web2py/wsgihandler.py'.
> <<<
>
> ==
>
> This is with the simple app above.  With my real app, RAM keeps
> getting increased and not released.
>
> It seems that if I load many rows (each with much data) into memory,
> we see this problem.
>
> Does the DAL leak memory?


[web2py] Re: potential memory leak???

2011-03-04 Thread Anthony
On Friday, March 4, 2011 1:41:13 AM UTC-5, VP wrote: 
>
> Apache configuration: 5 processes, 1 thread   (more than 1 threads 
> will cause WSGI premature script error as previously described).

 
I thought the WSGI premature script error problem was resolved by upgrading 
psycopg2 to a version greater than 2.0.7, as discussed here: 
https://groups.google.com/d/topic/web2py/AcCDl5eJnds/discussion. Did you 
upgrade psycopg2, and if so, did that not solve the problem for you (I mean, 
the premature script error problem, not the current memory leak problem)?
 
Anthony


Re: [web2py] how to change checkbox to button delete in SQLFORM

2011-03-04 Thread Richard Vézina
There is possibility, but I am not sure of the relevance of your needs.

1) jQuery (in view)
2) Once you have your form... (form = SQLFORM(db.table)) you can
modify the everything in there that will be under html (in
controller)... But it could brake the web2py workflow...
3) Build your own form from scratch with web2py Helpers (in controller)

Richard

On Fri, Mar 4, 2011 at 6:16 AM, Bruno Barbosa  wrote:
> I want change default checkbox to button in SQLFORM, suggestions?
>
> # ---
> # Bruno Barbosa
> # Seja livre - Use Linux!!!
> # http://algoritmizando.com
> # http://twitter.com/bruninbsb
> # ---
>


[web2py] Bug in MySQLAdapter

2011-03-04 Thread Milan Melena
I found bug in MySQLAdapter (repository version):

  1.1 --- a/gluon/dal.pyThu Mar 03 23:20:20 2011 -0600
 1.2 +++ b/gluon/dal.py Fri Mar 04 09:25:00 2011 +0100
 1.3 @@ -1470,11 +1470,11 @@
 1.4  charset = m.group('charset') or 'utf8'
 1.5  driver_args.update(dict(db=db,
 1.6
user=credential_decoder(user),
 1.7 -
password=credential_decoder(password),
 1.8 +
passwd=credential_decoder(password),
 1.9 host=host,
1.10 port=port,
1.11 charset=charset))
1.12 -def connect(dbpath=dbpath,driver_args=driver_args):
1.13 +def connect(driver_args=driver_args):
1.14  return self.driver.connect(**driver_args)
1.15  self.pool_connection(connect)
1.16  self.cursor = self.connection.cursor()

Best regards
Milan Melena


[web2py] Multiple forms grouped as one (django formset equivalent) with jquery plugin allowing clients to add and remove forms on the client-side

2011-03-04 Thread ChrisT
Hello everyone,

I am in the process of evaluating web2py and django to decide which
one I am going to use for a project of mine.
I am new to both frameworks and web frameworks in general (although I
did experiment with Ruby on Rails a while back)
I must say I am learning web2py much faster than Django which has a
much steeper learning curve I think.
For the past few days however I am trying to figure out the best way
to do a (relatively) simple thing with both frameworks that I guess
many people did before me.
I wanted to have multiple forms grouped as one on a sigle page and a
jquery plugin allowing clients to add and remove forms on the client-
side.
This would be very useful in many situations in my application.
One example would be:
   * Creating an invoice (table invoice with fields such as
reference_no , issue_date, customer_name, etc.) with multiple invoice
lines (table invoice_line with fields such as description, amount,
etc.)
So I need to create a single form for the invoice creation and the
client must be able to add or remove from the form as many
invoice_lines as needed each time.
The fact is that I was able to figure the best way to do it in Django
would be using formsets:
http://docs.djangoproject.com/en/dev/topics/forms/formsets/
and this: http://code.google.com/p/django-dynamic-formset/ jQuery
pluging
I am troubled I didn't find anything similar implemented in web2py, I
am sure many people before me did the same thing using both
frameworks. I found some pieces of code here and there that enabled me
to come close to doing it using web2py but I consider my efforts a
hack (and an incomplete one so far :-))
I would like to know your opinions on how this should be done in
web2py or how someone already did this.
Please forgive my ignorance if I am missing the obvious here as I am
new to all this. In fact this is my first post so go easy on me...

Regards,
ChrisT


[web2py] web2py console doesn't show activity

2011-03-04 Thread Tamas
Hi there,

I updated my web2py installation recently and after the update the
small window where I type IP, port and password doesn't show webserver
access any more. It was a pretty good feature that showed a green peak
every time I connected to the server.
Does somebody know why it is not working now?

Thanks
Tamas


[web2py] how to change checkbox to button delete in SQLFORM

2011-03-04 Thread Bruno Barbosa
I want change default checkbox to button in SQLFORM, suggestions?


# ---
# Bruno Barbosa
# Seja livre - Use Linux!!!
# http://algoritmizando.com
# http://twitter.com/bruninbsb
# ---


[web2py] cant use the python set function

2011-03-04 Thread Suhail Thakur
Hello,


in python there is a standard function set, which is used to uniquify
a list, the thing i can't use this in web2py, because in web2py/gluon/
contrib/memcache/__init__.py and web2py/gluon/contrib/memcache/
memcache.py there is a function named set which conflicts with the
python's standard function.

how are others managing without set function ?



Suhail


[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-04 Thread Eduardo
Thank you very much, Anthony. Your explanation and solution was
exactly what I needed.

Eduardo

On 4 mar, 00:23, Anthony  wrote:
> On Thursday, March 3, 2011 1:19:14 PM UTC-5, Eduardo wrote:
>
> > Thank you all. Editing appadmin will do. I am, however, having a hard
> > time identifying export_to_csv( ) either in views/appadmin.html or
> > appadmin.py. While import_from_csv is clearly called from within
> > appadmin.import_csv, I am unable to identify how export_to_csv is
> > called there.
>
> The export is done by the csv() function in 
> appadmin.py:http://code.google.com/p/web2py/source/browse/applications/welcome/co...
>
> That function returns:
>
> str(db(query).select())
>
> The db(query).select() is a DAL Rows object, and since it is passed to
> str(), the __str__ method of the Rows class is applied. You can see the
> __str__ method of the Rows class in dal.py 
> here:http://code.google.com/p/web2py/source/browse/gluon/dal.py#4850
>
> 
> As you can see, the __str__ method ultimately calls the export_to_csv_file
> method, which is 
> here:http://code.google.com/p/web2py/source/browse/gluon/dal.py#4947
>
> I suppose you could write your own export_tab_delimited function that works
> like __str__ but passes delimiter='\t' to export_to_csv_file. Maybe
> something like this added to appadmin.py:
>
> import cStringIO
> def export_tab_delimited(rows):
>     s = cStringIO.StringIO()
>     rows.export_to_csv_file(s, delimiter='\t')
>     return s.getvalue()
>
> And then change the last line of the csv() function to:
>
>     return export_tab_delimited(db(query).select())
>
> Anthony


[web2py] Weird self submitting forms all checkbox is checked after submit

2011-03-04 Thread szimszon
If I Submit form data which contains checkbox (boolean) field I got
back the form with all checkbox selected...

The database operation is ok. Just the returning form is displayed
with all checkbox checked...


[web2py] Re: Error in templating system

2011-03-04 Thread szimszon
Don't know could be but

The interpreter which checks the syntax about all the pass-es are in
right place give me the syntax error. What I try to say that first I
visit the page the msg is None so the "if" branch isn't executed at
all.

If I just byte compile the app I have the same syntax error message.
And if I close the =XML(msg) with }} and open before pass everything
is right. :(

On márc. 4, 11:26, pbreit  wrote:
> Oh, ok, I see, sorry about that. So it somehow dropped the closing ) after 
> =XML(msg).
> Could your msg have any special characters in it? I see some UTF-8 related
> diffs in the code for html.py recently.


[web2py] mysql dal.py boolean field

2011-03-04 Thread szimszon
I had a mysql table with boolean field but there was some rows with
empty fields than I got that:

Traceback (most recent call last):
File "applications/serveradmin/compiled/controllers_integrity_ftp.py",
line 191, in ftp
File "/usr/local/web2py/gluon/dal.py", line 4605, in select return
self.db._adapter.select(self.query,fields,attributes)
File "/usr/local/web2py/gluon/dal.py", line 1027, in select return
self.parse(rows,self._colnames)
File "/usr/local/web2py/gluon/dal.py", line 1225, in parse if value ==
True or str(value)[0].lower() == 't':
 IndexError: string index out of range

+-+---+--+-+-+
+
| Field   | Type  | Null | Key | Default | Extra
|
+-+---+--+-+-+
+
| User| varchar(128)  | NO   | UNI | |
|
| status  | enum('0','1') | NO   | | 0   |
|

It's an outer DB I just connect to it (migrate=False). After I put a
value to all the status field everything is working OK.


[web2py] Re: Error in templating system

2011-03-04 Thread pbreit
Oh, ok, I see, sorry about that. So it somehow dropped the closing ) after 
=XML(msg). 
Could your msg have any special characters in it? I see some UTF-8 related 
diffs in the code for html.py recently.

[web2py] Re: Error in templating system

2011-03-04 Thread szimszon

Yes I already did it and I mentioned it in the code above but the
point is that it was working until I upgraded the framework. The
original syntax was good too I mean I can't see what is wrong with it.
So it's a backward compatibility issue :(


On márc. 4, 10:58, pbreit  wrote:
> Maybe try closing up the pass with }} and then reopening the rest of the code?


[web2py] Error in templating system

2011-03-04 Thread pbreit
Maybe try closing up the pass with }} and then reopening the rest of the code?


[web2py] Error in templating system

2011-03-04 Thread szimszon
web2py™ Version 1.92.1 (2011-02-16 15:04:40)
Python  Python 2.5.2: /usr/bin/python

Traceback (most recent call last):
  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 186, in
restricted
ccode = compile2(code,layer)
  File "/home/szimszon_nfs/web2py/gluon/restricted.py", line 173, in
compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
'exec')
  File "/home/szimszon_nfs/web2py/applications/serveradmin/views/
integrity/ftp.html", line 123
pass
   ^
SyntaxError: invalid syntax

if msg:
response.write('\n', escape=False)
response.write(T("Commands executed"))
response.write('\n', escape=False)
response.write(XML(msg)
pass

My template was working until now (I don't know exactly from what
web2py version is it bad).

My template was:

{{if msg:}}
{{=T("Commands executed")}}
{{  =XML(msg)
pass
try:
  dname=request.args[1]
except:
  dname=0
pass
editname=T('New')}}

Now I had to modify:

{{if msg:}}
{{=T("Commands executed")}}
{{  =XML(msg)}}  < -
{{pass <---
try:
  dname=request.args[1]
except:
  dname=0
pass
editname=T('New')}}


[web2py] From .represent to csv: is this possible?

2011-03-04 Thread Johann Spies
I have a generic 'show_data'  function in my controller using the .represent
functions in the models to show linked fields correctly.

The clients wants the same now in the csv-downloads from the same data shown
by show_data.

There are many tables involved - it might be more than 20 and I do not want
to define a separate function or query for each one of them.  I am looking
for a way to adjust the query if any of those fields contained the
referenced data in question.

I do not know whether something like the following pseudocode is possible or
how to do it:

def csv_query(table):
refs = []
 queryfields = db[table].fields()
 if 'teacher' in queryfields:
refs.append('teacher')
index = queryfields('teacher')
queryfields.remove('teacher')
queryfields.insert(index-1,teacher.name)
 if 'school' in queryfields:
(you get the idea)

 return dict(queryfields=queryfields, refs = refs)

and then use the return value like this:

refs, queyfields = csv_query[table]
db(build this part of the query from refs eg (db.esp04.teacher ==
db.teacher.id) & db.esp04.school == db.school.id).select(build this part of
the query from queryfields eg(db.esp04.all the fields except 'school' and
'teacher' and those two replaced by db.school.name and db.teacher.name) )

Regards

Johann


-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-04 Thread ron_m
Thanks, it is easy to see how the default parameter gets changed with that 
example since the binding passes back outside the function through the 
return value, gets assigned to another variable and then the container 
contents modified through that assignment.