[web2py] TypeError: 'instancemethod' object is unsubscriptable

2012-05-05 Thread Annet
Using this code to customize a form:


  
{{=response.functionname}}
   
  
{{=form.custom.begin}}
{{=form.element['table']}}
   
  
{{=DIV(form.custom.end[1])}}
{{=form.custom.end[0]}}
   
 

I get the following error:

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
205, in restricted
exec ccode in environment
  File 
"/Library/Python/2.5/site-packages/web2py/applications/bootstrap/views/util/generic.html",
 line 166, in 
TypeError: 'instancemethod' object is unsubscriptable


Line 166:

164. response.write(form.custom.begin)
165. response.write('\n', escape=False)
166. response.write(form.element['table'])


I am using web2py 1.99.7


Kind regards,

Annet.


[web2py] Re: Auth form custom errors

2012-05-05 Thread Massimo Di Pierro
This is because of the mechanism to prevent CSRF attacks.
There are supposed to be two hidden fields, one is the formname. The other 
is the formkey (a unique onetime token).

Try:

{{
form=auth.login()
form['_action']=URL('user/login')
}}
{{=form.custom.begin}}
{{=form.custom.widget.email}}
{{=form.custom.widget.password}}


{{=form.custom.end}}


On Saturday, 5 May 2012 23:37:57 UTC-5, Rhys wrote:
>
> Hey Alan,
>
> I don't want to redirect. I'll try and to explain it a bit more.
>
> Basically I have two forms. One which is a drop down, in pure html
>
> 
> 
> 
>
> 
> 
> 
>
>
>
> ^ this Form is on every page which the user is not logged into. When they 
> fill out this form and click submit I want the /user/login page to process 
> it, but it is not doing so. When the page finds there is an error with the 
> login or the user is not authorised, I would like the /user/login form 
> which is exactly the same form as above but on another page with the drop 
> down one removed, to present there was an error with the login.
>
> Both forms I've done in html so there is no form key to process. I'm 
> trying to figure out why auth.login() doesn't process it as the 
> form.accepts() method in auth.login() has the same formname. What is 
> preventing it from being processed. It's driving me in sane. I'm stepping 
> through the code in debug mode and can't find why it would not process it. 
> It is basically a SQL form in html like described in the web2py book.
>
> Any insight would be great by any!
>
> On Sunday, May 6, 2012 12:19:49 AM UTC+10, Alan Etkin wrote:
>>
>> *auth.is_logged_in()* will return a bool object. True for authenticated 
>> user and I belive *auth.user_id* attribute is None for the non 
>> authenticated user. *auth *being the Auth class instance created by the 
>> welcome scaffolding application.
>>
>> You could use the returned values to catch unsuccessful authentication 
>> and redirect to the correct action
>>
>> There is an Auth setting for failed authentication (for example, it's 
>> possible to call a function on failed login)
>> ("Settings and Messages", web2py book 4th edition, 9.3.7)
>>
>> auth.settings.on_failed_authentication = lambda url: redirect(url)
>>
>> On Saturday, May 5, 2012 9:51:23 AM UTC-3, Rhys wrote:
>>>
>>> I'm creating a custom drop down login form for all pages where the user 
>>> isn't logged in. Once they try and login through this form if it 
>>> is unsuccessful it redirects to the /user/login page with the auth.login 
>>> form. How do I get a error if the login has resulted in an invalid login. 
>>> As there are two forms I've tried also tried to do a form out of html so 
>>> there is no form key. Still no luck. Is it s simple variable I can use to 
>>> determine if it is successful? 
>>
>>

[web2py] Re: Auth form custom errors

2012-05-05 Thread Rhys
Hey Alan,

I don't want to redirect. I'll try and to explain it a bit more.

Basically I have two forms. One which is a drop down, in pure html




   






^ this Form is on every page which the user is not logged into. When they 
fill out this form and click submit I want the /user/login page to process 
it, but it is not doing so. When the page finds there is an error with the 
login or the user is not authorised, I would like the /user/login form 
which is exactly the same form as above but on another page with the drop 
down one removed, to present there was an error with the login.

Both forms I've done in html so there is no form key to process. I'm trying 
to figure out why auth.login() doesn't process it as the form.accepts() 
method in auth.login() has the same formname. What is preventing it from 
being processed. It's driving me in sane. I'm stepping through the code in 
debug mode and can't find why it would not process it. It is basically a 
SQL form in html like described in the web2py book.

Any insight would be great by any!

On Sunday, May 6, 2012 12:19:49 AM UTC+10, Alan Etkin wrote:
>
> *auth.is_logged_in()* will return a bool object. True for authenticated 
> user and I belive *auth.user_id* attribute is None for the non 
> authenticated user. *auth *being the Auth class instance created by the 
> welcome scaffolding application.
>
> You could use the returned values to catch unsuccessful authentication and 
> redirect to the correct action
>
> There is an Auth setting for failed authentication (for example, it's 
> possible to call a function on failed login)
> ("Settings and Messages", web2py book 4th edition, 9.3.7)
>
> auth.settings.on_failed_authentication = lambda url: redirect(url)
>
> On Saturday, May 5, 2012 9:51:23 AM UTC-3, Rhys wrote:
>>
>> I'm creating a custom drop down login form for all pages where the user 
>> isn't logged in. Once they try and login through this form if it 
>> is unsuccessful it redirects to the /user/login page with the auth.login 
>> form. How do I get a error if the login has resulted in an invalid login. 
>> As there are two forms I've tried also tried to do a form out of html so 
>> there is no form key. Still no luck. Is it s simple variable I can use to 
>> determine if it is successful? 
>
>

[web2py] Re: Dynamic Subdomain Routing

2012-05-05 Thread Massimo Di Pierro
yes.

http://web2py.com/books/default/chapter/29/4#URL-rewrite

On Friday, 4 May 2012 10:20:10 UTC-5, chris wrote:
>
> Hi all,
>
> i'm trying to choose between frameworks for my new project and i'm liking 
> what I see with web2py but currently flask is the only one i can find that 
> will do what i need with routing / subdomains.
>
> basically, i'm trying to use the subdomain as the keyword I will run a 
> database qurey on. it does not need to redirect anywhere (like 
> mydomain.com/search/variable).
>
> with flask, my route would look like "@app.route("/", 
> subdomain="")", which would make my subdomain available in functions 
> as var1.
>
> is this kind of thing possible with web2py? if yes, is there anywhere it 
> would work (like when using url_for())?
>
> thanks
>


[web2py] Re: Installing scheduler on linux

2012-05-05 Thread Massimo Di Pierro
Can you send me a patch to the schedule including these instructions in the 
docstring?

On Saturday, 5 May 2012 20:54:01 UTC-5, Michael Toomim wrote:
>
> Also:
> 1. replace "friendbo" with the name of your app.
> 2. To start/stop the scheduler, use
>   "sudo start web2py-scheduler"
>   "sudo stop web2py-scheduler"
>   "sudo status web2py-scheduler"
>   ...etc.
>
> On Saturday, May 5, 2012 6:47:33 PM UTC-7, Michael Toomim wrote:
>>
>> Here's a solution I wrote. Is there a good place (like the web2py book) 
>> to share this recipe?
>>
>> Put this in /etc/init/web2py-scheduler.conf:
>>
>> description "web2py task scheduler"
>>
>> start on (local-filesystems and net-device-up IFACE=eth0)
>> stop  on shutdown
>>
>> # Give up if restart occurs 8 times in 60 seconds.   
>>
>> respawn limit 8 60
>>
>> exec sudo -u  python /home//web2py/web2py.py -K friendbo
>> respawn
>>
>> This assumes your web2py is in 's home directory, running with 
>> permission . Replace  with the right user id and change eth0 if 
>> your server uses a different network interface.
>>
>> On Thursday, May 3, 2012 1:22:25 PM UTC-7, Michael Toomim wrote:
>>>
>>> Anyone have a recipe to make the scheduler run on boot? I'm using 
>>> ubuntu. Web2py is run in apache (using the recipe in the book), so I can't 
>>> just use the cron @reboot line.
>>>
>>> This is the line that needs to be run when my system boots:
>>>python /home/web2py/web2py/web2py.py -K 
>>>
>>> It seems ubuntu uses Upstart instead of sysvinit. And it might be 
>>> possible to tell Upstart to launch the scheduler WITH apache, using a line 
>>> like "start on started apache2" but I don't know how it works, and 
>>> apache2 to use upstart.
>>>
>>> It would be nice to have a recipe for the scheduler that we could add 
>>> into the book, to synchronize it with apache.
>>>
>>

[web2py] Re: LOAD with timing arguments being loaded once

2012-05-05 Thread Massimo Di Pierro
Please do.


On Saturday, 5 May 2012 19:34:02 UTC-5, Alan Etkin wrote:
>
> I've found something on the subject. web2py.js function web2py_component 
> time and times arguments and the code related with js timing were not 
> included in the last version of the script. I think this should be fixed 
> for backwards compatibility (LOAD at compileapp.py builds web2py_component 
> commands with those arguments). Should I submit a patch for this?.
>
> On Saturday, May 5, 2012 8:23:26 PM UTC-3, Alan Etkin wrote:
>>
>> I am having trouble using the LOAD timing features i.e:
>>
>> LOAD(f="action.load", timeout=1000, times="infinity", ajax=True)
>>
>> The component is loaded just the first time and it should keep reloading 
>> it on each second.
>>
>> I've tried the command with the last trunk hg version. Anyone with the 
>> same issue?
>>
>> The system info:
>> web2py Version 1.99.7 (2012-05-05 09:00:54) dev (with rocket web server)
>> Browser: Firefox 10.0
>> OS: Mandriva GNU/Linux 2010.2
>>
>>

[web2py] Re: Installing scheduler on linux

2012-05-05 Thread Michael Toomim
Also:
1. replace "friendbo" with the name of your app.
2. To start/stop the scheduler, use
  "sudo start web2py-scheduler"
  "sudo stop web2py-scheduler"
  "sudo status web2py-scheduler"
  ...etc.

On Saturday, May 5, 2012 6:47:33 PM UTC-7, Michael Toomim wrote:
>
> Here's a solution I wrote. Is there a good place (like the web2py book) to 
> share this recipe?
>
> Put this in /etc/init/web2py-scheduler.conf:
>
> description "web2py task scheduler"
>
> start on (local-filesystems and net-device-up IFACE=eth0)
> stop  on shutdown
>
> # Give up if restart occurs 8 times in 60 seconds. 
>  
> respawn limit 8 60
>
> exec sudo -u  python /home//web2py/web2py.py -K friendbo
> respawn
>
> This assumes your web2py is in 's home directory, running with 
> permission . Replace  with the right user id and change eth0 if 
> your server uses a different network interface.
>
> On Thursday, May 3, 2012 1:22:25 PM UTC-7, Michael Toomim wrote:
>>
>> Anyone have a recipe to make the scheduler run on boot? I'm using ubuntu. 
>> Web2py is run in apache (using the recipe in the book), so I can't just use 
>> the cron @reboot line.
>>
>> This is the line that needs to be run when my system boots:
>>python /home/web2py/web2py/web2py.py -K 
>>
>> It seems ubuntu uses Upstart instead of sysvinit. And it might be 
>> possible to tell Upstart to launch the scheduler WITH apache, using a line 
>> like "start on started apache2" but I don't know how it works, and 
>> apache2 to use upstart.
>>
>> It would be nice to have a recipe for the scheduler that we could add 
>> into the book, to synchronize it with apache.
>>
>

Re: [web2py] Re: Installing scheduler on linux

2012-05-05 Thread Bruno Rocha
post that in web2pyslices.com
 Em 05/05/2012 22:47, "Michael Toomim"  escreveu:

> Here's a solution I wrote. Is there a good place (like the web2py book) to
> share this recipe?
>
> Put this in /etc/init/web2py-scheduler.conf:
>
> description "web2py task scheduler"
>
> start on (local-filesystems and net-device-up IFACE=eth0)
> stop  on shutdown
>
> # Give up if restart occurs 8 times in 60 seconds.
>
> respawn limit 8 60
>
> exec sudo -u  python /home//web2py/web2py.py -K friendbo
> respawn
>
> This assumes your web2py is in 's home directory, running with
> permission . Replace  with the right user id and change eth0 if
> your server uses a different network interface.
>
> On Thursday, May 3, 2012 1:22:25 PM UTC-7, Michael Toomim wrote:
>>
>> Anyone have a recipe to make the scheduler run on boot? I'm using ubuntu.
>> Web2py is run in apache (using the recipe in the book), so I can't just use
>> the cron @reboot line.
>>
>> This is the line that needs to be run when my system boots:
>>python /home/web2py/web2py/web2py.py -K 
>>
>> It seems ubuntu uses Upstart instead of sysvinit. And it might be
>> possible to tell Upstart to launch the scheduler WITH apache, using a line
>> like "start on started apache2" but I don't know how it works, and
>> apache2 to use upstart.
>>
>> It would be nice to have a recipe for the scheduler that we could add
>> into the book, to synchronize it with apache.
>>
>


[web2py] Re: Installing scheduler on linux

2012-05-05 Thread Michael Toomim
Here's a solution I wrote. Is there a good place (like the web2py book) to 
share this recipe?

Put this in /etc/init/web2py-scheduler.conf:

description "web2py task scheduler"

start on (local-filesystems and net-device-up IFACE=eth0)
stop  on shutdown

# Give up if restart occurs 8 times in 60 seconds. 
 
respawn limit 8 60

exec sudo -u  python /home//web2py/web2py.py -K friendbo
respawn

This assumes your web2py is in 's home directory, running with 
permission . Replace  with the right user id and change eth0 if 
your server uses a different network interface.

On Thursday, May 3, 2012 1:22:25 PM UTC-7, Michael Toomim wrote:
>
> Anyone have a recipe to make the scheduler run on boot? I'm using ubuntu. 
> Web2py is run in apache (using the recipe in the book), so I can't just use 
> the cron @reboot line.
>
> This is the line that needs to be run when my system boots:
>python /home/web2py/web2py/web2py.py -K 
>
> It seems ubuntu uses Upstart instead of sysvinit. And it might be possible 
> to tell Upstart to launch the scheduler WITH apache, using a line like "start 
> on started apache2" but I don't know how it works, and apache2 to use 
> upstart.
>
> It would be nice to have a recipe for the scheduler that we could add into 
> the book, to synchronize it with apache.
>


[web2py] Re: LOAD with timing arguments being loaded once

2012-05-05 Thread Alan Etkin
I've found something on the subject. web2py.js function web2py_component 
time and times arguments and the code related with js timing were not 
included in the last version of the script. I think this should be fixed 
for backwards compatibility (LOAD at compileapp.py builds web2py_component 
commands with those arguments). Should I submit a patch for this?.

On Saturday, May 5, 2012 8:23:26 PM UTC-3, Alan Etkin wrote:
>
> I am having trouble using the LOAD timing features i.e:
>
> LOAD(f="action.load", timeout=1000, times="infinity", ajax=True)
>
> The component is loaded just the first time and it should keep reloading 
> it on each second.
>
> I've tried the command with the last trunk hg version. Anyone with the 
> same issue?
>
> The system info:
> web2py Version 1.99.7 (2012-05-05 09:00:54) dev (with rocket web server)
> Browser: Firefox 10.0
> OS: Mandriva GNU/Linux 2010.2
>
>

[web2py] LOAD with timing arguments being loaded once

2012-05-05 Thread Alan Etkin
I am having trouble using the LOAD timing features i.e:

LOAD(f="action.load", timeout=1000, times="infinity", ajax=True)

The component is loaded just the first time and it should keep reloading it 
on each second.

I've tried the command with the last trunk hg version. Anyone with the same 
issue?

The system info:
web2py Version 1.99.7 (2012-05-05 09:00:54) dev (with rocket web server)
Browser: Firefox 10.0
OS: Mandriva GNU/Linux 2010.2



Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Tiago Almeida
That would be a cool feature..1 click deployment of code pulled from a
repository.

Regards
On May 5, 2012 11:19 PM, "Massimo Di Pierro" 
wrote:

> I think we all agree that the built in editor if definitively useful. It
> does not substitute a normal editor for production quality development, but
> there are many occasions when it is useful: quick and dirty fixes, editing
> code when there is no ssh access, editing configuration options, etc.
> Anyway, the online editor is just one of the tools in the web2py
> administrative interface, including mercurial integration, error browser,
> web based shell. We are looking into integrating automatic pulls from
> github (and other repositories).
>
> Massimo
>
> On Saturday, 5 May 2012 16:30:33 UTC-5, Khalil KHAMLICHI wrote:
>>
>> I must agree to good practices but that does not mean I cannot deploy
>> tested code using the built-in editor.
>>
>>
>> On Sat, May 5, 2012 at 8:49 PM, Tiago Almeida 
>> wrote:
>>
>>> Don't know why one does not use an oodbms. I've never used one. Are
>>> there any serious alternatives to current rdbms?
>>>
>>> Regarding the editor and editing in production. I was expecting that
>>> argument and think that shouldn't be done unless its some extreme
>>> emergency. One should not put code in production without testing it
>>> thoroughly. What if your emergency edit in prod introduces a new bug that
>>> causes a data loss for the client? Good practice says that you should have
>>> at least 1  staging server to deploy stuff and test before prod.
>>>
>>> Regards
>>> On May 5, 2012 9:23 PM, "Michele Comitini" 
>>> wrote:
>>>
 I do not see nothing in web2py that stops a developer from using a
 third party ORM.
 Not a common pattern in web2py, because DAL functional approach gives
 addiction: you forget the COO (Class Object Oriented) and stick to the
 true semantic of python which is full OO.  COO is typical of many
 static languages which need a static interface as blueprint for each
 object to be instantiated.
 The modeling using DAL is much relational modeling very little OO
 modeling.

 I agree it is more about faith and religion, but here a question
 raises.  I  suppose the answer is somewhere.  I just did not find it
 yet.
 Let's suppose that OOP modeling were superior to relational, the
 question is why we keep using RDBMS's?  There are some serious
 OODBMS's out there, why use an ORM then?


 mic

 2012/5/5 Massimo Di Pierro :
 >
 >
 > On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
 >>
 >> Thanks for the comment. This is an interesting debate.
 >>
 >> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
 >>>
 >>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
 
  Hi,
  The issue about dal/orm, like Anthony said, there are tradeoffs to
  consider. In my opinion you loose too much not having an orm to
 gain very
  little with the dal. Let me continue my example.
  In the Deparment/Teacher hypothetical model, you also have
 assignment of
  Teachers to Departments. This assignment is very simple (for the
 sake of
  brevity) and has the start/end dates of the assignment and the
 function
  (just a string) of the Teacher in that Department.
  You now want, Given the ID of a department list all the
 assignments of
  all teachers along with their functions in a cool graphical
 timeline
  fashion.
  It's not about how you get the data. It's about the effort you have
  implementing this req. and how you organize your code. Do you?
  a) write your .selects() in the view function
  b) write a historical_assignments(dep_id) function somewhere that
 hides
  the DAL and call it from the view
  c) write a computed field on the department model
  d) write a method  historical_assignments() on the class Department
 
  To me, the d) option is by far the most elegant. I would have had
 the
  Department class created anyway, so it's a matter of sticking a
 method in
  there. If I am working with an ORM, by defining the classes, I
 automagically
  get the tables defined. Without it, I have to repeat myself,
 redefining the
  fields and the fields in the tables and their types, etc. etc. in
 the
  persistance layer.
  What if I didn't define those classes? Then I couldn't contain
 these
  kinds of business related operations into a single application
 layer and
  they would leak everywhere, for instance in to the views, being
 much harder
  to maintain.
 >>>
 >>>
 >>> this is somewhat a religious matter. We do not like to pollute the
 >>> namespace with one class per table. We do not even

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Massimo Di Pierro
I think we all agree that the built in editor if definitively useful. It 
does not substitute a normal editor for production quality development, but 
there are many occasions when it is useful: quick and dirty fixes, editing 
code when there is no ssh access, editing configuration options, etc. 
Anyway, the online editor is just one of the tools in the web2py 
administrative interface, including mercurial integration, error browser, 
web based shell. We are looking into integrating automatic pulls from 
github (and other repositories).

Massimo

On Saturday, 5 May 2012 16:30:33 UTC-5, Khalil KHAMLICHI wrote:
>
> I must agree to good practices but that does not mean I cannot deploy 
> tested code using the built-in editor.
>
>
> On Sat, May 5, 2012 at 8:49 PM, Tiago Almeida 
> wrote:
>
>> Don't know why one does not use an oodbms. I've never used one. Are there 
>> any serious alternatives to current rdbms? 
>>
>> Regarding the editor and editing in production. I was expecting that 
>> argument and think that shouldn't be done unless its some extreme 
>> emergency. One should not put code in production without testing it 
>> thoroughly. What if your emergency edit in prod introduces a new bug that 
>> causes a data loss for the client? Good practice says that you should have 
>> at least 1  staging server to deploy stuff and test before prod. 
>>
>> Regards
>> On May 5, 2012 9:23 PM, "Michele Comitini"  
>> wrote:
>>
>>> I do not see nothing in web2py that stops a developer from using a
>>> third party ORM.
>>> Not a common pattern in web2py, because DAL functional approach gives
>>> addiction: you forget the COO (Class Object Oriented) and stick to the
>>> true semantic of python which is full OO.  COO is typical of many
>>> static languages which need a static interface as blueprint for each
>>> object to be instantiated.
>>> The modeling using DAL is much relational modeling very little OO 
>>> modeling.
>>>
>>> I agree it is more about faith and religion, but here a question
>>> raises.  I  suppose the answer is somewhere.  I just did not find it
>>> yet.
>>> Let's suppose that OOP modeling were superior to relational, the
>>> question is why we keep using RDBMS's?  There are some serious
>>> OODBMS's out there, why use an ORM then?
>>>
>>>
>>> mic
>>>
>>> 2012/5/5 Massimo Di Pierro :
>>> >
>>> >
>>> > On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
>>> >>
>>> >> Thanks for the comment. This is an interesting debate.
>>> >>
>>> >> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
>>> >>>
>>> >>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>>> 
>>>  Hi,
>>>  The issue about dal/orm, like Anthony said, there are tradeoffs to
>>>  consider. In my opinion you loose too much not having an orm to 
>>> gain very
>>>  little with the dal. Let me continue my example.
>>>  In the Deparment/Teacher hypothetical model, you also have 
>>> assignment of
>>>  Teachers to Departments. This assignment is very simple (for the 
>>> sake of
>>>  brevity) and has the start/end dates of the assignment and the 
>>> function
>>>  (just a string) of the Teacher in that Department.
>>>  You now want, Given the ID of a department list all the assignments 
>>> of
>>>  all teachers along with their functions in a cool graphical timeline
>>>  fashion.
>>>  It's not about how you get the data. It's about the effort you have
>>>  implementing this req. and how you organize your code. Do you?
>>>  a) write your .selects() in the view function
>>>  b) write a historical_assignments(dep_id) function somewhere that 
>>> hides
>>>  the DAL and call it from the view
>>>  c) write a computed field on the department model
>>>  d) write a method  historical_assignments() on the class Department
>>> 
>>>  To me, the d) option is by far the most elegant. I would have had 
>>> the
>>>  Department class created anyway, so it's a matter of sticking a 
>>> method in
>>>  there. If I am working with an ORM, by defining the classes, I 
>>> automagically
>>>  get the tables defined. Without it, I have to repeat myself, 
>>> redefining the
>>>  fields and the fields in the tables and their types, etc. etc. in 
>>> the
>>>  persistance layer.
>>>  What if I didn't define those classes? Then I couldn't contain these
>>>  kinds of business related operations into a single application 
>>> layer and
>>>  they would leak everywhere, for instance in to the views, being 
>>> much harder
>>>  to maintain.
>>> >>>
>>> >>>
>>> >>> this is somewhat a religious matter. We do not like to pollute the
>>> >>> namespace with one class per table. We do not even usually do 
>>> Department =
>>> >>> db.define_table(...). We just expose db and access department via
>>> >>> db.department. Given this preference:
>>> >>>
>>> >>> db.departement.historical_assignments = Field.Lazy(lambda 
>>> departement,
>>> 

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Khalil KHAMLICHI
I must agree to good practices but that does not mean I cannot deploy
tested code using the built-in editor.


On Sat, May 5, 2012 at 8:49 PM, Tiago Almeida wrote:

> Don't know why one does not use an oodbms. I've never used one. Are there
> any serious alternatives to current rdbms?
>
> Regarding the editor and editing in production. I was expecting that
> argument and think that shouldn't be done unless its some extreme
> emergency. One should not put code in production without testing it
> thoroughly. What if your emergency edit in prod introduces a new bug that
> causes a data loss for the client? Good practice says that you should have
> at least 1  staging server to deploy stuff and test before prod.
>
> Regards
> On May 5, 2012 9:23 PM, "Michele Comitini" 
> wrote:
>
>> I do not see nothing in web2py that stops a developer from using a
>> third party ORM.
>> Not a common pattern in web2py, because DAL functional approach gives
>> addiction: you forget the COO (Class Object Oriented) and stick to the
>> true semantic of python which is full OO.  COO is typical of many
>> static languages which need a static interface as blueprint for each
>> object to be instantiated.
>> The modeling using DAL is much relational modeling very little OO
>> modeling.
>>
>> I agree it is more about faith and religion, but here a question
>> raises.  I  suppose the answer is somewhere.  I just did not find it
>> yet.
>> Let's suppose that OOP modeling were superior to relational, the
>> question is why we keep using RDBMS's?  There are some serious
>> OODBMS's out there, why use an ORM then?
>>
>>
>> mic
>>
>> 2012/5/5 Massimo Di Pierro :
>> >
>> >
>> > On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
>> >>
>> >> Thanks for the comment. This is an interesting debate.
>> >>
>> >> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
>> >>>
>> >>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>> 
>>  Hi,
>>  The issue about dal/orm, like Anthony said, there are tradeoffs to
>>  consider. In my opinion you loose too much not having an orm to gain
>> very
>>  little with the dal. Let me continue my example.
>>  In the Deparment/Teacher hypothetical model, you also have
>> assignment of
>>  Teachers to Departments. This assignment is very simple (for the
>> sake of
>>  brevity) and has the start/end dates of the assignment and the
>> function
>>  (just a string) of the Teacher in that Department.
>>  You now want, Given the ID of a department list all the assignments
>> of
>>  all teachers along with their functions in a cool graphical timeline
>>  fashion.
>>  It's not about how you get the data. It's about the effort you have
>>  implementing this req. and how you organize your code. Do you?
>>  a) write your .selects() in the view function
>>  b) write a historical_assignments(dep_id) function somewhere that
>> hides
>>  the DAL and call it from the view
>>  c) write a computed field on the department model
>>  d) write a method  historical_assignments() on the class Department
>> 
>>  To me, the d) option is by far the most elegant. I would have had the
>>  Department class created anyway, so it's a matter of sticking a
>> method in
>>  there. If I am working with an ORM, by defining the classes, I
>> automagically
>>  get the tables defined. Without it, I have to repeat myself,
>> redefining the
>>  fields and the fields in the tables and their types, etc. etc. in the
>>  persistance layer.
>>  What if I didn't define those classes? Then I couldn't contain these
>>  kinds of business related operations into a single application layer
>> and
>>  they would leak everywhere, for instance in to the views, being much
>> harder
>>  to maintain.
>> >>>
>> >>>
>> >>> this is somewhat a religious matter. We do not like to pollute the
>> >>> namespace with one class per table. We do not even usually do
>> Department =
>> >>> db.define_table(...). We just expose db and access department via
>> >>> db.department. Given this preference:
>> >>>
>> >>> db.departement.historical_assignments = Field.Lazy(lambda departement,
>> >>> date: db(db.teacher.departement)(db.teacher.asdate> >>>
>> >>> seems simpler and clear than to define a class and a method. It does
>> not
>> >>> pollute the namespace. In fact web2py does allow to create a
>> VirtualField
>> >>> class and map that into table, so that records have fields
>> corresponding to
>> >>> methods. We consider it a legacy feature because users prefer the new
>> >>> syntax.
>> >>> Yet this is kind of a religious issue.
>> >>
>> >>
>> >> It may be a religious issue. I was assuming I already had the class
>> >> defined because it made sense if this hypothetical app had a very
>> complex
>> >> domain layer. Like a very complex MMO game. I really believe that not
>> all
>> >> operations could be patched as virtual fields. What abo

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Michele Comitini
2012/5/5 Tiago Almeida :
> Don't know why one does not use an oodbms. I've never used one. Are there
> any serious alternatives to current rdbms?
>
Two of them are quite good albeit complex.
http://www.db4o.com/?src=ODBMS-sidebar
http://www.eyedb.org/

But there is a problem with those they implement a standard that is
now developed by the OMG through the ODBT WG.
OMG is famous for creating too complex standards that are dead before
arrival, to name the two most well known:
- CORBA
- UML

A record track that casts shadows on a standard that is going to reach
version 4 and has been adopted very little.

mic


Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Tiago Almeida
Don't know why one does not use an oodbms. I've never used one. Are there
any serious alternatives to current rdbms?

Regarding the editor and editing in production. I was expecting that
argument and think that shouldn't be done unless its some extreme
emergency. One should not put code in production without testing it
thoroughly. What if your emergency edit in prod introduces a new bug that
causes a data loss for the client? Good practice says that you should have
at least 1  staging server to deploy stuff and test before prod.

Regards
On May 5, 2012 9:23 PM, "Michele Comitini" 
wrote:

> I do not see nothing in web2py that stops a developer from using a
> third party ORM.
> Not a common pattern in web2py, because DAL functional approach gives
> addiction: you forget the COO (Class Object Oriented) and stick to the
> true semantic of python which is full OO.  COO is typical of many
> static languages which need a static interface as blueprint for each
> object to be instantiated.
> The modeling using DAL is much relational modeling very little OO modeling.
>
> I agree it is more about faith and religion, but here a question
> raises.  I  suppose the answer is somewhere.  I just did not find it
> yet.
> Let's suppose that OOP modeling were superior to relational, the
> question is why we keep using RDBMS's?  There are some serious
> OODBMS's out there, why use an ORM then?
>
>
> mic
>
> 2012/5/5 Massimo Di Pierro :
> >
> >
> > On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
> >>
> >> Thanks for the comment. This is an interesting debate.
> >>
> >> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
> >>>
> >>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
> 
>  Hi,
>  The issue about dal/orm, like Anthony said, there are tradeoffs to
>  consider. In my opinion you loose too much not having an orm to gain
> very
>  little with the dal. Let me continue my example.
>  In the Deparment/Teacher hypothetical model, you also have assignment
> of
>  Teachers to Departments. This assignment is very simple (for the sake
> of
>  brevity) and has the start/end dates of the assignment and the
> function
>  (just a string) of the Teacher in that Department.
>  You now want, Given the ID of a department list all the assignments of
>  all teachers along with their functions in a cool graphical timeline
>  fashion.
>  It's not about how you get the data. It's about the effort you have
>  implementing this req. and how you organize your code. Do you?
>  a) write your .selects() in the view function
>  b) write a historical_assignments(dep_id) function somewhere that
> hides
>  the DAL and call it from the view
>  c) write a computed field on the department model
>  d) write a method  historical_assignments() on the class Department
> 
>  To me, the d) option is by far the most elegant. I would have had the
>  Department class created anyway, so it's a matter of sticking a
> method in
>  there. If I am working with an ORM, by defining the classes, I
> automagically
>  get the tables defined. Without it, I have to repeat myself,
> redefining the
>  fields and the fields in the tables and their types, etc. etc. in the
>  persistance layer.
>  What if I didn't define those classes? Then I couldn't contain these
>  kinds of business related operations into a single application layer
> and
>  they would leak everywhere, for instance in to the views, being much
> harder
>  to maintain.
> >>>
> >>>
> >>> this is somewhat a religious matter. We do not like to pollute the
> >>> namespace with one class per table. We do not even usually do
> Department =
> >>> db.define_table(...). We just expose db and access department via
> >>> db.department. Given this preference:
> >>>
> >>> db.departement.historical_assignments = Field.Lazy(lambda departement,
> >>> date: db(db.teacher.departement)(db.teacher.asdate >>>
> >>> seems simpler and clear than to define a class and a method. It does
> not
> >>> pollute the namespace. In fact web2py does allow to create a
> VirtualField
> >>> class and map that into table, so that records have fields
> corresponding to
> >>> methods. We consider it a legacy feature because users prefer the new
> >>> syntax.
> >>> Yet this is kind of a religious issue.
> >>
> >>
> >> It may be a religious issue. I was assuming I already had the class
> >> defined because it made sense if this hypothetical app had a very
> complex
> >> domain layer. Like a very complex MMO game. I really believe that not
> all
> >> operations could be patched as virtual fields. What about operations
> that
> >> have a side effect, instead of returning something?
> >
> >
> > Perhaps the name virtual fields is not the most descriptive. A virtual
> > fields is very much like a method in an ORM. You can pass values to it.
> They
> > can do everything method can including "side 

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Khalil KHAMLICHI
I had to write because you talked about the built-in editor of web2py AND
we have to be fair with this tool that is basicaly my only tool when it
comes to maintaining a server on a remote production site, I would say, on
most deployments this editor is the only tool that we've got to be able to
maintain our application, probably fix bugs before the client notices them,
I use it even when deploying new apps.
So please lets be fair to this really good tool (and friend) and lets not
say that nobody uses it.


Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Michele Comitini
I do not see nothing in web2py that stops a developer from using a
third party ORM.
Not a common pattern in web2py, because DAL functional approach gives
addiction: you forget the COO (Class Object Oriented) and stick to the
true semantic of python which is full OO.  COO is typical of many
static languages which need a static interface as blueprint for each
object to be instantiated.
The modeling using DAL is much relational modeling very little OO modeling.

I agree it is more about faith and religion, but here a question
raises.  I  suppose the answer is somewhere.  I just did not find it
yet.
Let's suppose that OOP modeling were superior to relational, the
question is why we keep using RDBMS's?  There are some serious
OODBMS's out there, why use an ORM then?


mic

2012/5/5 Massimo Di Pierro :
>
>
> On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
>>
>> Thanks for the comment. This is an interesting debate.
>>
>> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
>>>
>>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:

 Hi,
 The issue about dal/orm, like Anthony said, there are tradeoffs to
 consider. In my opinion you loose too much not having an orm to gain very
 little with the dal. Let me continue my example.
 In the Deparment/Teacher hypothetical model, you also have assignment of
 Teachers to Departments. This assignment is very simple (for the sake of
 brevity) and has the start/end dates of the assignment and the function
 (just a string) of the Teacher in that Department.
 You now want, Given the ID of a department list all the assignments of
 all teachers along with their functions in a cool graphical timeline
 fashion.
 It's not about how you get the data. It's about the effort you have
 implementing this req. and how you organize your code. Do you?
 a) write your .selects() in the view function
 b) write a historical_assignments(dep_id) function somewhere that hides
 the DAL and call it from the view
 c) write a computed field on the department model
 d) write a method  historical_assignments() on the class Department

 To me, the d) option is by far the most elegant. I would have had the
 Department class created anyway, so it's a matter of sticking a method in
 there. If I am working with an ORM, by defining the classes, I 
 automagically
 get the tables defined. Without it, I have to repeat myself, redefining the
 fields and the fields in the tables and their types, etc. etc. in the
 persistance layer.
 What if I didn't define those classes? Then I couldn't contain these
 kinds of business related operations into a single application layer and
 they would leak everywhere, for instance in to the views, being much harder
 to maintain.
>>>
>>>
>>> this is somewhat a religious matter. We do not like to pollute the
>>> namespace with one class per table. We do not even usually do Department =
>>> db.define_table(...). We just expose db and access department via
>>> db.department. Given this preference:
>>>
>>> db.departement.historical_assignments = Field.Lazy(lambda departement,
>>> date: db(db.teacher.departement)(db.teacher.asdate>>
>>> seems simpler and clear than to define a class and a method. It does not
>>> pollute the namespace. In fact web2py does allow to create a VirtualField
>>> class and map that into table, so that records have fields corresponding to
>>> methods. We consider it a legacy feature because users prefer the new
>>> syntax.
>>> Yet this is kind of a religious issue.
>>
>>
>> It may be a religious issue. I was assuming I already had the class
>> defined because it made sense if this hypothetical app had a very complex
>> domain layer. Like a very complex MMO game. I really believe that not all
>> operations could be patched as virtual fields. What about operations that
>> have a side effect, instead of returning something?
>
>
> Perhaps the name virtual fields is not the most descriptive. A virtual
> fields is very much like a method in an ORM. You can pass values to it. They
> can do everything method can including "side effects" such as writing to the
> db.
>
> db.teacher.give_raise=lambda row,raise:
> row.update_record(salary=row.salary+raise)
> and you can do:
> for teacher in db(db.teacher).select(): teacher.give_raise(5000)
>
> Virtual fields can also store a state in the row very much like a method
> stores member variables, access and change existing ones.
> By doing this outside of a class the DAL make it easier to have virtual
> fields which are context dependent. For example methods defined only for
> users who have permissions, such as:
>
> if auth.has_permission('give_raise','teacher'):
>     db.teacher.give_raise=lambda row,raise:
> row.update_record(salary=row.salary+raise)
>
>

 Regarding the higher  vs different abstraction. A "perfect" persistence
 layer (if there is such a

Re: [web2py] Re: Exception not thrown for duplicate values.

2012-05-05 Thread Massimo Di Pierro
You can try simply comment the field out, access appadmin once (will drop 
the field), and uncomment the field.

Otherwise You have to drop the tables and delete the corresponding/*.table 
 files. 

If you use sqlite you may as well delete everything in databases/*.


On Saturday, 5 May 2012 12:44:21 UTC-5, rahulserver wrote:
>
> Mr.Massimo,
> Thank you for your response.And it is not only the case of unique=true 
> constraing, but also other constraints like is_not_empty. The db is not 
> enforcing these constraints if they are not declared at the first shot. But 
> what shall be done if i wish to enforce theses? shall i drop the table and 
> recreate them? 
> Kindly do reply because I need to add a few constraints after table 
> creation.
>
> On 5 May 2012 09:33, Massimo Di Pierro  wrote:
>
>> Validators are not applied to CSV import. The unique=True may be ignored 
>> if you are suing sqlite, unless you added it when you first defined the 
>> table. If you added unique=True later it is ignored.
>>
>>
>> On Friday, 4 May 2012 22:40:12 UTC-5, rahulserver wrote:
>>>
>>> I am importing data from a csv file and the field declaration is 
>>> as:Field('Account',requires=**IS_NOT_EMPTY(),unique=True). But no 
>>> exception is thrown when duplicate values for the field is imported!  In 
>>> one of the posts, I have read that it is an sqllite specific issue which I 
>>> am using for backend How to get round it?
>>>
>>
>

Re: [web2py] Re: Exception not thrown for duplicate values.

2012-05-05 Thread RAHUL PRIYADARSI
Mr.Massimo,
Thank you for your response.And it is not only the case of unique=true
constraing, but also other constraints like is_not_empty. The db is not
enforcing these constraints if they are not declared at the first shot. But
what shall be done if i wish to enforce theses? shall i drop the table and
recreate them?
Kindly do reply because I need to add a few constraints after table
creation.

On 5 May 2012 09:33, Massimo Di Pierro  wrote:

> Validators are not applied to CSV import. The unique=True may be ignored
> if you are suing sqlite, unless you added it when you first defined the
> table. If you added unique=True later it is ignored.
>
>
> On Friday, 4 May 2012 22:40:12 UTC-5, rahulserver wrote:
>>
>> I am importing data from a csv file and the field declaration is
>> as:Field('Account',requires=**IS_NOT_EMPTY(),unique=True). But no
>> exception is thrown when duplicate values for the field is imported!  In
>> one of the posts, I have read that it is an sqllite specific issue which I
>> am using for backend How to get round it?
>>
>


Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Massimo Di Pierro


On Saturday, 5 May 2012 11:51:22 UTC-5, Tiago Almeida wrote:
>
> Thanks for the comment. This is an interesting debate.
>
> Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
>>
>> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>>>
>>> Hi,
>>> The issue about dal/orm, like Anthony said, there are tradeoffs to 
>>> consider. In my opinion you loose too much not having an orm to gain very 
>>> little with the dal. Let me continue my example.
>>> In the Deparment/Teacher hypothetical model, you also have assignment of 
>>> Teachers to Departments. This assignment is very simple (for the sake of 
>>> brevity) and has the start/end dates of the assignment and the function 
>>> (just a string) of the Teacher in that Department.
>>> You now want, Given the ID of a department list all the assignments of 
>>> all teachers along with their functions in a cool graphical timeline 
>>> fashion.
>>> It's not about how you get the data. It's about the effort you have 
>>> implementing this req. and how you organize your code. Do you?
>>> a) write your .selects() in the view function
>>> b) write a historical_assignments(dep_id) function somewhere that hides 
>>> the DAL and call it from the view
>>> c) write a computed field on the department model
>>> d) write a method  historical_assignments() on the class Department
>>>
>>> To me, the d) option is by far the most elegant. I would have had the 
>>> Department class created anyway, so it's a matter of sticking a method in 
>>> there. If I am working with an ORM, by defining the classes, I 
>>> automagically get the tables defined. Without it, I have to repeat myself, 
>>> redefining the fields and the fields in the tables and their types, etc. 
>>> etc. in the persistance layer.
>>> What if I didn't define those classes? Then I couldn't contain these 
>>> kinds of business related operations into a single application layer and 
>>> they would leak everywhere, for instance in to the views, being much harder 
>>> to maintain.
>>>
>>
>> this is somewhat a religious matter. We do not like to pollute the 
>> namespace with one class per table. We do not even usually do Department = 
>> db.define_table(...). We just expose db and access department via 
>> db.department. Given this preference:
>>
>> db.departement.historical_assignments = Field.Lazy(lambda departement, 
>> date: db(db.teacher.departement)(db.teacher.asdate>
>> seems simpler and clear than to define a class and a method. It does not 
>> pollute the namespace. In fact web2py does allow to create a VirtualField 
>> class and map that into table, so that records have fields corresponding to 
>> methods. We consider it a legacy feature because users prefer the new 
>> syntax.
>> Yet this is kind of a religious issue.
>>
>  
> It may be a religious issue. I was assuming I already had the class 
> defined because it made sense if this hypothetical app had a very complex 
> domain layer. Like a very complex MMO game. I really believe that not all 
> operations could be patched as virtual fields. What about operations that 
> have a side effect, instead of returning something?
>

Perhaps the name virtual fields is not the most descriptive. A virtual 
fields is very much like a method in an ORM. You can pass values to it. 
They can do everything method can including "side effects" such as writing 
to the db.

db.teacher.give_raise=lambda row,raise: 
row.update_record(salary=row.salary+raise)
and you can do:
for teacher in db(db.teacher).select(): teacher.give_raise(5000)

Virtual fields can also store a state in the row very much like a method 
stores member variables, access and change existing ones.
By doing this outside of a class the DAL make it easier to have virtual 
fields which are context dependent. For example methods defined only for 
users who have permissions, such as:

if auth.has_permission('give_raise','teacher'):
db.teacher.give_raise=lambda row,raise: 
row.update_record(salary=row.salary+raise)

 

> Regarding the higher  vs different abstraction. A "perfect" persistence 
>>> layer (if there is such a thing) allows one to actually forget that you 
>>> have a DB system. I honestly don't care, from the biz point of view, if 
>>> things are stored in tables in a DB, xml files or sent via the wire to 
>>> China. I only care that I create my Departments, .save() them and get them 
>>> later as they were saved .get(id=dep_id).
>>>
>>
>> We do not want to "forget" that we have a DB system. One can only forget 
>> when one builds simple queries. Ifone can only do simple queries than one 
>> starts to think a relational database is not good enough. We want to make 
>> sure .select() maps in an SQL SELECT, .insert() into SQL INSERT, etc. *We 
>> do not want to hide database access which can cause performance issues. 
>> This is a significative difference.* We do no need .save() and .get() 
>> because they are kind of like .insert() and .select() but the mapping is 
>> not a

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Tiago Almeida
Thanks for the comment. This is an interesting debate.

Sábado, 5 de Maio de 2012 17:13:07 UTC+1, Massimo Di Pierro escreveu:
>
> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>>
>> Hi,
>> The issue about dal/orm, like Anthony said, there are tradeoffs to 
>> consider. In my opinion you loose too much not having an orm to gain very 
>> little with the dal. Let me continue my example.
>> In the Deparment/Teacher hypothetical model, you also have assignment of 
>> Teachers to Departments. This assignment is very simple (for the sake of 
>> brevity) and has the start/end dates of the assignment and the function 
>> (just a string) of the Teacher in that Department.
>> You now want, Given the ID of a department list all the assignments of 
>> all teachers along with their functions in a cool graphical timeline 
>> fashion.
>> It's not about how you get the data. It's about the effort you have 
>> implementing this req. and how you organize your code. Do you?
>> a) write your .selects() in the view function
>> b) write a historical_assignments(dep_id) function somewhere that hides 
>> the DAL and call it from the view
>> c) write a computed field on the department model
>> d) write a method  historical_assignments() on the class Department
>>
>> To me, the d) option is by far the most elegant. I would have had the 
>> Department class created anyway, so it's a matter of sticking a method in 
>> there. If I am working with an ORM, by defining the classes, I 
>> automagically get the tables defined. Without it, I have to repeat myself, 
>> redefining the fields and the fields in the tables and their types, etc. 
>> etc. in the persistance layer.
>> What if I didn't define those classes? Then I couldn't contain these 
>> kinds of business related operations into a single application layer and 
>> they would leak everywhere, for instance in to the views, being much harder 
>> to maintain.
>>
>
> this is somewhat a religious matter. We do not like to pollute the 
> namespace with one class per table. We do not even usually do Department = 
> db.define_table(...). We just expose db and access department via 
> db.department. Given this preference:
>
> db.departement.historical_assignments = Field.Lazy(lambda departement, 
> date: db(db.teacher.departement)(db.teacher.asdate
> seems simpler and clear than to define a class and a method. It does not 
> pollute the namespace. In fact web2py does allow to create a VirtualField 
> class and map that into table, so that records have fields corresponding to 
> methods. We consider it a legacy feature because users prefer the new 
> syntax.
> Yet this is kind of a religious issue.
>
 
It may be a religious issue. I was assuming I already had the class defined 
because it made sense if this hypothetical app had a very complex domain 
layer. Like a very complex MMO game. I really believe that not all 
operations could be patched as virtual fields. What about operations that 
have a side effect, instead of returning something?
 

Regarding the higher  vs different abstraction. A "perfect" persistence 
>> layer (if there is such a thing) allows one to actually forget that you 
>> have a DB system. I honestly don't care, from the biz point of view, if 
>> things are stored in tables in a DB, xml files or sent via the wire to 
>> China. I only care that I create my Departments, .save() them and get them 
>> later as they were saved .get(id=dep_id).
>>
>
> We do not want to "forget" that we have a DB system. One can only forget 
> when one builds simple queries. Ifone can only do simple queries than one 
> starts to think a relational database is not good enough. We want to make 
> sure .select() maps in an SQL SELECT, .insert() into SQL INSERT, etc. *We 
> do not want to hide database access which can cause performance issues. 
> This is a significative difference.* We do no need .save() and .get() 
> because they are kind of like .insert() and .select() but the mapping is 
> not always as clear. Moreover is not very Object Oriented either.
>
Ok. This is the old issue of performance vs elegance and the correct answer 
really depends on the type of project. When you use Python, you "forget" 
that below you there is probably a cpu with lots of unused vector 
specialized instructions. They could be exposed, but they were not.
 
 

> Do you lose anything with this abstraction? Yes, of course. If you hide 
>> that it's a DB you lose, for instance, DB triggers. It's the normal 
>> tradeoff in any abstraction. If you use TCP, you get delivery guarantees 
>> and peace of mind regarding all the dropped/corrupted packets nonsense 
>> while loosing, say, realtime guarantees. Should we stop using TCP because 
>> we loose this 'realtimeness'? Of course not.
>> Are there things that you can do with an orm that you can not with adal? 
>> No, it's quite the opposite. The dal exposes more details therefore allows 
>> you to do more. However, by exposing all these details, you get a 

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Carlos Costa
I take this as opportunity to compliment the DAL.
I have never seen clever way to manipulate data in a relational database.
I am actually addicted to the way it works. I wish could work with
web2py as my primary job.

2012/5/5 Massimo Di Pierro :
> On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>>
>> Hi,
>> The issue about dal/orm, like Anthony said, there are tradeoffs to
>> consider. In my opinion you loose too much not having an orm to gain very
>> little with the dal. Let me continue my example.
>> In the Deparment/Teacher hypothetical model, you also have assignment of
>> Teachers to Departments. This assignment is very simple (for the sake of
>> brevity) and has the start/end dates of the assignment and the function
>> (just a string) of the Teacher in that Department.
>> You now want, Given the ID of a department list all the assignments of all
>> teachers along with their functions in a cool graphical timeline fashion.
>> It's not about how you get the data. It's about the effort you have
>> implementing this req. and how you organize your code. Do you?
>> a) write your .selects() in the view function
>> b) write a historical_assignments(dep_id) function somewhere that hides
>> the DAL and call it from the view
>> c) write a computed field on the department model
>> d) write a method  historical_assignments() on the class Department
>>
>> To me, the d) option is by far the most elegant. I would have had the
>> Department class created anyway, so it's a matter of sticking a method in
>> there. If I am working with an ORM, by defining the classes, I automagically
>> get the tables defined. Without it, I have to repeat myself, redefining the
>> fields and the fields in the tables and their types, etc. etc. in the
>> persistance layer.
>> What if I didn't define those classes? Then I couldn't contain these kinds
>> of business related operations into a single application layer and they
>> would leak everywhere, for instance in to the views, being much harder to
>> maintain.
>
>
> this is somewhat a religious matter. We do not like to pollute the namespace
> with one class per table. We do not even usually do Department =
> db.define_table(...). We just expose db and access department via
> db.department. Given this preference:
>
> db.departement.historical_assignments = Field.Lazy(lambda departement, date:
> db(db.teacher.departement)(db.teacher.asdate
> seems simpler and clear than to define a class and a method. It does not
> pollute the namespace. In fact web2py does allow to create a VirtualField
> class and map that into table, so that records have fields corresponding to
> methods. We consider it a legacy feature because users prefer the new
> syntax.
> Yet this is kind of a religious issue.
>
>> Regarding the higher  vs different abstraction. A "perfect" persistence
>> layer (if there is such a thing) allows one to actually forget that you have
>> a DB system. I honestly don't care, from the biz point of view, if things
>> are stored in tables in a DB, xml files or sent via the wire to China. I
>> only care that I create my Departments, .save() them and get them later as
>> they were saved .get(id=dep_id).
>
>
> We do not want to "forget" that we have a DB system. One can only forget
> when one builds simple queries. Ifone can only do simple queries than one
> starts to think a relational database is not good enough. We want to make
> sure .select() maps in an SQL SELECT, .insert() into SQL INSERT, etc. We do
> not want to hide database access which can cause performance issues. This is
> a significative difference. We do no need .save() and .get() because they
> are kind of like .insert() and .select() but the mapping is not always as
> clear. Moreover is not very Object Oriented either.
>
>>
>> Do you lose anything with this abstraction? Yes, of course. If you hide
>> that it's a DB you lose, for instance, DB triggers. It's the normal tradeoff
>> in any abstraction. If you use TCP, you get delivery guarantees and peace of
>> mind regarding all the dropped/corrupted packets nonsense while loosing,
>> say, realtime guarantees. Should we stop using TCP because we loose this
>> 'realtimeness'? Of course not.
>> Are there things that you can do with an orm that you can not with adal?
>> No, it's quite the opposite. The dal exposes more details therefore allows
>> you to do more. However, by exposing all these details, you get a tool that
>> is harder to use (in the sense that you have to repeat yourself) for all the
>> other scenarios where you don't need such details. Python is used because no
>> one wants to deal with the nonsense of lower level languanges that arise
>> from exposing too many details (manual memory management, target machine
>> dependency, etc).
>> Lastly, If I am working with an orm and need to implement a really complex
>> query, nothing stops me from going deeper and use the dal or even writing
>> SQL.
>
>
> This is what we do not like. The goal of the DAL is

[web2py] Re: default/user.html and custom form

2012-05-05 Thread Annet
@ Cèdric,

Thanks for your reply.

@Massimo,

Your reply is what I'd hoped for. Thanks.


Kind regards,

Annet


[web2py] Re: "time" picker not working, how to show 15min increments

2012-05-05 Thread Massimo Di Pierro
browser cache. Try load calendar.js in browser and click reload a few times.

On Saturday, 5 May 2012 10:25:16 UTC-5, Vincent Davis wrote:
>
> I am not sure what I don't get here. I edited web2py.js and changed this 
> line.
> FROM
>   jQuery("input.time",target).each(function(){jQuery(this).timeEntry();});
> TO
>   
> jQuery("input.time",target).each(function(){jQuery(this).timeEntry({showSeconds:
>  
> false, timeSteps: [1,15,0]});});
>
> This has no effect? In act when I load a page with a form and inspect the 
> loaded resources the web2py.js still has the first version. (I have 
> restarted the and cleaned the server)
> Also if I click "edit" on web2py.js it shows my changes, if I just click 
> on web2py.js chrome opens the file and show the original. I browsed into 
> the application (web2py>show contents>>applications>myapp>...>web2py.js 
> and it shows the changes I have made. Where is the other coming from? 
>
>
> Thanks
> Vincent
>
>
> On Saturday, May 5, 2012 7:31:35 AM UTC-6, Massimo Di Pierro wrote:
>>
>> I guess the book need updating. You need to install the jquery plugin 
>> time picker yourself and perhaps replace the line in web2py.js that calls 
>> timeentry.
>>
>> On Saturday, 5 May 2012 07:25:43 UTC-5, Vincent Davis wrote:
>>>
>>>  jquery timeentry is the behavior I am getting, I was expecting the 
>>> behavior show in the book :-)
>>>
>>> Suggestion on listing 15min time increments?
>>>
>>> Thanks
>>> Vincent
>>>
>>>
>>> On Friday, May 4, 2012 10:56:48 PM UTC-6, Massimo Di Pierro wrote:

 I am also using 1.99.7 with chrome on mac and it works for me. Perhaps 
 you expect a different behavior.
 The time field does not use timepicker (it used to). It uses jquery 
 timeentry. It has no popups.
 If you start typing a number into the field, it will format it as time 
 and will allow you to use arrows to change hhh:mm:ss.


 On Friday, 4 May 2012 23:19:01 UTC-5, Vincent Davis wrote:
>
> version 1.99.7 mac
> I have tried Chrome and Safari (osx 10.7)
>
> Just used the wizard to build a simple app. No modification from 
> wizard. see db below
>
> ### we prepend t_ to tablenames and f_ to fieldnames for disambiguity
>
>
> 
> db.define_table('t_children',
> Field('f_first_name', type='string', notnull=True,
>   label=T('First Name')),
> Field('f_last_name', type='string', notnull=True,
>   label=T('Last Name')),
> Field('f_dob', type='date', notnull=True,
>   label=T('Dob')),
> auth.signature,
> format='%(f_first_name)s',
> migrate=settings.migrate)
>
> db.define_table('t_children_archive',db.t_children,Field('current_record','reference
>  
> t_children',readable=False,writable=False))
>
> 
> db.define_table('t_parents',
> Field('f_first_name1', type='string', notnull=True,
>   label=T('First Name1')),
> Field('f_last_name1', type='string', notnull=True,
>   label=T('Last Name1')),
> Field('f_first_name2', type='string', notnull=True,
>   label=T('First Name2')),
> Field('f_last_name2', type='string', notnull=True,
>   label=T('Last Name2')),
> Field('f_phone', type='string',
>   label=T('Phone')),
> Field('f_children', type='list:reference t_children',
>   label=T('Children')),
> auth.signature,
> format='%(f_first_name1)s',
> migrate=settings.migrate)
>
> db.define_table('t_parents_archive',db.t_parents,Field('current_record','reference
>  
> t_parents',readable=False,writable=False))
>
> 
> db.define_table('t_reservation',
> Field('f_room', type='string', notnull=True,
>   label=T('Room')),
> Field('f_start', type='time',
>   label=T('Start')),
> Field('f_end', type='time',
>   label=T('End')),
> Field('f_day', type='date',
>   label=T('Day')),
> Field('f_child', type='reference t_children', notnull=True,
>   label=T('Child')),
> auth.signature,
> format='%(f_room)s',
> migrate=settings.migrate)
>
> db.define_table('t_reservation_archive',db.t_reservation,Field('current_record','reference
>  
> t_reservation',readable=False,writable=False))
>
> On Friday, May 4, 2012 10:02:03 PM UTC-6, Massimo Di Pierro wrote:
>>
>> which web2py version are you using? Which browser?
>>
>> On Friday, 4 May 2012 22:24:50 UTC-5, Vincent Davis wrote:
>>>
>>>
>>>1. The web2py book suggests there is a time picker ajax built 
>>>in. It does not work for me, both the date and datetime picker does. 
>>>http://web2py.com/books/default/chapt

Re: [web2py] An insult to web2py ?

2012-05-05 Thread Carlos Costa
I read it like a manifest of preferences, not like argumentations.
Nothing to worry about.

Em 3 de maio de 2012 08:40, António Ramos  escreveu:
> a person just wrote this about web2py in a portuguese forum
> Anyone care to coment?
>
>
> Viva,
>
> Eu conheci primeiro o web2py e só uns meses depois o Django.
> Ao início achei bastante interessante (a ferramenta de admin, tutorial fácil
> de seguir, etc.). O que me fez saltar do web2py para o django e nunca voltar
> para trás foi, entre outros, o seguinte:
>
> - web2py não tem um ORM, tem uma api OO mas que segue o mesmo paradigma de
> SQL, No fundo, ao fazer .select() / .union() estamos a escrever SQL
> disfarçado. Um bom ORM permite não ter de escrever SQL em 90% dos casos,
> poupando trabalho.
>
> - Os objectos retornados pela camada de persistência do web2py não têm
> classes que façam sentido no domínio (Books, Persons, whatever seja o
> domínio), aquilo retorna umas instâncias de Record (ou lá o que é) que não
> são mais do que dicts. O mapeamento disso para instâncias de classes do
> domínio tem de ser feito à mão.
>
> - A ideia de poder meter python arbitrário no template parece gira mas
> facilmente descamba para ficheiros com python+html+javascript tudo
> entrelaçado e impossível de manter.
>
> - A magia da framework. Se bem me lembro os dados do request actual são
> postos em variáveis globais sem qualquer necessidade (podiam ser passados
> para a view, como no django).
>
> - Os models são executados ( exec() ) a cada pedido. Não há necessidade para
> este overhead.
>
> - Com tantos editores excelentes (emacs,vim,eclipse,vstudio,..),porquê usar
> um editor inferior no browser? Se gastarem tempo a trazer esse editor ao
> nível dos outros, perderam tempo que podia ter sido usado para melhorar
> outras partes da framework.
>
> - A qualidade do código é incomparável. Pequeno exemplo: Lembro-me que o
> núcleo da persistência do web2py na altura era um sql.py com algumas 3000
> linhas, todo martelado com ifs para emitir SQL cozido ou assado consoante a
> BD e, de ver o Massimo* argumentar na mailing list que não era crítico
> melhorar aquela parte.
>
> Para mim, o web2py é bom como uma ferramenta de aprendizagem, nada mais.
>
> Cumprimentos.



-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Massimo Di Pierro
On Saturday, 5 May 2012 10:23:34 UTC-5, Tiago Almeida wrote:
>
> Hi,
> The issue about dal/orm, like Anthony said, there are tradeoffs to 
> consider. In my opinion you loose too much not having an orm to gain very 
> little with the dal. Let me continue my example.
> In the Deparment/Teacher hypothetical model, you also have assignment of 
> Teachers to Departments. This assignment is very simple (for the sake of 
> brevity) and has the start/end dates of the assignment and the function 
> (just a string) of the Teacher in that Department.
> You now want, Given the ID of a department list all the assignments of all 
> teachers along with their functions in a cool graphical timeline fashion.
> It's not about how you get the data. It's about the effort you have 
> implementing this req. and how you organize your code. Do you?
> a) write your .selects() in the view function
> b) write a historical_assignments(dep_id) function somewhere that hides 
> the DAL and call it from the view
> c) write a computed field on the department model
> d) write a method  historical_assignments() on the class Department
>
> To me, the d) option is by far the most elegant. I would have had the 
> Department class created anyway, so it's a matter of sticking a method in 
> there. If I am working with an ORM, by defining the classes, I 
> automagically get the tables defined. Without it, I have to repeat myself, 
> redefining the fields and the fields in the tables and their types, etc. 
> etc. in the persistance layer.
> What if I didn't define those classes? Then I couldn't contain these kinds 
> of business related operations into a single application layer and they 
> would leak everywhere, for instance in to the views, being much harder to 
> maintain.
>

this is somewhat a religious matter. We do not like to pollute the 
namespace with one class per table. We do not even usually do Department = 
db.define_table(...). We just expose db and access department via 
db.department. Given this preference:

db.departement.historical_assignments = Field.Lazy(lambda departement, 
date: db(db.teacher.departement)(db.teacher.asdate layer (if there is such a thing) allows one to actually forget that you 
> have a DB system. I honestly don't care, from the biz point of view, if 
> things are stored in tables in a DB, xml files or sent via the wire to 
> China. I only care that I create my Departments, .save() them and get them 
> later as they were saved .get(id=dep_id).
>

We do not want to "forget" that we have a DB system. One can only forget 
when one builds simple queries. Ifone can only do simple queries than one 
starts to think a relational database is not good enough. We want to make 
sure .select() maps in an SQL SELECT, .insert() into SQL INSERT, etc. We do 
not want to hide database access which can cause performance issues. This 
is a significative difference. We do no need .save() and .get() because 
they are kind of like .insert() and .select() but the mapping is not always 
as clear. Moreover is not very Object Oriented either.
 

> Do you lose anything with this abstraction? Yes, of course. If you hide 
> that it's a DB you lose, for instance, DB triggers. It's the normal 
> tradeoff in any abstraction. If you use TCP, you get delivery guarantees 
> and peace of mind regarding all the dropped/corrupted packets nonsense 
> while loosing, say, realtime guarantees. Should we stop using TCP because 
> we loose this 'realtimeness'? Of course not.
> Are there things that you can do with an orm that you can not with adal? 
> No, it's quite the opposite. The dal exposes more details therefore allows 
> you to do more. However, by exposing all these details, you get a tool that 
> is harder to use (in the sense that you have to repeat yourself) for all 
> the other scenarios where you don't need such details. Python is used 
> because no one wants to deal with the nonsense of lower level languanges 
> that arise from exposing too many details (manual memory management, target 
> machine dependency, etc).
> Lastly, If I am working with an orm and need to implement a really complex 
> query, nothing stops me from going deeper and use the dal or even writing 
> SQL. 
>

This is what we do not like. The goal of the DAL is to try avoid this as 
much as possible, although it does not prevent it.

 
>
>>  look at 
>> the Django ORM Tutorial example: 
>>
>> Poll.objects.filter(question__startswith='What') 
>>
>> In web2Py DAL it would use more standard python methods: 
>>
>> db( db.Poll.question.startswith("what") ).select() 
>>
> I've never said that Django's orm is perfect. That "__operator" thing 
> could be done in a different way. Anyway I accept that minor annoyance 
> because it saves me time overall.
>

I see this in a different light. Web2py supported left joins, aggregates, 
and nested selects 2 years before Django did. While they added those 
features over time, we added so many other features (list types, native GAE 
sup

Re: [web2py] Re: Trying to implement a full-page calendar

2012-05-05 Thread Cindy Michalowski
Thanks so much for the suggestions! I'll check these out and follow up with
anything that might be helpful to someone else in the future.

Kind regards,
Cindy

On Fri, May 4, 2012 at 5:19 PM, villas  wrote:

> In fact,  it is using  FullCalendar so I'm sure it will be interesting for
> you.
>
>
> On Friday, 4 May 2012 23:18:48 UTC+1, villas wrote:
>>
>> Don't forget the appliances page:
>> http://web2py.com/appliances
>>
>> I think the AppointmentManager app implements a calendar that might be
>> interesting.
>> Anyway, it is easy to download it and take a look.
>>
>>
>>
>> On Thursday, 3 May 2012 22:32:50 UTC+1, Cindy Michalowski wrote:
>>>
>>> Hello all,
>>>
>>> I am trying to implement a full page calendar as part of a web2py
>>> website, and after many google/bing/etc. searches I'm finding very few
>>> results. Basically, I want to make a calendar - month view only - that
>>> allows the user to view a calendar in the current month by default, and
>>> then a specified number of past and future months as well. The site
>>> administrators should be able to easily add events to the calendar which
>>> can be clicked on by any user for a detaiedl view of the event. Overall,
>>> the functionality that I'm trying to achieve is pretty simple.
>>>
>>> I found two apps - both of which have been mentioned in the web2py
>>> Google groups before - that are pretty close to what I want to build:
>>>
>>> 1) http://arshaw.com/**fullcalendar/ 
>>> This is a j-query plugin. Aside from moving the .css files to the
>>> static/css folder and the .js files to the static/js folder, I really don't
>>> know how to integrate this into web2py.
>>>
>>> 2) 
>>> http://www.agendadulibre.qc.**ca/event/2011/9/
>>> I believe this is written in Python.
>>>
>>> As a third option, I considered writing the calendar in ActionScript 3
>>> and trying to link the interaction in the AIR app to the database in
>>> web2py, but this is just an idea that I have and I'm only starting to
>>> research it. I have no idea as to whether or not its feasible.
>>>
>>> I am a fairly new web2py user, and I'm just looking for a nudge in the
>>> right direction. Does anyone have any experience with integrating either of
>>> these calendars, and if so, would you mind sharing a few tips just to help
>>> me get started? Or does anyone know of a web2py slice or a web2py widget
>>> that I may have overlooked while researching how to implement this?
>>>
>>> Thanks in advance,
>>> Cindy
>>>
>>


[web2py] Re: "time" picker not working, how to show 15min increments

2012-05-05 Thread Vincent Davis
I am not sure what I don't get here. I edited web2py.js and changed this 
line.
FROM
  jQuery("input.time",target).each(function(){jQuery(this).timeEntry();});
TO
  
jQuery("input.time",target).each(function(){jQuery(this).timeEntry({showSeconds:
 
false, timeSteps: [1,15,0]});});

This has no effect? In act when I load a page with a form and inspect the 
loaded resources the web2py.js still has the first version. (I have 
restarted the and cleaned the server)
Also if I click "edit" on web2py.js it shows my changes, if I just click on 
web2py.js chrome opens the file and show the original. I browsed into the 
application (web2py>show contents>>applications>myapp>...>web2py.js and 
it shows the changes I have made. Where is the other coming from? 


Thanks
Vincent


On Saturday, May 5, 2012 7:31:35 AM UTC-6, Massimo Di Pierro wrote:
>
> I guess the book need updating. You need to install the jquery plugin time 
> picker yourself and perhaps replace the line in web2py.js that calls 
> timeentry.
>
> On Saturday, 5 May 2012 07:25:43 UTC-5, Vincent Davis wrote:
>>
>>  jquery timeentry is the behavior I am getting, I was expecting the 
>> behavior show in the book :-)
>>
>> Suggestion on listing 15min time increments?
>>
>> Thanks
>> Vincent
>>
>>
>> On Friday, May 4, 2012 10:56:48 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> I am also using 1.99.7 with chrome on mac and it works for me. Perhaps 
>>> you expect a different behavior.
>>> The time field does not use timepicker (it used to). It uses jquery 
>>> timeentry. It has no popups.
>>> If you start typing a number into the field, it will format it as time 
>>> and will allow you to use arrows to change hhh:mm:ss.
>>>
>>>
>>> On Friday, 4 May 2012 23:19:01 UTC-5, Vincent Davis wrote:

 version 1.99.7 mac
 I have tried Chrome and Safari (osx 10.7)

 Just used the wizard to build a simple app. No modification from 
 wizard. see db below

 ### we prepend t_ to tablenames and f_ to fieldnames for disambiguity


 
 db.define_table('t_children',
 Field('f_first_name', type='string', notnull=True,
   label=T('First Name')),
 Field('f_last_name', type='string', notnull=True,
   label=T('Last Name')),
 Field('f_dob', type='date', notnull=True,
   label=T('Dob')),
 auth.signature,
 format='%(f_first_name)s',
 migrate=settings.migrate)

 db.define_table('t_children_archive',db.t_children,Field('current_record','reference
  
 t_children',readable=False,writable=False))

 
 db.define_table('t_parents',
 Field('f_first_name1', type='string', notnull=True,
   label=T('First Name1')),
 Field('f_last_name1', type='string', notnull=True,
   label=T('Last Name1')),
 Field('f_first_name2', type='string', notnull=True,
   label=T('First Name2')),
 Field('f_last_name2', type='string', notnull=True,
   label=T('Last Name2')),
 Field('f_phone', type='string',
   label=T('Phone')),
 Field('f_children', type='list:reference t_children',
   label=T('Children')),
 auth.signature,
 format='%(f_first_name1)s',
 migrate=settings.migrate)

 db.define_table('t_parents_archive',db.t_parents,Field('current_record','reference
  
 t_parents',readable=False,writable=False))

 
 db.define_table('t_reservation',
 Field('f_room', type='string', notnull=True,
   label=T('Room')),
 Field('f_start', type='time',
   label=T('Start')),
 Field('f_end', type='time',
   label=T('End')),
 Field('f_day', type='date',
   label=T('Day')),
 Field('f_child', type='reference t_children', notnull=True,
   label=T('Child')),
 auth.signature,
 format='%(f_room)s',
 migrate=settings.migrate)

 db.define_table('t_reservation_archive',db.t_reservation,Field('current_record','reference
  
 t_reservation',readable=False,writable=False))

 On Friday, May 4, 2012 10:02:03 PM UTC-6, Massimo Di Pierro wrote:
>
> which web2py version are you using? Which browser?
>
> On Friday, 4 May 2012 22:24:50 UTC-5, Vincent Davis wrote:
>>
>>
>>1. The web2py book suggests there is a time picker ajax built in. 
>>It does not work for me, both the date and datetime picker does. 
>>http://web2py.com/books/default/chapter/29/11#web2py_ajax.html  I 
>>don't get the time picker shown here or any time picker.
>>2. I would like to only display time in 15min increments. is it 
>>possible and should I do this with a drop down rather than a ajax?
>>3. Ultimately the think I woul

Re: [web2py] Re: An insult to web2py ?

2012-05-05 Thread Tiago Almeida
Hi,
The issue about dal/orm, like Anthony said, there are tradeoffs to 
consider. In my opinion you loose too much not having an orm to gain very 
little with the dal. Let me continue my example.
In the Deparment/Teacher hypothetical model, you also have assignment of 
Teachers to Departments. This assignment is very simple (for the sake of 
brevity) and has the start/end dates of the assignment and the function 
(just a string) of the Teacher in that Department.
You now want, Given the ID of a department list all the assignments of all 
teachers along with their functions in a cool graphical timeline fashion.
It's not about how you get the data. It's about the effort you have 
implementing this req. and how you organize your code. Do you?
a) write your .selects() in the view function
b) write a historical_assignments(dep_id) function somewhere that hides the 
DAL and call it from the view
c) write a computed field on the department model
d) write a method  historical_assignments() on the class Department

To me, the d) option is by far the most elegant. I would have had the 
Department class created anyway, so it's a matter of sticking a method in 
there. If I am working with an ORM, by defining the classes, I 
automagically get the tables defined. Without it, I have to repeat myself, 
redefining the fields and the fields in the tables and their types, etc. 
etc. in the persistance layer.
What if I didn't define those classes? Then I couldn't contain these kinds 
of business related operations into a single application layer and they 
would leak everywhere, for instance in to the views, being much harder to 
maintain.

Regarding the higher  vs different abstraction. A "perfect" persistence 
layer (if there is such a thing) allows one to actually forget that you 
have a DB system. I honestly don't care, from the biz point of view, if 
things are stored in tables in a DB, xml files or sent via the wire to 
China. I only care that I create my Departments, .save() them and get them 
later as they were saved .get(id=dep_id).
Do you lose anything with this abstraction? Yes, of course. If you hide 
that it's a DB you lose, for instance, DB triggers. It's the normal 
tradeoff in any abstraction. If you use TCP, you get delivery guarantees 
and peace of mind regarding all the dropped/corrupted packets nonsense 
while loosing, say, realtime guarantees. Should we stop using TCP because 
we loose this 'realtimeness'? Of course not.
Are there things that you can do with an orm that you can not with adal? 
No, it's quite the opposite. The dal exposes more details therefore allows 
you to do more. However, by exposing all these details, you get a tool that 
is harder to use (in the sense that you have to repeat yourself) for all 
the other scenarios where you don't need such details. Python is used 
because no one wants to deal with the nonsense of lower level languanges 
that arise from exposing too many details (manual memory management, target 
machine dependency, etc).
Lastly, If I am working with an orm and need to implement a really complex 
query, nothing stops me from going deeper and use the dal or even writing 
SQL. The same way, not all projects are done in Python.


For professional programmers, instead the editor, I'm developing rad2py ;-) 
>
> http://code.google.com/p/rad2py/ 
>
Looks great. But I am still not convinced I would use it :P

Also, please note that the relational model (and so the DAL) has a 
> "mathematical" formal theory behind

I've learned this in college. I've never seen anyone use relational algebra 
in a real world project. I've also learned in my experience that database 
normalization sometimes has to go in order to get, for instance, 
performance. Don't really see how this scores points for the DAL.
 

>  * learning a non-standard query language (many times it is incomplete 
> and changes often, with ) 
>

Don't see why it should change often 

 * forcing you to use OOP techniques (that may not be viable for high 
> school students or casual programmers) 
>
Like I said in my first post in the other thread and dragged out of context 
to here: Web2py is good as a learning tool. It also happens that I'm not a 
casual programmer so don't see that as an advantage.

 * sticking with a particular programming language and/or few database 
> engines 
>  * performance issues (for example, most times you don't need all the 
> fields of a table) 
>
An ORM does not have to select * everytime.
 

>  * lack of declarative expressiveness (many times you'll end writing 
> procedural code, fetching, mixing and processing records by hand...) 
>
 
You also have to map data from the dal into you business layer by hand. 

>
>  

>  look at 
> the Django ORM Tutorial example: 
>
> Poll.objects.filter(question__startswith='What') 
>
> In web2Py DAL it would use more standard python methods: 
>
> db( db.Poll.question.startswith("what") ).select() 
>
I've never said that Django's orm is perfect. That "__o

[web2py] Re: Creating a select widget in the html template with data corresponding to a list in models

2012-05-05 Thread Alan Etkin
A quick (and maybe vague) response:

mylist = ["apples", "oranges", "bananas", "cows"]

# assuming there is a string myfield defined in the model
db.mytable.myfield.requires=IS_IN_SET(mylist)

Note: validators can be set in an action basis, for example, for a given 
form, they are configurable with options, and you can customize them with 
special features:
http://web2py.com/books/default/chapter/29/7?search=is_in_set#Custom-validators

It is possible also to customize the widgets used by default with the 
validators for more sophisticated interfaces:
http://web2py.com/books/default/chapter/29/7?search=is_in_set#Widgets 

The API with more info
http://www.web2py.com/examples/static/epydoc/web2py.gluon.validators.IS_IN_SET-class.html

For simple and excellent examples check the official web2py book at 

http://web2py.com/books/default/chapter/29/7?search=is_in_set#Validators

On Saturday, May 5, 2012 10:26:28 AM UTC-3, novice007 wrote:
>
> I come from the django background and wanted to play around with web2py. 
> There is an awesome feature in django model forms, the analogous to SQL 
> Forms in web2py. 
> The feature which i want to implement in web2py is 
> this
> .
>
> I tried searching for stuff, but the solutions were more complicated, i 
> have posted a SO question 
> here
> . 
>


[web2py] Re: Auth form custom errors

2012-05-05 Thread Alan Etkin
*auth.is_logged_in()* will return a bool object. True for authenticated 
user and I belive *auth.user_id* attribute is None for the non 
authenticated user. *auth *being the Auth class instance created by the 
welcome scaffolding application.

You could use the returned values to catch unsuccessful authentication and 
redirect to the correct action

There is an Auth setting for failed authentication (for example, it's 
possible to call a function on failed login)
("Settings and Messages", web2py book 4th edition, 9.3.7)

auth.settings.on_failed_authentication = lambda url: redirect(url)

On Saturday, May 5, 2012 9:51:23 AM UTC-3, Rhys wrote:
>
> I'm creating a custom drop down login form for all pages where the user 
> isn't logged in. Once they try and login through this form if it 
> is unsuccessful it redirects to the /user/login page with the auth.login 
> form. How do I get a error if the login has resulted in an invalid login. 
> As there are two forms I've tried also tried to do a form out of html so 
> there is no form key. Still no luck. Is it s simple variable I can use to 
> determine if it is successful? 



Re: [web2py] Re: TR and TD

2012-05-05 Thread praveen krishna
Ya ,Thank you

On Sat, May 5, 2012 at 3:34 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This is wrong. Should be:
>
>  def records():
> 'show all recors in plugin_seq db to user'
> records = db(db.plugin_seq.id>0).select(**)
> items = []
> for record in records:
> items.append(TR(TD(record.**filename),(TD('del'
> return TABLE(*items)
>
> >>> print  TD('hello')
> hello
> >>> print  TR(TD('hello'),TD('world'))
> helloworld
> >>> items = [TR(TD('hello'),TD('world'))]
> >>> print TABLE(*items)
> helloworld
>
> Hope it makes sense.
>
> On Saturday, 5 May 2012 07:32:09 UTC-5, praveen krishna wrote:
>>
>> Hii,
>>  What does TR and TD do in the function
>>  def records():
>> 'show all recors in plugin_seq db to user'
>> records = db(db.plugin_seq.id>0).select(**)
>> items = []
>> for record in records:
>> items.append(TR(TD(record.**filename)(TD('del'
>> return TABLE(items)
>>  and what does actually TR and TD mean.
>>
>


[web2py] Creating a select widget in the html template with data corresponding to a list in models

2012-05-05 Thread novice007
I come from the django background and wanted to play around with web2py. 
There is an awesome feature in django model forms, the analogous to SQL 
Forms in web2py. 
The feature which i want to implement in web2py is 
this
.

I tried searching for stuff, but the solutions were more complicated, i 
have posted a SO question 
here
. 


[web2py] Dynamic Subdomain Routing

2012-05-05 Thread chris
Hi all,

i'm trying to choose between frameworks for my new project and i'm liking 
what I see with web2py but currently flask is the only one i can find that 
will do what i need with routing / subdomains.

basically, i'm trying to use the subdomain as the keyword I will run a 
database qurey on. it does not need to redirect anywhere (like 
mydomain.com/search/variable).

with flask, my route would look like "@app.route("/", 
subdomain="")", which would make my subdomain available in functions 
as var1.

is this kind of thing possible with web2py? if yes, is there anywhere it 
would work (like when using url_for())?

thanks


[web2py] Re: TR and TD

2012-05-05 Thread Massimo Di Pierro
This is wrong. Should be:

 def records():
'show all recors in plugin_seq db to user'
records = db(db.plugin_seq.id>0).select()
items = []
for record in records:
items.append(TR(TD(record.filename),(TD('del'
return TABLE(*items)

>>> print  TD('hello')
hello
>>> print  TR(TD('hello'),TD('world'))
helloworld
>>> items = [TR(TD('hello'),TD('world'))]
>>> print TABLE(*items)
helloworld

Hope it makes sense.

On Saturday, 5 May 2012 07:32:09 UTC-5, praveen krishna wrote:
>
> Hii,
>  What does TR and TD do in the function 
>  def records():
> 'show all recors in plugin_seq db to user'
> records = db(db.plugin_seq.id>0).select()
> items = []
> for record in records:
> items.append(TR(TD(record.filename)(TD('del'
> return TABLE(items)
>  and what does actually TR and TD mean.
>


[web2py] Re: "time" picker not working, how to show 15min increments

2012-05-05 Thread Massimo Di Pierro
I guess the book need updating. You need to install the jquery plugin time 
picker yourself and perhaps replace the line in web2py.js that calls 
timeentry.

On Saturday, 5 May 2012 07:25:43 UTC-5, Vincent Davis wrote:
>
>  jquery timeentry is the behavior I am getting, I was expecting the 
> behavior show in the book :-)
>
> Suggestion on listing 15min time increments?
>
> Thanks
> Vincent
>
>
> On Friday, May 4, 2012 10:56:48 PM UTC-6, Massimo Di Pierro wrote:
>>
>> I am also using 1.99.7 with chrome on mac and it works for me. Perhaps 
>> you expect a different behavior.
>> The time field does not use timepicker (it used to). It uses jquery 
>> timeentry. It has no popups.
>> If you start typing a number into the field, it will format it as time 
>> and will allow you to use arrows to change hhh:mm:ss.
>>
>>
>> On Friday, 4 May 2012 23:19:01 UTC-5, Vincent Davis wrote:
>>>
>>> version 1.99.7 mac
>>> I have tried Chrome and Safari (osx 10.7)
>>>
>>> Just used the wizard to build a simple app. No modification from wizard. 
>>> see db below
>>>
>>> ### we prepend t_ to tablenames and f_ to fieldnames for disambiguity
>>>
>>>
>>> 
>>> db.define_table('t_children',
>>> Field('f_first_name', type='string', notnull=True,
>>>   label=T('First Name')),
>>> Field('f_last_name', type='string', notnull=True,
>>>   label=T('Last Name')),
>>> Field('f_dob', type='date', notnull=True,
>>>   label=T('Dob')),
>>> auth.signature,
>>> format='%(f_first_name)s',
>>> migrate=settings.migrate)
>>>
>>> db.define_table('t_children_archive',db.t_children,Field('current_record','reference
>>>  
>>> t_children',readable=False,writable=False))
>>>
>>> 
>>> db.define_table('t_parents',
>>> Field('f_first_name1', type='string', notnull=True,
>>>   label=T('First Name1')),
>>> Field('f_last_name1', type='string', notnull=True,
>>>   label=T('Last Name1')),
>>> Field('f_first_name2', type='string', notnull=True,
>>>   label=T('First Name2')),
>>> Field('f_last_name2', type='string', notnull=True,
>>>   label=T('Last Name2')),
>>> Field('f_phone', type='string',
>>>   label=T('Phone')),
>>> Field('f_children', type='list:reference t_children',
>>>   label=T('Children')),
>>> auth.signature,
>>> format='%(f_first_name1)s',
>>> migrate=settings.migrate)
>>>
>>> db.define_table('t_parents_archive',db.t_parents,Field('current_record','reference
>>>  
>>> t_parents',readable=False,writable=False))
>>>
>>> 
>>> db.define_table('t_reservation',
>>> Field('f_room', type='string', notnull=True,
>>>   label=T('Room')),
>>> Field('f_start', type='time',
>>>   label=T('Start')),
>>> Field('f_end', type='time',
>>>   label=T('End')),
>>> Field('f_day', type='date',
>>>   label=T('Day')),
>>> Field('f_child', type='reference t_children', notnull=True,
>>>   label=T('Child')),
>>> auth.signature,
>>> format='%(f_room)s',
>>> migrate=settings.migrate)
>>>
>>> db.define_table('t_reservation_archive',db.t_reservation,Field('current_record','reference
>>>  
>>> t_reservation',readable=False,writable=False))
>>>
>>> On Friday, May 4, 2012 10:02:03 PM UTC-6, Massimo Di Pierro wrote:

 which web2py version are you using? Which browser?

 On Friday, 4 May 2012 22:24:50 UTC-5, Vincent Davis wrote:
>
>
>1. The web2py book suggests there is a time picker ajax built in. 
>It does not work for me, both the date and datetime picker does. 
>http://web2py.com/books/default/chapter/29/11#web2py_ajax.html  I 
>don't get the time picker shown here or any time picker.
>2. I would like to only display time in 15min increments. is it 
>possible and should I do this with a drop down rather than a ajax?
>3. Ultimately the think I would like a multi select dropdown 
>showing 15min increments with a second column showing availability or 
> only 
>show those avalible. This seems doable and I think I have found 
> examples to 
>do this except for the 15min increments.
>
> Thanks for any suggestions and help I am very new to web2py any 
> examples or pointers to examples would be great.
>
> Vincent
>


[web2py] Re: default/user.html and custom form

2012-05-05 Thread Massimo Di Pierro
I do not understand the purpose of all this. Why not:


{{=form.custom.begin}}
{{#}}
{{=form.element['table']}}
{{#}}
{{=DIV(form.custom.end[1] # hidden field}}
{{#}}
{{=INPUT('extra button'}}
{{=form.custom.end[0] # }}


Notice there is also a form.add_button() in trunk.

On Saturday, 5 May 2012 00:49:38 UTC-5, Cédric Mayer wrote:
>
> As I needed to build my own submit buttons, or add my own widgets, I use 
> the following function to split a SQLFORM:
> import re
>
> def expurgate_form(web2py_form):
> '''
> Deletes surrounding  tag, and submit row.
> '''
> regexp_opening_tag = re.compile("^<[^><]*>")
> regexp_closing_tag = re.compile("<[^><]*>$")
> form_xml = web2py_form.xml()
> opening_tag = regexp_opening_tag.search(form_xml).group()
> closing_tag = regexp_closing_tag.search(form_xml).group()
> realform=TAG(form_xml)
> table = realform.elements('table')[0]
> hidden_elements = realform.elements("input[type=hidden]")
> hidden_element = DIV(*hidden_elements)
> hidden_element['_style'] = "display:none;"
> todelete = table.elements("input[type=submit]")
> submit = todelete[0]
> todelete[0].parent[0]=''
> return (table,hidden_element,XML(opening_tag),XML(closing_tag),submit)
>
>
> To use it in a view:
> {{(table,hidden_element,opening_tag,closing_tag,submit)=expurgate_form(
> form)}}
> {{=opening_tag}}
> {{#}}
> {{=table}}
> {{#}}
>  {{=hidden_element}}
> {{#}}
>  {{=submit}}
>  {{=closing_tag}}
>
>
> I hope it will help :-)
>
>
> Le vendredi 4 mai 2012 08:30:23 UTC+2, Annet a écrit :
>>
>> I'd like to divide the default/user.html forms into a body and footer 
>> part, the body containing the fields the footer containing the cancel and 
>> submit button, something like this:
>>
>> 
>>   
>> Login with your Leonexus ID
>>
>>   
>>   Enter your username and password
>>
>>   the form fields here
>>
>>
>>   
>>
>>   the form controls here
>>
>>
>>   
>>
>> Is there a way to split the form in these components?
>>
>>
>> Kind regards,
>>
>> Annet
>>
>

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft


On Saturday, May 5, 2012 2:40:52 PM UTC+3, kenji4569 wrote:
>
> I think so, but I don't have any clue for this session problem..
>
> 2012年5月5日土曜日 19時58分19秒 UTC+9 CtrlSoft:
>>
>> on localhost works fine beacause, it is using the same session, but on 
>> server, when i acces page app creates one session and when i submit the 
>> upload form it creates another one session, i think the problem is that 
>> there is different sessions. app remember previous session but form pass 
>> another session? it is right? 
>
>
this problem is only in Chrome, IE,Firefox,Opera everything works fine. 


[web2py] Auth form custom errors

2012-05-05 Thread Rhys
I'm creating a custom drop down login form for all pages where the user 
isn't logged in. Once they try and login through this form if it 
is unsuccessful it redirects to the /user/login page with the auth.login 
form. How do I get a error if the login has resulted in an invalid login. 
As there are two forms I've tried also tried to do a form out of html so 
there is no form key. Still no luck. Is it s simple variable I can use to 
determine if it is successful? 

[web2py] TR and TD

2012-05-05 Thread praveen krishna
Hii,
 What does TR and TD do in the function 
 def records():
'show all recors in plugin_seq db to user'
records = db(db.plugin_seq.id>0).select()
items = []
for record in records:
items.append(TR(TD(record.filename)(TD('del'
return TABLE(items)
 and what does actually TR and TD mean.


[web2py] Re: "time" picker not working, how to show 15min increments

2012-05-05 Thread Vincent Davis
 jquery timeentry is the behavior I am getting, I was expecting the 
behavior show in the book :-)

Suggestion on listing 15min time increments?

Thanks
Vincent


On Friday, May 4, 2012 10:56:48 PM UTC-6, Massimo Di Pierro wrote:
>
> I am also using 1.99.7 with chrome on mac and it works for me. Perhaps you 
> expect a different behavior.
> The time field does not use timepicker (it used to). It uses jquery 
> timeentry. It has no popups.
> If you start typing a number into the field, it will format it as time and 
> will allow you to use arrows to change hhh:mm:ss.
>
>
> On Friday, 4 May 2012 23:19:01 UTC-5, Vincent Davis wrote:
>>
>> version 1.99.7 mac
>> I have tried Chrome and Safari (osx 10.7)
>>
>> Just used the wizard to build a simple app. No modification from wizard. 
>> see db below
>>
>> ### we prepend t_ to tablenames and f_ to fieldnames for disambiguity
>>
>>
>> 
>> db.define_table('t_children',
>> Field('f_first_name', type='string', notnull=True,
>>   label=T('First Name')),
>> Field('f_last_name', type='string', notnull=True,
>>   label=T('Last Name')),
>> Field('f_dob', type='date', notnull=True,
>>   label=T('Dob')),
>> auth.signature,
>> format='%(f_first_name)s',
>> migrate=settings.migrate)
>>
>> db.define_table('t_children_archive',db.t_children,Field('current_record','reference
>>  
>> t_children',readable=False,writable=False))
>>
>> 
>> db.define_table('t_parents',
>> Field('f_first_name1', type='string', notnull=True,
>>   label=T('First Name1')),
>> Field('f_last_name1', type='string', notnull=True,
>>   label=T('Last Name1')),
>> Field('f_first_name2', type='string', notnull=True,
>>   label=T('First Name2')),
>> Field('f_last_name2', type='string', notnull=True,
>>   label=T('Last Name2')),
>> Field('f_phone', type='string',
>>   label=T('Phone')),
>> Field('f_children', type='list:reference t_children',
>>   label=T('Children')),
>> auth.signature,
>> format='%(f_first_name1)s',
>> migrate=settings.migrate)
>>
>> db.define_table('t_parents_archive',db.t_parents,Field('current_record','reference
>>  
>> t_parents',readable=False,writable=False))
>>
>> 
>> db.define_table('t_reservation',
>> Field('f_room', type='string', notnull=True,
>>   label=T('Room')),
>> Field('f_start', type='time',
>>   label=T('Start')),
>> Field('f_end', type='time',
>>   label=T('End')),
>> Field('f_day', type='date',
>>   label=T('Day')),
>> Field('f_child', type='reference t_children', notnull=True,
>>   label=T('Child')),
>> auth.signature,
>> format='%(f_room)s',
>> migrate=settings.migrate)
>>
>> db.define_table('t_reservation_archive',db.t_reservation,Field('current_record','reference
>>  
>> t_reservation',readable=False,writable=False))
>>
>> On Friday, May 4, 2012 10:02:03 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> which web2py version are you using? Which browser?
>>>
>>> On Friday, 4 May 2012 22:24:50 UTC-5, Vincent Davis wrote:


1. The web2py book suggests there is a time picker ajax built in. 
It does not work for me, both the date and datetime picker does. 
http://web2py.com/books/default/chapter/29/11#web2py_ajax.html  I 
don't get the time picker shown here or any time picker.
2. I would like to only display time in 15min increments. is it 
possible and should I do this with a drop down rather than a ajax?
3. Ultimately the think I would like a multi select dropdown 
showing 15min increments with a second column showing availability or 
 only 
show those avalible. This seems doable and I think I have found 
 examples to 
do this except for the 15min increments.

 Thanks for any suggestions and help I am very new to web2py any 
 examples or pointers to examples would be great.

 Vincent

>>>

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread kenji4569
I think so, but I don't have any clue for this session problem..

2012年5月5日土曜日 19時58分19秒 UTC+9 CtrlSoft:
>
> on localhost works fine beacause, it is using the same session, but on 
> server, when i acces page app creates one session and when i submit the 
> upload form it creates another one session, i think the problem is that 
> there is different sessions. app remember previous session but form pass 
> another session? it is right? 



[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
on localhost works fine beacause, it is using the same session, but on 
server, when i acces page app creates one session and when i submit the 
upload form it creates another one session, i think the problem is that 
there is different sessions. app remember previous session but form pass 
another session? it is right? 

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread kenji4569
The direct submit command "$('.dialog-front').find('form').submit()"
still produces the same result. So the problem might be not the uploadify 
widget but the form processing it self. Could you debug inside the 
form.accepts method and check its passed variables such as request.vars and 
session.

2012年5月5日土曜日 16時24分27秒 UTC+9 CtrlSoft:
>
> u can check above links, still not solved problem



[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
u can check above links, still not solved problem

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
this is my online version

> http://agsystem.md/upload/plugin_elrte_widget/index
>>  
>>
>
local host version can be accesed here:
 http://89.28.110.232:8100/upload/plugin_elrte_widget/index


is the same application