[web2py] Re: Web2py and PyScripter debugging

2011-06-11 Thread Dmitriy
Here it is:

1. Download the latest web2py sources 
http://web2py.com/examples/default/download

2. Create the following 'web2py_no_threads.py' file at the web2py
directory:

### web2py_no_threads.py ###
from wsgiref.simple_server import make_server, demo_app
from gluon.main import wsgibase
httpd = make_server('', 8000, wsgibase)
print "Serving HTTP on port 8000..."
# Respond to requests until process is killed
httpd.serve_forever()
### end file ###

3. Download and install PyScripter 
http://code.google.com/p/pyscripter/downloads/list

4. Create new project in PyScripter.

5. Import all web2py or single application files to the project

6. Select Run->Python Engine->Remote in menu

7. Place somewhere in the sources break point (F5)

8. Open web2py_no_threads.py file

9. Start debugging the project (menu Run->Debug)

Sometimes PyScripter hangs on debug. Also you can't debug a modified
source code - you need to restart the debugging.
Despite these shortcomings, PyScripter is convenient tool for
debugging and editing web2py on Windows.


[web2py] Re: Web2py and PyScripter debugging

2011-06-08 Thread Dmitriy
Thank you!
It works with a latest sources and after fixing the import line to
'from gluon.main import wsgibase'

On Jun 3, 5:18 pm, Massimo Di Pierro 
wrote:
> ### no_threads_web2py.py ###
> from wsgiref.simple_server import make_server, demo_app
> from gluon import wsgibase
> httpd = make_server('', 8000, wsgibase)
> print "Serving HTTP on port 8000..."
> # Respond to requests until process is killed
> httpd.serve_forever()
> ### end file ###
>
> On Jun 3, 12:07 am, Dmitriy  wrote:
>
>
>
>
>
>
>
> > Is there any way to executeweb2pyin one (main) thread?
> > If not, can it be added?
> > This can help to debugweb2pyinPyScripter.PyScripteris great IDE
> > for Windows, but currently support only single-threaddebugging. A '-n
> > 1' command line option doesn't help.
>
> > Thanks!


[web2py] Web2py and PyScripter debugging

2011-06-02 Thread Dmitriy
Is there any way to execute web2py in one (main) thread?
If not, can it be added?
This can help to debug web2py in PyScripter. PyScripter is great IDE
for Windows, but currently support only single-thread debugging. A '-n
1' command line option doesn't help.

Thanks!


[web2py] Re: field.represent doesn't work with plugin_jqgrid in controller

2011-05-31 Thread Dmitriy
It is a problem.
I need to have the id field link to the two different controllers in
the one table.

For example:
1) db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='controller1',f='plot_update',args=id)))

2) db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='controller2',f='plot_update',args=id)))


[web2py] field.represent doesn't work with plugin_jqgrid in controller

2011-05-31 Thread Dmitriy
It is works inside model file. But I have several controllers that
working with a same table and I need to set the controller name in
model. Currently I can't setup second controller. So assigning
field.represent in model is not suitable for me.

Can anyone describe me why assigning the field.represent in controller
with plugin_jqgrid doesn't work?


Model code:

db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='default',f='plot_update',args=id)))
#works!
...

Controller code:

def plot_list():
db.plot.id.represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='default',f='plot_update',args=id)))
# not works!!!

table=plugin_jqgrid(db.plot)
return dict(table=table)

Please help.


[web2py] Re: Required password

2011-05-30 Thread Dmitriy
Thanks!


[web2py] Required password

2011-05-29 Thread Dmitriy
Hi,

How I can make required password field in auth_user?
Adding the 'required = True,' doesn't works.

Field('password', type='password', required = True,  readable=False,
label=T('Password')),

I use web2py 1.95.1, sqlite on Windows.

Thanks a lot,
Dmitriy


[web2py] Re: Class-based controllers and prefixes in wizard

2011-05-18 Thread Dmitriy
Thanks Bruno, this is an interesting optimisation!

On May 15, 9:16 pm, Bruno Rocha  wrote:
> in your controllers you will just need to instantiate your classes and work 
> with inheritance,

But I need to have some basic controller class. It must expose methods
as callable URLs. Do you have any idea how to implement such class?


[web2py] Re: Class-based controllers and prefixes in wizard

2011-05-15 Thread Dmitriy
Thanks all for the prompt answers! Massimo, I think that the flag in
Wizard can solve the prefixes issue.

Regarding the class-based controllers.

pbreit, the components and the load function can help me in the
composition, but can't help in the  inheritance.

Thanks for a good example, Bruno! I agree with you that domain
specific logic must be located in the Model and Flow specific logic
must be located in the Controller.
For such case we need ORM in the Model, but we have DAL. OK, suppose
we  have created an ORM over the DAL. It will give me a possibility to
inherit domain (model) specific logic. But I want to inherit work-flow
logic too.

Here is an example.
Suppose we have a class/table hierarchy:

Person<-Customer<-VipCustomer. Customer can Purchase something, Vip
Customer can Purchase goods with discount and get a branded gift.

1. The case of class-based controllers:

class Person(BaseController):
   def Create()
   def Read()
   def Update()
   def Delete()

class Customer(Person):
   def Purchase()

class VipCustomer(Customer):
   def Create()  #define discount
   def Purchase() #purchase a product with discount and direct a
user to a gift page
   def SelectGift()#select a gift after purchase

2. The case of function-based controllers:
Person_Create()
Person_Read()
Person_Update()
Person_Delete()

Person_Create()
Person_Read()
Person_Update()
Person_Delete()
Person_Purchase()

VipCustomer_Create()
VipCustomer_Read()
VipCustomer_Update()
VipCustomer_Delete()
VipCustomer_Purchase()
VipCustomer_SelectGift()

The functional case has 15 methods. In the first case there are 3
classes and 8 methods (more compact and readable). Why do I need to
repeat some methods in the successors?


[web2py] Class-based controllers and prefixes in wizard

2011-05-14 Thread Dmitriy
First of all, I would like to thank Massimo Di Pierro and other
developers for the excellent framework!

I have several questions:

1. Is it possible to create class-based controllers instead of
function-based? The class will expose their public methods for calling
like functions. I want to make a controllers hierarchy. This will give
a possibility to inherit methods from ancestors following the DRY
principle :)

Maybe you know, that Django has already implemented such functionality
in the 1.3 version: 
http://docs.djangoproject.com/en/dev/topics/class-based-views/
I think that we need to get such functionality in the web2py too!

2. Is it possible to remove 'T_' and 'F_' prefixes from the 'New
application wizard'? They are really not needed in real tables and
fields.

Thanks