[web2py] Display IS_IN_SET() label

2010-08-24 Thread annet
In a controller I defined a form:

form=SQLFORM.factory(Field('bedrijf',requires=IS_IN_SET([2,3,4,5,6,7],labels=['Fitnesscentrum','Fysiofitnesscentrum','Personal
Trainer','Dietist(e)','Voedingsconsulent(e)','Yogaschool'],zero=None)))

In the view I would like to display the label of the selected option,
is this possible?


Kind regards,

Annet.


[web2py] represent in crud.select

2010-08-24 Thread firedragon852
If I do this:
db.friendship.to_user.represent = lambda id: db.auth_user[id].nickname
friends = crud.select(db.friendship, db.friendship.from_user ==
auth.user.id,
  fields=['id', 'to_user'],
  headers={'id':T('ID'),
'to_user':T('Friend')})

to_user.represent never shows the nicknames.

If I change the crud.select statement to:
friends = crud.select(db.friendship, db.friendship.from_user ==
auth.user.id)

to_user.represent shows the nicknames.

Is this a bug?


[web2py] auto complete widget

2010-08-24 Thread annet
I am using web2py's auto complete widget, and wonder whether the div
containing the options could fade out faster.  At the moment it takes
about 4 seconds before the div fades out after the user selects an
option. Since the div hides the submit button, this is rather long.

Kind regards,

Annet.


[web2py] jqgrid and edit-link

2010-08-24 Thread Johann Spies
I followed the example in the radiolog-example of using jqgrid but I
am doing something wrong I suppose.

Given the following model

db.define_table("teacher",
db.person,
Field("highest_qualification"),
Field("id_number",length=13),
Field("school"),
Field("gender"),
Field("cell", "string", length=15, default=None),
Field("grade"),
Field("domain")
)


#db.teacher.id.represent = lambda id:
SPAN(A('edit',_href=URL(r=request,c='default',f='edit_teacher',args=id)))
db.teacher.grade.requires=IS_IN_SET(grades,multiple=True)
db.teacher.grade.widget = horizontal_grade_checkbox

When I uncomment the 'represent' line the grid is empty.  Why?
How do I get an 'edit' link in the id-cell in the grid?

Regards
Johann
-- 
    "Be not deceived; God is not mocked: for whatsoever a
     man soweth, that shall he also reap."
                                  Galatians 6:7


[web2py] Currency formating

2010-08-24 Thread Bruno Rocha
Hi,

Actually, I am using these methods to work with money formating.

some tries with python-money and works very well
http://code.google.com/p/python-money/

and sometimes

import locale
locale.setlocale(locale.LC_ALL,('pt_BR','UTF8'))
>>> locale.currency(1090909, grouping=True)
'R$ 1.090.909,00'

So I a thinking about, how to include that as a DAL type? exactly in
the same way web2py threats with Upload fields, we could have a
datatype 'money' working with 'locale'

db.define_table('product',Field('price','money',locale=('pt_BR','UTF8')))
or even declaring locale.setlocale() in the begining of the model file

By now I am doing that with 'represent' or directly in views, but,
Is there any chance to include that in web2py core?










[web2py] Re: Pagination manual bug?

2010-08-24 Thread dlin
As I know, at least this is manual's bug.

In the mannual, it use
next

But, it will raise error, I use this line instead
next

On 8月25日, 上午1時55分, Vidul Petrov  wrote:
> Not sure if this help, but you may want to take a look at this
> Pagination class:http://packages.python.org/web2py_utils/paginate.html
>
> On Aug 24, 6:37 pm, dlin  wrote:
>
> > ref:http://web2py.com/book/default/chapter/12#Pagination
>
> > In following code, there is two problem:
> > 1. The 'next' button always show.  And the len(rows) always = 2
> > 2. I don't know how to proper show the {{=rows}} without last row, I
> > want to use the odd row background-color trick.
>
> > I wrote simliar code in default.py
> > -
> > def listall():
> >     if len(request.args): page=int(request.args[0])
> >     else: page=0
> >     items_per_page=2
> >     limitby=(page*items_per_page,(page+1)*items_per_page + 1)
> >     words= db().select(db.mytable.ALL, limitby=limitby)
> >     cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
> >     hdrs = dict([(str(c),c.label) for c in db.mytable])
> >     rows =SQLTABLE(words,
> >          headers = hdrs,
> >          columns=cols,
> >          truncate=32)
> >     rows['_id'] = 'rows'
> >     return dict(rows=rows, page=page, items_per_page=items_per_page)
>
> > And the view listall.html:
> > ---
> > {{extend 'layout.html'}}
> > {{=rows}}
> > page:{{=page}} 
> > len(rows):{{=len(rows)}} 
>
> > {{if page:}}
> > previous
> > {{pass}}
>
> > {{if len(rows)>=items_per_page:}}
> > next
> > {{pass}}
>
> > 

Re: [web2py] Re: dashes in controller names?

2010-08-24 Thread Jonathan Lundell
On Aug 24, 2010, at 8:03 PM, Kevin wrote:

> As far as I can find, you have to set up web2py routes to do this --
> it's pretty easy to do redirection using routes (using routes_in), but
> I'm not aware of any way off-hand to do the equivalent of rewriting/
> translation the URL for inbound requests (routes_out does to
> translation).

I think it would be difficult, unless you explicitly translated known 
controller names. Which you could do...

We could translate incoming hyphens to underscores, I suppose, without too much 
effort, but we wouldn't know whether to reverse the translation on the outbound 
side.

Come the revolution (new rewrite logic), all things will be possible. But no 
promises on a schedule.

We *could* simply allow hyphens in controller names, without translation. We 
can't do that with functions, since they need to function as Python 
identifiers. 

> 
> This is something I (and doubtless) many others need as well, and it
> really should be a (default enabled) option for web2py to
> automatically treat URL-embedded hyphens as though they were
> underscores for matching app, controller and function names, and an
> optionally enablable setting to make all generated routes use hyphens
> instead of underscores for apps, controllers, and functions.
> 
> The open-and-shut arguments for using hyphens boil down to (in order
> of severity):
> 
> * Underscores are obscured when URLs are underlined
> * Hyphens are easier to type than underscores – no need for the shift
> key
> * Hyphens are easier to read
> * Underscores are a typographical construction invented primarily for
> underlining characters (   on a
> typewriter), and today is used primarily in programming and other
> technical contexts. In short, there is little justification for
> exposing back-end considerations to the world.
> 
> Many references can be found on this subject:
> 
> * 
> http://pylonsbook.com/en/1.1/urls-routing-and-dispatch.html#choosing-good-urls
> * http://semicolons.org/post/256699383/friendly-urls
> * 
> http://www.wordsellinc.com/blog/content-optimization/use-hyphens-not-underscores-in-urls/
> 
> This is one of the sore points I have with anything I put on the web
> -- to provide what I feel is a correct URL scheme to the user, I'll
> bypass or override half of the backend code if necessary, which is
> suboptimal.
> 
> Web2py is very close to making it easy to provide URLs that'll
> withstand the scrutiny of bloggers -- besides the hyphen bit, all I
> really see as being needed is:
> 
> * The aforementioned settings for hyphenization.
> 
> * in routes_in and routes_out add the ability to supply a function/
> lambda in the second index of any inner two-tuple, which would receive
> a match object and return a string. For example, the following could
> be a stop-gap way to perform this kind of underscore-to-hyphen
> conversion:
> 
>  routes_out = ( (r'/([^/]*)/([^/]*)/([^/]*)(/?P.*)?',
>  lambda match: '/'.join(part.replace('_', '-') for part in
> match.groups()) +  match.group('any')), )
> 
> On Aug 24, 7:47 pm, Cory Coager  wrote:
>> How do you use dashes in controller names?  I get errors, "Invalid
>> request".




[web2py] Re: web2py minimalist version

2010-08-24 Thread Kevin
You can remove gluon/contrib/populate.py, which is almost 1 mb.

You can also run web2py with `python -OO web2py.py`, and after getting
the app to load all your modules (perhaps by accessing every page on
your app), close down the server.  Then remove all the .py and .pyc
files, just leaving pyo files. These files won't have docstrings in
them or comments, and will be rather minimalistic bytecode (just be
sure to keep any of your original python code somewhere safe).

Make sure your application isn't set to cache to disk -- if any
caching is done, cache in ram or not at all.  Remove the README file
and the scripts folder.

Anything else appears to be too small to be worth the effort.

On Aug 23, 10:05 am, Jose  wrote:
> I have hosting in webfaction and I am very satisfied with the service
> and support.
>
> Yesterday I was trying alwaysdata, which provides a free hosting
> alternative. The free option has some limitations, such as used disk
> space (10MB) and RAM (40MB).
>
> Following the tutorial [2], in a few minutes was running application
> welcome.
>
> I deleted the applications admin and examples, leaving only welcome,
> with that used disk space on my account is 6-7 MB.
>
> What else can be deleted, so as to leave the bare minimum in web2py?
> docs, scripts, etc?
>
> Jose
>
> [1]http://www.alwaysdata.com/
> [2]http://wiki.alwaysdata.com/wiki/D%C3%
> A9ployer_une_application_web2py


[web2py] Re: dashes in controller names?

2010-08-24 Thread Kevin
As far as I can find, you have to set up web2py routes to do this --
it's pretty easy to do redirection using routes (using routes_in), but
I'm not aware of any way off-hand to do the equivalent of rewriting/
translation the URL for inbound requests (routes_out does to
translation).

This is something I (and doubtless) many others need as well, and it
really should be a (default enabled) option for web2py to
automatically treat URL-embedded hyphens as though they were
underscores for matching app, controller and function names, and an
optionally enablable setting to make all generated routes use hyphens
instead of underscores for apps, controllers, and functions.

The open-and-shut arguments for using hyphens boil down to (in order
of severity):

* Underscores are obscured when URLs are underlined
* Hyphens are easier to type than underscores – no need for the shift
key
* Hyphens are easier to read
* Underscores are a typographical construction invented primarily for
underlining characters (   on a
typewriter), and today is used primarily in programming and other
technical contexts. In short, there is little justification for
exposing back-end considerations to the world.

Many references can be found on this subject:

* http://pylonsbook.com/en/1.1/urls-routing-and-dispatch.html#choosing-good-urls
* http://semicolons.org/post/256699383/friendly-urls
* 
http://www.wordsellinc.com/blog/content-optimization/use-hyphens-not-underscores-in-urls/

This is one of the sore points I have with anything I put on the web
-- to provide what I feel is a correct URL scheme to the user, I'll
bypass or override half of the backend code if necessary, which is
suboptimal.

Web2py is very close to making it easy to provide URLs that'll
withstand the scrutiny of bloggers -- besides the hyphen bit, all I
really see as being needed is:

* The aforementioned settings for hyphenization.

* in routes_in and routes_out add the ability to supply a function/
lambda in the second index of any inner two-tuple, which would receive
a match object and return a string. For example, the following could
be a stop-gap way to perform this kind of underscore-to-hyphen
conversion:

  routes_out = ( (r'/([^/]*)/([^/]*)/([^/]*)(/?P.*)?',
  lambda match: '/'.join(part.replace('_', '-') for part in
match.groups()) +  match.group('any')), )

On Aug 24, 7:47 pm, Cory Coager  wrote:
> How do you use dashes in controller names?  I get errors, "Invalid
> request".


[web2py] Re: Web2py and threads

2010-08-24 Thread pierreth
I don't understand. The link is broken at the moment.

Do you mean using only on thread and dispatching using the observer
pattern? Doing only one request at a time? It does not makes sense to
me. But I guess there is something I don't understand... Can someone
guide me?

On 24 août, 20:04, mdipierro  wrote:
> I agree with you. web2py does not care. It is the web server that
> decides. The question that started this thread was about the built-in
> web server and it does follow the thread model.
>
> On Aug 24, 2:00 pm, John Heenan  wrote:
>
> > Can't we at least have an acknowledgement that it is not necessary for
> > web2py to use a thread per request model and that web2py could instead
> > use an event model?
>


[web2py] Re: Web2py and threads

2010-08-24 Thread pierreth
On 24 août, 13:04, mdipierro  wrote:
> when you do "python web2py.py" you do not start the wsgi app. You
> start the rocket web server which makes a number of threads. When a
> new http request arrives it is assigned to a free thread (or a new
> thread is created) and the wsgi is run in that thread to server that
> request and only that request.
>
>

I guess that each time a thread is put in service the model is
executed again. So, for the model, a version of the instance exist for
each thread. Right?

> > So, as a web2py developer, what do I have to do to avoid
> > synchronization problems in my application. Where is the danger of
> > having multiple threads for the web2py developers? What are the
> > instances shared my multiple threads? What are the instances living in
> > their own threads?
>
> You do have to do anything because every concurrency issue is taken
> care automatically. There are some DO NOTs:
> - do not ever call os.chdir
> - do not import third party modules that are not thread safe
> - do not use thread.start_new_thread and threading.Thread.start()
> - if you open a file that is not uniquely associate to this http/
> request/client/session lock the file.

OK


Re: [web2py] dashes in controller names?

2010-08-24 Thread Jonathan Lundell
On Aug 24, 2010, at 6:47 PM, Cory Coager wrote:

> How do you use dashes in controller names?  I get errors, "Invalid
> request".

You can't. The URL parser allows only \w+ (alphanumeric or underscore).


Re: [web2py] Re: Multiple submit not working on component

2010-08-24 Thread Miguel Lopes
On Tue, Aug 24, 2010 at 1:04 PM, mdipierro  wrote:

> jquery serialize also does not support type=file. If you have a way to
> get around these, please let me know.
>
>
I've researched this a bit. Although I have not found an authoritarive
source, the "problem" is that Javascript cannot access files on the desktop,
the browser must do it. Thus, not supporting inout type=file is not a jQuery
problem. It is possible to code around this, namely using iframe (any
other?). Someone more knowledgable may confirm this.

Some interesting solutions are (untested):
http://valums.com/ajax-upload/- a dedicated javascript script library
http://trentrichardson.com/2009/06/05/meet-jquery-iframer/- a jQuery
plugin
http://www.webtoolkit.info/ajax-file-upload.html  - a 1Kb Javascript
file

Anyone has experience with these or other solutions?
Miguel


[web2py] dashes in controller names?

2010-08-24 Thread Cory Coager
How do you use dashes in controller names?  I get errors, "Invalid
request".


[web2py] Re: Should we have a feature freeze and stability maintenance period in future?

2010-08-24 Thread mart
Yeah, thanks for the tip :) Above was really a question of
disagreement with that workingDirectory -> branch thing, simply
because IMHO, branches should be planned and managed following set
criteria and purpose (again that's just me). Of course, there are many
possible avenues, and it is possible I am talking through my hat here,
and I have never met Professor Di Pierro but I do know he has dreamed
up this great thing then brought it to life. So that has to be the the
leading concern when wrt requirement/guide line to  establish what
needs to happens (at a high level) and here, it is clear:

“... the less I use mercurial the better. For example I keep one
single branch of web2py. I simply apply patches, test them, and either
revert or commit. This model has worked well for me and I would not
like to change it. “

If this model helps Mr Di Pierro and enables him, then I say, by all
means, lets start there and then fashion the tooling around that (even
if we need to make Mercurial have the look and feel or Perforce, or
CVS, etc... or what ever it takes). Its all do-able. Under-layers of
getting code-to-production can still be improved without adding extra
grief for Mr Di Pierro's.

WRT bug tracking: a bug tracking system in the key of web2py!? What a
great idea! And what better way to integrate a bug tracking system to
a web2py front end for Mercurial than to integrate it with a web2py
front end for Mercurial? Of course, handling permissions and
privileges would be a challenge? Maybe not? (I'm thinking the
contributing community vs web2py leads/leader)... but that just may be
logistical.

Mart :)

On Aug 24, 6:52 pm, Michele Comitini 
wrote:
> Actually I would like to ask if bug tracking is used on web2py?
>
> Code is available from either (btw Massimo how do you keep those 2 in
> sync? just too curious :-) ):
> a) googlecode (with hg)
> b) launchpad (with bzr)
>
> both have some sort of bugtracking ticket system I do not know which
> one is best (or worst),  we could start with one those, but
> the choice must taken with care and other systems must be evaluated
> (on: usability, independece, web2py phylosophy ...), and first
> they must meet Massimo needs.
>
> BTW: I would like to see  a web2py application for doing serious
> bugtracking in the future... so that submitting
> a bug would be just one click on the ticket reported by any web2py
> installation! mmm too easy... that would be dangerous! ;-)
>
> ciao,
> mic
>
> 2010/8/24 mart :
>
> > I don't know if you are currently using a specific bug tracking
> > system, but they are typically easy to interface with and made part of
> > build/release & test processes/automation. I.e. As part of a release
> > process, I would set rules with the source control system where non-
> > bugTraking releated changes can either be automatically rejected, or
> > moved to another set of prioritiesArea, etc... the build (or packaged
> > fileset, or whatever the output is) contains a detailed inventory of
> > bug fixes/features/etc... as part of an automated delivery system
> > (these are part of the build notes)...


[web2py] Re: ajax post before ajax reload

2010-08-24 Thread KMax
Issue too obvious,

In function definition, select goes before crud.update, so before new
data updated old data selected.

Thank you.

for i in db(db.mytable.id > 0).select():
onclick=XML( "jQuery('#form"+str(i.id)
+"').slideToggle();return false;" )
 
form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
 
result.append(DIV(DIV(A(XML(db.mytable[i.id].myfield),_href='#',_onclick=onclick)),

## db.mytable[i.id].myfield - force to reread data from table.
# two days of brain breaking :)
On 24 авг, 21:30, KMax  wrote:
> I am glad you writing poems, but it is not the wall for comments :)
> This is for issue invetigation.
>
> On 24 авг, 07:33, KMax  wrote:
>
>
>
> > This is link to examplehttp://web2py.ru/test
> > Click on 'show me' then on any in link of list and update. Second
> > update will reflect changes in first time
> > On 23 авг, 11:52, KMax  wrote:
>
> > > ## to db.py added
> > > db.define_table('mytable',Field('myfield','string'))
> > > ## controllers/default.py
> > > def index():
> > >     """
> > >     example action using the internationalization operator T and flash
> > >     rendered by views/default/index.html or views/generic.html
> > >     """
> > >     onclick =
> > > XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
> > > ['test'], 'content');return false;" )
> > >     linkdiv=DIV(DIV(A('show me',_href='#',
> > > _onclick=onclick)),DIV(_id='content'))
> > >     return dict(linkdiv=linkdiv)
>
> > > def loadlist():
> > >     return dict()
>
> > > def list():
> > >     result = []
> > >     for i in db(db.mytable.id > 0).select():
> > >         onclick=XML( "jQuery('#form"+str(i.id)
> > > +"').slideToggle();return false;" )
>
> > > form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
>
> > > result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
> > >         DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
> > >     return dict(results=result)
>
> > > ## views/default/list.load
> > > {{response.headers['Content-Type']='text/
> > > html';response.headers['web2py-response-flash']=response.flash}}
> > > 
> > > {{for result in results:}}{{ =TR(TD(result))}}{{pass}}
> > > 
> > > ## views/default/loadlist.load
> > > {{response.headers['Content-Type']='text/
> > > html';response.headers['web2py-response-flash']=response.flash}}
> > > {{=LOAD ('default','list.load',args=[],ajax=True)}}
>
> > > -
> > > Adding to mytables some strings to see the list of them in example
> > > code.
> > > Clicking on 'show me' give a list of table rows.
> > > Clicking on any of row shows form for string update.
> > > But if you submit changes, they does not reflect in list of items (but
> > > the same time db table row was updated)
> > > Next time submit updates the list of items was made last time.
>
> > > Question: how to make update of db table before updating list of item
> > > of the same table?
>
> > > On 23 авг, 08:19, mdipierro  wrote:
>
> > > > I think I need more explanation, a practical example of usage and an
> > > > example of code. I do not understand.


[web2py] Web2Py developer needed

2010-08-24 Thread david.waldrop
I am working on a application and very much want to continue the
development in Web2Py.  However I need some help.  Despite posting
several questions to the forum and getting the basics of the app to
work, I am unsure of the correct way of doing things (Controller -
view interactions, overall application architecture, Javascript/jQuery/
CSS)  in web2py.  I live in the DC area and would prefer (not
mandatory) someone local.  Please sen a private message if you are
interested or know of anyone who may be.   Thanks.


[web2py] Re: Web2py and threads

2010-08-24 Thread mdipierro
I agree with you. web2py does not care. It is the web server that
decides. The question that started this thread was about the built-in
web server and it does follow the thread model.

On Aug 24, 2:00 pm, John Heenan  wrote:
> Can't we at least have an acknowledgement that it is not necessary for
> web2py to use a thread per request model and that web2py could instead
> use an event model?
>
> WSGI can be viewed as an evil conspiracy to force Python web apps to
> follow the Apache thread per request model! Also with Apace mod_wsgi,
> Apache controls the Python process that web2py runs under! How evil
> and ugly!
>
> There is no inherent reason why web2py needs to run a separate thread
> for each NON static http request, if WSGI is not used!
>
> If web2py uses WSGI then a thread per request is forced upon web2py.
> This suits Apache but not web serves with better event driven models
> such as Lighttpd and Nginx
>
> For example Lighttpd does not even support WSGI. Instead web2py used
> fastcgi for communication Lighttpd via a UNIX socket and web2py then
> needlessly converts each request into a thread for handling by a WSGI
> handler!
>
> Why should web2py be forced into using a thread model? Anyone who
> writes PC applications avoids thread as if they are a plague. Even
> academics openly call using threads evil. Here is an article by Edward
> A. Lee professor at Berkely University with the title "The Problem
> with Threads" (PDF).
>
> John Heenan
>
> On Aug 25, 1:00 am, John Heenan  wrote:
>
> > There is absolutely no need to serve up static web pages of a pure
> > Python web app or a WGSI app with a separate thread.  It is
> > inefficient to use an inbuilt web server (of a Python web app) or
> > Apache (if WGSI used) to serve up static web pages using separate
> > threads. Both Lighttpd and Nginx are well known web servers that
> > thrash Apache in objective tests for static pages when a web server is
> > under load. These web servers use event handlers to serve static web
> > pages, not necessarily separate threads.
>
> > Of course the question remains, how much can the performance of WSGI
> > type apps be improved by an analogous event handling model within the
> > app and how much of a change in development style would be required to
> > take full advantage of such an approach. As far as I am aware these
> > questions has never even been posed.
>
> > Further background:
>
> > There is no need to use web2py to serve up its css pages, javascript
> > and images.  A compiled static language (such as C) web server can be
> > used instead.
>
> > The question then becomes which web server. The answer is obvious: web
> > servers that use event handlers to serve static web pages, not
> > necessarily threads. Unfortunately you will find religious bigots,
> > even on this forum, who will ridicule anyone who points out the
> > obvious. Expect abuse from this reply.
>
> > John Heenan
>
> > On Aug 24, 3:21 pm, mdipierro  wrote:
>
> > > P.S. In the end the bottle neck is ALWAYS database access.
>
> > > On Aug 24, 12:20 am, mdipierro  wrote:
>
> > > > In Java a serverlet, as far as I understand, is a class which conforms
> > > > to some API that allows it to serve one http request. Each instance is
> > > > executed in its own thread. The Python equivalent of the serverlet API
> > > > is a WSGI application and web2py is based on WSGI, therefore the
> > > > parallelization mechanism is equivalent to Java serverlets.
>
> > > > In web2py (the same in Django, Pylons, any any WSGI app) each http
> > > > request is executed in its own thread. Threads are recycled to server
> > > > non-concurrent requests and reuse database connections (pooling)
> > > > without need to close and reopen them. The web server can be
> > > > configured for a min number and a max number of threads.
>
> > > > I think the GIL in this context is a false problem. In fact in
> > > > production you can use Apache and run as many processes as the number
> > > > of cores that you have. Each process will create as many threads as it
> > > > needs to server multiple requests. The GIL is a problems only if one
> > > > process runs multiple threads on multiple cores. It is possible there
> > > > are some caveats with many cores but I have not really played with
> > > > apache configurations and benchmarks.
>
> > > > I do not think using Jython helps anything. According to these tests:
> > > >  http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p...
> > > >  http://pyevolve.sourceforge.net/wordpress/?p=1189
> > > > Jython is 2x-3x slower than cpython. So you may get better scaling
> > > > with multiple cores but you pay huge perfomance hit.
>
> > > > Web2py runs on Jython but there is a known bug in Java regular
> > > > expressions that Sun marked as "won'tfix" that can cause runaway
> > > > problems when parsing complex templates. This is not a web2py specific
> > > > problem but we have seen effects of the bug in some web2py apps.
>
> > > > 

Re: [web2py] Re: Should we have a feature freeze and stability maintenance period in future?

2010-08-24 Thread Michele Comitini
Actually I would like to ask if bug tracking is used on web2py?

Code is available from either (btw Massimo how do you keep those 2 in
sync? just too curious :-) ):
a) googlecode (with hg)
b) launchpad (with bzr)

both have some sort of bugtracking ticket system I do not know which
one is best (or worst),  we could start with one those, but
the choice must taken with care and other systems must be evaluated
(on: usability, independece, web2py phylosophy ...), and first
they must meet Massimo needs.

BTW: I would like to see  a web2py application for doing serious
bugtracking in the future... so that submitting
a bug would be just one click on the ticket reported by any web2py
installation! mmm too easy... that would be dangerous! ;-)

ciao,
mic

2010/8/24 mart :

> I don't know if you are currently using a specific bug tracking
> system, but they are typically easy to interface with and made part of
> build/release & test processes/automation. I.e. As part of a release
> process, I would set rules with the source control system where non-
> bugTraking releated changes can either be automatically rejected, or
> moved to another set of prioritiesArea, etc... the build (or packaged
> fileset, or whatever the output is) contains a detailed inventory of
> bug fixes/features/etc... as part of an automated delivery system
> (these are part of the build notes)...
>


Re: [web2py] Re: Web2py and threads

2010-08-24 Thread Michele Comitini
John,
Tnx ... I'll keep this under my pillow ;-)

2010/8/24 John Heenan :
> Lee's 'The Problem with Threads' link is at
> http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf
>
> There is in Lee at http://ptolemy.eecs.berkeley.edu/%7Eeal/
>
> John Heenan
>
> On Aug 25, 5:00 am, John Heenan  wrote:
>> Can't we at least have an acknowledgement that it is not necessary for
>> web2py to use a thread per request model and that web2py could instead
>> use an event model?
>>
>> WSGI can be viewed as an evil conspiracy to force Python web apps to
>> follow the Apache thread per request model! Also with Apace mod_wsgi,
>> Apache controls the Python process that web2py runs under! How evil
>> and ugly!
>>
>> There is no inherent reason why web2py needs to run a separate thread
>> for each NON static http request, if WSGI is not used!
>>
>> If web2py uses WSGI then a thread per request is forced upon web2py.
>> This suits Apache but not web serves with better event driven models
>> such as Lighttpd and Nginx
>>
>> For example Lighttpd does not even support WSGI. Instead web2py used
>> fastcgi for communication Lighttpd via a UNIX socket and web2py then
>> needlessly converts each request into a thread for handling by a WSGI
>> handler!
>>
>> Why should web2py be forced into using a thread model? Anyone who
>> writes PC applications avoids thread as if they are a plague. Even
>> academics openly call using threads evil. Here is an article by Edward
>> A. Lee professor at Berkely University with the title "The Problem
>> with Threads" (PDF).
>>
>> John Heenan
>>
>> On Aug 25, 1:00 am, John Heenan  wrote:
>>
>> > There is absolutely no need to serve up static web pages of a pure
>> > Python web app or a WGSI app with a separate thread.  It is
>> > inefficient to use an inbuilt web server (of a Python web app) or
>> > Apache (if WGSI used) to serve up static web pages using separate
>> > threads. Both Lighttpd and Nginx are well known web servers that
>> > thrash Apache in objective tests for static pages when a web server is
>> > under load. These web servers use event handlers to serve static web
>> > pages, not necessarily separate threads.
>>
>> > Of course the question remains, how much can the performance of WSGI
>> > type apps be improved by an analogous event handling model within the
>> > app and how much of a change in development style would be required to
>> > take full advantage of such an approach. As far as I am aware these
>> > questions has never even been posed.
>>
>> > Further background:
>>
>> > There is no need to use web2py to serve up its css pages, javascript
>> > and images.  A compiled static language (such as C) web server can be
>> > used instead.
>>
>> > The question then becomes which web server. The answer is obvious: web
>> > servers that use event handlers to serve static web pages, not
>> > necessarily threads. Unfortunately you will find religious bigots,
>> > even on this forum, who will ridicule anyone who points out the
>> > obvious. Expect abuse from this reply.
>>
>> > John Heenan
>>
>> > On Aug 24, 3:21 pm, mdipierro  wrote:
>>
>> > > P.S. In the end the bottle neck is ALWAYS database access.
>>
>> > > On Aug 24, 12:20 am, mdipierro  wrote:
>>
>> > > > In Java a serverlet, as far as I understand, is a class which conforms
>> > > > to some API that allows it to serve one http request. Each instance is
>> > > > executed in its own thread. The Python equivalent of the serverlet API
>> > > > is a WSGI application and web2py is based on WSGI, therefore the
>> > > > parallelization mechanism is equivalent to Java serverlets.
>>
>> > > > In web2py (the same in Django, Pylons, any any WSGI app) each http
>> > > > request is executed in its own thread. Threads are recycled to server
>> > > > non-concurrent requests and reuse database connections (pooling)
>> > > > without need to close and reopen them. The web server can be
>> > > > configured for a min number and a max number of threads.
>>
>> > > > I think the GIL in this context is a false problem. In fact in
>> > > > production you can use Apache and run as many processes as the number
>> > > > of cores that you have. Each process will create as many threads as it
>> > > > needs to server multiple requests. The GIL is a problems only if one
>> > > > process runs multiple threads on multiple cores. It is possible there
>> > > > are some caveats with many cores but I have not really played with
>> > > > apache configurations and benchmarks.
>>
>> > > > I do not think using Jython helps anything. According to these tests:
>> > > >  http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p...
>> > > >  http://pyevolve.sourceforge.net/wordpress/?p=1189
>> > > > Jython is 2x-3x slower than cpython. So you may get better scaling
>> > > > with multiple cores but you pay huge perfomance hit.
>>
>> > > > Web2py runs on Jython but there is a known bug in Java regular
>> > > > expressions that Sun marked as "won'tfix" that c

[web2py] Re: Web2py and threads

2010-08-24 Thread cjrh
On Aug 24, 9:00 pm, John Heenan  wrote:
> Can't we at least have an acknowledgement that it is not necessary for
> web2py to use a thread per request model and that web2py could instead
> use an event model?

Acknowledged.


Re: [web2py] Re: Line continuation problem in new parser?

2010-08-24 Thread Phyo Arkar
that wasn't supported hmm

On Mon, Aug 23, 2010 at 6:47 PM, Michael Ellis wrote:

> Probably didn't.  I encountered it while trying to clean up some view code
> that was looking messy.  I'm in favor of supporting line continuation if at
> all possible or, if not, at least issuing an error message to that effect.
>
>
>
>
> On Sun, Aug 22, 2010 at 9:14 PM, mdipierro wrote:
>
>> Did this work before? I do not think continuation was ever supported.
>>
>> Massimo
>>
>> On Aug 22, 2:13 pm, Michael Ellis  wrote:
>> > In Version 1.83.2 (2010-08-15 02:10:01)
>> >
>> > this works:
>> >
>> > {{
>> > for r in rows:
>> > =DIV(SPAN(r[0]), SPAN(fcw[r[0]]), SPAN(fcw[r[1]]))
>> > pass
>> >
>> > }}
>> >
>> > but this raises a syntax error:
>> > {{
>> > for r in rows:
>> > =DIV(SPAN(r[0]),
>> >   SPAN(fcw[r[0]]),
>> >   SPAN(fcw[r[1]]))
>> > pass
>> >
>> > }}
>> >
>> > Tried '\' continuations also.  The parser thinks there are extra chars
>> > after the backslash even when there aren't.
>> >
>> > Apologies if this is a known issue or intentional limitation.
>> >
>> > Cheers,
>> > Mike
>
>
>


[web2py] Re: Web2py and threads

2010-08-24 Thread John Heenan
Lee's 'The Problem with Threads' link is at
http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf

There is in Lee at http://ptolemy.eecs.berkeley.edu/%7Eeal/

John Heenan

On Aug 25, 5:00 am, John Heenan  wrote:
> Can't we at least have an acknowledgement that it is not necessary for
> web2py to use a thread per request model and that web2py could instead
> use an event model?
>
> WSGI can be viewed as an evil conspiracy to force Python web apps to
> follow the Apache thread per request model! Also with Apace mod_wsgi,
> Apache controls the Python process that web2py runs under! How evil
> and ugly!
>
> There is no inherent reason why web2py needs to run a separate thread
> for each NON static http request, if WSGI is not used!
>
> If web2py uses WSGI then a thread per request is forced upon web2py.
> This suits Apache but not web serves with better event driven models
> such as Lighttpd and Nginx
>
> For example Lighttpd does not even support WSGI. Instead web2py used
> fastcgi for communication Lighttpd via a UNIX socket and web2py then
> needlessly converts each request into a thread for handling by a WSGI
> handler!
>
> Why should web2py be forced into using a thread model? Anyone who
> writes PC applications avoids thread as if they are a plague. Even
> academics openly call using threads evil. Here is an article by Edward
> A. Lee professor at Berkely University with the title "The Problem
> with Threads" (PDF).
>
> John Heenan
>
> On Aug 25, 1:00 am, John Heenan  wrote:
>
> > There is absolutely no need to serve up static web pages of a pure
> > Python web app or a WGSI app with a separate thread.  It is
> > inefficient to use an inbuilt web server (of a Python web app) or
> > Apache (if WGSI used) to serve up static web pages using separate
> > threads. Both Lighttpd and Nginx are well known web servers that
> > thrash Apache in objective tests for static pages when a web server is
> > under load. These web servers use event handlers to serve static web
> > pages, not necessarily separate threads.
>
> > Of course the question remains, how much can the performance of WSGI
> > type apps be improved by an analogous event handling model within the
> > app and how much of a change in development style would be required to
> > take full advantage of such an approach. As far as I am aware these
> > questions has never even been posed.
>
> > Further background:
>
> > There is no need to use web2py to serve up its css pages, javascript
> > and images.  A compiled static language (such as C) web server can be
> > used instead.
>
> > The question then becomes which web server. The answer is obvious: web
> > servers that use event handlers to serve static web pages, not
> > necessarily threads. Unfortunately you will find religious bigots,
> > even on this forum, who will ridicule anyone who points out the
> > obvious. Expect abuse from this reply.
>
> > John Heenan
>
> > On Aug 24, 3:21 pm, mdipierro  wrote:
>
> > > P.S. In the end the bottle neck is ALWAYS database access.
>
> > > On Aug 24, 12:20 am, mdipierro  wrote:
>
> > > > In Java a serverlet, as far as I understand, is a class which conforms
> > > > to some API that allows it to serve one http request. Each instance is
> > > > executed in its own thread. The Python equivalent of the serverlet API
> > > > is a WSGI application and web2py is based on WSGI, therefore the
> > > > parallelization mechanism is equivalent to Java serverlets.
>
> > > > In web2py (the same in Django, Pylons, any any WSGI app) each http
> > > > request is executed in its own thread. Threads are recycled to server
> > > > non-concurrent requests and reuse database connections (pooling)
> > > > without need to close and reopen them. The web server can be
> > > > configured for a min number and a max number of threads.
>
> > > > I think the GIL in this context is a false problem. In fact in
> > > > production you can use Apache and run as many processes as the number
> > > > of cores that you have. Each process will create as many threads as it
> > > > needs to server multiple requests. The GIL is a problems only if one
> > > > process runs multiple threads on multiple cores. It is possible there
> > > > are some caveats with many cores but I have not really played with
> > > > apache configurations and benchmarks.
>
> > > > I do not think using Jython helps anything. According to these tests:
> > > >  http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p...
> > > >  http://pyevolve.sourceforge.net/wordpress/?p=1189
> > > > Jython is 2x-3x slower than cpython. So you may get better scaling
> > > > with multiple cores but you pay huge perfomance hit.
>
> > > > Web2py runs on Jython but there is a known bug in Java regular
> > > > expressions that Sun marked as "won'tfix" that can cause runaway
> > > > problems when parsing complex templates. This is not a web2py specific
> > > > problem but we have seen effects of the bug in some web2py apps.
>
> > > > Ma

Re: [web2py] Re: Should we have a feature freeze and stability maintenance period in future?

2010-08-24 Thread Jonathan Lundell
On Aug 24, 2010, at 11:29 AM, mart wrote:

> Well, this is all interesting :) After reading Michele's email, I just
> had to spend hours looking at Mercurial (& the like) as deeply as the
> day would let me (I'm on PTO, so I can do this). I thought I had a
> good idea about "distributed" version control system but, as it turns
> out, a few surprises were there waiting for me. I have always been a
> believer in "development against the known reference version" (now,
> that's me being old fashioned). So, yes... Mercurial must be a painful
> thing.  Based on what I have read, mercurial seems a little too
> chaotic for my taste. I do believe there is one way to manage a source
> repository (did I really just say that?) wrt to input/output. Well,
> honestly, I am way too big of a "exactly what is going to any of the
> products I build" junky, to even accept some of the basic premises of
> Mercurial.  Like any workingDirectory is a potential branch?

The O'Reilly Hg book "Mercurial: The Definitive Guide" is a really good 
reference here, not just for day-to-day help, but for real insight into the 
advantages and strategies of distributed version control. Highly recommended.



[web2py] Re: Web2py and threads

2010-08-24 Thread John Heenan
Can't we at least have an acknowledgement that it is not necessary for
web2py to use a thread per request model and that web2py could instead
use an event model?

WSGI can be viewed as an evil conspiracy to force Python web apps to
follow the Apache thread per request model! Also with Apace mod_wsgi,
Apache controls the Python process that web2py runs under! How evil
and ugly!

There is no inherent reason why web2py needs to run a separate thread
for each NON static http request, if WSGI is not used!

If web2py uses WSGI then a thread per request is forced upon web2py.
This suits Apache but not web serves with better event driven models
such as Lighttpd and Nginx

For example Lighttpd does not even support WSGI. Instead web2py used
fastcgi for communication Lighttpd via a UNIX socket and web2py then
needlessly converts each request into a thread for handling by a WSGI
handler!

Why should web2py be forced into using a thread model? Anyone who
writes PC applications avoids thread as if they are a plague. Even
academics openly call using threads evil. Here is an article by Edward
A. Lee professor at Berkely University with the title "The Problem
with Threads" (PDF).

John Heenan


On Aug 25, 1:00 am, John Heenan  wrote:
> There is absolutely no need to serve up static web pages of a pure
> Python web app or a WGSI app with a separate thread.  It is
> inefficient to use an inbuilt web server (of a Python web app) or
> Apache (if WGSI used) to serve up static web pages using separate
> threads. Both Lighttpd and Nginx are well known web servers that
> thrash Apache in objective tests for static pages when a web server is
> under load. These web servers use event handlers to serve static web
> pages, not necessarily separate threads.
>
> Of course the question remains, how much can the performance of WSGI
> type apps be improved by an analogous event handling model within the
> app and how much of a change in development style would be required to
> take full advantage of such an approach. As far as I am aware these
> questions has never even been posed.
>
> Further background:
>
> There is no need to use web2py to serve up its css pages, javascript
> and images.  A compiled static language (such as C) web server can be
> used instead.
>
> The question then becomes which web server. The answer is obvious: web
> servers that use event handlers to serve static web pages, not
> necessarily threads. Unfortunately you will find religious bigots,
> even on this forum, who will ridicule anyone who points out the
> obvious. Expect abuse from this reply.
>
> John Heenan
>
> On Aug 24, 3:21 pm, mdipierro  wrote:
>
> > P.S. In the end the bottle neck is ALWAYS database access.
>
> > On Aug 24, 12:20 am, mdipierro  wrote:
>
> > > In Java a serverlet, as far as I understand, is a class which conforms
> > > to some API that allows it to serve one http request. Each instance is
> > > executed in its own thread. The Python equivalent of the serverlet API
> > > is a WSGI application and web2py is based on WSGI, therefore the
> > > parallelization mechanism is equivalent to Java serverlets.
>
> > > In web2py (the same in Django, Pylons, any any WSGI app) each http
> > > request is executed in its own thread. Threads are recycled to server
> > > non-concurrent requests and reuse database connections (pooling)
> > > without need to close and reopen them. The web server can be
> > > configured for a min number and a max number of threads.
>
> > > I think the GIL in this context is a false problem. In fact in
> > > production you can use Apache and run as many processes as the number
> > > of cores that you have. Each process will create as many threads as it
> > > needs to server multiple requests. The GIL is a problems only if one
> > > process runs multiple threads on multiple cores. It is possible there
> > > are some caveats with many cores but I have not really played with
> > > apache configurations and benchmarks.
>
> > > I do not think using Jython helps anything. According to these tests:
> > >  http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p...
> > >  http://pyevolve.sourceforge.net/wordpress/?p=1189
> > > Jython is 2x-3x slower than cpython. So you may get better scaling
> > > with multiple cores but you pay huge perfomance hit.
>
> > > Web2py runs on Jython but there is a known bug in Java regular
> > > expressions that Sun marked as "won'tfix" that can cause runaway
> > > problems when parsing complex templates. This is not a web2py specific
> > > problem but we have seen effects of the bug in some web2py apps.
>
> > > Massimo
>
> > > On Aug 23, 11:29 pm, pierreth  wrote:
>
> > > > Hello,
>
> > > > I would like to know how Web2py is managing threads. Is it like Java
> > > > servlets where requests are mapped to servlets while one servlet
> > > > object can be used by multiple threads at the same time to serve many
> > > > requests?
>
> > > > Are some users here using Jython with Web2py to get arou

[web2py] Re: Should we have a feature freeze and stability maintenance period in future?

2010-08-24 Thread mart
Well, this is all interesting :) After reading Michele's email, I just
had to spend hours looking at Mercurial (& the like) as deeply as the
day would let me (I'm on PTO, so I can do this). I thought I had a
good idea about "distributed" version control system but, as it turns
out, a few surprises were there waiting for me. I have always been a
believer in "development against the known reference version" (now,
that's me being old fashioned). So, yes... Mercurial must be a painful
thing.  Based on what I have read, mercurial seems a little too
chaotic for my taste. I do believe there is one way to manage a source
repository (did I really just say that?) wrt to input/output. Well,
honestly, I am way too big of a "exactly what is going to any of the
products I build" junky, to even accept some of the basic premises of
Mercurial.  Like any workingDirectory is a potential branch?
Personally, I tend to think that when it comes to managing those "ins
and outs" of code lines (I'm talking about production code lines - and
not in the sense of "experimental" as Mercurial would say), VCS should
enforce structure, rules and accountability, in the sense of knowing
where code goes (again that's me being old fashioned and yes, perhaps
a little “corporate” minded). But... I do recognize some potential.
The benefit that jumps up @ me (that's just my take) is that Mercurial
has no real sense of “Mercurial best practices” and has no bias  for
particular model more than another (which i think is a good thing
here).

That said, I would usually take more time in reaching my own
conclusions about such things, but, I feel compelled to send what I
think at this point. I will keep those 2 key areas needing focus that
Michele mentions (version control and bug tracking).

Here are my 2 cents:

** "if something is not doing it for me , I change it”.

Michele mentions the that feature development is slowed by bug fixing.
Well,  I have certainly seen that before, and worse. I really do
encourage the web2py leads to re-think you source control strategies.
When symptoms like above surface, it is often an indication of harder
times ahead. As an example, without mentioning names, I have started
with a company last spring, where things have gotten so out of control
in this matter, that slower feature development is the least of there
problems. The changes required put development/QA/release processes
back on track are severe. Not a good place to be. And this stemmed
from fast growth and not having an infrastructure in place to handle
higher levels of activity. I am not familiar with the details wrt
process in the web2py community. but if both the existing
infrastructure and rising volume are an area of concern, then I would
recommend, looking at things from another angle. I would define your
needs (i.e. Professor Di Pierro has mentioned his requirements, i.e.
the one branch model where he can control commits to the code line –
and if it is what he is comfortable with, then THAT is where I would
start.

** “If I can't change something that's not doing it for me I make
it work"

There are opportunities for change while preserving Professor Di
Pierro's comfort zone (wrt what goes in to the production/golden
branch). One, If keeping with Mercurial is a requirement in the
analysis, then I would change what Mercurial looks like and its
“driving experience”. Web2py has all the functionality needed to
create a front end  designed to  better that experience. Rules and
structure can certainly be backed in to that front end and set as
“guide lines to the contributors”. Remember, Mercurial has been
conceived without direction, in the sense where strategies to suite
you own needs entirely possible.

The distributed nature of this model (contribution vs “corporate”/
proprietary), does impose that that chaotic mesh and hierarchical
structure will continue to be a consideration. However, at the top
level, that is where these efforts can have a positive impact.

This is what I would suggest we look at:

3 branches to manage “going to production” :

1.the golden/production branch (this belongs to Prof. Di Pierro)
2.the silver/staging branch (this is where Prof, Di Pirerro picks up
changes/patches/features,etc.)
3.the bronze/testing branch (this is where the code that made it up
the ladder goes)
  Note: test suites can occur at the silver level as well (same
pattern)

So it looks like this (sorry for the bad graphic):

golden >
^^
| pull   | pull
silver   __|_|_>  \
  ^  ^| 
managed by
  | pull || 
web2py leads
bronze __x__|_x__|>/
|___test|___test: test pulls a specific 
changeset
 

[web2py] Re: Pagination manual bug?

2010-08-24 Thread Vidul Petrov
Not sure if this help, but you may want to take a look at this
Pagination class:
http://packages.python.org/web2py_utils/paginate.html

On Aug 24, 6:37 pm, dlin  wrote:
> ref:http://web2py.com/book/default/chapter/12#Pagination
>
> In following code, there is two problem:
> 1. The 'next' button always show.  And the len(rows) always = 2
> 2. I don't know how to proper show the {{=rows}} without last row, I
> want to use the odd row background-color trick.
>
> I wrote simliar code in default.py
> -
> def listall():
>     if len(request.args): page=int(request.args[0])
>     else: page=0
>     items_per_page=2
>     limitby=(page*items_per_page,(page+1)*items_per_page + 1)
>     words= db().select(db.mytable.ALL, limitby=limitby)
>     cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
>     hdrs = dict([(str(c),c.label) for c in db.mytable])
>     rows =SQLTABLE(words,
>          headers = hdrs,
>          columns=cols,
>          truncate=32)
>     rows['_id'] = 'rows'
>     return dict(rows=rows, page=page, items_per_page=items_per_page)
>
> And the view listall.html:
> ---
> {{extend 'layout.html'}}
> {{=rows}}
> page:{{=page}} 
> len(rows):{{=len(rows)}} 
>
> {{if page:}}
> previous
> {{pass}}
>
> {{if len(rows)>=items_per_page:}}
> next
> {{pass}}
>
> 

Re: [web2py] Re: Web2py and threads

2010-08-24 Thread Michele Comitini
2010/8/24 pierreth :

> Yes but a web2py server is running with only one process and using
> more web2py processes for serving the same web2py app will lead to
> synchronization problems. With processors having more and more cores,
> having a web server that cannot use them is not very fun. It is an
> issue to be solved with Python 3.2 I think.
>

the GIL is still in place, maybe faster but still serializing...
http://docs.python.org/dev/whatsnew/3.2.html#multi-threading


[web2py] Re: Web2py and threads

2010-08-24 Thread mdipierro
On Aug 24, 10:36 am, pierreth  wrote:
> On 24 août, 01:20, mdipierro  wrote:
>
> > In Java a serverlet, as far as I understand, is a class which conforms
> > to some API that allows it to serve one http request. Each instance is
> > executed in its own thread.
>
> Yes, but one instance can be executed by multiple threads at the same
> time. It is one thread per request. EJB, Enterprise Java Beans, are
> running on their own threads.

it is the same in web2py

> >The Python equivalent of the serverlet API
> > is a WSGI application and web2py is based on WSGI, therefore the
> > parallelization mechanism is equivalent to Java serverlets.
>
> Is web2py running as a WSGI application when we do "python web2py.py"
> or is it only when used in a specific deployment with WSGI?

when you do "python web2py.py" you do not start the wsgi app. You
start the rocket web server which makes a number of threads. When a
new http request arrives it is assigned to a free thread (or a new
thread is created) and the wsgi is run in that thread to server that
request and only that request.

> > In web2py (the same in Django, Pylons, any any WSGI app) each http
> > request is executed in its own thread. Threads are recycled to server
> > non-concurrent requests and reuse database connections (pooling)
> > without need to close and reopen them. The web server can be
> > configured for a min number and a max number of threads.
>
> So, as a web2py developer, what do I have to do to avoid
> synchronization problems in my application. Where is the danger of
> having multiple threads for the web2py developers? What are the
> instances shared my multiple threads? What are the instances living in
> their own threads?

You do have to do anything because every concurrency issue is taken
care automatically. There are some DO NOTs:
- do not ever call os.chdir
- do not import third party modules that are not thread safe
- do not use thread.start_new_thread and threading.Thread.start()
- if you open a file that is not uniquely associate to this http/
request/client/session lock the file.

> > I think the GIL in this context is a false problem. In fact in
> > production you can use Apache and run as many processes as the number
> > of cores that you have. Each process will create as many threads as it
> > needs to server multiple requests. The GIL is a problems only if one
> > process runs multiple threads on multiple cores. It is possible there
> > are some caveats with many cores but I have not really played with
> > apache configurations and benchmarks.
>
> Yes but a web2py server is running with only one process and using
> more web2py processes for serving the same web2py app will lead to
> synchronization problems. With processors having more and more cores,
> having a web server that cannot use them is not very fun.

In production you should not use the rocket web server. Use Apache and
preform more than one process.

> It is an
> issue to be solved with Python 3.2 I think.

We are not moving to 3.2. Not at least until Google App Engine moves
to 3.x and all database drivers are supported. Than we'll open this
discussion.


> > Massimo
>
> Thank you for this precious information.


[web2py] Re: Simple Drop Down List with Auto Submit

2010-08-24 Thread mdipierro
Is is set expects a python list or dict. If you want to a dropdown
from a list of records:

def get_services()
form = SQLFORM.factory(SQLField('name', label='Select a service',
   requires=IS_IN_DB(db,'service.name',orderby=db.service.name))
return dict(form=form)

On Aug 24, 10:04 am, David  wrote:
> I've been having a heck of a time trying to figure out how to make a
> simple drop down list from a table in the database.
>
> What I would like to do is have a drop down list populated by the
> table information and when a person selects that item from the drop
> down I want it to go to a page that pulls up all of those types of
> items.
>
> I've seen reference to IS_IN_SET() and IS_IN_DB() but it doesn't make
> much sense to me since there are a lack of examples.
>
> This is what I have so far on it.
>
> def get_services()
>     services = db(db.services.name>0).select(orderby=db.services.name)
>     form = SQLFORM.factory(SQLField('name', label='Select a
> service',requires=IS_IN_SET(services)))
>     return dict(form=form)
>
> default/get_services.html
>
> {{=form}
>
> This does create a drop down but it has a bunch of extra information
> about query and lambda which I don't need and only displays about half
> of the names in the table.  I just need the name and the ID like a
> normal dropdown list with auto submit.
>
> Has anyone a reference to something like this?
>
> Thanks,
> David


[web2py] Re: bg-bg.py (Bulgarian translation)

2010-08-24 Thread mdipierro
Please email to me as an attachment. Thanks.

On Aug 24, 8:21 am, Vidul Petrov  wrote:
> # coding: utf8
> {
> '"update" is an optional expression like "field1=\'newvalue\'". You
> cannot update or delete the results of a JOIN': '"обнови" е
> незадължителен израз от вида "field1=\'нова стойност\'". Резултатите
> от JOIN не могат да се обновяват или изтриват.',
> '%Y-%m-%d': '%Y-%m-%d',
> '%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
> '%s rows deleted': '%s редици бяха изтрити',
> '%s rows updated': '%s редици бяха обновени',
> 'Available databases and tables': 'Налични бази данни и таблици',
> 'Cannot be empty': 'Не може да бъде празно',
> 'Change Password': 'Смяна на парола',
> 'Check to delete': 'Маркирайте за изтриване',
> 'Check to delete:': 'Маркирайте за изтриване:',
> 'Client IP': 'IP на клиента',
> 'Controller': 'Контролер',
> 'Copyright': 'Авторски права',
> 'Current request': 'Tekyща заявка',
> 'Current response': 'Текущ отговор',
> 'Current session': 'Текуща сесия',
> 'DB Model': 'DB Модел',
> 'Database': 'База Данни',
> 'Delete:': 'Изтрии:',
> 'Description': 'Описание',
> 'E-mail': 'Е-мейл',
> 'Edit': 'Редакция',
> 'Edit Profile': 'Редакция на Профила',
> 'Edit current record': 'Редакция на текущия профил',
> 'First name': 'Малко име',
> 'Group ID': 'ID на група',
> 'Hello World': 'Здравей, Свят!',
> 'Import/Export': 'Импорт/експорт',
> 'Index': 'Индекс',
> 'Internal State': 'Вътрешно състояние',
> 'Invalid Query': 'Невалидна заявка',
> 'Invalid email': 'Невалиден е-мейл',
> 'Invalid login': 'Невалиден логин',
> 'Invalid password': 'Невалидна парола',
> 'Last name': 'Фамилно име',
> 'Layout': 'Лейаут',
> 'Logged in': 'Вход в системата',
> 'Logged out': 'Изход от системата',
> 'Login': 'Вход',
> 'Logout': 'Изход',
> 'Lost Password': 'Забравена Парола',
> 'Menu Model': 'Меню Модел',
> 'Name': 'Име',
> 'New Record': 'Нов Запис',
> 'New password': 'Нова парола',
> 'No databases in this application': 'В това приложение няма бази
> данни',
> 'Old password': 'Стара парола',
> 'Origin': 'Произход',
> 'Password': 'Парола',
> "Password fields don't match": 'Паролите не съвпадат',
> 'Powered by': 'Базирано на',
> 'Query:': 'Заявка:',
> 'Record ID': 'ID на сапис',
> 'Register': 'Регистрация',
> 'Registration key': 'Регистрационен ключ',
> 'Remember me (for 30 days)': 'Запомни ме (за 30 дена)',
> 'Reset Password key': 'Генериране на нов ключ за паролата',
> 'Role': 'Роля',
> 'Rows in table': 'Редове в таблица',
> 'Rows selected': 'Избрани редове',
> 'Stylesheet': 'Стайлшийт',
> 'Submit': 'Потвърдете',
> 'Sure you want to delete this object?': 'Сигурни ли сте, че искате да
> изтриете този обект?',
> 'Table name': 'Име на таблица',
> 'The "query" is a condition like "db.table1.field1==\'value\'".
> Something like "db.table1.field1==db.table2.field2" results in a SQL
> JOIN.': '"Заявка" - това е условие от вида "db.table1.field1==
> \'стойност\'". Нещо подобно на "db.table1.field1==db.table2.field2"
> формира SQL JOIN.',
> 'The output of the file is a dictionary that was rendered by the
> view': 'Изходящият резултат от файла е речник, който се рендира от
> темплейта',
> 'This is a copy of the scaffolding application': 'Това е копие на
> базисното приложение',
> 'Timestamp': 'Времева отметка',
> 'Update:': 'Обновете:',
> 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to
> build more complex queries.': 'Използвайте (...)&(...) за "И", (...)|
> (...) за "ИЛИ", ~(...) за "НЕ", за да съставите по сложни заявки.',
> 'User %(id)s Logged-in': 'Потребителят %(id)s влезе в системата',
> 'User %(id)s Logged-out': 'Потребителят %(id)s излезе от системата',
> 'User %(id)s Password changed': 'Потребителят %(id)s смени паролата
> си',
> 'User %(id)s Profile updated': 'Потребителят %(id)s обнови профила
> си',
> 'User %(id)s Registered': 'Потребителят %(id)s беше регистриран',
> 'User ID': 'ID на потребителя',
> 'Verify Password': 'Повторете паролата',
> 'View': 'Темплейт',
> 'Welcome to web2py': 'Добре дошли в web2py',
> 'Which called the function': 'Което извика функцията',
> 'You are successfully running web2py': 'Вие работите успешно с
> web2py',
> 'You can modify this application and adapt it to your needs': 'Вие
> може да промените това проложение и да го нагодите спрямо Вашите
> нужди',
> 'You visited the url': 'Вие посетихте следния URL',
> 'appadmin is disabled because insecure channel': 'appadmin e забранен
> поради несигурен канал',
> 'cache': 'кеш',
> 'click here for online examples': 'онлайн примери',
> 'click here for the administrative interface': 'административен
> интерфейс',
> 'customize me!': 'настройте външния вид!',
> 'data uploaded': 'данните бяха качени',
> 'database': 'база данни',
> 'database %s select': 'избор на база данни %s',
> 'db': 'БД',
> 'design': 'дизайн',
> 'documentation': 'документация',
> 'done!': 'готово!',
> 'export as csv file': 'експорт в csv файл',
> 'insert new': 'добавете нов',
> 'insert new %s': 'добавете нови %s',
> 'invalid request': 'невалидна заявка',
> 'located

Re: [web2py] Re: Web2py and threads

2010-08-24 Thread Michele Comitini
CPython threading is not useful for (real) parallel processing
1) thread (with GIL) is good for *cpu bound processes* that do not
stop the main process while blocked by a system call (the intent is
similar to select/poll)
2) for really using multiple cores/cpus use something more
appropriated or make Mr. Van Rossum change his mind! :-)

http://mail.python.org/pipermail/python-3000/2007-May/007414.html

Object instantiated in python threads are isolated so they live their
own life no worry about that
Anyway do you like singletons? Python threading has many ways to
support that... but read this:
http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/

wow! :-)


2010/8/24 pierreth :
> On 24 août, 01:20, mdipierro  wrote:
>> In Java a serverlet, as far as I understand, is a class which conforms
>> to some API that allows it to serve one http request. Each instance is
>> executed in its own thread.
>
> Yes, but one instance can be executed by multiple threads at the same
> time. It is one thread per request. EJB, Enterprise Java Beans, are
> running on their own threads.
>
>>The Python equivalent of the serverlet API
>> is a WSGI application and web2py is based on WSGI, therefore the
>> parallelization mechanism is equivalent to Java serverlets.
>
> Is web2py running as a WSGI application when we do "python web2py.py"
> or is it only when used in a specific deployment with WSGI?
>
>>
>> In web2py (the same in Django, Pylons, any any WSGI app) each http
>> request is executed in its own thread. Threads are recycled to server
>> non-concurrent requests and reuse database connections (pooling)
>> without need to close and reopen them. The web server can be
>> configured for a min number and a max number of threads.
>
> So, as a web2py developer, what do I have to do to avoid
> synchronization problems in my application. Where is the danger of
> having multiple threads for the web2py developers? What are the
> instances shared my multiple threads? What are the instances living in
> their own threads?
>
>>
>> I think the GIL in this context is a false problem. In fact in
>> production you can use Apache and run as many processes as the number
>> of cores that you have. Each process will create as many threads as it
>> needs to server multiple requests. The GIL is a problems only if one
>> process runs multiple threads on multiple cores. It is possible there
>> are some caveats with many cores but I have not really played with
>> apache configurations and benchmarks.
>
> Yes but a web2py server is running with only one process and using
> more web2py processes for serving the same web2py app will lead to
> synchronization problems. With processors having more and more cores,
> having a web server that cannot use them is not very fun. It is an
> issue to be solved with Python 3.2 I think.
>
>> Massimo
>>
>
> Thank you for this precious information.


[web2py] Slovak translation: sk-sk.py

2010-08-24 Thread Julius Minka

# coding: utf8
{
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" je voliteľný výraz ako "field1=\'newvalue\'". Nemôžete upravovať alebo zmazať výsledky JOINu',
'%Y-%m-%d': '%d.%m.%Y',
'%Y-%m-%d %H:%M:%S': '%d.%m.%Y %H:%M:%S',
'%s rows deleted': '%s zmazaných záznamov',
'%s rows updated': '%s upravených záznamov',
'Available databases and tables': 'Dostupné databázy a tabuľky',
'Cannot be empty': 'Nemôže byť prázdne',
'Check to delete': 'Označiť na zmazanie',
'Controller': 'Controller',
'Copyright': 'Copyright',
'Current request': 'Aktuálna požiadavka',
'Current response': 'Aktuálna odpoveď',
'Current session': 'Aktuálne sedenie',
'DB Model': 'DB Model',
'Database': 'Databáza',
'Delete:': 'Zmazať:',
'Description': 'Popis',
'Edit': 'Upraviť',
'Edit Profile': 'Upraviť profil',
'Edit current record': 'Upraviť aktuálny záznam',
'First name': 'Krstné meno',
'Group ID': 'ID skupiny',
'Hello World': 'Ahoj svet',
'Import/Export': 'Import/Export',
'Index': 'Index',
'Internal State': 'Vnútorný stav',
'Invalid email': 'Neplatný email',
'Invalid Query': 'Neplatná otázka',
'Invalid password': 'Nesprávne heslo',
'Last name': 'Priezvisko',
'Layout': 'Layout',
'Logged in': 'Prihlásený',
'Logged out': 'Odhlásený',
'Lost Password': 'Stratené heslo?',
'Menu Model': 'Menu Model',
'Name': 'Meno',
'New Record': 'Nový záznam',
'New password': 'Nové heslo',
'No databases in this application': 'V tejto aplikácii nie sú databázy',
'Old password': 'Staré heslo',
'Origin': 'Pôvod',
'Password': 'Heslo',
'Powered by': 'Powered by',
'Query:': 'Otázka:',
'Record ID': 'ID záznamu',
'Register': 'Zaregistrovať sa',
'Registration key': 'Registračný kľúč',
'Remember me (for 30 days)': 'Zapamätaj si ma (na 30 dní)',
'Reset Password key': 'Nastaviť registračný kľúč',
'Role': 'Rola',
'Rows in table': 'riadkov v tabuľke',
'Rows selected': 'označených riadkov',
'Submit': 'Odoslať',
'Stylesheet': 'Stylesheet',
'Sure you want to delete this object?': 'Ste si istí, že chcete zmazať tento objekt?',
'Table name': 'Názov tabuľky',
'The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.': '"query" je podmienka ako "db.table1.field1==\'value\'". Niečo ako "db.table1.field1==db.table2.field2" má za výsledok SQL JOIN.',
'The output of the file is a dictionary that was rendered by the view': 'Výstup zo súboru je slovník, ktorý bol zobrazený vo view',
'This is a copy of the scaffolding application': 'Toto je kópia skeletu aplikácie',
'Timestamp': 'Časová pečiatka',
'Update:': 'Upraviť:',
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to build more complex queries.': 'Použite (...)&(...) pre AND, (...)|(...) pre OR a ~(...) pre NOT na poskladanie komplexnejších otázok.',
'User %(id)s Logged-in': 'Používateľ %(id)s prihlásený',
'User %(id)s Logged-out': 'Používateľ %(id)s odhlásený',
'User %(id)s Password changed': 'Používateľ %(id)s zmenil heslo',
'User %(id)s Profile updated': 'Používateľ %(id)s upravil profil',
'User %(id)s Registered': 'Používateľ %(id)s sa zaregistroval',
'User ID': 'ID používateľa',
'Verify Password': 'Zopakujte heslo',
'View': 'Zobraziť',
'Welcome to web2py': 'Vitajte vo web2py',
'Which called the function': 'Ktorý zavolal funkciu',
'You are successfully running web2py': 'Úspešne ste spustili web2py',
'You can modify this application and adapt it to your needs': 'Môžete upraviť túto aplikáciu a prispôsobiť ju svojim potrebám',
'You visited the url': 'Navštívili ste URL',
'appadmin is disabled because insecure channel': 'appadmin je zakázaný bez zabezpečeného spojenia',
'cache': 'cache',
'click here for online examples': 'pre online príklady kliknite sem',
'click here for the administrative interface': 'pre administrátorské rozhranie kliknite sem',
'customize me!': 'prispôsob ma!',
'data uploaded': 'údaje naplnené',
'database': 'databáza',
'database %s select': 'databáza %s výber',
'db': 'db',
'design': 'návrh',
'documentation': 'dokumentácia',
'done!': 'hotovo!',
'export as csv file': 'exportovať do csv súboru',
'insert new': 'vložiť nový záznam ',
'insert new %s': 'vložiť nový  záznam %s',
'invalid request': 'Neplatná požiadavka',
'located in the file': 'nachádzajúci sa v súbore ',
'login': 'prihlásiť',
'logout': 'odhlásiť',
'lost password?': 'stratené heslo?',
'new record inserted': 'nový záznam bol vložený',
'next 100 rows': 'ďalších 100 riadkov',
'or import from csv file': 'alebo naimportovať z csv súboru',
'password': 'heslo',
'previous 100 rows': 'predchádzajúcich 100 riadkov',
'record': 'záznam',
'record does not exist': 'záznam neexistuje',
'record id': 'id záznamu',
'register': 'registrovať',
'selected': 'označených',
'state': 'stav',
'table': 'tabuľka',
'unable to parse csv file': 'nedá sa načítať csv súbor',
}


[web2py] Pagination manual bug?

2010-08-24 Thread dlin
ref: http://web2py.com/book/default/chapter/12#Pagination

In following code, there is two problem:
1. The 'next' button always show.  And the len(rows) always = 2
2. I don't know how to proper show the {{=rows}} without last row, I
want to use the odd row background-color trick.

I wrote simliar code in default.py
-
def listall():
if len(request.args): page=int(request.args[0])
else: page=0
items_per_page=2
limitby=(page*items_per_page,(page+1)*items_per_page + 1)
words= db().select(db.mytable.ALL, limitby=limitby)
cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]]
hdrs = dict([(str(c),c.label) for c in db.mytable])
rows =SQLTABLE(words,
 headers = hdrs,
 columns=cols,
 truncate=32)
rows['_id'] = 'rows'
return dict(rows=rows, page=page, items_per_page=items_per_page)

And the view listall.html:
---
{{extend 'layout.html'}}
{{=rows}}
page:{{=page}} 
len(rows):{{=len(rows)}} 

{{if page:}}
previous
{{pass}}

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

jQuery("#rows tr:odd").css("background-color", "#ff");


[web2py] Re: Web2py and threads

2010-08-24 Thread pierreth
On 24 août, 01:20, mdipierro  wrote:
> In Java a serverlet, as far as I understand, is a class which conforms
> to some API that allows it to serve one http request. Each instance is
> executed in its own thread.

Yes, but one instance can be executed by multiple threads at the same
time. It is one thread per request. EJB, Enterprise Java Beans, are
running on their own threads.

>The Python equivalent of the serverlet API
> is a WSGI application and web2py is based on WSGI, therefore the
> parallelization mechanism is equivalent to Java serverlets.

Is web2py running as a WSGI application when we do "python web2py.py"
or is it only when used in a specific deployment with WSGI?

>
> In web2py (the same in Django, Pylons, any any WSGI app) each http
> request is executed in its own thread. Threads are recycled to server
> non-concurrent requests and reuse database connections (pooling)
> without need to close and reopen them. The web server can be
> configured for a min number and a max number of threads.

So, as a web2py developer, what do I have to do to avoid
synchronization problems in my application. Where is the danger of
having multiple threads for the web2py developers? What are the
instances shared my multiple threads? What are the instances living in
their own threads?

>
> I think the GIL in this context is a false problem. In fact in
> production you can use Apache and run as many processes as the number
> of cores that you have. Each process will create as many threads as it
> needs to server multiple requests. The GIL is a problems only if one
> process runs multiple threads on multiple cores. It is possible there
> are some caveats with many cores but I have not really played with
> apache configurations and benchmarks.

Yes but a web2py server is running with only one process and using
more web2py processes for serving the same web2py app will lead to
synchronization problems. With processors having more and more cores,
having a web server that cannot use them is not very fun. It is an
issue to be solved with Python 3.2 I think.

> Massimo
>

Thank you for this precious information.


[web2py] Re: build a row base questionnaire

2010-08-24 Thread dlin
Thanks.
But I found this method have a problem:

when I show the score after submit, the form's random data is changed.
And the form become empty, so the user can not see why he is wrong.

On 8月23日, 上午10時31分, mdipierro  wrote:
> We need to clarify the goal. The goal is not to propose questions to
> the user. the goal is to check if he answers correctly. Should each
> correct answer be recorded for each user? should incorrect answers be
> recorded? Should the list of proposed questions be recored? Should a
> score be computed? What is the answer is "Darwin" and he answers
> "darwin" or "Charles Darwin"?
>
> Anyway, the above code can be simplified in:
>
> db.define_table('q_and_a',
>     Field('question'),
>     Field('answer'))
>
> def check(correct_answer,answer):
>     if correct_answer.lower() in answer.lower(): return 1
>     return 0
>
> def ask():
>     asked =
> db(db.q_and_a.id>0).select(orderby='',limitby=(0,3))
>     form=SQLFORM.factory(*[Field('a%s'%i, label = a.question) for i,a
> in enumerate(asked)])
>     if form.accepts(request.vars,session):
>            score = sum((check(a.answer,request.vars.get('a%s'%i,''))
> for i,a in enumerate(asked))
>            # do something with score
>     return dict(form=form)
>
> On Aug 22, 6:04 pm, Russell  wrote:
>
> > In my experience, it is a bit awkward to do this using SQLFORM.  You
> > could try something like this:
>
> > db.define_table('q_and_a',
> >     Field('question'),
> >     Field('answer'))
>
> > rows = db(db.q_and_a.id>0).select()
>
> > import random
> > random.seed()
> > asked = random.sample(rows, 3))
>
> > form=SQLFORM.factory(
> >     Field('asked_0', label = asked [0]['question']),
> >     Field('asked_1 ', label = asked [1]['question']),
> >     Field('asked_2 ', label = asked [2]['question']))
>
> > But this can create more problems than it solves.  Ultimately it might
> > be easier to put your questions in a wide table and use something like
> > Massimo proposed here:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/d0093fa190...
>
> > On Aug 20, 1:10 pm,dlin wrote:
>
> > > Tks, Bruno.
> > > I seems haven't describe the 'row base' questionaire.
>
> > > That is:
>
> > > I've already a table like:
> > > Question Answer
> > > Q1...           A1
> > > Q2...           A2
> > > Q3...           A3
> > > ...
> > > Q13...           A1
>
> > > Then, I'll random choose three(or by customized) questions to ask.
>
> > > Question  Answer
> > > Q3.      
> > > Q8.      
> > > Q9.      
> > >  [submit]
>
> > > sometimes, it
> > > Question  Answer
> > > Q7.      
> > > Q9.      
> > > Q13.      
> > >  [submit]
>
> > > I think it is not proper to save it fixed on 3 field on table.
>
> > > I'm thinking should I use following steps:
> > > 1. SQLTABLE to select some random rows from my question and answer .
> > > 2. try to form a FORM() (I haven't idea now)
> > > 3. when user submit form, then try to compare the answer and store the
> > > scores of user in another table.
>
> > > On Aug 19, 7:54 am, Bruno Rocha  wrote:
>
> > > > You can use FORM(), and also use the table configuration to define
> > > > questions,
> > > > you can use the arguments "label" and "comment" on field definition.
>
> > > > After that, you can use CSS to improve the form layout.
>
> > > > You can't create a new field to store the login info and putting by 
> > > > default
> > > > the auth.user value?
>
> > > > 2010/8/18dlin
>
> > > > > I want a form like:
>
> > > > > Question  Answer
> > > > > Q1.      
> > > > > Q2.      
> > > > > Q3.      
> > > > > [submit]
>
> > > > > Q1,Q2,Q3 and correct answer is stored in a table.
> > > > > But the 'Answer' field should combined with login user's answer.
>
> > > > > What's the best way to display the form to user?
> > > > > Do you suggest use FORM() in control or use  in view?
>
> > > > --
>
> > > >http://rochacbruno.com.br


[web2py] Re: IS_IMAGE() broke?

2010-08-24 Thread Joe Wakefield
I didn't think a tuple of one element needed a comma, but I tried your
suggestion anyway. It had no effect on the issue. Can you verify that
you do not experience the same issue?

I made a sequence of screenshots demonstrating my test process:
http://yfrog.com/e3compvj

On Aug 23, 5:06 pm, mdipierro  wrote:
> Something is wrong here
>
> IS_IMAGE(extensions=('jpeg'))
>
> should be
>
> IS_IMAGE(extensions=('jpeg',))
>
> A tuple of one element must contain a comma. Not sure if that may be
> the cause of your problem.
>
> On Aug 23, 3:16 pm, Joe Wakefield  wrote:
>
> > I was also experiencing this issue, but found that rebuilding the
> > database only worked until the first valid upload, after which it is
> > broken again.
>
> > In my case, I am using:
> > Field('photo', 'upload', uploadfield='photo_data',
> > requires=IS_IMAGE(extensions=('jpeg'))),
> > Field('photo_data', 'blob', requires=IS_IMAGE(extensions=('jpeg'))),
>
> > And was using SQLFORM to display the update form.
>
> > When I first added this, it was accepting absolutely everything (pdf,
> > odt, zip) as an upload. I deleted my database entirely, and had it
> > rebuilt. I first noticed that it started rejecting non-image uploads.
> > However, once I had uploaded an image, all subsequent uploads of non-
> > image types were allowed again. A second database build showed the
> > exact same behaviour; proper rejection until the first valid upload.
>
> > I then made a backup of my web2py folder, and extracted today's
> > nightly build over my folder. Rebuilding my database one last time, it
> > shows the exact same behaviour.
>
> > On Jul 11, 2:56 pm, Rob  wrote:
>
> > > I just recently added:
>
> > > db.Item.image.requires =IS_IMAGE()
>
> > > The records that existed prior to adding this line does not obey 
> > > theIS_IMAGE() (ie: they still allow me to upload a PDF).  All new records
> > > created DO work - they force me to select an image or else they show
> > > an error.
>
> > > steps to reproduce (untested)
> > > 1)  create DB
> > > db.define_table('Item',
> > >                 Field('description'),
> > >                 Field('need', 'boolean'),
> > >                 Field('image', 'upload'))
>
> > > 2) add rows to the table
> > > 3) add rules:
> > > db.Item.category.requires = IS_IN_DB(db, db.Category.id,'%(name)s')
> > > db.Item.description.requires = IS_NOT_EMPTY()
> > > db.Item.image.requires =IS_IMAGE()
>
> > > 4) go back to the rows you added to the Item table and add non-image
> > > files - notice it works
>
> > > Does that help?
>
> > > On Jul 11, 11:42 am, mdipierro  wrote:
>
> > > > Please tell us more. When do you get an error? What is the error?
>
> > > > On 11 Lug, 11:57, Rob  wrote:
>
> > > > > This issue only happens for records that were created before I added
> > > > > the .requires fields.  Error handling on new records works as
> > > > > expected...  so... is it still a bug?
>
> > > > > On Jul 11, 9:15 am, Rob  wrote:
>
> > > > > > db.define_table('Category',
> > > > > >                 Field('name'))
>
> > > > > > db.define_table('Item',
> > > > > >                 Field('category', db.Category),
> > > > > >                 Field('description'),
> > > > > >                 Field('need', 'boolean'),
> > > > > >                 Field('image', 'upload'))
>
> > > > > > db.Item.category.requires = IS_IN_DB(db, db.Category.id)
> > > > > > db.Item.description.requires = IS_NOT_EMPTY()
> > > > > > db.Item.image.requires =IS_IMAGE()
>
> > > > > > def details():
> > > > > >     item = request.args(0)
> > > > > >     form = crud.update(db.Item, item, next=URL(r=request, 
> > > > > > args=item))
> > > > > >     return dict(form=form)
>
> > > > > > It allows me to upload PDFs and flashes 'record updated'
>
>


[web2py] Simple Drop Down List with Auto Submit

2010-08-24 Thread David
I've been having a heck of a time trying to figure out how to make a
simple drop down list from a table in the database.

What I would like to do is have a drop down list populated by the
table information and when a person selects that item from the drop
down I want it to go to a page that pulls up all of those types of
items.

I've seen reference to IS_IN_SET() and IS_IN_DB() but it doesn't make
much sense to me since there are a lack of examples.

This is what I have so far on it.

def get_services()
services = db(db.services.name>0).select(orderby=db.services.name)
form = SQLFORM.factory(SQLField('name', label='Select a
service',requires=IS_IN_SET(services)))
return dict(form=form)

default/get_services.html

{{=form}

This does create a drop down but it has a bunch of extra information
about query and lambda which I don't need and only displays about half
of the names in the table.  I just need the name and the ID like a
normal dropdown list with auto submit.

Has anyone a reference to something like this?

Thanks,
David


[web2py] Re: Web2py and threads

2010-08-24 Thread John Heenan
There is absolutely no need to serve up static web pages of a pure
Python web app or a WGSI app with a separate thread.  It is
inefficient to use an inbuilt web server (of a Python web app) or
Apache (if WGSI used) to serve up static web pages using separate
threads. Both Lighttpd and Nginx are well known web servers that
thrash Apache in objective tests for static pages when a web server is
under load. These web servers use event handlers to serve static web
pages, not necessarily separate threads.

Of course the question remains, how much can the performance of WSGI
type apps be improved by an analogous event handling model within the
app and how much of a change in development style would be required to
take full advantage of such an approach. As far as I am aware these
questions has never even been posed.

Further background:

There is no need to use web2py to serve up its css pages, javascript
and images.  A compiled static language (such as C) web server can be
used instead.

The question then becomes which web server. The answer is obvious: web
servers that use event handlers to serve static web pages, not
necessarily threads. Unfortunately you will find religious bigots,
even on this forum, who will ridicule anyone who points out the
obvious. Expect abuse from this reply.

John Heenan

On Aug 24, 3:21 pm, mdipierro  wrote:
> P.S. In the end the bottle neck is ALWAYS database access.
>
> On Aug 24, 12:20 am, mdipierro  wrote:
>
> > In Java a serverlet, as far as I understand, is a class which conforms
> > to some API that allows it to serve one http request. Each instance is
> > executed in its own thread. The Python equivalent of the serverlet API
> > is a WSGI application and web2py is based on WSGI, therefore the
> > parallelization mechanism is equivalent to Java serverlets.
>
> > In web2py (the same in Django, Pylons, any any WSGI app) each http
> > request is executed in its own thread. Threads are recycled to server
> > non-concurrent requests and reuse database connections (pooling)
> > without need to close and reopen them. The web server can be
> > configured for a min number and a max number of threads.
>
> > I think the GIL in this context is a false problem. In fact in
> > production you can use Apache and run as many processes as the number
> > of cores that you have. Each process will create as many threads as it
> > needs to server multiple requests. The GIL is a problems only if one
> > process runs multiple threads on multiple cores. It is possible there
> > are some caveats with many cores but I have not really played with
> > apache configurations and benchmarks.
>
> > I do not think using Jython helps anything. According to these tests:
> >  http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p...
> >  http://pyevolve.sourceforge.net/wordpress/?p=1189
> > Jython is 2x-3x slower than cpython. So you may get better scaling
> > with multiple cores but you pay huge perfomance hit.
>
> > Web2py runs on Jython but there is a known bug in Java regular
> > expressions that Sun marked as "won'tfix" that can cause runaway
> > problems when parsing complex templates. This is not a web2py specific
> > problem but we have seen effects of the bug in some web2py apps.
>
> > Massimo
>
> > On Aug 23, 11:29 pm, pierreth  wrote:
>
> > > Hello,
>
> > > I would like to know how Web2py is managing threads. Is it like Java
> > > servlets where requests are mapped to servlets while one servlet
> > > object can be used by multiple threads at the same time to serve many
> > > requests?
>
> > > Are some users here using Jython with Web2py to get around the ugly
> > > Pyhton GIL? I would to know about your experience.
>
> > > --
> > > Pierre


[web2py] Re: ajax post before ajax reload

2010-08-24 Thread KMax
I am glad you writing poems, but it is not the wall for comments :)
This is for issue invetigation.

On 24 авг, 07:33, KMax  wrote:
> This is link to examplehttp://web2py.ru/test
> Click on 'show me' then on any in link of list and update. Second
> update will reflect changes in first time
> On 23 авг, 11:52, KMax  wrote:
>
>
>
> > ## to db.py added
> > db.define_table('mytable',Field('myfield','string'))
> > ## controllers/default.py
> > def index():
> >     """
> >     example action using the internationalization operator T and flash
> >     rendered by views/default/index.html or views/generic.html
> >     """
> >     onclick =
> > XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
> > ['test'], 'content');return false;" )
> >     linkdiv=DIV(DIV(A('show me',_href='#',
> > _onclick=onclick)),DIV(_id='content'))
> >     return dict(linkdiv=linkdiv)
>
> > def loadlist():
> >     return dict()
>
> > def list():
> >     result = []
> >     for i in db(db.mytable.id > 0).select():
> >         onclick=XML( "jQuery('#form"+str(i.id)
> > +"').slideToggle();return false;" )
>
> > form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
>
> > result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
> >         DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
> >     return dict(results=result)
>
> > ## views/default/list.load
> > {{response.headers['Content-Type']='text/
> > html';response.headers['web2py-response-flash']=response.flash}}
> > 
> > {{for result in results:}}{{ =TR(TD(result))}}{{pass}}
> > 
> > ## views/default/loadlist.load
> > {{response.headers['Content-Type']='text/
> > html';response.headers['web2py-response-flash']=response.flash}}
> > {{=LOAD ('default','list.load',args=[],ajax=True)}}
>
> > -
> > Adding to mytables some strings to see the list of them in example
> > code.
> > Clicking on 'show me' give a list of table rows.
> > Clicking on any of row shows form for string update.
> > But if you submit changes, they does not reflect in list of items (but
> > the same time db table row was updated)
> > Next time submit updates the list of items was made last time.
>
> > Question: how to make update of db table before updating list of item
> > of the same table?
>
> > On 23 авг, 08:19, mdipierro  wrote:
>
> > > I think I need more explanation, a practical example of usage and an
> > > example of code. I do not understand.


[web2py] Re: bg-bg.py (Bulgarian translation)

2010-08-24 Thread Vidul Petrov
I've missed the closing curly bracket.

On Aug 24, 4:21 pm, Vidul Petrov  wrote:
> # coding: utf8
> {
> '"update" is an optional expression like "field1=\'newvalue\'". You
> cannot update or delete the results of a JOIN': '"обнови" е
> незадължителен израз от вида "field1=\'нова стойност\'". Резултатите
> от JOIN не могат да се обновяват или изтриват.',
> '%Y-%m-%d': '%Y-%m-%d',
> '%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
> '%s rows deleted': '%s редици бяха изтрити',
> '%s rows updated': '%s редици бяха обновени',
> 'Available databases and tables': 'Налични бази данни и таблици',
> 'Cannot be empty': 'Не може да бъде празно',
> 'Change Password': 'Смяна на парола',
> 'Check to delete': 'Маркирайте за изтриване',
> 'Check to delete:': 'Маркирайте за изтриване:',
> 'Client IP': 'IP на клиента',
> 'Controller': 'Контролер',
> 'Copyright': 'Авторски права',
> 'Current request': 'Tekyща заявка',
> 'Current response': 'Текущ отговор',
> 'Current session': 'Текуща сесия',
> 'DB Model': 'DB Модел',
> 'Database': 'База Данни',
> 'Delete:': 'Изтрии:',
> 'Description': 'Описание',
> 'E-mail': 'Е-мейл',
> 'Edit': 'Редакция',
> 'Edit Profile': 'Редакция на Профила',
> 'Edit current record': 'Редакция на текущия профил',
> 'First name': 'Малко име',
> 'Group ID': 'ID на група',
> 'Hello World': 'Здравей, Свят!',
> 'Import/Export': 'Импорт/експорт',
> 'Index': 'Индекс',
> 'Internal State': 'Вътрешно състояние',
> 'Invalid Query': 'Невалидна заявка',
> 'Invalid email': 'Невалиден е-мейл',
> 'Invalid login': 'Невалиден логин',
> 'Invalid password': 'Невалидна парола',
> 'Last name': 'Фамилно име',
> 'Layout': 'Лейаут',
> 'Logged in': 'Вход в системата',
> 'Logged out': 'Изход от системата',
> 'Login': 'Вход',
> 'Logout': 'Изход',
> 'Lost Password': 'Забравена Парола',
> 'Menu Model': 'Меню Модел',
> 'Name': 'Име',
> 'New Record': 'Нов Запис',
> 'New password': 'Нова парола',
> 'No databases in this application': 'В това приложение няма бази
> данни',
> 'Old password': 'Стара парола',
> 'Origin': 'Произход',
> 'Password': 'Парола',
> "Password fields don't match": 'Паролите не съвпадат',
> 'Powered by': 'Базирано на',
> 'Query:': 'Заявка:',
> 'Record ID': 'ID на сапис',
> 'Register': 'Регистрация',
> 'Registration key': 'Регистрационен ключ',
> 'Remember me (for 30 days)': 'Запомни ме (за 30 дена)',
> 'Reset Password key': 'Генериране на нов ключ за паролата',
> 'Role': 'Роля',
> 'Rows in table': 'Редове в таблица',
> 'Rows selected': 'Избрани редове',
> 'Stylesheet': 'Стайлшийт',
> 'Submit': 'Потвърдете',
> 'Sure you want to delete this object?': 'Сигурни ли сте, че искате да
> изтриете този обект?',
> 'Table name': 'Име на таблица',
> 'The "query" is a condition like "db.table1.field1==\'value\'".
> Something like "db.table1.field1==db.table2.field2" results in a SQL
> JOIN.': '"Заявка" - това е условие от вида "db.table1.field1==
> \'стойност\'". Нещо подобно на "db.table1.field1==db.table2.field2"
> формира SQL JOIN.',
> 'The output of the file is a dictionary that was rendered by the
> view': 'Изходящият резултат от файла е речник, който се рендира от
> темплейта',
> 'This is a copy of the scaffolding application': 'Това е копие на
> базисното приложение',
> 'Timestamp': 'Времева отметка',
> 'Update:': 'Обновете:',
> 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to
> build more complex queries.': 'Използвайте (...)&(...) за "И", (...)|
> (...) за "ИЛИ", ~(...) за "НЕ", за да съставите по сложни заявки.',
> 'User %(id)s Logged-in': 'Потребителят %(id)s влезе в системата',
> 'User %(id)s Logged-out': 'Потребителят %(id)s излезе от системата',
> 'User %(id)s Password changed': 'Потребителят %(id)s смени паролата
> си',
> 'User %(id)s Profile updated': 'Потребителят %(id)s обнови профила
> си',
> 'User %(id)s Registered': 'Потребителят %(id)s беше регистриран',
> 'User ID': 'ID на потребителя',
> 'Verify Password': 'Повторете паролата',
> 'View': 'Темплейт',
> 'Welcome to web2py': 'Добре дошли в web2py',
> 'Which called the function': 'Което извика функцията',
> 'You are successfully running web2py': 'Вие работите успешно с
> web2py',
> 'You can modify this application and adapt it to your needs': 'Вие
> може да промените това проложение и да го нагодите спрямо Вашите
> нужди',
> 'You visited the url': 'Вие посетихте следния URL',
> 'appadmin is disabled because insecure channel': 'appadmin e забранен
> поради несигурен канал',
> 'cache': 'кеш',
> 'click here for online examples': 'онлайн примери',
> 'click here for the administrative interface': 'административен
> интерфейс',
> 'customize me!': 'настройте външния вид!',
> 'data uploaded': 'данните бяха качени',
> 'database': 'база данни',
> 'database %s select': 'избор на база данни %s',
> 'db': 'БД',
> 'design': 'дизайн',
> 'documentation': 'документация',
> 'done!': 'готово!',
> 'export as csv file': 'експорт в csv файл',
> 'insert new': 'добавете нов',
> 'insert new %s': 'добавете нови %s',
> 'invalid request': 'невалидна заявка',
> 'located in th

[web2py] bg-bg.py (Bulgarian translation)

2010-08-24 Thread Vidul Petrov
# coding: utf8
{
'"update" is an optional expression like "field1=\'newvalue\'". You
cannot update or delete the results of a JOIN': '"обнови" е
незадължителен израз от вида "field1=\'нова стойност\'". Резултатите
от JOIN не могат да се обновяват или изтриват.',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'%s rows deleted': '%s редици бяха изтрити',
'%s rows updated': '%s редици бяха обновени',
'Available databases and tables': 'Налични бази данни и таблици',
'Cannot be empty': 'Не може да бъде празно',
'Change Password': 'Смяна на парола',
'Check to delete': 'Маркирайте за изтриване',
'Check to delete:': 'Маркирайте за изтриване:',
'Client IP': 'IP на клиента',
'Controller': 'Контролер',
'Copyright': 'Авторски права',
'Current request': 'Tekyща заявка',
'Current response': 'Текущ отговор',
'Current session': 'Текуща сесия',
'DB Model': 'DB Модел',
'Database': 'База Данни',
'Delete:': 'Изтрии:',
'Description': 'Описание',
'E-mail': 'Е-мейл',
'Edit': 'Редакция',
'Edit Profile': 'Редакция на Профила',
'Edit current record': 'Редакция на текущия профил',
'First name': 'Малко име',
'Group ID': 'ID на група',
'Hello World': 'Здравей, Свят!',
'Import/Export': 'Импорт/експорт',
'Index': 'Индекс',
'Internal State': 'Вътрешно състояние',
'Invalid Query': 'Невалидна заявка',
'Invalid email': 'Невалиден е-мейл',
'Invalid login': 'Невалиден логин',
'Invalid password': 'Невалидна парола',
'Last name': 'Фамилно име',
'Layout': 'Лейаут',
'Logged in': 'Вход в системата',
'Logged out': 'Изход от системата',
'Login': 'Вход',
'Logout': 'Изход',
'Lost Password': 'Забравена Парола',
'Menu Model': 'Меню Модел',
'Name': 'Име',
'New Record': 'Нов Запис',
'New password': 'Нова парола',
'No databases in this application': 'В това приложение няма бази
данни',
'Old password': 'Стара парола',
'Origin': 'Произход',
'Password': 'Парола',
"Password fields don't match": 'Паролите не съвпадат',
'Powered by': 'Базирано на',
'Query:': 'Заявка:',
'Record ID': 'ID на сапис',
'Register': 'Регистрация',
'Registration key': 'Регистрационен ключ',
'Remember me (for 30 days)': 'Запомни ме (за 30 дена)',
'Reset Password key': 'Генериране на нов ключ за паролата',
'Role': 'Роля',
'Rows in table': 'Редове в таблица',
'Rows selected': 'Избрани редове',
'Stylesheet': 'Стайлшийт',
'Submit': 'Потвърдете',
'Sure you want to delete this object?': 'Сигурни ли сте, че искате да
изтриете този обект?',
'Table name': 'Име на таблица',
'The "query" is a condition like "db.table1.field1==\'value\'".
Something like "db.table1.field1==db.table2.field2" results in a SQL
JOIN.': '"Заявка" - това е условие от вида "db.table1.field1==
\'стойност\'". Нещо подобно на "db.table1.field1==db.table2.field2"
формира SQL JOIN.',
'The output of the file is a dictionary that was rendered by the
view': 'Изходящият резултат от файла е речник, който се рендира от
темплейта',
'This is a copy of the scaffolding application': 'Това е копие на
базисното приложение',
'Timestamp': 'Времева отметка',
'Update:': 'Обновете:',
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to
build more complex queries.': 'Използвайте (...)&(...) за "И", (...)|
(...) за "ИЛИ", ~(...) за "НЕ", за да съставите по сложни заявки.',
'User %(id)s Logged-in': 'Потребителят %(id)s влезе в системата',
'User %(id)s Logged-out': 'Потребителят %(id)s излезе от системата',
'User %(id)s Password changed': 'Потребителят %(id)s смени паролата
си',
'User %(id)s Profile updated': 'Потребителят %(id)s обнови профила
си',
'User %(id)s Registered': 'Потребителят %(id)s беше регистриран',
'User ID': 'ID на потребителя',
'Verify Password': 'Повторете паролата',
'View': 'Темплейт',
'Welcome to web2py': 'Добре дошли в web2py',
'Which called the function': 'Което извика функцията',
'You are successfully running web2py': 'Вие работите успешно с
web2py',
'You can modify this application and adapt it to your needs': 'Вие
може да промените това проложение и да го нагодите спрямо Вашите
нужди',
'You visited the url': 'Вие посетихте следния URL',
'appadmin is disabled because insecure channel': 'appadmin e забранен
поради несигурен канал',
'cache': 'кеш',
'click here for online examples': 'онлайн примери',
'click here for the administrative interface': 'административен
интерфейс',
'customize me!': 'настройте външния вид!',
'data uploaded': 'данните бяха качени',
'database': 'база данни',
'database %s select': 'избор на база данни %s',
'db': 'БД',
'design': 'дизайн',
'documentation': 'документация',
'done!': 'готово!',
'export as csv file': 'експорт в csv файл',
'insert new': 'добавете нов',
'insert new %s': 'добавете нови %s',
'invalid request': 'невалидна заявка',
'located in the file': 'намира се във файла',
'login': 'вход',
'logout': 'изход',
'new record inserted': 'новият запис беше добавен',
'next 100 rows': 'следующие 100 строк',
'or import from csv file': 'или импорт от csv файл',
'password': 'парола',
'previous 100 rows': 'предходните 100 реда',
'profile': 'профил',
'record': 'запис',
'record

[web2py] Re: Multiple submit not working on component

2010-08-24 Thread mdipierro
jquery serialize also does not support type=file. If you have a way to
get around these, please let me know.

On Aug 24, 5:35 am, Miguel Lopes  wrote:
> Thank you!
> Importantly, although it is very convenient to have these values
> serialized, it is simple to get around this jQuery imposed limitation (bug).
> Miguel
>
> On Tue, Aug 24, 2010 at 4:02 AM, mdipierro  wrote:
> > well... it is a bug not not in web2py, in jQuery:
>
> >http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesn...
>
> > We cannot fork jQuery to fix this. Eventually they will fix it.
>
> > Massimo
>
> > On Aug 23, 8:46 am, Miguel Lopes  wrote:
> > > As an update, the issue remains with the following combinations:
> > > * if input type='submit' and different names
> > > * if input type='button', with or without different name attributes
>
> > > However, input type='text' are present in form.vars.
>
> > > For the interested a solution for usage in components is to use set a
> > hidden
> > > input text field via the click event of each button.
> > > Miguel
>
> > > On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes 
> > wrote:
> > > > I'm using the "same name to all input type submits" technique. This is
> > very
> > > > nice because it avoids some js and works like a charm :-)
> > > > In a regular controller the code works flawlessly. However when I try
> > to
> > > > put it in a controller, it fails:
>
> > > > status_form = FORM(_id='status_form')
> > > > for status in OPPTY_STATUS:
> > > >     btn = INPUT(_type='submit', _name='status', _value=status,
> > > > _class='status_btn')
> > > >     status_form.append(btn)
>
> > > > if status_form.accepts(request.vars, session, formname='status_form'):
> > > >     # status_form.vars.status is None in component
> > > >     # status_form.vars.status corresponds to whatever submit was
> > pressed in
> > > > regular controller
> > > > ...
>
> > > > It seems like the component mechanisms is ignoring the value of
> > 'status'.
>
> > > > Miguel


[web2py] Re: updated ru-ru.py file

2010-08-24 Thread mdipierro
thanks. in trunk soon.

On Aug 24, 5:23 am, Alexey Nezhdanov  wrote:
> Hi.
> While writting an application bumped into partial translation of russian
> language.
> Updated file attached. It is from welcome.py application, no my app specific
> strings present.
>
> Regards
> Alexey
>
>  ru-ru.py
> 6KViewDownload


[web2py] Re: Web2py and threads

2010-08-24 Thread mdipierro
Somebody here did. They found it works but there was a proliferation
of open files. We never got to the bottom of this.

On Aug 24, 4:55 am, Michele Comitini 
wrote:
> 2010/8/24 mdipierro :> P.S. In the end the bottle 
> neck is ALWAYS database access.
>
> true! many driver implementations do not release the GIL properly on a
> blocking call.
> Anyway a well designed db would avoid the problem entirely.
>
> Do you know if anyone tried web2py on pypy [http://pypy.org] ?


Re: [web2py] Re: My editor ...

2010-08-24 Thread Stef Mientki
 On 24-08-2010 07:05, Johan wrote:
> Is it possible to post a free version of this _as it is_ ?
> Some of us my find it very useful.
> Or even, a version without the wysiwyg, if that's the problem.
I'll do my best and will try to make a first alfa release by the end of the 
week.

cheers,
Stef


Re: [web2py] Re: How to start server from within a python file ?

2010-08-24 Thread Stef Mientki
 thanks Massimo,

that's the solution,
works under windows and probably will also work under Linux, I'll try.
cheers,
Stef

On 24-08-2010 04:43, mdipierro wrote:
> It does not hang. It starts the server. The server blocks. If you want
> to start the server is a new thread:
>
> import os, sys, thread, time
> filepath = r'P:/Web2Py/web2py_src/web2py'
> sys.path.append ( filepath )
> os.chdir ( filepath ) ## <== absolutely necessary to
> get the version number !!!
> from gluon.main import HttpServer
> server = HttpServer ( password='xxx' ) #ip,port,admin_password)
> thread.start_new_thread(server.start,(,))
> print 'piep'
> time.sleep(1)
>
> will print piep but will only live for 1. It is up to you to
> handle concurrency.



[web2py] Re: Auth and CAS

2010-08-24 Thread huimies
I just found out that you can actually share sessions with other apps
by adding this to your model:

session.connect(request, response, masterapp='myapp')

That solved the problem of having to authenticate separately for each
app.


On Aug 24, 11:26 am, huimies  wrote:
> Hi,
>
> What are the latest in integrating Auth with CAS?
>
> I found this bit in the auth code:
>
>             # use a central authentication server
>             cas = self.settings.login_form
>             cas_user = cas.get_user()
>
>             if cas_user:
>                 cas_user[passfield] = None
>                 user = self.get_or_create_user(cas_user)
>             elif hasattr(cas,'login_form'):
>                 return cas.login_form()
>             else:
>                 # we need to pass through login again before going on
>                 next = URL(r=request) + '?_next=' + next
>                 redirect(cas.login_url(next))
>
> What's that all about, some prototyping or is there already a way?
>
> Right now I have LDAP authentication for my apps, but I need to
> authenticate with each of my apps separately. What I'd really like to
> do is to modify CAS appliance to use LDAP as its backend and then use
> CAS with Auth for single sign on. Are there any plans in making auth
> work with CAS?


Re: [web2py] Re: Multiple submit not working on component

2010-08-24 Thread Miguel Lopes
Thank you!
Importantly, although it is very convenient to have these values
serialized, it is simple to get around this jQuery imposed limitation (bug).
Miguel

On Tue, Aug 24, 2010 at 4:02 AM, mdipierro  wrote:

> well... it is a bug not not in web2py, in jQuery:
>
>
> http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesnt-post-submit-and-button-values-duh/
>
> We cannot fork jQuery to fix this. Eventually they will fix it.
>
> Massimo
>
> On Aug 23, 8:46 am, Miguel Lopes  wrote:
> > As an update, the issue remains with the following combinations:
> > * if input type='submit' and different names
> > * if input type='button', with or without different name attributes
> >
> > However, input type='text' are present in form.vars.
> >
> > For the interested a solution for usage in components is to use set a
> hidden
> > input text field via the click event of each button.
> > Miguel
> >
> > On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes 
> wrote:
> > > I'm using the "same name to all input type submits" technique. This is
> very
> > > nice because it avoids some js and works like a charm :-)
> > > In a regular controller the code works flawlessly. However when I try
> to
> > > put it in a controller, it fails:
> >
> > > status_form = FORM(_id='status_form')
> > > for status in OPPTY_STATUS:
> > > btn = INPUT(_type='submit', _name='status', _value=status,
> > > _class='status_btn')
> > > status_form.append(btn)
> >
> > > if status_form.accepts(request.vars, session, formname='status_form'):
> > > # status_form.vars.status is None in component
> > > # status_form.vars.status corresponds to whatever submit was
> pressed in
> > > regular controller
> > > ...
> >
> > > It seems like the component mechanisms is ignoring the value of
> 'status'.
> >
> > > Miguel
>


Re: [web2py] Re: Should we have a feature freeze and stability maintenance period in future?

2010-08-24 Thread Kenneth Lundström

Hello Paul,

I´d be happy helping putting up a Linux box for web2py. I use CentOS as 
my distribution, but if needed it should not be a big problem setting it 
up on Ubuntu either.



Kenneth



Hi all,

Sounds like there's a little momentum in this :-)

Here's what I can contribute to the party:

1. Part of the test management tool I am writing is a 'case
management' facility. It is basic, but it supports multiple case
types. Cases can be issues/incidents/defects, to do/actions, and
notifications to review changes to other entities in the system (in my
case, requirements, stories, tests etc...). There is a messaging/
notifications module, uploads/attachments and a case notes history.
This functionality is part of the system we will will make available
as a free hosted option to Agile Development teams. I'd be delighted
to offer this to "the team" to use. I benefit by getting feedback and
ideas for improvement. I also get a little kudos with the testing
market :O)

2. As a sideline we have (currently 4) servers colocated at a data
centre that is a mile away from where I live (Maidenhead UK).
Currently, all are using Windows 2008 and I have my dev web2py set up
on one of them. I would like to deploy on Linux, I use Mysql at the
moment - the only proprietary code I currently use is Windows and I
want to be 100% open source. So I'd be happy to provide a Linux box
for a Linux expert to set up apache/mail/web2py. I'm familiar with
Ubuntu, but if there's a preferred distribution - please advise - I'll
use that. I anticipate this would host the tools required of the team,
plus my own development environment. I would deploy on another server.
I guess there should be a mirror of the web2py team content somewhere
else on the planet. (I could also use my Amazon web services account,
but this is a tad more expensive for me).

3. I'm sure none of us want to be drawn into a bureacratic, committee
based group- but a little organisation is required. I also host three
community stes using Druapl CMS. One is public (www.uktmf.com) and I
have two private ones that are probably a better model for a small
group).I also use Drupal for my own company website.I'd be happy to
host (initially on Windows, but I'd migrate to the Linux box later) a
Drupal site for the group to use. The value of a CMS is we could
define a brief terms of reference for the group, assign roles etc and
make a start. Mailing lists are a bit cumbersome :O)

4. There's also a slight possibility I can corral some professional
testers into helping us. There's an interesting group I know who do
weekend testing for fun - mainly exploratory, but if we released apps
that needed some testing, I can publicise this in my testing network
we might get them on board. Just a thought.

This is what I can contribute.

Paul.

On Aug 23, 10:47 am, Michele Comitini
wrote:
   

Hi all,

I do develomplent with many different things, different languages
architectures and looking for tools for managing software projects is
a must for me

;-)

I think the "problem" here is that web2py has started to receive the
deserved attention by the user and developer community.
Prof. Massimo is  doing his best to keep with the growing volume of
request. The  question is: "design of new features is slowed by
bugfixing?"

Well I red from Massimo 2 alerts similar to the following (Massimo
feel free to correct me if I am wrong!!):
1. "Please remind me of patches to be applied"
2. "I need to keep track of messages, so no IRC"

Due to web2py success things will get worse, then I would suggest to
start focusing on 2 main points to see if we can find some
ideas/solutions.

1) version control

I perfectly understand Massimo position: dealing with mercurial
(git,bzr) is a pain! Anyhow we must help Massimo
delegate some dirty work to others, since we need Massimo to do the
important stuff.
I think that somehow Massimo's web2py problems resemble those that
Linus' Linux faced at the end of '90s.  I just
remind that Linus to end the thing had written the git system!

Please take time to read this 
chapter:http://hgbook.red-bean.com/read/collaborating-with-other-people.html

and 
this:http://hgbook.red-bean.com/read/collaborating-with-other-people.html#...

The model for Linux development IMHO is too much at this time, but
some ideas should be taken into consideration.

2) issue tracking

We *must* setup a ticket system.  Discussion on groups,IRC will
eventually lead to a new ticket, but *only* tickets must be
taken into account for bugfixing. Code snippets, error log, must be
tracked there.

ciao,
mic

2010/8/23 mart:



 

Hi Again,
   
 

So, spending the day with my 3 girls certainly does provide
perspective on requirements and how well attached we can be to them
sometimes ;). That in mind, I certainly do understand your personal
requirements on keeping what you know and what works for you (I
respect old fashion ;) ). We can work with that, while hopefully
bringing something efficient, scala

[web2py] updated ru-ru.py file

2010-08-24 Thread Alexey Nezhdanov
Hi.
While writting an application bumped into partial translation of russian
language.
Updated file attached. It is from welcome.py application, no my app specific
strings present.

Regards
Alexey
# coding: utf8
{
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"Изменить" - необязательное выражение вида "field1=\'новое значение\'". Результаты операции JOIN нельзя изменить или удалить.',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'%s rows deleted': '%s строк удалено',
'%s rows updated': '%s строк изменено',
'Available databases and tables': 'Базы данных и таблицы',
'Cannot be empty': 'Пустое значение недопустимо',
'Change Password': 'Смените пароль',
'Check to delete': 'Удалить',
'Check to delete:': 'Удалить:',
'Client IP': 'Client IP',
'Current request': 'Текущий запрос',
'Current response': 'Текущий ответ',
'Current session': 'Текущая сессия',
'Delete:': 'Удалить:',
'Description': 'Описание',
'E-mail': 'E-mail',
'Edit Profile': 'Редактировать профиль',
'Edit current record': 'Редактировать текущую запись',
'First name': 'Имя',
'Group ID': 'Group ID',
'Hello World': 'Заработало!',
'Import/Export': 'Импорт/экспорт',
'Internal State': 'Внутренне состояние',
'Invalid Query': 'Неверный запрос',
'Invalid email': 'Неверный email',
'Invalid login': 'Неверный логин',
'Invalid password': 'Неверный пароль',
'Last name': 'Фамилия',
'Logged in': 'Вход выполнен',
'Logged out': 'Выход выполнен',
'Login': 'Вход',
'Logout': 'Выход',
'Lost Password': 'Забыли пароль?',
'Name': 'Name',
'New Record': 'Новая запись',
'New password': 'Новый пароль',
'No databases in this application': 'В приложении нет баз данных',
'Old password': 'Старый пароль',
'Origin': 'Происхождение',
'Password': 'Пароль',
"Password fields don't match": 'Пароли не совпадают',
'Query:': 'Запрос:',
'Record ID': 'ID записи',
'Register': 'Зарегистрироваться',
'Registration key': 'Ключ регистрации',
'Remember me (for 30 days)': 'Запомнить меня (на 30 дней)',
'Reset Password key': 'Сбросить ключ пароля',
'Role': 'Роль',
'Rows in table': 'Строк в таблице',
'Rows selected': 'Выделено строк',
'Submit': 'Отправить',
'Sure you want to delete this object?': 'Подтвердите удаление объекта',
'Table name': 'Имя таблицы',
'The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.': '"Запрос" - это условие вида "db.table1.field1==\'значение\'". Выражение вида "db.table1.field1==db.table2.field2" формирует SQL JOIN.',
'Timestamp': 'Отметка времени',
'Update:': 'Изменить:',
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to build more complex queries.': 'Для построение сложных запросов используйте операторы "И": (...)&(...), "ИЛИ": (...)|(...), "НЕ": ~(...).',
'User %(id)s Logged-in': 'Пользователь %(id)s вошёл',
'User %(id)s Logged-out': 'Пользователь %(id)s вышел',
'User %(id)s Password changed': 'Пользователь %(id)s сменил пароль',
'User %(id)s Profile updated': 'Пользователь %(id)s обновил профиль',
'User %(id)s Registered': 'Пользователь %(id)s зарегистрировался',
'User ID': 'ID пользователя',
'Verify Password': 'Повторите пароль',
'Welcome to web2py': 'Добро пожаловать в web2py',
'click here for online examples': 'примеры он-лайн',
'click here for the administrative interface': 'административный интерфейс',
'customize me!': 'настройте внешний вид!',
'data uploaded': 'данные загружены',
'database': 'база данных',
'database %s select': 'выбор базы данных %s',
'db': 'БД',
'design': 'дизайн',
'done!': 'готово!',
'export as csv file': 'экспорт в  csv-файл',
'insert new': 'добавить',
'insert new %s': 'добавить %s',
'invalid request': 'неверный запрос',
'login': 'вход',
'logout': 'выход',
'new record inserted': 'новая запись добавлена',
'next 100 rows': 'следующие 100 строк',
'or import from csv file': 'или импорт из csv-файла',
'password': 'пароль',
'previous 100 rows': 'предыдущие 100 строк',
'profile': 'профиль',
'record does not exist': 'запись не найдена',
'record id': 'id записи',
'selected': 'выбрано',
'state': 'состояние',
'table': 'таблица',
'unable to parse csv file': 'нечитаемый csv-файл',
}


Re: [web2py] Re: Web2py and threads

2010-08-24 Thread Michele Comitini
2010/8/24 mdipierro :
> P.S. In the end the bottle neck is ALWAYS database access.
true! many driver implementations do not release the GIL properly on a
blocking call.
Anyway a well designed db would avoid the problem entirely.

Do you know if anyone tried web2py on pypy [http://pypy.org] ?


[web2py] Auth and CAS

2010-08-24 Thread huimies
Hi,

What are the latest in integrating Auth with CAS?

I found this bit in the auth code:

# use a central authentication server
cas = self.settings.login_form
cas_user = cas.get_user()

if cas_user:
cas_user[passfield] = None
user = self.get_or_create_user(cas_user)
elif hasattr(cas,'login_form'):
return cas.login_form()
else:
# we need to pass through login again before going on
next = URL(r=request) + '?_next=' + next
redirect(cas.login_url(next))

What's that all about, some prototyping or is there already a way?

Right now I have LDAP authentication for my apps, but I need to
authenticate with each of my apps separately. What I'd really like to
do is to modify CAS appliance to use LDAP as its backend and then use
CAS with Auth for single sign on. Are there any plans in making auth
work with CAS?