[web2py] Re: pagination previous and next on the controller

2011-05-14 Thread pbreit
You don't put {{ and }} in controllers. Just do it like it is in the book. 
HTML typically belongs in the view.

[web2py] differntial of request.args[0] and request.args(0)

2011-05-14 Thread 黄祥
hi,

is there anybody knows the differntial between request.args[0] and
request.args(0)?
which better to be used on the application?

thank you so much.


[web2py] pagination previous and next on the controller

2011-05-14 Thread 黄祥
hi,

i've test the pagination from : 
http://web2py.com/book/default/chapter/12?search=pagination#Pagination
and tried to change the next and previous that on view into the
controller

e.g.
from view:
{{if page:}}
previous
{{pass}}

{{if len(rows)>items_per_page:}}
next
{{pass}}

into controller:
def list_items():
if len(request.args): page=int(request.args[0])
else: page=0
items_per_page=20
limitby=(page*items_per_page,(page+1)*items_per_page+1)
rows=db().select(db.prime.ALL,limitby=limitby)
if page:
previous = "previous"

if len(rows)>items_per_page:
next = "next"
return
dict(rows=rows,page=page,items_per_page=items_per_page,previous=previous,next=next)


but returned an error, is there any solution for this?
thank you very much before


[web2py] Re: develop iphone apps with web2py with this plugin

2011-05-14 Thread Massimo Di Pierro
I find that designing the app for mobile first forces to keep
navigation simple and that is good.

On May 14, 10:23 pm, Jason Brower  wrote:
> On 05/14/2011 11:57 PM, Massimo Di Pierro 
> wrote:>http://web2py.com/plugins/plugin_jqmobile/about
>
> > Please send us comments and suggestions
>
> Excited to give it a try in some of my apps. Though I should probably
> complete the apps first for normal browsers. :D
> BR,
> Jason Brower


[web2py] Re: Security problem with LOAD()

2011-05-14 Thread pbreit
I'm going to try this out to reduce the risk of a security breach:

in a model:

def is_localhost():
import socket

http_host = request.env.http_host.split(':')[0]
try:
hosts = (http_host, socket.gethostname(),
 socket.gethostbyname(http_host),
 '::1','127.0.0.1',':::127.0.0.1')
except:
hosts = (http_host,)

if request.env.remote_addr in hosts:
return True

in generic.xxx:

{{if is_localhost():}}

{{else:}}
Not allowed
{{pass}}




[web2py] Re: default usage

2011-05-14 Thread pbreit
I still don't understand Record Representation. Is there a plain english 
description or, better, examples of what it actually does?

Re: [web2py] develop iphone apps with web2py with this plugin

2011-05-14 Thread Jason Brower

On 05/14/2011 11:57 PM, Massimo Di Pierro wrote:

http://web2py.com/plugins/plugin_jqmobile/about

Please send us comments and suggestions
Excited to give it a try in some of my apps. Though I should probably 
complete the apps first for normal browsers. :D

BR,
Jason Brower


[web2py] use "is None" instead of "== None"

2011-05-14 Thread Carlos
Hi,

One of the recent changes in Storage.__setattr__ is [ if value == None: ].

Shouldn't we always use "is" instead of "==" for all singletons like None?.

For reference in the particular case of Storage.__setattr__ with a Row 
object as the value (using the current "==" instead of "is"), it will 
internally execute the Row.__eq__ function, which itself calls 
"self.as_dict()" via try, thus doing some unnecessary processing which 
affects performance.

Please correct me if I'm wrong - thanks,

   Carlos



Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Ross Peoples
Just to give an update, I have successfully split this off into two web2py 
instances: one running under Python 2.4.4 that only acts as a JSON-RPC 
server, and a second web2py instance running on 2.6.1 that is using the 
trunk version of web2py. After banging my head against a wall with regards 
to serializing datetime objects, I have finally got this work beautifully.

So Python 2.4 support is no longer a concern of mine. I am finally able to 
join the rest of the world in using modern Python versions!!!

Thanks for the comments everyone! It should come as no surprise that once 
again, web2py has succeeded where other frameworks have failed.


[web2py] Re: develop iphone apps with web2py with this plugin

2011-05-14 Thread Nite
Interesting... I am able to confirm by building out static menus on
the welcome app, but my more complex app is going to be more difficult
to change. Add to that the desire to have 2 layouts one for mobiles
and one for larger computer based browsers.

What's the best way to handle the complex layout? Variablize (is that
even a word?) the layout path and if/then fork the menus?

Regardless of the annyoance of this "feature" it's still far less work
that I had planned in converting the slablet template:
http://host.sonspring.com/slablet/light.html

--Nite

On May 14, 7:11 pm, Massimo Di Pierro 
wrote:
> If they link a page that does not use the plugin_jqmobile/layout.html
> (or return an invalid request, including an error), it hangs. If is a
> jquery.mobile "feature". I wish there was a way to disable. I have not
> found it so far.
>
> On May 14, 5:26 pm, Nite  wrote:
>
>
>
>
>
>
>
> > I love it! Talk about bootstrapping app development! :-)
>
> > I tried it against my app and also the welcome app with the same
> > results.
>
> > The menus do not behave as expected. Most of the time (tested in
> > Chrome 11, Firefox 4, and Safari) the clicking a menu item results in
> > a "Loading box" with nothing happening. I'm guessing this is because
> > the first level menu doesn't link to anything and the menu structure
> > should be modified to support this layout?
>
> > -- Nite
>
> > On May 14, 5:50 pm, Anthony  wrote:
>
> > > Excellent!
>
> > > Note, the demo page doesn't render properly in IE:
>
> > > 
>
> > > It looks fine in Chrome and Firefox, but what is the demo supposed to do? 
> > > In
> > > Firefox, when I click on any buttons, it says "loading", but nothing
> > > happens. Same thing in Chrome, although in Chrome, the page refreshes by
> > > sliding to the left. Is anything else supposed to happen?
>
> > > Two other things:
>
> > >    - In layout.html, {{block booter}} should probably be {{block footer}} 
> > > (I
> > >    assume).
> > >    - On the demo page, it says "Try click on a button on the right", but 
> > > the
> > >    phone is actually on the left.
>
> > > Great work.
>
> > > Anthony
>
> > > On Saturday, May 14, 2011 4:57:12 PM UTC-4, Massimo Di Pierro wrote:
> > > >http://web2py.com/plugins/plugin_jqmobile/about
>
> > > > Please send us comments and suggestions


[web2py] Re: develop iphone apps with web2py with this plugin

2011-05-14 Thread Massimo Di Pierro
If they link a page that does not use the plugin_jqmobile/layout.html
(or return an invalid request, including an error), it hangs. If is a
jquery.mobile "feature". I wish there was a way to disable. I have not
found it so far.

On May 14, 5:26 pm, Nite  wrote:
> I love it! Talk about bootstrapping app development! :-)
>
> I tried it against my app and also the welcome app with the same
> results.
>
> The menus do not behave as expected. Most of the time (tested in
> Chrome 11, Firefox 4, and Safari) the clicking a menu item results in
> a "Loading box" with nothing happening. I'm guessing this is because
> the first level menu doesn't link to anything and the menu structure
> should be modified to support this layout?
>
> -- Nite
>
> On May 14, 5:50 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > Excellent!
>
> > Note, the demo page doesn't render properly in IE:
>
> > 
>
> > It looks fine in Chrome and Firefox, but what is the demo supposed to do? In
> > Firefox, when I click on any buttons, it says "loading", but nothing
> > happens. Same thing in Chrome, although in Chrome, the page refreshes by
> > sliding to the left. Is anything else supposed to happen?
>
> > Two other things:
>
> >    - In layout.html, {{block booter}} should probably be {{block footer}} (I
> >    assume).
> >    - On the demo page, it says "Try click on a button on the right", but the
> >    phone is actually on the left.
>
> > Great work.
>
> > Anthony
>
> > On Saturday, May 14, 2011 4:57:12 PM UTC-4, Massimo Di Pierro wrote:
> > >http://web2py.com/plugins/plugin_jqmobile/about
>
> > > Please send us comments and suggestions


Re: [web2py] Re: default usage

2011-05-14 Thread Stifan Kristi
i'm understand right now, thank you so much for your detail explaination.

On Sun, May 15, 2011 at 5:02 AM, Anthony  wrote:

> On Saturday, May 14, 2011 5:37:39 PM UTC-4, 黄祥 wrote:
>>
>> hi,
>>
>> is there anyone can explain about the usage of default?
>>
>> e.g. on http://web2py.com/book/default/chapter/03#Adding-CRUD
>> db.comment.image_id.default = image.id
>
>
> You can read about it here:
> http://web2py.com/book/default/chapter/06#Record-Representation
>
> It sets the default value for a field for when an insert is done without
> specifying any value, and it is also used to pre-populate SQLFORM fields.
> You can specify it when you define your table, but you can also change it at
> other points in your code (e.g., you may specify a default where the table
> is defined in your model file, but then later change the default in a
> controller function). In the example above, it looks like it's being used to
> pre-populate the crud form with the currently selected image.
>
> Anthony
>


[web2py] Re: develop iphone apps with web2py with this plugin

2011-05-14 Thread Nite
I love it! Talk about bootstrapping app development! :-)

I tried it against my app and also the welcome app with the same
results.

The menus do not behave as expected. Most of the time (tested in
Chrome 11, Firefox 4, and Safari) the clicking a menu item results in
a "Loading box" with nothing happening. I'm guessing this is because
the first level menu doesn't link to anything and the menu structure
should be modified to support this layout?

-- Nite

On May 14, 5:50 pm, Anthony  wrote:
> Excellent!
>
> Note, the demo page doesn't render properly in IE:
>
> 
>
> It looks fine in Chrome and Firefox, but what is the demo supposed to do? In
> Firefox, when I click on any buttons, it says "loading", but nothing
> happens. Same thing in Chrome, although in Chrome, the page refreshes by
> sliding to the left. Is anything else supposed to happen?
>
> Two other things:
>
>    - In layout.html, {{block booter}} should probably be {{block footer}} (I
>    assume).
>    - On the demo page, it says "Try click on a button on the right", but the
>    phone is actually on the left.
>
> Great work.
>
> Anthony
>
>
>
>
>
>
>
> On Saturday, May 14, 2011 4:57:12 PM UTC-4, Massimo Di Pierro wrote:
> >http://web2py.com/plugins/plugin_jqmobile/about
>
> > Please send us comments and suggestions


[web2py] Re: plugins

2011-05-14 Thread Anthony
web2py Plugin for jQuery Mobile: 
http://web2py.com/plugins/plugin_jqmobile/about
 


[web2py] Re: default usage

2011-05-14 Thread Anthony
On Saturday, May 14, 2011 5:37:39 PM UTC-4, 黄祥 wrote: 
>
> hi, 
>
> is there anyone can explain about the usage of default? 
>
> e.g. on http://web2py.com/book/default/chapter/03#Adding-CRUD 
> db.comment.image_id.default = image.id

 
You can read about it here: 
http://web2py.com/book/default/chapter/06#Record-Representation
 
It sets the default value for a field for when an insert is done without 
specifying any value, and it is also used to pre-populate SQLFORM fields. 
You can specify it when you define your table, but you can also change it at 
other points in your code (e.g., you may specify a default where the table 
is defined in your model file, but then later change the default in a 
controller function). In the example above, it looks like it's being used to 
pre-populate the crud form with the currently selected image.
 
Anthony


[web2py] Re: develop iphone apps with web2py with this plugin

2011-05-14 Thread Anthony
Excellent!
 
Note, the demo page doesn't render properly in IE:
 

 
 
 
It looks fine in Chrome and Firefox, but what is the demo supposed to do? In 
Firefox, when I click on any buttons, it says "loading", but nothing 
happens. Same thing in Chrome, although in Chrome, the page refreshes by 
sliding to the left. Is anything else supposed to happen?
 
Two other things:

   - In layout.html, {{block booter}} should probably be {{block footer}} (I 
   assume). 
   - On the demo page, it says "Try click on a button on the right", but the 
   phone is actually on the left.

Great work.
 
Anthony
 

On Saturday, May 14, 2011 4:57:12 PM UTC-4, Massimo Di Pierro wrote:

> http://web2py.com/plugins/plugin_jqmobile/about 
>
> Please send us comments and suggestions



[web2py] default usage

2011-05-14 Thread 黄祥
hi,

is there anyone can explain about the usage of default?

e.g. on http://web2py.com/book/default/chapter/03#Adding-CRUD
db.comment.image_id.default = image.id

thank you so much before


[web2py] Re: Facebook community group for web2py and web2pyslices

2011-05-14 Thread Bruno Rocha
Shortcuts

http://on.fb.me/web2py

http://on.fb.me/web2pyslices

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


Re: [web2py] 2 or more query on db

2011-05-14 Thread Stifan Kristi
pardon me, it's my fault, i didn't realized the brackets, thank you so much.
it's solved now.


Re: [web2py] 2 or more query on db

2011-05-14 Thread Stifan Kristi
thank you so much for your replied vasile, but, unfortunately is not going
to work because the syntax error related with &

e.g. like this is return an error
comments = db(db.comment.image_id == image.id *&* db.comment.is_active
== True).select(orderby = ~db_comment.id)

comments = db(db.comment.image_id == image.id *&&* db.comment.is_active
== True).select(orderby = ~db_comment.id)

is there any solutions for this?
thank you so much in advance


Re: [web2py] 2 or more query on db

2011-05-14 Thread Vasile Ermicioi
comments = db( (db.comment.image_id == image.id) & (db.comment.is_active==
True) ).select(orderby = ~db_comment.id)


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

2011-05-14 Thread Stifan Kristi
i hope there are a lots of examples on the next book version. e.g. class
implement on models, modules, controllers. because people learned from the
book and sharpened it through testing and experience, especially when an
error occured. lol.

thank you so much.


Re: [web2py] develop iphone apps with web2py with this plugin

2011-05-14 Thread Bruno Rocha
:) NIce! I am testing it today on my Android.

Very nice design on the plugin page

(web2py keeps improving every two weeks)

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



On Sat, May 14, 2011 at 5:57 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> http://web2py.com/plugins/plugin_jqmobile/about
>
> Please send us comments and suggestions


[web2py] 2 or more query on db

2011-05-14 Thread 黄祥
hi,

is it possible to use 2 or more query on db?
i just tried on http://web2py.com/book/default/chapter/03#Adding-CRUD

e.g.
comments = db(db.comment.image_id == image.id and db.comment.is_active
== True).select(orderby = ~db_comment.id)

my question is when i put db.comment.is_active the page show all the
comment that active, i think the correct one is to show the comment
that related with image and status is active, but the page shown up
unexpectaly.

when i follow exactly same like on the book everything is fine, i just
want to add some query on that.

is there any way to do that?
thank you so much for any hints or pointers.


[web2py] develop iphone apps with web2py with this plugin

2011-05-14 Thread Massimo Di Pierro
http://web2py.com/plugins/plugin_jqmobile/about

Please send us comments and suggestions


[web2py] Re: profiler: ImportError: No module named pstats?

2011-05-14 Thread Massimo Di Pierro
I am running it with 2.5

On May 14, 3:11 pm, Philip  wrote:
> python 2.6.5 running on Linux (ubuntu) using current web2py src. Does
> the profiler require 2.7?
>
> Thanks,
> Philip
>
> On May 14, 1:22 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > -F profiler.log
>
> > works for me. Which python version? which os?
>
> > On May 13, 6:45 pm, Philip  wrote:
>
> > > I am trying to use the web2py profiler (which I haven't used before).
> > > I tried starting web2py with the -F option and a filename, and I get
> > > the following error:
>
> > > ImportError: No module named pstats
>
> > > Any ideas on why it isn't working? I couldn't find any documentation
> > > for the profiler feature other than a few posts on this group and the
> > > listing of -F as one of the command line options.
>
> > > Thanks,
> > > Philip


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

2011-05-14 Thread Bruno Rocha
On Sat, May 14, 2011 at 9:53 AM, Dmitriy  wrote:

> 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 :)
>

As I know (and as I believe) you are not encouraged to create nested
functions in controllers actions, and I do not think it is good for MVC
patters,
I think controllers actions has to be responsible only for the "control
flow" of the requested page. The "control flow" include object declarations,
data access and function/method calling, the result of this "control flow"
is what you "return" to the view.

For sure, you can declare classes inside controllers, but just like
parametrized and __protected functions this classes and methods will not be
visible or routed. (so this kind of function will not be called "action"
because it is not fired by the request)

The better way is to declare your class based logic under /models or even
better under /modules folder (which has new improvement comming in trunk),
so in controller actions you will just instantiate and call classes methods.


Example (dirty but tested):

*Defining a class in model*
 /models/mylogic.py -
class MyModelClass(object):
def sum(self,x,y):
self.total = x + y
--

*Defining a class in modules*
--- /modules/mymodule.py ---
from gluon import *
class MyModuleClass(object):
def foo(self):
return DIV(P("bar"))


*Defining a class in controller*
--- /applications/myapp/controllers/default.py 
from mymodule import MyModuleClass
class ControllerClass(object):
def controller_function(self):
c = MyModuleClass()
m = MyModelClass()
return dict(moduleclass=c.foo(), controllerclass=m.sum())

#this is an action, just calls method and classes.
def mypage():
o = ControllerClass()
return o.controller_function()

---


[web2py] Re: Make ID identical

2011-05-14 Thread Andrew Evans
Never mind I just figured out what I needed to do *cheers


Thank You


[web2py] Make ID identical

2011-05-14 Thread Andrew Evans
Hello I have a table

db.define_table('comments',
Field('userinfo', db.auth_user, default=auth.user_id, readable=False,
writable=False),
Field('project_id', db.project, requires = IS_IN_DB(db, db.project.id,
'%(project_title)s'), readable=False, writable=False),
Field('isReply', 'integer', default=0, readable=False, writable=False),
Field('comment_title', length=256, requires = IS_NOT_EMPTY()),
Field('comment_description', 'text'),
Field('created_on', 'datetime', default=datetime.datetime.now(),
readable=False, writable=False))

and a form to comment as well as a form to reply to comments

The form to reply to comments is where I am having trouble I am trying to
match comment.id to isReply so I can out put them correctly

here is my reply form model

@auth.requires_login()
def reply_comment():
post_reply = db(db.comments.id == request.args(0)).select().first()
form = SQLFORM(db.comments)
form.vars.isReply = post_reply.id
if form.accepts(request.vars, session):
response.flash = 'Comment Posted'
elif form.errors:
response.flash = 'Please fix the highlighted areas'
return dict(form = form)


Any ideas *cheers

And ty For your help :-)


[web2py] Re: profiler: ImportError: No module named pstats?

2011-05-14 Thread Philip
python 2.6.5 running on Linux (ubuntu) using current web2py src. Does
the profiler require 2.7?

Thanks,
Philip

On May 14, 1:22 pm, Massimo Di Pierro 
wrote:
> -F profiler.log
>
> works for me. Which python version? which os?
>
> On May 13, 6:45 pm, Philip  wrote:
>
>
>
>
>
>
>
> > I am trying to use the web2py profiler (which I haven't used before).
> > I tried starting web2py with the -F option and a filename, and I get
> > the following error:
>
> > ImportError: No module named pstats
>
> > Any ideas on why it isn't working? I couldn't find any documentation
> > for the profiler feature other than a few posts on this group and the
> > listing of -F as one of the command line options.
>
> > Thanks,
> > Philip


[web2py] Re: Install in hostgator

2011-05-14 Thread pepe_eloy
Hello!

do you think hostgator is a bad hosting provider? I've development
joomla applications and they works well and the support system is very
good.

pity that site hostgator.web2py.es doesn't works to learn how deploy
my application

Anybody has another answer?

Thanks


Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Ross Peoples
I had thought about that and just using the builtin Rocket server to host 
the service. That might be the best way to go.

Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread pbreit
Web2py 1.95.1. :-)


[web2py] Re: I found this poll

2011-05-14 Thread Massimo Di Pierro
No and it will not.

That does not mean there will not a web3py that is not backward
compatible and has major redesign. No hurry anyway.

On May 13, 12:37 pm, Ross Peoples  wrote:
> Does web2py support Python 3?


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

2011-05-14 Thread Massimo Di Pierro
On May 14, 7:53 am, Dmitriy  wrote:
> 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 :)

It is not possible. It is not clear to me what problem is that trying
to solve. Could you make an example? Perhaps there is a web2py way.

> 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.

We are trying to make the wizard fool proof. It should be possible to
remove them. Perhaps add an admin config flag to disable them. I will
look into it.


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

2011-05-14 Thread Anthony
On Saturday, May 14, 2011 8:53:25 AM UTC-4, Dmitriy wrote: 
>
> 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.

 
If you really don't want them, you could probably edit the make_table() 
function in /web2py/applications/admin/controllers/wizard.py.
 


Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Ross Peoples
I spent about 45 minutes hashing this out over the phone and I think the 
best solution (at least for our needs) is to make a lightweight JSON-RPC 
server that talks directly with the third-party API running in Python 2.4.4. 
Then we can run web2py on whatever Python version we want and just make 
JSON-RPC calls from web2py. This will also allow us to run the service and 
web2py application on two different servers if we need to (which was a 
concern).

This also frees us up from the restrictions that were imposed on us by the 
customized Python 2.4.4 environment that the API installs. Only thing is, we 
have to make sure the communication between web2py and the Python 2.4.4 
service is done over SSL.

So does anyone have any recommendations for a lightweight JSON-RPC server 
implementation that uses SSL and works under Python 2.4.4?

P.S. I feel much better about this now since running web2py itself in Python 
2.4.4 may no longer be a requirement for me.


[web2py] Re: profiler: ImportError: No module named pstats?

2011-05-14 Thread Massimo Di Pierro
-F profiler.log

works for me. Which python version? which os?

On May 13, 6:45 pm, Philip  wrote:
> I am trying to use the web2py profiler (which I haven't used before).
> I tried starting web2py with the -F option and a filename, and I get
> the following error:
>
> ImportError: No module named pstats
>
> Any ideas on why it isn't working? I couldn't find any documentation
> for the profiler feature other than a few posts on this group and the
> listing of -F as one of the command line options.
>
> Thanks,
> Philip


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

2011-05-14 Thread pbreit
You can kind of get that type of structure with components and LOAD():
http://web2py.com/book/default/chapter/13?search=load%28#Components

Since the import wizard is primarily for newer users, I think the t_ and f_ 
are important to avoid reserved word conflicts. If you still want to use it, 
you could edit the table/field names and then delete all the database files 
(which will get regenerated on the next run).

I typically discourage anyone from using the wizard. I think it's useful, 
even for newbies, to manually create models.


Re: [web2py] Re: pass request.args(0) to sqlform

2011-05-14 Thread Andrew Evans
Thank you I was able to figure it out *cheers



On Fri, May 13, 2011 at 8:05 PM, pbreit  wrote:

> I think this will do it:
>
> def add_task():
> form = SQLFORM(db.tasks)
> form.vars.project_id = request.args(0)
>
> if form.accepts(request.vars, session):
>
> ...
>


Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread pbreit
I think you might be on to something with the separate Python versions. 
Perhaps with "virtualenv" or "#!/usr/bin/env python2.4" ?

[web2py] [off] Nginx & Batman

2011-05-14 Thread Bruno Rocha
This article should be useful for someone...

Batman is fast. Nginx is fast. Batman fights crime. Nginx fights wasted CPU
cycles and memory leaks. Batman performs well under pressure. Nginx, for its
part, excels under heavy server loads.

http://www.evanmiller.org/nginx-modules-guide.html


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


Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Ross Peoples
I don't suppose there's a way to run this module under Python 2.4.4 and run 
web2py under 2.5 is there? The API is bytecompiled and has to run 2.4.4 (and 
actually the API installs it own custom Python 2.4.4 instance). Is there any 
way to do this? This would solve the web2py dependence on Python 2.4.4 for 
me.

[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


Re: [web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Jonathan Lundell
On May 14, 2011, at 6:54 AM, Ross Peoples wrote:
> 
> The problem is that our app is using an API as a frontend to a third party 
> application. The Python API available to talk to this product only works in 
> Python 2.4.4. I have been successfully using Web2py 1.95.1 on Python 2.4.4 
> without any issues. It was only after I updated to the trunk version that I 
> ran in to a couple of problems. 
> 
> The problems I ran in to were minor and only involved adding a couple lines 
> of code to make it compatible. I understand not wanting to keep Python 2.4 
> officially supported. If I could, I would use at least Python 2.5, but in 
> this case I can't. 
> 
> So in the interest of compromise, would it be alright to unofficially support 
> 2.4? Meaning that if there is something that doesn't work under 2.4, would 
> you accept minor patches that would make it work (assuming no side effects to 
> officially supported versions)?

The issue is that there's going to be quite a bit more non-2.4 material. 

[web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread Ross Peoples
The problem is that our app is using an API as a frontend to a third party 
application. The Python API available to talk to this product only works in 
Python 2.4.4. I have been successfully using Web2py 1.95.1 on Python 2.4.4 
without any issues. It was only after I updated to the trunk version that I ran 
in to a couple of problems. 

The problems I ran in to were minor and only involved adding a couple lines of 
code to make it compatible. I understand not wanting to keep Python 2.4 
officially supported. If I could, I would use at least Python 2.5, but in this 
case I can't. 

So in the interest of compromise, would it be alright to unofficially support 
2.4? Meaning that if there is something that doesn't work under 2.4, would you 
accept minor patches that would make it work (assuming no side effects to 
officially supported versions)?


Re: [web2py] Re: reference field allowing None fields

2011-05-14 Thread Anthony
On Saturday, May 14, 2011 9:27:35 AM UTC-4, sebastian wrote: 
>
> yes, it did work ! 
>
> why ?
>
 
According to the book:
 
 
If you want the field validated, but you do not want a dropbox, you must put 
the validator in a list.
  
1.

db.dog.owner.requires = [IS_IN_DB 
(db, 'person.id', 
'%(name)s')]

 
 
So, by design, putting the IS_IN_DB validator inside a list causes it not to 
create a dropdown -- as long as it's not inside a list, it will create the 
dropdown. If you need to apply IS_IN_DB in addition to some other validators 
but still want the dropdown, you can add additional validators inside the 
IS_IN_DB call via its '_and' argument. See 
http://web2py.com/book/default/chapter/07#Database-Validators.
 
Anthony
 


[web2py] Re: Discussion: Python 2.4 Support

2011-05-14 Thread pierreth
I think 2.4 is getting old. Why now update the module you use to
version 2.5 instead?

If webp2y is too obsess with backward compatibility, new developers
will now be interested in the project.

I don't think supporting version 2.4 is a good thing.

On 14 mai, 01:14, Ross Peoples  wrote:
> I am developing a web2py app that uses a third party python module that only 
> works on Python 2.4.4. Basically, we are using we2py as a front end for an 
> API. Since recently updating to trunk, I noticed that several things didn't 
> seem to work anymore. I submitted patches to Massimo and he told me that 
> there was discussion before about dropping Python 2.4 support.
>
> I am wondering who else is using Python under 2.4? I am hoping that we can 
> continue to support 2.4. The latest patches I provided only make minor 
> changes to support 2.4, so it's really not too bad to support it, even with 
> the latest trunk.
>
> Thought? Concerns?
>
> Thanks


Re: [web2py] Re: reference field allowing None fields

2011-05-14 Thread Sebastian E. Ovide
yes, it did work !

why ?

On Sat, May 14, 2011 at 2:09 PM, Anthony  wrote:

> On Saturday, May 14, 2011 8:51:40 AM UTC-4, sebastian wrote:
>>
>>
>> db.dog.owner.requires = [IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id'))]
>>
>
>> would make the drop down menu disappear...
>>
>
> Do you get the drop down menu back if you take the validator out of the
> list:
>
> db.dog.owner.requires = IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id'))
>
> Anthony
>



-- 
Sebastian E. Ovide


[web2py] Re: reference field allowing None fields

2011-05-14 Thread Anthony
On Saturday, May 14, 2011 8:51:40 AM UTC-4, sebastian wrote: 
>
>   
> db.dog.owner.requires = [IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id'))]
>
 
> would make the drop down menu disappear...
>
 
Do you get the drop down menu back if you take the validator out of the 
list:
 
db.dog.owner.requires = IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id'))
 
Anthony


[web2py] reference field allowing None fields

2011-05-14 Thread Sebastian E. Ovide
Hi All,

db.define_table('dog',
Field('owner',db.auth_user))

wont allows me to select an empty user

adding

db.dog.owner.requires = [IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id'))]

would make the drop down menu disappear...

any ideas ?

thanks
-- 
Sebastian E. Ovide


Re: [web2py] Lighter processing for AJAX requests ?

2011-05-14 Thread Martín Mulone
>
>  1) when and why to user "current"

I don't be sure I understand, "user current", current is the object you can
access from the module instead of passing globals

2) where to put "imports". since in Python we've always been told to put
> them at top of file. But it looks like they need to go in the def function()
> in order to not be loaded when other functions run.


Use in the top of controller nobody restrict you to do that, I'm only
importing when I need it.

2011/5/13 pbreit 

> Good writeup, thanks, Martin.
>
> The things that still confuse me are:
> 1) when and why to user "current"
> 2) where to put "imports". since in Python we've always been told to put
> them at top of file. But it looks like they need to go in the def function()
> in order to not be loaded when other functions run.
>



-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Discussion: Python 2.4 Support

2011-05-14 Thread Martín Mulone
Like massimo said there was a dicussion before and a poll. If you are
talking about to change try, except logic, this is one of the things that
the develpers want to change, that makes the code hard to follow and ugly.

2011/5/14 Ross Peoples 

> I am developing a web2py app that uses a third party python module that
> only works on Python 2.4.4. Basically, we are using we2py as a front end for
> an API. Since recently updating to trunk, I noticed that several things
> didn't seem to work anymore. I submitted patches to Massimo and he told me
> that there was discussion before about dropping Python 2.4 support.
>
> I am wondering who else is using Python under 2.4? I am hoping that we can
> continue to support 2.4. The latest patches I provided only make minor
> changes to support 2.4, so it's really not too bad to support it, even with
> the latest trunk.
>
> Thought? Concerns?
>
> Thanks




-- 
 http://martin.tecnodoc.com.ar