[web2py] [OFF] what-should-a-developer-know-before-building-a-public-web-site

2011-08-16 Thread Bruno Rocha
useful reading

http://programmers.stackexchange.com/questions/46716/what-should-a-developer-know-before-building-a-public-web-site


Re: [web2py] Re: How to insert icons into a column of a table created using SQLTABLE()

2011-08-16 Thread Bruno Rocha
On Wed, Aug 17, 2011 at 3:28 AM, TomPliss  wrote:

> Can't you use the represent field of the column, to show an image ?


Yes you can.


db.table.field.represent = lambda value: IMG(_src=URL(...), _alt=value)


[web2py] Re: ajax Jquery code for button

2011-08-16 Thread TomPliss
Hey (little noob here),

If you can generate
+
can't you generate
+
?

And the Ajax function changes to
*function addButtonCallback(myDate) {
so that you can access to "2011-08-17" in your function.
I don't know anything about the Ajax->web2py aspect, but the pure Ajax
aspect, should work as it ;)


On Aug 17, 12:00 am, IK  wrote:
> Hi,
>
> I'm trying to implement this jquery 
> pluginhttp://collectivegarbage.wordpress.com/2011/06/22/abhorred-calendar,
> check the demohttp://mithundaa.kodingen.com/and 
> githubhttps://github.com/mithun-daa/abhorredCalendar. I was playing with this 
> for
> few days, I tried to reuse examples in book and I searched throughout this
> group, but couldn't crack it or find similar examples or behavior.
>
> Could somebody suggest what would be jquery code for button ajax call?
>
> in view, jquery function which triggers onclick event to increase hours by
> one is:
>
> *function addButtonCallback() {*
> *         //I need this code*
> *         //not sure how to pass button id="2011-08-16" value as variable to
> web2py (request.vars.name worked at some stage but if I try with id, output
> is None )*
> *        }*
>
> html code for button id value is dynamically generated
>  + 
>
> let's say this is the model
>
> ## model
> db.define_table("calendar",
>     Field('date',type="date"),
>     Field('hours',type="integer"))
>
> Controller should be easy enough to write once jquery part is sorted and
> variables are passed to web2py... I hope ;)
>
> Thanks for your help
>
> Regards,
> IK


[web2py] Re: DAL query - GAE & local

2011-08-16 Thread Massimo Di Pierro
Can you try:

db(db.Statuses).select().first()

did you check with the GAE console that the record is there?

On Aug 16, 8:21 pm, ram  wrote:
> Thanks for your response. My problem is there is a record in the
> database. While standalone returns a record, while in GAE environment,
> it returns none.
>
> On Aug 16, 11:40 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Nothing. first() returns None if there is no first record. Try
>
> >      row = db().select(db.Statuses.ALL).first() or 'nothing to see
> > here'
>
> > On Aug 16, 1:09 pm, ram  wrote:
>
> > > This  following code segment displays the first row from the table in
> > > the view correctly when run using ./web2py. It returns None when run
> > > in GAE development environment. What's wrong with this code?
>
> > > Controller:
> > > def print_status():
> > >     row = db().select(db.Statuses.ALL).first()
> > >     return dict(message=row)
>
> > > in the view, I have the default code:
> > > {{extend 'layout.html'}}
> > > This is the default/test_db.html template
> > > {{=BEAUTIFY(response._vars)}}
>
> > > Thanks in advance


[web2py] Re: How to insert icons into a column of a table created using SQLTABLE()

2011-08-16 Thread TomPliss
Can't you use the represent field of the column, to show an image ?

On Aug 17, 7:44 am, Bruno Rocha  wrote:
> use virtualfields for that.
>
> class Virtual(object)
>         def my16pximage(self):
>              return IMG(_src=URl(...))
>
> db.table.virtualfields.append(Virtual())
>
> table = SQLTABLE(db.table)
>
> On Tue, Aug 16, 2011 at 1:23 PM, Valter Foresto 
> wrote:
>
> > I'm using SQLTABLE() into a controller to generate a table for the next
> > view.
>
> > A column of the table report only few states (text) that can might be
> > better represented using small, 16x16 or 32x32, images.
> > It is possible to insert icons, instead of text, into a table column and
> > then pass the result to the viewer ?
>
> > Thanks in advance for suggestions.
> > Valter
>
> --
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
> [ Aprenda a programar:http://CursoDePython.com.br]
> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> [ Consultoria em desenvolvimento web:http://www.blouweb.com]


Re: [web2py] How to insert icons into a column of a table created using SQLTABLE()

2011-08-16 Thread Bruno Rocha
use virtualfields for that.

class Virtual(object)
def my16pximage(self):
 return IMG(_src=URl(...))


db.table.virtualfields.append(Virtual())

table = SQLTABLE(db.table)



On Tue, Aug 16, 2011 at 1:23 PM, Valter Foresto wrote:

> I'm using SQLTABLE() into a controller to generate a table for the next
> view.
>
> A column of the table report only few states (text) that can might be
> better represented using small, 16x16 or 32x32, images.
> It is possible to insert icons, instead of text, into a table column and
> then pass the result to the viewer ?
>
> Thanks in advance for suggestions.
> Valter
>



-- 



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


Re: [web2py] How to customize widget rendering in form

2011-08-16 Thread Bruno Rocha
insert in any place before the crud creation (model or controller)

crud.settings.formstyle = 'divs'

On Wed, Aug 17, 2011 at 2:15 AM, Noel Villamor  wrote:

> I have this for a field definition:
>
> Field('tags','list:reference
> tag',widget=SQLFORM.widgets.checkboxes.widget)
>
> I use crud and it renders the field as an html table, as shown below:
>
> 
> business tr>
> family
> friend
> 
>
> How do I customize the rendering into:
>
> 
> business
> family
> friend
> 
>
> Thanks in advance.




-- 



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


[web2py] How to customize widget rendering in form

2011-08-16 Thread Noel Villamor
I have this for a field definition:

Field('tags','list:reference
tag',widget=SQLFORM.widgets.checkboxes.widget)

I use crud and it renders the field as an html table, as shown below:


business
family
friend


How do I customize the rendering into:


business
family
friend


Thanks in advance.


[web2py] Re: Insert not working on Keyed Table

2011-08-16 Thread Andrew
Hi Again,
I did infact change my controller while testing from
form=SQLFORM(...   to form=FORM(
I've changed it back to SQLFORM and it all works great.

Good job and thankyou for the quick response.

Regards
Andrew W

On Aug 17, 3:18 am, DenesL  wrote:
> Fixed in trunk.
> Please test.


[web2py] Re: Insert not working on Keyed Table

2011-08-16 Thread Andrew
Thanks Denes,
The Admin "database administration" inserts now work correctly, but my
simple application form doesn't.  I'll recheck my own app as there may
be an issue there (It's my first one).


On Aug 17, 3:18 am, DenesL  wrote:
> Fixed in trunk.
> Please test.


Re: [web2py] Re: custom form trouble

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 11:35:40 PM UTC-4, Bruno Codeman wrote:
>
> Thanks for answering, Denes. I included manually the  tags 
> because it wasn't been generated by web2py. I thought it very strange, but 
> I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol). 
> Thanks for helping me again.

 
You have {{form.custom.begin}}, but it should be {{=form.custom.begin}} 
(same for form.custom.end).
 
Anthony
 


Re: [web2py] Re: custom form trouble

2011-08-16 Thread Bruno de Oliva Bemfica
Thanks for answering, Denes. I included manually the  tags
because it wasn't been generated by web2py. I thought it very strange, but
I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol).
Thanks for helping me again.

2011/8/16 DenesL 

> Hi Bruno,
>
> not sure if this is the problem but I believe you can not have nested
> forms.
> Your view has:
>
>  {{form.custom.begin}}
>  
>  
>
> and
>
>  
>  
>  © 2011, Groupon Inc. Todos os direitos
> reservados.
>  {{form.custom.end}}
>
> form.custom begin and end contain the opening  and closing  form> tags,
> so you will have an invalid construct of a form inside another.
>
> Denes




-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: custom form trouble

2011-08-16 Thread DenesL
Hi Bruno,

not sure if this is the problem but I believe you can not have nested
forms.
Your view has:

  {{form.custom.begin}}
  
  

and

  
  
  © 2011, Groupon Inc. Todos os direitos
reservados.
  {{form.custom.end}}

form.custom begin and end contain the opening  and closing  tags,
so you will have an invalid construct of a form inside another.

Denes


[web2py] Re: DAL query - GAE & local

2011-08-16 Thread ram
Thanks for your response. My problem is there is a record in the
database. While standalone returns a record, while in GAE environment,
it returns none.

On Aug 16, 11:40 pm, Massimo Di Pierro 
wrote:
> Nothing. first() returns None if there is no first record. Try
>
>      row = db().select(db.Statuses.ALL).first() or 'nothing to see
> here'
>
> On Aug 16, 1:09 pm, ram  wrote:
>
>
>
> > This  following code segment displays the first row from the table in
> > the view correctly when run using ./web2py. It returns None when run
> > in GAE development environment. What's wrong with this code?
>
> > Controller:
> > def print_status():
> >     row = db().select(db.Statuses.ALL).first()
> >     return dict(message=row)
>
> > in the view, I have the default code:
> > {{extend 'layout.html'}}
> > This is the default/test_db.html template
> > {{=BEAUTIFY(response._vars)}}
>
> > Thanks in advance


[web2py] Re: custom form trouble

2011-08-16 Thread pbreit
Probably need to see the relevant controller and view code.

[web2py] custom form trouble

2011-08-16 Thread Bruno de Oliva Bemfica
Hi, I'm trying to make a customized login form and when I click the submit
button, the screen just blink, but no response. I'm using cas auth.

-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: migrate file system uploads to database?

2011-08-16 Thread Massimo Di Pierro
I am afraid it will not move the files. You have to do that yourself.
There should be a script to do it. Please open a ticket in google
code.

Massimo

On Aug 16, 5:24 pm, Mothmonsterman  wrote:
> Thank you, Massimo. Web2py rocks!
>
> I saw what you are saying in the docs as how to setup the model for
> filesystem vs. db, but what I was wondering was how one would switch
> after the app has already been deployed and files are sitting in /
> uploads. Will updating the model move whats currently in uploads/ to
> the newly defined 'myblob'?.. Or is it something that must be done
> from the start either one way or the other?.. Or maybe its something
> that could be done with a nice little bit of code?.. Thanks again.
>
> On Aug 16, 4:24 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > normally:
>
> > Field('name','upload'),...
>
> > to upload to db
>
> > Field('name','upload',uploadfield="myblob"),Field('myblob','blob',default=' 
> > '),...
>
> > or just
>
> > Field('name','upload',uploadfield="myblob"),...
>
> > as this is implicit: Field('myblob','blob',default='')
>
> > On Aug 15, 8:10 pm, Mothmonsterman  wrote:
>
> > > Hello,
>
> > > I read the docs and searched the posts to see if there was an easy way
> > > to migrate file system uploads to database. I could not find
> > > anything.. Please excuse me if I missed something obvious, but does
> > > anyone know of a way to accomplish this in a batch process? Thanks.
>
> > > Patrick


[web2py] Re: web2py server console print limit?

2011-08-16 Thread Massimo Di Pierro
Not that I know.

On Aug 16, 4:45 pm, António Ramos  wrote:
> hello,
> does the server console has a limit in the amount of printed data?
>
> i have an application that every time it is acessed it prints to the console
> so i can see for debugging purposes who was logged and the queries they
> made,etc.
>
> Will the server hang with the amount of printed data?
>
> The server console is good for this purpose
>
> Just a side note.
> It would be cool if i could print text in different colors for different
> purposes...
>
> thank you
>
> António


[web2py] Re: {{web2py_conflict}}

2011-08-16 Thread Massimo Di Pierro
you can pass delimiters=('') to the gluon/remplate.py
render function but you have to call it explicitly. I do not want to
encourage it. It can only cause portability issues.

On Aug 16, 4:24 pm, Niphlod  wrote:
> another way to go is "redefine" delimiters of template.
>
> http://groups.google.com/group/web2py/browse_thread/thread/40e0d80807...


[web2py] Re: migrate file system uploads to database?

2011-08-16 Thread Mothmonsterman
Thank you, Massimo. Web2py rocks!

I saw what you are saying in the docs as how to setup the model for
filesystem vs. db, but what I was wondering was how one would switch
after the app has already been deployed and files are sitting in /
uploads. Will updating the model move whats currently in uploads/ to
the newly defined 'myblob'?.. Or is it something that must be done
from the start either one way or the other?.. Or maybe its something
that could be done with a nice little bit of code?.. Thanks again.


On Aug 16, 4:24 am, Massimo Di Pierro 
wrote:
> normally:
>
> Field('name','upload'),...
>
> to upload to db
>
> Field('name','upload',uploadfield="myblob"),Field('myblob','blob',default=' 
> '),...
>
> or just
>
> Field('name','upload',uploadfield="myblob"),...
>
> as this is implicit: Field('myblob','blob',default='')
>
> On Aug 15, 8:10 pm, Mothmonsterman  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I read the docs and searched the posts to see if there was an easy way
> > to migrate file system uploads to database. I could not find
> > anything.. Please excuse me if I missed something obvious, but does
> > anyone know of a way to accomplish this in a batch process? Thanks.
>
> > Patrick


[web2py] proper usage of exclusive_domain = True ?

2011-08-16 Thread vapirix
So I'm attempting to set up the usage scenario of:

domain1.com -> load app 1
domain2.com -> load app 2
etc. etc.

I need domain1 to NOT have access to app 2, 3, 4, 5, etc.

That all works using the router's "domain" settings. Obviously you run
into the problem of: domain1.com loads app1, but domain1.com/app2
loading app2, so I use "exclusive_domain = True", and then I have to
do domain1.com/app1/ to load the app without raising an exception,
which seems counter productive. Besides that, even with
exclusive_domain = True, I can do domain1.com/app2 to load the second
app. Is there any way to do what I'm attempting to do here? I'd rather
not have to set up separate web2py installs for the tons of tiny apps
I do for my clients that get 1 hit every 6 months.

What can I do here, friends?


[web2py] ajax Jquery code for button

2011-08-16 Thread IK
Hi,

I'm trying to implement this jquery plugin 
http://collectivegarbage.wordpress.com/2011/06/22/abhorred-calendar,
 
check the demo http://mithundaa.kodingen.com/ and github 
https://github.com/mithun-daa/abhorredCalendar. I was playing with this for 
few days, I tried to reuse examples in book and I searched throughout this 
group, but couldn't crack it or find similar examples or behavior.

Could somebody suggest what would be jquery code for button ajax call?

in view, jquery function which triggers onclick event to increase hours by 
one is:

*function addButtonCallback() {*
* //I need this code*
* //not sure how to pass button id="2011-08-16" value as variable to 
web2py (request.vars.name worked at some stage but if I try with id, output 
is None )*
*}*

html code for button id value is dynamically generated
 + 


let's say this is the model

## model
db.define_table("calendar",
Field('date',type="date"),
Field('hours',type="integer"))

Controller should be easy enough to write once jquery part is sorted and 
variables are passed to web2py... I hope ;)

Thanks for your help

Regards,
IK


[web2py] Re: dowloading attachments with AJAX

2011-08-16 Thread mart
Hi Mic!

This is very interesting! :) how does it work?  you have
"URL('gen_pdf')", what is that referencing?

would you have a model/sample app that we could peek at? :)


Thanks,
Mart :)


On Aug 15, 4:47 pm, Michele Comitini 
wrote:
> Suppose you want to make an AJAX call that starts a file download.
> How can you do that?
> 1. form submission
> 2. a element href
> 3. iframe
>
> Too complex!
>
> of course *web2py* comes to rescue...
> BIG NOTE: the following is based on 'data:' url type and was tested
> only on FF and chrome. I do not have
>  IE but I suppose that  is not compatible with the standard!
>
> In your view put a web2py ajax call similar to the following wherever
> you need it:
>
> ajax('%s',[],':eval');" % URL('gen_pdf')
>
> ex.
>
> {{=A(T('be brave!'), _onclick="ajax('%s',[],':eval');" %
> URL('gen_pdf'), _class='button')}}
>
> in the controller use embed64.
>
> def gen_pdf():
>     from gluon.contrib.pyfpdf import FPDF
>
>     pdf=FPDF()
>     pdf.add_page()
>     pdf.set_font('Arial','B',16)
>     pdf.cell(40,10,'Hello World at %s!' % request.now)
>     doc=pdf.output(dest='S')
>
>     doc64=embed64(data=doc,extension='application/pdf')
>
>     return 'window.location="%s";' % doc64
>
> have fun!
>
> mic


Re: [web2py] How to insert icons into a column of a table created using SQLTABLE()

2011-08-16 Thread Richard Vézina
The same way I do deletion with this function you can add stuff or replace
stuff base on a if case on your differents text states... Not the best
approach I think, but you can...

def __del_sqltable_column(sqltable, column_name):
"""
For deleting a given column in an instance of web2py SQLTABLE class.
Pass the SQLTABLE object and the column name to delete.
Ex.: table1 = SQLTABLE(rows) contains id column and we want to delete
it.
So we call __del_sqltable_column(tabel1, 'table.id') or
__del_sqltable_column(request.args(0), db[request.args(0)].id)
When the column name is changed with represent the representation should
be
passed as column name.
"""
import re
regex_colum_name = re.compile(str(TH(column_name)))
for i in range(0, len(sqltable[0][0])):
if regex_colum_name.match(str(sqltable[0][0][i])):
for r in range(0, len(sqltable[1])):
del(sqltable[1][r][i])
del(sqltable[0][0][i])
return sqltable
return sqltable

Hope it helps.

Richard

On Tue, Aug 16, 2011 at 12:23 PM, Valter Foresto
wrote:

> I'm using SQLTABLE() into a controller to generate a table for the next
> view.
>
> A column of the table report only few states (text) that can might be
> better represented using small, 16x16 or 32x32, images.
> It is possible to insert icons, instead of text, into a table column and
> then pass the result to the viewer ?
>
> Thanks in advance for suggestions.
> Valter
>


Re: [web2py] navbar missing space before bracket

2011-08-16 Thread Richard Vézina
Did this one commited too!!

;-)

Richard

On Mon, Aug 15, 2011 at 11:36 AM, Richard wrote:

> Hello,
>
> Would you correct this little glitch (gluon tools.py line 1101) :
>
> Change :
> bar = SPAN(prefix,self.user.first_name,' [ ', logout,
> ']',_class='auth_navbar')
>
> For :
> bar = SPAN(prefix,self.user.first_name,' [ ', logout,
> ' ]',_class='auth_navbar')
>
> Thanks
>
> Richard


[web2py] web2py server console print limit?

2011-08-16 Thread António Ramos
hello,
does the server console has a limit in the amount of printed data?

i have an application that every time it is acessed it prints to the console
so i can see for debugging purposes who was logged and the queries they
made,etc.


Will the server hang with the amount of printed data?

The server console is good for this purpose

Just a side note.
It would be cool if i could print text in different colors for different
purposes...

thank you

António


[web2py] Re: {{web2py_conflict}}

2011-08-16 Thread Niphlod
another way to go is "redefine" delimiters of template.

http://groups.google.com/group/web2py/browse_thread/thread/40e0d80807e14000/be29ae833c5ef23a


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Massimo Di Pierro
Decorators will only make thinks worse (because all decorators in the
same controller are still executed at ever request for any function in
the controller). importing should speed things a bit (i.e. move the
db.define_table in a function called in a module, importing the
module, calling the function). I do not expect a major speed-up.

On Aug 16, 3:11 pm, pbreit  wrote:
> I wonder if conditional model loading would be best performed with either
> decorators or, dare I say it, importing (if either is even possible)?


[web2py] Re: MSSQL Field Name: file is not allowed

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 3:43:41 PM UTC-4, Omi Chiba wrote:
>
> I just want to share my experience which takes hours to figure out. I 
> was reading web2py book - 03 Overview - An Image Blog, it worked fine 
> with SQLite and tried to use mssql server on my local PC which is also 
> the new experience to me... 
>
> Replaced the DAL for sqlite with mssql 
> db = DAL("sqlite://storage.sqlite") 
> => db = DAL("mssql://ID:PASS@SERVERNAME\SQLEXPRESS/images") 
>
> db.define_table('image', 
>Field('title'), 
>Field('file', 'upload')) 
>
> Then It complains  "Incorrect syntax near the keyword 'file'. 
>
> ... the problem was that field name "file" is reserved word for mssql 
> server and cannot use it even I run the statement directly on the 
> server.. 
>
> CREATE TABLE image( 
> id INT IDENTITY PRIMARY KEY, 
> title VARCHAR(512) NULL, 
> file VARCHAR(512) NULL 
> ); 
>
> But it actually allow to create the field called "file" using new 
> table wizard. 
> It's very strange.

 
The wizard prepends 'f_' before each field name, so it would be 'f_file', 
which obviously won't cause an error.
 
Note, there is a 'check_reserved' argument to help you identify reserved 
keywords for each database: 
http://web2py.com/book/default/chapter/06#Reserved-Keywords.
 
Anthony
 

>  



[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread pbreit
I wonder if conditional model loading would be best performed with either 
decorators or, dare I say it, importing (if either is even possible)?

[web2py] MSSQL Field Name: file is not allowed

2011-08-16 Thread Omi Chiba
I just want to share my experience which takes hours to figure out. I
was reading web2py book - 03 Overview - An Image Blog, it worked fine
with SQLite and tried to use mssql server on my local PC which is also
the new experience to me...

Replaced the DAL for sqlite with mssql
db = DAL("sqlite://storage.sqlite")
=> db = DAL("mssql://ID:PASS@SERVERNAME\SQLEXPRESS/images")

db.define_table('image',
   Field('title'),
   Field('file', 'upload'))

Then It complains  "Incorrect syntax near the keyword 'file'.

... the problem was that field name "file" is reserved word for mssql
server and cannot use it even I run the statement directly on the
server..

CREATE TABLE image(
id INT IDENTITY PRIMARY KEY,
title VARCHAR(512) NULL,
file VARCHAR(512) NULL
);

But it actually allow to create the field called "file" using new
table wizard.
It's very strange.



[web2py] XMPP chat client

2011-08-16 Thread Fernando Macedo
Hello all,

I'm trying to figure out how to implement a xmpp chat bot to run some
intranet queries and return those data. Like add the bot as friend on Google
Talk, and ask him a 'list employees' command.

I'd like to use the built-in server (not in gae).

Is there an easy way to get this working?

Can anyone suggest me the first steps or some reference? I've also googled
it, but I don't know much about de xmpp protocol itself.


Thanks in advance,

Fernando Macedo

"Somos o que repetidamente fazemos; a excelência, portanto, não é um feito,
mas sim um hábito!" - Aristóteles


[web2py] Re: book translations

2011-08-16 Thread Anthony
The markmin is successfully updating, but the rendered HTML is remaining the 
same. Is it a caching issue?
 
Anthony

On Tuesday, August 16, 2011 1:32:13 PM UTC-4, Massimo Di Pierro wrote:

> can you try now? 
>
> On Aug 16, 11:05 am, Anthony  wrote: 
> > On Tuesday, August 16, 2011 11:45:12 AM UTC-4, DenesL wrote: 
> > 
> > > Submitting changes does not update the book. 
> > > Anybody else having the same issue?. 
> > 
> > Good catch -- I thought I made a change earlier, but looks like it didn't 
>
> > update. 
> > 
> > Anthony



[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Ross Peoples
So then my previous example for having two controllers access the same model 
is still valid?

[web2py] Re: DAL query - GAE & local

2011-08-16 Thread Massimo Di Pierro
Nothing. first() returns None if there is no first record. Try

     row = db().select(db.Statuses.ALL).first() or 'nothing to see
here'


On Aug 16, 1:09 pm, ram  wrote:
> This  following code segment displays the first row from the table in
> the view correctly when run using ./web2py. It returns None when run
> in GAE development environment. What's wrong with this code?
>
> Controller:
> def print_status():
>     row = db().select(db.Statuses.ALL).first()
>     return dict(message=row)
>
> in the view, I have the default code:
> {{extend 'layout.html'}}
> This is the default/test_db.html template
> {{=BEAUTIFY(response._vars)}}
>
> Thanks in advance


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Massimo Di Pierro
all files in

models/a/

are executed only for actions in controllers/a.py

all files in

models/a/b/

are executed only for actions b() in controllers/a.py

this is for every a and b.

On Aug 16, 1:14 pm, Ross Peoples  wrote:
> I didn't know could share a model file between two controllers by simply
> adding another folder. That's pretty cool and "magic" like. Would this work
> with a third controller as well?
>
> Like if you have 'address_book', 'mail', and 'calendar' controllers all
> needing to access a single model by doing this?:
>
> models/mail/address_book/calendar/db.py
>
> It true, then that could really help out a lot.


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Ross Peoples
I didn't know could share a model file between two controllers by simply 
adding another folder. That's pretty cool and "magic" like. Would this work 
with a third controller as well?

Like if you have 'address_book', 'mail', and 'calendar' controllers all 
needing to access a single model by doing this?:

models/mail/address_book/calendar/db.py

It true, then that could really help out a lot.


[web2py] DAL query - GAE & local

2011-08-16 Thread ram
This  following code segment displays the first row from the table in
the view correctly when run using ./web2py. It returns None when run
in GAE development environment. What's wrong with this code?

Controller:
def print_status():
row = db().select(db.Statuses.ALL).first()
return dict(message=row)

in the view, I have the default code:
{{extend 'layout.html'}}
This is the default/test_db.html template
{{=BEAUTIFY(response._vars)}}

Thanks in advance


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Massimo Di Pierro
The model is loaded at every request.

Instead of this

> if request.controller == 'mail' or request.controller == 'address_book':
>     db.define_table('contact',
>         Field('name'),
>         
>     )

you can just put this


>     db.define_table('contact',
>         Field('name'),
>         
>     )


into

modes/mail/address_book/db.py


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Ross Peoples
If I recall correctly, from my testing, the model is only really loaded once 
the first time the app is accessed. So Massimo is correct that loading is 
not the issue. The issue is that the model needs to be executed for every 
request, so breaking your models up will really help with this. Also, you 
may be able to throw a couple of performance tricks in there by 
conditionally loading tables based on the request object.

For example, if you have a 'contact' table that needs to be shared between 
the 'mail' and the 'address_book' controllers, then instead of making it 
global, you could do something like this in the model:

if request.controller == 'mail' or request.controller == 'address_book':
db.define_table('contact',
Field('name'),

)

So if you have a 100 controllers, but only two or three need access to a 
table, then this should speed things up.


Re: [web2py] Re: Noob question

2011-08-16 Thread Furqan Rauf
great answer, and your comment about developing ERP in web2py says it all I
am totally wowed how powerful it is I learned python when I started my
college and every employer I talk to since was about Java or C# .NET etc and
I totally neglected python until I was introduced to Django and now web2py
thanks guys you all are doing a great job.

again thanks for the answer.

On Tue, Aug 16, 2011 at 12:26 PM, Ross Peoples wrote:

> I haven't run web2py in a huge scalability setting before, but I know there
> are a couple in the forum that have. I know that last weekend, the
> web2py.com site had about 262,000 hits in one day, and I think that is
> running on a small VPS.net instance (if I remember correctly). The
> web2py.com site is actually running web2py, so that should say something.
> The result of most of the scalability questions is that the database is
> usually the thing that slows everything down (something that .NET developers
> have to deal with as well).
>
> Web2py really wants you to use MVC. I've never used .NET MVC3, but I can
> tell you that web2py makes a clear distinction of the MVC pattern by using
> folder names that coincide with each part (models, views, controllers). The
> main reason for big shops to use .NET is mostly the corporate backing of MS.
> They offer these shops some incentives when they start out to get them
> "hooked", then they charge through the nose after a while.
>
> I haven't used .NET for web development in quite a few years, so I can't
> comment on its current state. What I can tell you is that I could not have
> accomplished some of the things I have done with .NET, Java, Django, etc.
> The only language/framework combination that gave me the power and
> flexibility I needed was Python as web2py.
>
> As for the size of projects, there are quite a few (including myself) that
> are developing ERP applications (if you don't know what those are, think of
> the most complicated business application ever, ever that can basically run
> an entire company by itself). I have also developed an appliance using
> web2py that assists in the deployment and provisioning of servers.
>
> I think imagination is the only limitation here :)
>



-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


[web2py] Re: little admin improvement

2011-08-16 Thread Massimo Di Pierro
sure. in trunk. thanks!

On Aug 16, 11:29 am, Richard Vézina 
wrote:
> Will you add the mod to admin app?
>
> Richard
>
>
>
>
>
>
>
> On Tue, Aug 16, 2011 at 12:20 PM, Anthony  wrote:
> > On Tuesday, August 16, 2011 12:18:53 PM UTC-4, Anthony wrote:
>
> >> In URL(), args and vars are url encoded. Instead, use the anchor argument:
>
> >> URL('design',args=app,anchor='**#languages')
>
> > Sorry, that should be:
>
> >  URL('design',args=app,anchor='languages')
>
> > It will add the '#' for you.
>
> > Anthony


[web2py] Re: can I turn off the auto back-references?

2011-08-16 Thread Carlos
Hi Massimo,

It seems to be working great - thanks!,

   Carlos



[web2py] Re: book translations

2011-08-16 Thread Massimo Di Pierro
can you try now?

On Aug 16, 11:05 am, Anthony  wrote:
> On Tuesday, August 16, 2011 11:45:12 AM UTC-4, DenesL wrote:
>
> > Submitting changes does not update the book.
> > Anybody else having the same issue?.
>
> Good catch -- I thought I made a change earlier, but looks like it didn't
> update.
>
> Anthony


[web2py] Re: please help me test new form API

2011-08-16 Thread Ross Peoples
The compact will also reduce some mistakes. If you forget session, you can't 
use CSRF. So really, using form.process() assists in ensuring the security 
of the form.

[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Massimo Di Pierro
The problem is not loading. The time is spend in execution. If there
is a lot of logic in models and it is not conditional it must be
executed.

On Aug 16, 10:58 am, Jay  wrote:
> Massimo,
>
>  Would it be possible to only load db.py if it has changed and when
> changed generate a python object that is the db, and save/load it as
> required? I know it would work, But would it be too slow? Slower then
> running all of db.py.
>
>  I am looking at using web2py to write a small ERP like app. It could
> have 100's of tables. So keeping up the conditional models could be a
> nightmare!
>
> Regards,
>
> Jay Kelkar
>
> P.S. Happy 4th Birthday web2py! Many happy returns.


[web2py] Re: can I turn off the auto back-references?

2011-08-16 Thread Massimo Di Pierro
Great idea! In trunk:

  db._referee_name = '%(table)s' # default

and you can do

  db._referee_name = 'prefix_%(table)s_%(field)s'

This may still break plugins. Anyway, please check it.


On Aug 16, 10:23 am, Carlos  wrote:
> Hi Massimo,
>
> What about having a new  'referee_prefix' var in DAL, which defaults to
> empty string, and replacing:
>
>    colset[referee_table] = Set(db, s == id)
>
> with:
>
>    colset[*referee_prefix+*referee_table] = Set(db, s == id)
>
> And then just have a way to override this 'referee_prefix' value as a web2py
> setting or so.
>
> This way backward compatibility will not be broken (because of the initial
> default empty string value) and we can change the way we access such back
> references.
>
> Can this be included in trunk?.
>
> Thanks,
>
>    Carlos


[web2py] Re: Noob question

2011-08-16 Thread Ross Peoples
I haven't run web2py in a huge scalability setting before, but I know there 
are a couple in the forum that have. I know that last weekend, the 
web2py.com site had about 262,000 hits in one day, and I think that is 
running on a small VPS.net instance (if I remember correctly). The 
web2py.com site is actually running web2py, so that should say something. 
The result of most of the scalability questions is that the database is 
usually the thing that slows everything down (something that .NET developers 
have to deal with as well).

Web2py really wants you to use MVC. I've never used .NET MVC3, but I can 
tell you that web2py makes a clear distinction of the MVC pattern by using 
folder names that coincide with each part (models, views, controllers). The 
main reason for big shops to use .NET is mostly the corporate backing of MS. 
They offer these shops some incentives when they start out to get them 
"hooked", then they charge through the nose after a while.

I haven't used .NET for web development in quite a few years, so I can't 
comment on its current state. What I can tell you is that I could not have 
accomplished some of the things I have done with .NET, Java, Django, etc. 
The only language/framework combination that gave me the power and 
flexibility I needed was Python as web2py.

As for the size of projects, there are quite a few (including myself) that 
are developing ERP applications (if you don't know what those are, think of 
the most complicated business application ever, ever that can basically run 
an entire company by itself). I have also developed an appliance using 
web2py that assists in the deployment and provisioning of servers.

I think imagination is the only limitation here :)


[web2py] Re: please help me test new form API

2011-08-16 Thread Massimo Di Pierro
What do you think,

should recommend using

   if form.process().accepted:

over

   if form.accepts(request,session):

The only benefit is more compact notation.


On Aug 16, 8:53 am, Anthony  wrote:
> It still uses request.vars and session -- it just doesn't require you to
> explicitly pass them as arguments (if you don't pass them, it uses
> current.session and current.request.post_vars).
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, August 16, 2011 9:10:40 AM UTC-4, Richard wrote:
> > Hello,
>
> > Since process() not require request.vars and session does it make things
> > faster?
>
> > And if so, could it be percetible?
>
> > Thanks
>
> > Richard
>
> > On Mon, Aug 15, 2011 at 3:56 AM, Massimo Di Pierro 
> > wrote:
>
> >> I agree with you that having three ways to do the same thing is not
> >> good but:
>
> >> There are three reasons:
>
> >> 1) some people may want to validate without processing the form fully
> >> (no insert). shortcut to accepts(...dbio=True)
> >> 2) it allows to write onliners: form = SQLFORM().process()
> >> 3) no longer need to pass request and session.
>
> >> see process() replacing accepts() and I see validate() as a way to
> >> check if form validates without insertion.
>
> >> There are also some different defaults. If you do not pass a session
> >> to accepts(...) you do not get CRSF protection. In process(...) you
> >> must pass session=None explicitly to disable RSCF protection.
>
> >> We can talk more about these pros, cons, etc.
>
> >> These functions have been in web2py for a while. We just made them
> >> work better.
>
> >> On Aug 15, 12:25 am, pbreit  wrote:
> >> > I'm not totally clear on the gain here. Is it that flash messages get
> >> > automatically set? Is this going to splinter implementations (ie some
> >> will
> >> > use .accepts, some will use .process, others will use .validate)? Is
> >> that a
> >> > good thing?


[web2py] Noob question

2011-08-16 Thread Furqan Rauf
Hey guys,
I have another noob question just came to my mind while reading some online
article. Web2py implements MVC logic just like .NET MVC3 right? so why
companies shy away from using small frameworks as far as I am concern I
believe Web2py is nice for small projects and simpler than .NET (just worked
on it for 20 days) I dont know about the scalability of web2py though how
big of a project can it support? I would love to know the difference.

Thanks


-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


Re: [web2py] Re: ajax function returns None

2011-08-16 Thread Martin Weissenboeck
Sorry, my mistake...
It works!

There has been a file "one.html" and another file "one.html.bak"
The editor opens "one.html.bak" (why?), but web2py uses "one.html" (of
course!)

Thnak you very much!

2011/8/16 Martin Weissenboeck 

> Now I have tried:
>
> {{extend 'layout.html'}}
> 
> 
> 
> 
>
>
> Sorry, same result:  "None"
> echo is called, but request.vars does not contain any value.
> Martin
>
> 2011/8/16 Massimo Di Pierro 
>
> Try
>>
>> 
>>
>> I think this is typo in the book.
>>
>> On Aug 16, 6:53 am, Martin Weissenboeck  wrote:
>> > Hi,
>> >
>> > I have tried the example from chapter 10.3 The ajax Function
>> >
>> > Controller:
>> > def one():
>> > return dict()
>> >
>> > def echo():
>> > return request.vars.name
>> >
>> > one.html:
>> > {{extend 'layout.html'}}
>> > 
>> > 
>> > 
>> > 
>> >
>> > No success, because the value of request.vars.name is None
>> > Just for fun I have tried "request.now", "request.extension",
>> > "request.folder" and so on instead of "request.vars.name" - these
>> examples
>> > worked fine, but I had no chance to get the value of name.
>> >
>> > Version: web2py 1.98.2, started from source with Windows Python 2.7.2
>> > and web2py 1.98.2 Python 2.5
>> >
>> > What is wrong - any ideas?
>> >
>> > Regards, Martin
>>
>
>
>


Re: [web2py] little admin improvement

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 12:18:53 PM UTC-4, Anthony wrote:
>
> In URL(), args and vars are url encoded. Instead, use the anchor argument:
>  
> URL('design',args=app,anchor='#languages')
>  
>
 
Sorry, that should be:
 
 URL('design',args=app,anchor='languages')
 
It will add the '#' for you.
 
Anthony


[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Jay
Massimo,

 Would it be possible to only load db.py if it has changed and when
changed generate a python object that is the db, and save/load it as
required? I know it would work, But would it be too slow? Slower then
running all of db.py.

 I am looking at using web2py to write a small ERP like app. It could
have 100's of tables. So keeping up the conditional models could be a
nightmare!

Regards,

Jay Kelkar

P.S. Happy 4th Birthday web2py! Many happy returns.


[web2py] How to insert icons into a column of a table created using SQLTABLE()

2011-08-16 Thread Valter Foresto
I'm using SQLTABLE() into a controller to generate a table for the next 
view. 

A column of the table report only few states (text) that can might be better 
represented using small, 16x16 or 32x32, images.
It is possible to insert icons, instead of text, into a table column and 
then pass the result to the viewer ?  

Thanks in advance for suggestions.
Valter


Re: [web2py] little admin improvement

2011-08-16 Thread Richard Vézina
Will you add the mod to admin app?

Richard

On Tue, Aug 16, 2011 at 12:20 PM, Anthony  wrote:

> On Tuesday, August 16, 2011 12:18:53 PM UTC-4, Anthony wrote:
>>
>> In URL(), args and vars are url encoded. Instead, use the anchor argument:
>>
>> URL('design',args=app,anchor='**#languages')
>>
>>
>
> Sorry, that should be:
>
>  URL('design',args=app,anchor='languages')
>
> It will add the '#' for you.
>
> Anthony
>


Re: [web2py] little admin improvement

2011-08-16 Thread Richard Vézina
Ok, I was really sad I can't figure out how to make it works...

It works now.

Richard

On Tue, Aug 16, 2011 at 12:18 PM, Anthony  wrote:

> On Tuesday, August 16, 2011 12:09:45 PM UTC-4, Richard wrote:
>>
>> Hello,
>>
>> Consider this little change at admin app line 1195 of default
>> controller under 1.98.2 :
>>
>> def update_languages():
>> """ Update available languages """
>>
>> app = get_app()
>> update_all_languages(apath(**app, r=request))
>> session.flash = T('Language files (static strings) updated')
>> redirect(URL('design',args=**app+'#languages')) # Line 1195
>>
>> Only one problem the dial (#) caracter does not seems to pass
>> correctly... Don't why and I can't figure it out... Encoding
>> problem..
>>
> In URL(), args and vars are url encoded. Instead, use the anchor argument:
>
> URL('design',args=**app,anchor='#languages')
>
> Anthony
>


Re: [web2py] little admin improvement

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 12:09:45 PM UTC-4, Richard wrote:
>
> Hello, 
>
> Consider this little change at admin app line 1195 of default 
> controller under 1.98.2 : 
>
> def update_languages(): 
> """ Update available languages """ 
>
> app = get_app() 
> update_all_languages(apath(app, r=request)) 
> session.flash = T('Language files (static strings) updated') 
> redirect(URL('design',args=app+'#languages')) # Line 1195 
>
> Only one problem the dial (#) caracter does not seems to pass 
> correctly... Don't why and I can't figure it out... Encoding 
> problem..
>
In URL(), args and vars are url encoded. Instead, use the anchor argument:
 
URL('design',args=app,anchor='#languages')
 
Anthony


[web2py] Re: book translations

2011-08-16 Thread DenesL

Submitting changes does not update the book.
Anybody else having the same issue?.


Re: [web2py] [SOLVED] Call web2py from a microcontroller

2011-08-16 Thread Angelo Compagnucci
You are absolutely right!

I'm aware of the generic view issue, but I've completely forgotten!

Thank you very much for your help!

2011/8/16 Ross Peoples :
> I should probably clarify "why" this is happening. The line I mentioned
> checks to see if the client is running on the localhost (i.e. the web
> browser running on the same machine as the web2py server). If it is, then
> web2py is authorized to use a generic view to respond to the request if a
> view is not found. However, when accessing the web2py server from another
> machine, web2py will not automatically fallback to generic views because of
> security concerns. You have to authorize web2py to hand out generic views to
> non-localhost clients by modifying the line mentioned previously.
> Hope that helps.


[web2py] little admin improvement

2011-08-16 Thread Richard
Hello,

Consider this little change at admin app line 1195 of default
controller under 1.98.2 :

def update_languages():
""" Update available languages """

app = get_app()
update_all_languages(apath(app, r=request))
session.flash = T('Language files (static strings) updated')
redirect(URL('design',args=app+'#languages')) # Line 1195

Only one problem the dial (#) caracter does not seems to pass
correctly... Don't why and I can't figure it out... Encoding
problem...

I get %23languages in my URL...

Rational : Most time I update languages files is to go make some
traductions into one of the languages files... So it borring to have
to make two clicks to finally edit the language file I want to update.

Thanks.

Richard



Re: [web2py] Re: ajax function returns None

2011-08-16 Thread Martin Weissenboeck
Now I have tried:

{{extend 'layout.html'}}






Sorry, same result:  "None"
echo is called, but request.vars does not contain any value.
Martin

2011/8/16 Massimo Di Pierro 

Try
>
> 
>
> I think this is typo in the book.
>
> On Aug 16, 6:53 am, Martin Weissenboeck  wrote:
> > Hi,
> >
> > I have tried the example from chapter 10.3 The ajax Function
> >
> > Controller:
> > def one():
> > return dict()
> >
> > def echo():
> > return request.vars.name
> >
> > one.html:
> > {{extend 'layout.html'}}
> > 
> > 
> > 
> > 
> >
> > No success, because the value of request.vars.name is None
> > Just for fun I have tried "request.now", "request.extension",
> > "request.folder" and so on instead of "request.vars.name" - these
> examples
> > worked fine, but I had no chance to get the value of name.
> >
> > Version: web2py 1.98.2, started from source with Windows Python 2.7.2
> > and web2py 1.98.2 Python 2.5
> >
> > What is wrong - any ideas?
> >
> > Regards, Martin
>


[web2py] Re: book translations

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 11:45:12 AM UTC-4, DenesL wrote:
>
>
> Submitting changes does not update the book. 
> Anybody else having the same issue?.
>
Good catch -- I thought I made a change earlier, but looks like it didn't 
update.
 
Anthony 


[web2py] Re: Call web2py from a microcontroller

2011-08-16 Thread Ross Peoples
I should probably clarify "why" this is happening. The line I mentioned 
checks to see if the client is running on the localhost (i.e. the web 
browser running on the same machine as the web2py server). If it is, then 
web2py is authorized to use a generic view to respond to the request if a 
view is not found. However, when accessing the web2py server from another 
machine, web2py will not automatically fallback to generic views because of 
security concerns. You have to authorize web2py to hand out generic views to 
non-localhost clients by modifying the line mentioned previously.

Hope that helps.


[web2py] Re: Call web2py from a microcontroller

2011-08-16 Thread Ross Peoples
The screenshot makes it pretty clear that it can't find the view: 
default/count.json. If you are expecting a generic view to take over 
instead, you will need to go into your db.py model and change this line:

response.generic_patterns = ['*'] if request.is_local else []

to:

response.generic_patterns = ['*']


[web2py] Re: can I turn off the auto back-references?

2011-08-16 Thread Carlos
Hi Massimo,

What about having a new  'referee_prefix' var in DAL, which defaults to 
empty string, and replacing:

   colset[referee_table] = Set(db, s == id)

with:

   colset[*referee_prefix+*referee_table] = Set(db, s == id)

And then just have a way to override this 'referee_prefix' value as a web2py 
setting or so.

This way backward compatibility will not be broken (because of the initial 
default empty string value) and we can change the way we access such back 
references.

Can this be included in trunk?.

Thanks,

   Carlos



[web2py] Re: one2many DB, delete() deleteing sons ?

2011-08-16 Thread TomPliss
Have jsut tested: it works !
(without resetting the DB).


Thanks !


On Aug 16, 2:35 pm, Massimo Di Pierro 
wrote:
> I think...
>
> Field(...,'reference something',ondelete='ignore')
>
> I am not sure whether this change will trigger a migration of not.
> Give it a try.
> You may have to reset the database.
> Please let us know if this solved the problem.
>
> On Aug 16, 4:06 am, TomPliss  wrote:
>
>
>
>
>
>
>
> > Hey guys,
>
> > (newbie here)
>
> > I'm working on a batabase, with many one2many relationship.
> > exemple :
> > "labs" have "equipments", which have "devices".
> > and "contracts" have "equipments" too (as they are maintenance
> > contracts).
>
> > the problem is : if I delete a contract, every equipments which refers
> > to it is deleted.
>
> > I'd like to turn this off (isn't there an option for this in the
> > database-model definition ?)...
>
> > Thanks,
> > tom.
>
> > PS: i'm a little frenchy noob,
> > please forgive my english, and state the obvious ;)


[web2py] Re: Insert not working on Keyed Table

2011-08-16 Thread DenesL

Fixed in trunk.
Please test.


Re: [web2py] book translations

2011-08-16 Thread Richard Vézina
I can help with French.

Richard

On Tue, Aug 16, 2011 at 9:03 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The online book is not fully multi language. The language is set by
> your browser preferences
>
> The title indicates which language you are looking at: web2py Book(en)
>
> Only "en" and "it" translations exist. es, pt, de, ch, jp translations
> have been enabled. Register and email me to become an editor and you
> will be able to add edit translations.
>
> Massimo
>


[web2py] Re: auth.accessible_query(...)

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 4:21:37 AM UTC-4, Marin wrote:
>
> Hi, 
>
> there is a bug in documentation, 
> http://web2py.com/book/default/chapter/08#Authorization 
>
> rows = db(accessible_query('read', db.mytable, user_id))\ 
> .select(db.mytable.ALL) 
>
> should be: 
>
> rows = db(auth.accessible_query('read', db.mytable, user_id))\ 
> .select(db.mytable.ALL)

 
Fixed.
 


[web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-16 Thread Carlos
Great to know, thanks Massimo for (re-)confirming this.

I'll share more information about these problems as soon as I can.

Take care,

   Carlos



Re: [web2py] Re: please help me test new form API

2011-08-16 Thread Anthony
It still uses request.vars and session -- it just doesn't require you to 
explicitly pass them as arguments (if you don't pass them, it uses 
current.session and current.request.post_vars).
 
Anthony

On Tuesday, August 16, 2011 9:10:40 AM UTC-4, Richard wrote:

> Hello,
>
> Since process() not require request.vars and session does it make things 
> faster?
>
> And if so, could it be percetible?
>
> Thanks
>
> Richard
>
> On Mon, Aug 15, 2011 at 3:56 AM, Massimo Di Pierro 
> wrote:
>
>> I agree with you that having three ways to do the same thing is not
>> good but:
>>
>> There are three reasons:
>>
>> 1) some people may want to validate without processing the form fully
>> (no insert). shortcut to accepts(...dbio=True)
>> 2) it allows to write onliners: form = SQLFORM().process()
>> 3) no longer need to pass request and session.
>>
>> see process() replacing accepts() and I see validate() as a way to
>> check if form validates without insertion.
>>
>> There are also some different defaults. If you do not pass a session
>> to accepts(...) you do not get CRSF protection. In process(...) you
>> must pass session=None explicitly to disable RSCF protection.
>>
>> We can talk more about these pros, cons, etc.
>>
>> These functions have been in web2py for a while. We just made them
>> work better.
>>
>>
>>
>> On Aug 15, 12:25 am, pbreit  wrote:
>> > I'm not totally clear on the gain here. Is it that flash messages get
>> > automatically set? Is this going to splinter implementations (ie some 
>> will
>> > use .accepts, some will use .process, others will use .validate)? Is 
>> that a
>> > good thing?
>>
>
>

[web2py] Re: downloads

2011-08-16 Thread Anthony
On Tuesday, August 16, 2011 9:41:17 AM UTC-4, peter wrote:
>
> The URL I gave in the example happens behind the scenes, so it does 
> not get displayed to the user.
>
That's good, but note that an attacker could look at your HTML/Javascript 
source code or watch the outgoing requests from your application, observe 
the structure of your URLs, and still put together a directory traversal 
attack, so be careful.
 
Anthony


[web2py] Re: downloads

2011-08-16 Thread peter
Thanks for your informative responses Anthony. I will do some
exploring when I get a chance.

The URL I gave in the example happens behind the scenes, so it does
not get displayed to the user. But your comments about security are
useful.

Peter

On Aug 15, 7:08 pm, Anthony  wrote:
> On Monday, August 15, 2011 11:08:10 AM UTC-4, Anthony wrote:
>
> > On Monday, August 15, 2011 6:09:00 AM UTC-4, peter wrote:
>
> >> If I have a url
>
> >> .../default/my_download/abc.mp3?album=def&filename=ghi.mp3
>
> >> Then it does correctly download  web2py/albums/def/ghi.mp3
>
> >> The popup for the user say 'do you want to open or save "abc.mp3"
>
> > I'm not sure web2py is doing anything to affect that -- I think it's
> > probably the browser -- when it receives the audio stream, it assumes the
> > name is the last part of the URL before the query string. You might be able
> > to fix that by setting the Content-Dispostion header
>
> > response.headers['Content-Disposition'] = 'inline; filename=%s' %
> > request.vars.filename   # for streaming
>
> > response.headers['Content-Disposition'] = 'attachment; filename=%s' %
> > request.vars.filename   # to force download as attachment
>
> Note, I'm not sure specifying 'filename' has any effect with 'inline'. Also,
> you may need to url encode the filename before adding it to the header.
>
> Anthony- Hide quoted text -
>
> - Show quoted text -


Re: [web2py] Re: please help me test new form API

2011-08-16 Thread Richard Vézina
Hello,

Since process() not require request.vars and session does it make things
faster?

And if so, could it be percetible?

Thanks

Richard

On Mon, Aug 15, 2011 at 3:56 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I agree with you that having three ways to do the same thing is not
> good but:
>
> There are three reasons:
>
> 1) some people may want to validate without processing the form fully
> (no insert). shortcut to accepts(...dbio=True)
> 2) it allows to write onliners: form = SQLFORM().process()
> 3) no longer need to pass request and session.
>
> see process() replacing accepts() and I see validate() as a way to
> check if form validates without insertion.
>
> There are also some different defaults. If you do not pass a session
> to accepts(...) you do not get CRSF protection. In process(...) you
> must pass session=None explicitly to disable RSCF protection.
>
> We can talk more about these pros, cons, etc.
>
> These functions have been in web2py for a while. We just made them
> work better.
>
>
>
> On Aug 15, 12:25 am, pbreit  wrote:
> > I'm not totally clear on the gain here. Is it that flash messages get
> > automatically set? Is this going to splinter implementations (ie some
> will
> > use .accepts, some will use .process, others will use .validate)? Is that
> a
> > good thing?
>


[web2py] book translations

2011-08-16 Thread Massimo Di Pierro
The online book is not fully multi language. The language is set by
your browser preferences

The title indicates which language you are looking at: web2py Book(en)

Only "en" and "it" translations exist. es, pt, de, ch, jp translations
have been enabled. Register and email me to become an editor and you
will be able to add edit translations.

Massimo


[web2py] Re: one2many DB, delete() deleteing sons ?

2011-08-16 Thread Massimo Di Pierro
I think...

Field(...,'reference something',ondelete='ignore')

I am not sure whether this change will trigger a migration of not.
Give it a try.
You may have to reset the database.
Please let us know if this solved the problem.

On Aug 16, 4:06 am, TomPliss  wrote:
> Hey guys,
>
> (newbie here)
>
> I'm working on a batabase, with many one2many relationship.
> exemple :
> "labs" have "equipments", which have "devices".
> and "contracts" have "equipments" too (as they are maintenance
> contracts).
>
> the problem is : if I delete a contract, every equipments which refers
> to it is deleted.
>
> I'd like to turn this off (isn't there an option for this in the
> database-model definition ?)...
>
> Thanks,
> tom.
>
> PS: i'm a little frenchy noob,
> please forgive my english, and state the obvious ;)


[web2py] Re: ajax function returns None

2011-08-16 Thread Massimo Di Pierro
Try



I think this is typo in the book.

On Aug 16, 6:53 am, Martin Weissenboeck  wrote:
> Hi,
>
> I have tried the example from chapter 10.3 The ajax Function
>
> Controller:
> def one():
>     return dict()
>
> def echo():
>     return request.vars.name
>
> one.html:
> {{extend 'layout.html'}}
> 
> 
> 
> 
>
> No success, because the value of request.vars.name is None
> Just for fun I have tried "request.now", "request.extension",
> "request.folder" and so on instead of "request.vars.name" - these examples
> worked fine, but I had no chance to get the value of name.
>
> Version: web2py 1.98.2, started from source with Windows Python 2.7.2
> and web2py 1.98.2 Python 2.5
>
> What is wrong - any ideas?
>
> Regards, Martin


[web2py] Re: Ace now powering GitHub edit

2011-08-16 Thread Massimo Di Pierro
If somebody sends me a patch I will take a look.

On Aug 16, 6:29 am, Saurabh  Sawant  wrote:
> Yes.  It has Vi keybindings too it seems.


[web2py] one2many DB, delete() deleteing sons ?

2011-08-16 Thread TomPliss
Hey guys,

(newbie here)


I'm working on a batabase, with many one2many relationship.
exemple :
"labs" have "equipments", which have "devices".
and "contracts" have "equipments" too (as they are maintenance
contracts).

the problem is : if I delete a contract, every equipments which refers
to it is deleted.

I'd like to turn this off (isn't there an option for this in the
database-model definition ?)...


Thanks,
tom.


PS: i'm a little frenchy noob,
please forgive my english, and state the obvious ;)


Re: [web2py] Re: Birth Date

2011-08-16 Thread Ramaseshan Ramachandran
Great going.
I enjoy development using web2py.
In my 25 years of coding and several frameworks, I found to be the best.

On Mon, Aug 15, 2011 at 10:14 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The first version was written in August 2007.
> It was made public on Oct 1, 2007.
> This group was created on Oct 19, 2007.
> We moved to Mercurial in Dec 4, 2009.
> Things have sped up a lot since than.
> Since 2007 web2py has doubled in size and more than 70% has been
> rewritten (while keeping backward compatibility).
>
> Massimo
>
>
>
> On Aug 15, 11:09 am, Re Fabro  wrote:
> > Hello, dudes!!
> >
> > I want to know which the date of Birth of Web2Py and how many Years. :)
> >
> > *
> > Obrigado,
> > Renato Fabro*
> >
> > C2C Balloon - Humanizing Technology
> > +55 (19) 3289-9610http://www.c2cballoon.com
>



-- 
Thanks and regards
Ramaseshan


[web2py] Re: Can seem to get JanRain to work...

2011-08-16 Thread dhmorgan
it looks like Janrain expected to interact with 'https:...' and your
browser was pointed to 'http:...'

On Aug 15, 2:06 pm, Jason Brower  wrote:
> Is there any restriction of using the system on localhost?
> I feel I have entered all the data in correctly.  But it still seems to
> give me issues.  I get this when I come to the login screen.
> Any ideas on what I may be doing wrong?
>
>  Screenshot.png
> 130KViewDownload


[web2py] Re: Birth Date

2011-08-16 Thread guruyaya
Which means web2py is celebrating it's 4th birthday this month. I say
we should celebrate. Tommorow, every single one of us has to eat cake.

On Aug 15, 7:44 pm, Massimo Di Pierro 
wrote:
> The first version was written in August 2007.
> It was made public on Oct 1, 2007.
> This group was created on Oct 19, 2007.
> We moved to Mercurial in Dec 4, 2009.
> Things have sped up a lot since than.
> Since 2007 web2py has doubled in size and more than 70% has been
> rewritten (while keeping backward compatibility).
>
> Massimo
>
> On Aug 15, 11:09 am, Re Fabro  wrote:
>
>
>
>
>
>
>
> > Hello, dudes!!
>
> > I want to know which the date of Birth of Web2Py and how many Years. :)
>
> > *
> > Obrigado,
> > Renato Fabro*
>
> > C2C Balloon - Humanizing Technology
> > +55 (19) 3289-9610http://www.c2cballoon.com


[web2py] ajax function returns None

2011-08-16 Thread Martin Weissenboeck
Hi,

I have tried the example from chapter 10.3 The ajax Function

Controller:
def one():
return dict()

def echo():
return request.vars.name


one.html:
{{extend 'layout.html'}}





No success, because the value of request.vars.name is None
Just for fun I have tried "request.now", "request.extension",
"request.folder" and so on instead of "request.vars.name" - these examples
worked fine, but I had no chance to get the value of name.

Version: web2py 1.98.2, started from source with Windows Python 2.7.2
and web2py 1.98.2 Python 2.5

What is wrong - any ideas?

Regards, Martin


[web2py] Re: Ace now powering GitHub edit

2011-08-16 Thread Saurabh Sawant
Yes.  It has Vi keybindings too it seems.

[web2py] Re: Speeding up model execution for large models

2011-08-16 Thread Massimo Di Pierro
I would suggest you move some tables to conditional models.
If you have a lot of

Field(,requires=IS_NO_EMPTY())

you can

ne = IS_NO_EMPTY()
and then reuse the same object
Field(,requires=ne)

You can do this for all validators.

Set defaults in controllers if complex.

you may want to do

from mytables inport define_tables
define_tables(db)

and move the table definition in modules/mytables.py


On Aug 15, 7:18 pm, Kevin Ivarsen  wrote:
> Hi Anthony,
>
> Thanks for the quick response.
>
> I do use migrate=False already. I have not tried bytecode compiling
> the app, but earlier today I did a quick test: I wrapped the contents
> of my long db.py in an "if False:" block (causing it to compile, but
> not run, the code for each request), and compared this to an empty
> db.py (nothing to compile or run). It looks like compiling the code
> took about 7ms - about 5% of the total overhead. I don't think
> bytecode compiling will produce the dramatic improvement that I'm
> hoping to find (though I will of course try it when I get a chance.)
>
> Conditional models might help some - at the expense of additional
> planning and maintenance required during development. In any case, I
> still worry about the number of tables that need to be shared across
> at least two controllers, and the lower bound on performance those
> will impose. I was hoping to find a more global way to speed up
> models.
>
> Optimizing DAL creation would be an interesting area for future web2py
> development, IMHO. When I get some more time I might try to look at
> this in more detail.
>
> Cheers,
> Kevin
>
> On Aug 15, 3:59 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > First, have you set migrate to False for all tables, and have you bytecode
> > compiled the app? That should speed things up.
>
> > Also, do you need all 70 tables for any requests, or can they be broken up
> > based on the particular controller/function called? If so, you may speed
> > things up with conditional models. Any files in /models/controller1 will
> > only be executed on requests for controller1, and any files in
> > /models/controller1/function1 will only be executed on requests for
> > controller1/function1. (We're working on more general functionality for
> > conditional models that won't be based solely on the controller and
> > function.)
>
> > Anthony
>
> > On Monday, August 15, 2011 6:30:06 PM UTC-4, Kevin Ivarsen wrote:
> > > Hello,
>
> > > I'm using web2py with a relatively large legacy database. We have
> > > about 70 tables, and models/db.py is close to 1000 lines long.
>
> > > The problem I'm facing is that all of these Field() constructors and
> > > define_table() calls take about 150-200ms to execute, and this
> > > overhead occurs each time any request is made to web2py. Compare this
> > > to a minimal web2py app, which might have a (reasonable) 10-30ms of
> > > overhead before response data starts flowing to the client.
>
> > > I was hoping that a simple solution would be to declare the DAL
> > > structure once in an importable module, which would be run once on
> > > web2py startup rather than at each request. I could then deepcopy it
> > > in my model file (which I think would be faster than all the calls to
> > > define_table(), Field(), etc.), and then establish a connection to the
> > > database from this copied DAL.
>
> > > Unfortunately, there are a few problems with this:
> > >   1. If a DAL instance is to be connected to the database, it must
> > > happen in the constructor. It doesn't seem that you can do "db =
> > > DAL(None)" and then establish a connection after the fact. Also, it
> > > looks like some db-specific behavior is set up in the DAL constructor
> > > based on the connection URL - this wouldn't happen in the case of
> > > DAL(None).
>
> > >   2. Table and Field instances have a reference to db, so it seems
> > > that define_table() needs to be called *after* the DAL connection has
> > > been established in order to set up these references.
>
> > > I suppose it would be possible to deepcopy a DAL(None) instance that
> > > has been established with Tables and Fields, and monkey-patch the db
> > > references thoughout the DAL structure, but chances seem good that
> > > this will create subtle bugs down the road if the internal DAL
> > > implementation ever changes.
>
> > > Can anyone suggest a better way to speed up DAL creation for large
> > > schemas?
>
> > > Thanks,
> > > Kevin


[web2py] Re: can I turn off the auto back-references?

2011-08-16 Thread Massimo Di Pierro
Look into dal.py this is added in:
if not referee_table in colset:
colset[referee_table] = Set(db, s == id)

For now you can just comment these two lines.
we could add a switch. One time I thought about

if not referee_table in colset:
colset[referee_table+'_by_'+refree_name] =
Set(db, s == id)

perhaps the switch should offer that as a third option?
I am afraid the switch will break plugins.

On Aug 15, 10:03 pm, Carlos  wrote:
> Hi pbreit,
>
> Thanks for your input, but that will not work, since row.fieldname still
> incorrectly returns the Set object (therefore not executing the 'or'
> statement).
>
> Secondly, fieldname is a str variable in my case, which can't be used
> directly with the dot notation.
>
> I just need to not have these back references automatically added to the row
> dictionary, maybe via a new switch, if possible.
>
> Massimo, what do you think?.
>
> Thanks,
>
>    Carlos


[web2py] Re: migrate file system uploads to database?

2011-08-16 Thread Massimo Di Pierro
normally:

Field('name','upload'),...

to upload to db

Field('name','upload',uploadfield="myblob"),Field('myblob','blob',default=''),...

or just

Field('name','upload',uploadfield="myblob"),...

as this is implicit: Field('myblob','blob',default='')


On Aug 15, 8:10 pm, Mothmonsterman  wrote:
> Hello,
>
> I read the docs and searched the posts to see if there was an easy way
> to migrate file system uploads to database. I could not find
> anything.. Please excuse me if I missed something obvious, but does
> anyone know of a way to accomplish this in a batch process? Thanks.
>
> Patrick


[web2py] Re: Ace now powering GitHub edit

2011-08-16 Thread Massimo Di Pierro
should we replace editarea?

On Aug 15, 3:59 pm, pbreit  wrote:
> https://github.com/blog/905-edit-like-an-ace


[web2py] auth.accessible_query(...)

2011-08-16 Thread Marin
Hi,

there is a bug in documentation, 
http://web2py.com/book/default/chapter/08#Authorization

rows = db(accessible_query('read', db.mytable, user_id))\
.select(db.mytable.ALL)

should be:

rows = db(auth.accessible_query('read', db.mytable, user_id))\
.select(db.mytable.ALL)

Also, I noticed that accessible_query raises an exception if user is
not logged in.
It's because of a line 2805 (trunk) in gluon/tools.py:
user_id = self.user.id

What is expected behavior if user is not logged in? Is this
intentional?


[web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-16 Thread Massimo Di Pierro

> But I just want to make sure: are the environments created by web2py fully
> independent in every single web request (even with multiple concurrent
> requests) ?.

yes


[web2py] Re: I keep getting the error: invalid literal for int() with base 10: 'Plumber'

2011-08-16 Thread Jarrod Cugley
I have to use some form of autocomplete input instead of a drop down
because there will be a lot of titles, like hundreds, so it would be
easier to have people type and have it auto corrected.

I'm still unsure why this code, would return the error: ValueError:
invalid literal for int() with base 10: 'Painter'.

def search():
searches = db(db.listing.title==request.args(0)).select()
items = []
for search in searches:
items.append(DIV(A(search, _href=URL('index'

return TAG[''](*items)

Why would it expect an int and not a literal, when my models is:

db.define_table('title',
Field('name'),
format='%(name)s',
   )

db.define_table(auth.settings.table_user_name,
Field('first_name'),
Field('last_name'),
Field('email'),
Field('password','password', length=512,
readable=False, label='Password'),
Field('title', db.title, '%(name)s'),
Field('bio','text'),
Field('phone'),
Field('website'),
Field('address'),
Field('registration_key', length=512,
writable=False, readable=False, default=''),
Field('reset_password_key', length=512,
writable=False, readable=False, default=''),
Field('registration_id', length=512,
writable=False, readable=False, default=''),
)

I've got to be missing something??? :/

On Aug 15, 10:01 am, Anthony  wrote:
> On Sunday, August 14, 2011 7:05:17 PM UTC-4, Jarrod Cugley wrote:
>
> > Woohoo it's now working! Thank you Anthony!!!
>
> > 2 questions:
>
> > 1. When I have
>
> > listing.title.requires = [IS_IN_DB(db, db.title.id, '%(name)s')]
>
> > as a list (which is how I want it, it doesn't seem to let me register,
> > it still expects an int, how can I make it expect a string that's
> > equal to an id? Cause obviously people can't just guess the id of
> > their title hahaha
>
> If you want to enforce the requirement that titles are existing titles in
> the 'title' table, why not stick with the dropdown widget instead of
> allowing users to enter whatever title they want (which presumably will lead
> to more errors)? Another option may be the autocomplete widget 
> (http://web2py.com/book/default/chapter/07#Autocomplete-Widget), though it
> seems to have problems in IE (I hope to come up with a fix for that soon).
> Otherwise, I suppose you could write a custom validator that takes the name,
> looks up the matching title.id, and changes the value to that id (or returns
> an error if not found). 
> Seehttp://web2py.com/book/default/chapter/07#Custom-Validators.
>
>
>
> > 2. I'm running a little test on index to figure out how to display the
> > first names that have the reference id '36' using this code:
>
> > def index():
> > painters = db(db.listing.title == 36).select()
> > items = []
> > for painter in painters:
> > items.append(DIV(A(painter.first_name, _href=URL('index'
> > return dict(items=items)
>
> > But it's just displaying this on the index page:
>
> > [,  > 0x9982b30>]
>
> 'items' is a list of HTML helpers, not a single HTML helper. If your view
> does {{=items}}, it won't serialize the separate DIV objects because they're
> part of a list. Instead, you'll need to unpack the list somehow. For
> example:
> {{for item in items:}}
> {{=item}}
> {{pass}}
>
> > P.S Are you the Anthony that was helping me on Stack Overflow too? If
> > so thanks, your help is awesome, hopefully I can pay it back one
> > day :)
>
> Yes, same Anthony. No problem, happy to help. Enjoy web2py. :-)
>
> Anthony