[web2py] Re: Display IS_IN_SET() label

2010-08-25 Thread jeff
Wuth SQLFORM.factory, the way to do that is to use the default arg the
Field.

On 25 août, 02:58, annet  wrote:
> 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] Re: dashes in controller names?

2010-08-25 Thread Kevin
It would be safe for the routing code to treat hyphens as underscores
when matching for app, controller, or function, though -- since web2py
(and python) semantics require that the code itself uses underscores.
Of course underscores in the rest of the URL would have to pass
through untouched.

Reverse translation is not an issue, since I could just do something
like:

{{= DASH(URL(...)) }}

Where DASH replaces all underscores with hyphens (which is acceptable
for me, since I don't use any underscores in URLs), though it would be
handy to make the routes.py configurable to do that automatically in
the URL call itself if I wanted.

On Aug 24, 9:46 pm, Jonathan Lundell  wrote:
> 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-...
> > *http://semicolons.org/post/256699383/friendly-urls
> > *http://www.wordsellinc.com/blog/content-optimization/use-hyphens-not-...
>
> > 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] Web2py with barcode Reader

2010-08-25 Thread Neveen Adel
Hello,

Is there a way to connect my  web2py application to barcode reader and
then get the data  after passing
barcode card into the barcode?

Thanks in Advance

Neveen


Re: [web2py] Web2py with barcode Reader

2010-08-25 Thread Alexey Nezhdanov
The question is not THAT clear, but I guess you can use external library to
connect to barcode reader.

However there is at least one problem - using the barcode reader is not a
browser operation.
So you will need either an ajax app that will poll the server for the
presence of an active barcode or write a server-side standalone daemon and
query it.

Regards
Alexey

On Wed, Aug 25, 2010 at 1:33 PM, Neveen Adel  wrote:

> Hello,
>
> Is there a way to connect my  web2py application to barcode reader and
> then get the data  after passing
> barcode card into the barcode?
>
> Thanks in Advance
>
> Neveen


[web2py] IS_DATETIME validator bug

2010-08-25 Thread Andrew Buchan
Hello,

I'm getting an error report using

Field('When_Actually_Delivered', requires =
IS_NULL_OR(IS_DATETIME())),

The form is created with SQLFORM, and the input in the textbox was as
per format quidelines from error message, so seems to be a bug in the
validator...

 File "C:\Program Files\Hub Pages\web2py\applications\HubForms\modules
\ComplaintSystem.py", line 100, in ReadOnlyForm
form = SQLFORM(table, record= record, fields=fields, readonly =
True, showid=showid)
  File "C:\Program Files\Hub Pages\web2py\gluon\sqlhtml.py", line 693,
in __init__
inp = field.formatter(default)
  File "C:\Program Files\Hub Pages\web2py\gluon\sql.py", line 2766, in
formatter
value = item.formatter(value)
  File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
2316, in formatter
return self.other.formatter(value)
  File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
2076, in formatter
year = value.year
AttributeError: 'str' object has no attribute 'year'


Re: [web2py] Web2py with barcode Reader

2010-08-25 Thread Michele Comitini
Is the barcode reader connected on the same machine running web2py?

If yes you just need to create a function in the controller that you
can call and reads the value and puts it in the session or
where you need.
something like this (it will be more complex depending on hw):

def barcoderead:
 barfile = file('', 'r')
 code = barfile.read() # blocks  here until data arrives
 barfile.close()
 return dict(barcode=code)

You can callit as a normal url:
http://your.host.name/barcodeapplication/barcodecontroller/barcoderead
so you
can use anything you like for instance ajax

hope that helps!
mic


2010/8/25 Neveen Adel :
> Hello,
>
> Is there a way to connect my  web2py application to barcode reader and
> then get the data  after passing
> barcode card into the barcode?
>
> Thanks in Advance
>
> Neveen


[web2py] Re: IS_DATETIME validator bug

2010-08-25 Thread KR
maybe Field('When_Actually_Delivered','datetime', requires =
IS_NULL_OR(IS_DATETIME())),

On 25 août, 11:58, Andrew Buchan  wrote:
> Hello,
>
> I'm getting an error report using
>
> Field('When_Actually_Delivered', requires =
> IS_NULL_OR(IS_DATETIME())),
>
> The form is created with SQLFORM, and the input in the textbox was as
> per format quidelines from error message, so seems to be a bug in the
> validator...
>
>  File "C:\Program Files\Hub Pages\web2py\applications\HubForms\modules
> \ComplaintSystem.py", line 100, in ReadOnlyForm
>     form = SQLFORM(table, record= record, fields=fields, readonly =
> True, showid=showid)
>   File "C:\Program Files\Hub Pages\web2py\gluon\sqlhtml.py", line 693,
> in __init__
>     inp = field.formatter(default)
>   File "C:\Program Files\Hub Pages\web2py\gluon\sql.py", line 2766, in
> formatter
>     value = item.formatter(value)
>   File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
> 2316, in formatter
>     return self.other.formatter(value)
>   File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
> 2076, in formatter
>     year = value.year
> AttributeError: 'str' object has no attribute 'year'


Re: [web2py] Re: IS_DATETIME validator bug

2010-08-25 Thread Andrew Buchan
Yes, that somehow makes sense :-)
Thanks.

On Wed, Aug 25, 2010 at 11:39 AM, KR  wrote:

> maybe Field('When_Actually_Delivered','datetime', requires =
> IS_NULL_OR(IS_DATETIME())),
>
> On 25 août, 11:58, Andrew Buchan  wrote:
> > Hello,
> >
> > I'm getting an error report using
> >
> > Field('When_Actually_Delivered', requires =
> > IS_NULL_OR(IS_DATETIME())),
> >
> > The form is created with SQLFORM, and the input in the textbox was as
> > per format quidelines from error message, so seems to be a bug in the
> > validator...
> >
> >  File "C:\Program Files\Hub Pages\web2py\applications\HubForms\modules
> > \ComplaintSystem.py", line 100, in ReadOnlyForm
> > form = SQLFORM(table, record= record, fields=fields, readonly =
> > True, showid=showid)
> >   File "C:\Program Files\Hub Pages\web2py\gluon\sqlhtml.py", line 693,
> > in __init__
> > inp = field.formatter(default)
> >   File "C:\Program Files\Hub Pages\web2py\gluon\sql.py", line 2766, in
> > formatter
> > value = item.formatter(value)
> >   File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
> > 2316, in formatter
> > return self.other.formatter(value)
> >   File "C:\Program Files\Hub Pages\web2py\gluon\validators.py", line
> > 2076, in formatter
> > year = value.year
> > AttributeError: 'str' object has no attribute 'year'
>


[web2py] Re: auth.settings.retrieve_password_next not being honoured

2010-08-25 Thread Adi
Yup, this one works!

Thanks.

On Aug 23, 5:55 pm, mdipierro  wrote:
> One more try please:
>
> auth.settings.request_reset_password_next
>
> On Aug 23, 2:32 am, Adi  wrote:
>
>
>
> > Help me please! :)
>
> > On Aug 20, 6:38 pm, Adi  wrote:
>
> > > Tried both. No change.
>
> > > I think retrieve_password is the form where an email to reset password
> > > is sent. After sending the mail I want to go to my own controller
> > > function.
>
> > > On Aug 20, 4:26 pm, mdipierro  wrote:
>
> > > > I think you want to set reset_password_next
>
> > > > auth.settings.retrieve_password_next
>
> > > > On Aug 20, 6:01 am, Adi  wrote:
>
> > > > > Hi,
>
> > > > > I'm setting auth.settings.retrieve_password_next= my_custom_url so
> > > > > that after sending out reset password mail, the my_custom_url page
> > > > > should open. However, web2py is taking user to default/index.
>
> > > > > Any help?


[web2py] Re: auto complete widget

2010-08-25 Thread Martin.Mulone
I dont know this is the reason because i never tried automplete, but
in web2py_ajax.html change code like fadeIn('slow') or fadeOut('slow')
to fadeIn('fast') or fadeOut('fast')

On Aug 25, 3:23 am, annet  wrote:
> 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] Invalid Reset Password

2010-08-25 Thread Francisco Costa
I have this function in the default controller

def retrieve_password():
return dict(form=auth.retrieve_password())


and I have this view default/retrieve_password.html

{{response.title=T('Retrieve Password')}}
{{extend 'layout.html'}}
{{app=request.application}}
{{=form}}


When I click submit this error happens: ProgrammingError: (1064, "You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'WHERE
auth_user.id=1' at line 1")

But the email is sent. When i click on the email link I get a flash
message with 'Invalid reset password'

Any help?


[web2py] Re: Web2Py developer needed

2010-08-25 Thread mdipierro
David, I apologize, I did not have the time to respond some of your
questions. They involve plugins_tagging which I have not used in some
time. I will try run some tests and respond asap.

On Aug 24, 7:21 pm, "david.waldrop"  wrote:
> 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: Should we have a feature freeze and stability maintenance period in future?

2010-08-25 Thread mdipierro
we do use googlecode for not. Here is the current (imperfect) process:

1) people post a question about a possible bug
2) somebody checks that it is a bug, usually me
3) if the bug does not get fixed in 24h, the original poster opens a
googlecode ticket
4) when the bug is fixed the ticket is closed

because many bugs are dealt with in <24hrs there is no record. Because
bugs are fixed in trunk and trunk takes a couple of weeks to become
steable and because most users never upgrade to the latest stable,
occasionally there are multiple questions related to the same fixed
bug. I am not sure better workflow management fixes this latter
problem.

I have not read all messages on this thread carefully yet. Eventually
I will but I am happy to hear more of your ideas.


On Aug 24, 5: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: Web2py and threads

2010-08-25 Thread mdipierro
The model is executed at every http request, new thread or not new
thread.

On Aug 24, 9:36 pm, pierreth  wrote:
> 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


[web2py] Re: Pagination manual bug?

2010-08-25 Thread mdipierro
This is not a bug. the manual syntax is correct for web2py 1.83.1 and
beyond.

On Aug 24, 10:56 pm, dlin  wrote:
> 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}}
>
> > > 

[web2py] Re: Currency formating

2010-08-25 Thread mdipierro
web2py cannot support locale because it is not thread safe, If one app
changes the locale it would change it for all apps.

On Aug 25, 12:07 am, Bruno Rocha  wrote:
> Hi,
>
> Actually, I am using these methods to work with money formating.
>
> some tries with python-money and works very 
> wellhttp://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: Display IS_IN_SET() label

2010-08-25 Thread annet
Hi Jeff,

Thanks for your reply. Could you please provide me with the correct
syntax to solve this problem?


Kind regards,

Annet


[web2py] Re: jqgrid and edit-link

2010-08-25 Thread mdipierro
Are you using plugin_jqgrid. If so please use widget jqgrid from
plugin_wiki.

On Aug 25, 12:45 am, Johann Spies  wrote:
> 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] Re: auto complete widget

2010-08-25 Thread annet
Hi Martin,

I gave you solution a try, but it doesn't make any difference to the
auto complete's behaviour.

Kind regards,

Annet.


[web2py] Re: represent in crud.select

2010-08-25 Thread mdipierro
fields should be

fields=['friendship.id', 'friendship.to_user'],

On Aug 25, 1:28 am, firedragon852  wrote:
> 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] Re: Display IS_IN_SET() label

2010-08-25 Thread mdipierro
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),default=3))

On Aug 25, 1:58 am, annet  wrote:
> 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] Re: auto complete widget

2010-08-25 Thread mdipierro
this is hardcoded in gluon/sqlhtml.py

attr['_onblur']="jQuery('#%
(div_id)s').delay(3000).fadeOut('slow');" 

I guess we can make it is a parameter of the widget. I would take a
patch.


On Aug 25, 1:23 am, annet  wrote:
> 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] Re: Invalid Reset Password

2010-08-25 Thread mdipierro
If you have auth.define_tables(migrate=False), try change it to true
If you use a custom auth_user table, please post it.

On Aug 25, 7:10 am, Francisco Costa  wrote:
> I have this function in the default controller
>
>     def retrieve_password():
>         return dict(form=auth.retrieve_password())
>
> and I have this view default/retrieve_password.html
>
>     {{response.title=T('Retrieve Password')}}
>     {{extend 'layout.html'}}
>     {{app=request.application}}
>     {{=form}}
>
> When I click submit this error happens: ProgrammingError: (1064, "You
> have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'WHERE
> auth_user.id=1' at line 1")
>
> But the email is sent. When i click on the email link I get a flash
> message with 'Invalid reset password'
>
> Any help?


[web2py] MS SQL driver in Windows binary.

2010-08-25 Thread Seeker
Hi guys,

>From what I gather the Windows binary distro only contains the MySQL
and SQLite drivers and that I would have to run the source version in
order to utilise other drivers.

Is there any chance of including the MS SQL driver in the Windows
binary as well?  In my view chances are fairly good that the Windows
distribution will be used with MS SQL ... Running from binary is also
the only way that I will be permitted to run Web2Py on our servers ;-)

Thanks lots.


[web2py] Setting default groups for app

2010-08-25 Thread Antti
Hi,

What's the best practice in adding default groups and permissions for
apps?

Should I write a script which would add groups and permissions if they
do not exist? And how to trigger it?

cheers,
Antti


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

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 1:42 AM, Kevin wrote:

> It would be safe for the routing code to treat hyphens as underscores
> when matching for app, controller, or function, though -- since web2py
> (and python) semantics require that the code itself uses underscores.
> Of course underscores in the rest of the URL would have to pass
> through untouched.

Are Python restrictions relevant for applications and controllers? Or just 
filename restrictions? I'm not sure.

> 
> Reverse translation is not an issue, since I could just do something
> like:
> 
> {{= DASH(URL(...)) }}
> 
> Where DASH replaces all underscores with hyphens (which is acceptable
> for me, since I don't use any underscores in URLs), though it would be
> handy to make the routes.py configurable to do that automatically in
> the URL call itself if I wanted.

It could be an option to URL, I suppose. I'm thinking that you wouldn't want to 
translate underscores in the query string.

> 
> On Aug 24, 9:46 pm, Jonathan Lundell  wrote:
>> 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-...
>>> *http://semicolons.org/post/256699383/friendly-urls
>>> *http://www.wordsellinc.com/blog/content-optimization/use-hyphens-not-...
>> 
>>> 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: MS SQL driver in Windows binary.

2010-08-25 Thread mdipierro
I have no technical objection. Does the license allows it?

On Aug 25, 1:41 am, Seeker  wrote:
> Hi guys,
>
> From what I gather the Windows binary distro only contains the MySQL
> and SQLite drivers and that I would have to run the source version in
> order to utilise other drivers.
>
> Is there any chance of including the MS SQL driver in the Windows
> binary as well?  In my view chances are fairly good that the Windows
> distribution will be used with MS SQL ... Running from binary is also
> the only way that I will be permitted to run Web2Py on our servers ;-)
>
> Thanks lots.


[web2py] Re: Setting default groups for app

2010-08-25 Thread mdipierro
You have two options:
1) create a scrpt and run it manually once

web2py.py -S yourapp -M -N -R script.py

2) use a model like:

if no group exists:
create missing groups and permissions

Massimo

On Aug 24, 7:14 am, Antti  wrote:
> Hi,
>
> What's the best practice in adding default groups and permissions for
> apps?
>
> Should I write a script which would add groups and permissions if they
> do not exist? And how to trigger it?
>
> cheers,
> Antti


[web2py] Re: Invalid Reset Password

2010-08-25 Thread Francisco Costa

auth_table = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('username', length=128, default=''),
Field('email', length=128, default='', unique=True),
Field('password', 'password', length=256, readable=False,
label='Password', requires=CRYPT()),
Field('picture','upload'),
Field('thumb','upload',writable=False,readable=False),
Field('registration_key', length=128, default= '', writable=False,
readable=False)
)
auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
auth_table.first_name.requires = \
  IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires = \
  IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [CRYPT()]
auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, auth_table.email)]
auth.settings.table_user = auth_table


and


auth.define_tables(migrate=True)




On Aug 25, 2:58 pm, mdipierro  wrote:
> If you have auth.define_tables(migrate=False), try change it to true
> If you use a custom auth_user table, please post it.
>
> On Aug 25, 7:10 am, Francisco Costa  wrote:
>
> > I have this function in the default controller
>
> >     def retrieve_password():
> >         return dict(form=auth.retrieve_password())
>
> > and I have this view default/retrieve_password.html
>
> >     {{response.title=T('Retrieve Password')}}
> >     {{extend 'layout.html'}}
> >     {{app=request.application}}
> >     {{=form}}
>
> > When I click submit this error happens: ProgrammingError: (1064, "You
> > have an error in your SQL syntax; check the manual that corresponds to
> > your MySQL server version for the right syntax to use near 'WHERE
> > auth_user.id=1' at line 1")
>
> > But the email is sent. When i click on the email link I get a flash
> > message with 'Invalid reset password'
>
> > Any help?


Re: [web2py] Re: Currency formating

2010-08-25 Thread Bruno Rocha
Look at
http://code.google.com/p/python-money/source/browse/trunk/money/Money.py

Python-money does not use "locale"

2010/8/25 mdipierro 

> web2py cannot support locale because it is not thread safe, If one app
> changes the locale it would change it for all apps.
>
> On Aug 25, 12:07 am, Bruno Rocha  wrote:
> > Hi,
> >
> > Actually, I am using these methods to work with money formating.
> >
> > some tries with python-money and works very wellhttp://
> 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?
>



-- 

http://rochacbruno.com.br


[web2py] Re: Invalid Reset Password

2010-08-25 Thread Francisco Costa
Just realized I was missing this field in the database table:
   Field('reset_password_key', length=128, default= '',
writable=False, readable=False),

On Aug 25, 3:10 pm, Francisco Costa  wrote:
> auth_table = db.define_table(
>     auth.settings.table_user_name,
>     Field('first_name', length=128, default=''),
>     Field('last_name', length=128, default=''),
>     Field('username', length=128, default=''),
>     Field('email', length=128, default='', unique=True),
>     Field('password', 'password', length=256, readable=False,
> label='Password', requires=CRYPT()),
>     Field('picture','upload'),
>     Field('thumb','upload',writable=False,readable=False),
>     Field('registration_key', length=128, default= '', writable=False,
> readable=False)
> )
> auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
> auth_table.first_name.requires = \
>   IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> auth_table.last_name.requires = \
>   IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> auth_table.password.requires = [CRYPT()]
> auth_table.email.requires = [
>   IS_EMAIL(error_message=auth.messages.invalid_email),
>   IS_NOT_IN_DB(db, auth_table.email)]
> auth.settings.table_user = auth_table
>
> and
>
> auth.define_tables(migrate=True)
>
> On Aug 25, 2:58 pm, mdipierro  wrote:
>
> > If you have auth.define_tables(migrate=False), try change it to true
> > If you use a custom auth_user table, please post it.
>
> > On Aug 25, 7:10 am, Francisco Costa  wrote:
>
> > > I have this function in the default controller
>
> > >     def retrieve_password():
> > >         return dict(form=auth.retrieve_password())
>
> > > and I have this view default/retrieve_password.html
>
> > >     {{response.title=T('Retrieve Password')}}
> > >     {{extend 'layout.html'}}
> > >     {{app=request.application}}
> > >     {{=form}}
>
> > > When I click submit this error happens: ProgrammingError: (1064, "You
> > > have an error in your SQL syntax; check the manual that corresponds to
> > > your MySQL server version for the right syntax to use near 'WHERE
> > > auth_user.id=1' at line 1")
>
> > > But the email is sent. When i click on the email link I get a flash
> > > message with 'Invalid reset password'
>
> > > Any help?


[web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread mdipierro
can you help me debug?

in gluon/validators.py

class IS_IMAGE:
def __call__(self,value):
   
except:
return (value, self.error_message)

replace last two lines with

except Exception, e:
return (value, str(r))

what does the error say?




On Aug 23, 4: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'


Re: [web2py] Re: Currency formating

2010-08-25 Thread Bruno Rocha
Massimo,

What is your recomendation to deal with currency in web2py?

2010/8/25 Bruno Rocha 

> Look at
> http://code.google.com/p/python-money/source/browse/trunk/money/Money.py
>
> Python-money does not use "locale"
>
> 2010/8/25 mdipierro 
>
> web2py cannot support locale because it is not thread safe, If one app
>> changes the locale it would change it for all apps.
>>
>> On Aug 25, 12:07 am, Bruno Rocha  wrote:
>> > Hi,
>> >
>> > Actually, I am using these methods to work with money formating.
>> >
>> > some tries with python-money and works very wellhttp://
>> 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?
>>
>
>
>
> --
>
> http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br


[web2py] Re: auto complete widget

2010-08-25 Thread annet
Massimo,

To solve the problem I changed the code in gluon/sqlhtml.py.

I think making it a parameter is a good idea, at the moment I don't
have the skills to provide you with a patch :-(


Kind regards,

Annet,


[web2py] Re: Display IS_IN_SET() label

2010-08-25 Thread annet
Massimo,

I am not sure you did understand my question correctly.

When in the form the user selects 'Fitnesscentre' in the drop box, the
function that selects all the Fitnesscentres takes 2 as its argument.
I would like the flash in the view to display something like:

"Fitnesscentres in Amsterdam"

request.vars.city gives me Amsterdam, what I am looking for is
something similar for Fitnesscentres, however, request.vars.bedrijf
gives me 2.


Kind regards,

Annet


[web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread Joe Wakefield
The assertion errors are blank, so I added some extra output:

-IS_IMAGE STARTED-
filename: 1.png
extension: png
self.extensions: jpeg
ERROR IN IS_IMAGE:

-IS_IMAGE STARTED-
filename: llamas.jpg
extension: jpg
self.extensions: jpeg
__jpeg called
width, height: 400, 300
new: users.photo.81f708977b7f7851.6c6c616d61732e6a7067.jpgold:

-IS_IMAGE STARTED-
filename: 1.png
extension: png
self.extensions: jpeg
ERROR IN IS_IMAGE:
new: users.photo.8ef32f83074cd5bf.312e706e67.pngold: users.photo.
81f708977b7f7851.6c6c616d61732e6a7067.jpg

-IS_IMAGE STARTED-
filename: test.zip
extension: zip
self.extensions: jpeg
ERROR IN IS_IMAGE:
new: users.photo.a4b74cd11efaf711.746573742e7a6970.zipold:
users.photo.8ef32f83074cd5bf.312e706e67.png

This would suggest that the IS_IMAGE validator is working fine, and
I'm guessing the problem would be in sqlform.accepts()?


On Aug 25, 10:17 am, mdipierro  wrote:
> can you help me debug?
>
> in gluon/validators.py
>
> classIS_IMAGE:
>     def __call__(self,value):
>        
>         except:
>             return (value, self.error_message)
>
> replace last two lines with
>
>         except Exception, e:
>             return (value, str(r))
>
> what does the error say?
>
> On Aug 23, 4: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] Ajax Long Pooling (comet)

2010-08-25 Thread Phyo Arkar
Hello Web2py

I am running the resource extensive function , which is extracting
every archive , parse text out of every file under there and then
inserting into database.

But i want to make an ajax progressbar , by polling at specific
interval. But it wont work as web2py

How can i achieve this?

1) Long Polling , is that supported in web2py ? (rocket supports it)

2) Fork the function ? how can i achieve this?

3) May be run it as separate process?


[web2py] Re: Web2py and threads

2010-08-25 Thread John Heenan
No, nothing that abstract. Using WSGI forces a new thread for each
request. This is is a simple and inefficient brute force approach that
really only suits the simplest Python applications and where only a
small number of concurrent connection might be expected.

Any application that provides web services is going to OS block on
file reading (and writing) and on database access. Using threads is a
classic and easy way out that carries a lot of baggage. Windows has
had a way out of this for years with its asynch (or event)
notification set up through an OVERLAPPED structure.

Lightttpd makes use of efficient event notification schemes like
kqueue and epoll. Apache only uses such schemes for listening and Keep-
Alives.

No matter how careful one is with threads and processes there always
appears to be unexpected gotchas. Python has a notorious example, the
now fixed 'Beazly Effect' that affected the GIL. Also I don't think
there is a single experienced Python user that trusts the GIL.

John Heenan

On Aug 25, 12:40 pm, pierreth  wrote:
> 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?


Re: [web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 8:11 AM, Joe Wakefield wrote:

> The assertion errors are blank, so I added some extra output:
> 
> -IS_IMAGE STARTED-
> filename: 1.png
> extension: png
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> 
> -IS_IMAGE STARTED-
> filename: llamas.jpg
> extension: jpg
> self.extensions: jpeg
> __jpeg called
> width, height: 400, 300
> new: users.photo.81f708977b7f7851.6c6c616d61732e6a7067.jpgold:
> 
> -IS_IMAGE STARTED-
> filename: 1.png
> extension: png
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> new: users.photo.8ef32f83074cd5bf.312e706e67.pngold: users.photo.
> 81f708977b7f7851.6c6c616d61732e6a7067.jpg
> 
> -IS_IMAGE STARTED-
> filename: test.zip
> extension: zip
> self.extensions: jpeg
> ERROR IN IS_IMAGE:
> new: users.photo.a4b74cd11efaf711.746573742e7a6970.zipold:
> users.photo.8ef32f83074cd5bf.312e706e67.png
> 
> This would suggest that the IS_IMAGE validator is working fine, and
> I'm guessing the problem would be in sqlform.accepts()?

My desk-check of IS_IMAGE suggested that it was OK, too. It could use a couple 
of documenting doctests, I think. 

You're deliberately restricting it to jpeg above, right? Hence the rejection of 
png?


> 
> 
> On Aug 25, 10:17 am, mdipierro  wrote:
>> can you help me debug?
>> 
>> in gluon/validators.py
>> 
>> classIS_IMAGE:
>> def __call__(self,value):
>>
>> except:
>> return (value, self.error_message)
>> 
>> replace last two lines with
>> 
>> except Exception, e:
>> return (value, str(r))
>> 
>> what does the error say?
>> 
>> On Aug 23, 4: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=ite

[web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread Joe Wakefield
I'll do you one better. The problem is in "sqlhtml.py" at lines
909-917. It changes ret=False to ret=True if the field already has a
value.

===
ret, errors: False, 
new ret:False
===
ret, errors: True, 
new ret:True
new: users.photo.8a5327ab32003765.6c6c616d61732e6a7067.jpgold:
===
ret, errors: False, 
new ret:True
new: users.photo.b6369c7a23ae4813.312e706e67.pngold: users.photo.
8a5327ab32003765.6c6c616d61732e6a7067.jpg

On Aug 25, 10:17 am, mdipierro  wrote:
> can you help me debug?
>
> in gluon/validators.py
>
> classIS_IMAGE:
>     def __call__(self,value):
>        
>         except:
>             return (value, self.error_message)
>
> replace last two lines with
>
>         except Exception, e:
>             return (value, str(r))
>
> what does the error say?
>
> On Aug 23, 4: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] Re: Web2py and threads

2010-08-25 Thread pierreth
I would appreciate a good reference to understand the concepts you are
talking about. It is something new to me and I don't understand.

On 25 août, 11:22, John Heenan  wrote:
> No, nothing that abstract. Using WSGI forces a new thread for each
> request. This is is a simple and inefficient brute force approach that
> really only suits the simplest Python applications and where only a
> small number of concurrent connection might be expected.
>
> Any application that provides web services is going to OS block on
> file reading (and writing) and on database access. Using threads is a
> classic and easy way out that carries a lot of baggage. Windows has
> had a way out of this for years with its asynch (or event)
> notification set up through an OVERLAPPED structure.
>
> Lightttpd makes use of efficient event notification schemes like
> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> Alives.
>
> No matter how careful one is with threads and processes there always
> appears to be unexpected gotchas. Python has a notorious example, the
> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> there is a single experienced Python user that trusts the GIL.
>
> John Heenan
>


Re: [web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 8:33 AM, Joe Wakefield wrote:

> I'll do you one better. The problem is in "sqlhtml.py" at lines
> 909-917. It changes ret=False to ret=True if the field already has a
> value.

Good catch. This is a case where a comment documenting the intent of this hunk 
of code would come in handy for those of us reading it. The error is cancelled 
under certain conditions, but what's the intent?

> 
> ===
> ret, errors: False, 
> new ret:False
> ===
> ret, errors: True, 
> new ret:True
> new: users.photo.8a5327ab32003765.6c6c616d61732e6a7067.jpgold:
> ===
> ret, errors: False, 
> new ret:True
> new: users.photo.b6369c7a23ae4813.312e706e67.pngold: users.photo.
> 8a5327ab32003765.6c6c616d61732e6a7067.jpg
> 
> On Aug 25, 10:17 am, mdipierro  wrote:
>> can you help me debug?
>> 
>> in gluon/validators.py
>> 
>> classIS_IMAGE:
>> def __call__(self,value):
>>
>> except:
>> return (value, self.error_message)
>> 
>> replace last two lines with
>> 
>> except Exception, e:
>> return (value, str(r))
>> 
>> what does the error say?
>> 
>> On Aug 23, 4: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'
>> 
>> 




Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Phyo Arkar
Did I Read that reading files inside controller will block web2py , Does it?

Thats a bad news.. i am doing a file crawler and while crawling ,
web2py is blocked even tho the process talke only 25% of 1 out of 4
CPUs ..



On 8/25/10, pierreth  wrote:
> I would appreciate a good reference to understand the concepts you are
> talking about. It is something new to me and I don't understand.
>
> On 25 août, 11:22, John Heenan  wrote:
>> No, nothing that abstract. Using WSGI forces a new thread for each
>> request. This is is a simple and inefficient brute force approach that
>> really only suits the simplest Python applications and where only a
>> small number of concurrent connection might be expected.
>>
>> Any application that provides web services is going to OS block on
>> file reading (and writing) and on database access. Using threads is a
>> classic and easy way out that carries a lot of baggage. Windows has
>> had a way out of this for years with its asynch (or event)
>> notification set up through an OVERLAPPED structure.
>>
>> Lightttpd makes use of efficient event notification schemes like
>> kqueue and epoll. Apache only uses such schemes for listening and Keep-
>> Alives.
>>
>> No matter how careful one is with threads and processes there always
>> appears to be unexpected gotchas. Python has a notorious example, the
>> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
>> there is a single experienced Python user that trusts the GIL.
>>
>> John Heenan
>>
>


[web2py] Custom Forms validation

2010-08-25 Thread Francisco Costa
Hello,
I would like to know if you can have ajax validators when using custom
forms.

I leave here an example of a view to change password:

{{form=auth.change_password(next=URL(r=request, c='default',
f='login'))}}

{{=T('Change Password')}}
{{=form.custom.begin}}


{{=T('Old Password:')}} 


{{=T('New Password:')}} 


{{=T('Verify Password:')}} 

 {{=form.custom.submit}}


{{=form.custom.end}}


In this case what i wanted is something that validates the old
password and that the new and verief password are the same.

Thank you


Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 9:00 AM, Phyo Arkar wrote:

> Did I Read that reading files inside controller will block web2py , Does it?
> 
> Thats a bad news.. i am doing a file crawler and while crawling ,
> web2py is blocked even tho the process talke only 25% of 1 out of 4
> CPUs ..

This stuff gets a little coverage in the book's deployment chapter, but it 
could use a systematic discussion.

What are the implication for web2py apps of http server policies, database 
locks (sqlite especially), session locking, the GIL, etc? With a section on 
best practices.

> 
> 
> 
> On 8/25/10, pierreth  wrote:
>> I would appreciate a good reference to understand the concepts you are
>> talking about. It is something new to me and I don't understand.
>> 
>> On 25 août, 11:22, John Heenan  wrote:
>>> No, nothing that abstract. Using WSGI forces a new thread for each
>>> request. This is is a simple and inefficient brute force approach that
>>> really only suits the simplest Python applications and where only a
>>> small number of concurrent connection might be expected.
>>> 
>>> Any application that provides web services is going to OS block on
>>> file reading (and writing) and on database access. Using threads is a
>>> classic and easy way out that carries a lot of baggage. Windows has
>>> had a way out of this for years with its asynch (or event)
>>> notification set up through an OVERLAPPED structure.
>>> 
>>> Lightttpd makes use of efficient event notification schemes like
>>> kqueue and epoll. Apache only uses such schemes for listening and Keep-
>>> Alives.
>>> 
>>> No matter how careful one is with threads and processes there always
>>> appears to be unexpected gotchas. Python has a notorious example, the
>>> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
>>> there is a single experienced Python user that trusts the GIL.
>>> 
>>> John Heenan
>>> 
>> 




[web2py] Re: Web2py and threads

2010-08-25 Thread mdipierro


On Aug 25, 11:00 am, Phyo Arkar  wrote:
> Did I Read that reading files inside controller will block web2py , Does it?

No web2py does not block. web2py only locks sessions that means one
user cannot request two concurrent pages because there would be a race
condition in saving sessions. Two user can request different pages
which open the same file unless the file is explicitly locked by your
code.

> Thats a bad news.. i am doing a file crawler and while crawling ,
> web2py is blocked even tho the process talke only 25% of 1 out of 4
> CPUs ..

Tell us more or I cannot help.


>
> On 8/25/10, pierreth  wrote:
>
> > I would appreciate a good reference to understand the concepts you are
> > talking about. It is something new to me and I don't understand.
>
> > On 25 août, 11:22, John Heenan  wrote:
> >> No, nothing that abstract. Using WSGI forces a new thread for each
> >> request. This is is a simple and inefficient brute force approach that
> >> really only suits the simplest Python applications and where only a
> >> small number of concurrent connection might be expected.
>
> >> Any application that provides web services is going to OS block on
> >> file reading (and writing) and on database access. Using threads is a
> >> classic and easy way out that carries a lot of baggage. Windows has
> >> had a way out of this for years with its asynch (or event)
> >> notification set up through an OVERLAPPED structure.
>
> >> Lightttpd makes use of efficient event notification schemes like
> >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> >> Alives.
>
> >> No matter how careful one is with threads and processes there always
> >> appears to be unexpected gotchas. Python has a notorious example, the
> >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> >> there is a single experienced Python user that trusts the GIL.
>
> >> John Heenan


Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Phyo Arkar
Yes may be session was locked , thats why
session.current=processing_path not working

But then again , while processing files i try opening separate page ,
to other controller , it was waited till the first (file Crawler) page
finished parsing.


ok i will make a separate thread about this.


On 8/25/10, mdipierro  wrote:
>
>
> On Aug 25, 11:00 am, Phyo Arkar  wrote:
>> Did I Read that reading files inside controller will block web2py , Does
>> it?
>
> No web2py does not block. web2py only locks sessions that means one
> user cannot request two concurrent pages because there would be a race
> condition in saving sessions. Two user can request different pages
> which open the same file unless the file is explicitly locked by your
> code.
>
>> Thats a bad news.. i am doing a file crawler and while crawling ,
>> web2py is blocked even tho the process talke only 25% of 1 out of 4
>> CPUs ..
>
> Tell us more or I cannot help.
>
>
>>
>> On 8/25/10, pierreth  wrote:
>>
>> > I would appreciate a good reference to understand the concepts you are
>> > talking about. It is something new to me and I don't understand.
>>
>> > On 25 août, 11:22, John Heenan  wrote:
>> >> No, nothing that abstract. Using WSGI forces a new thread for each
>> >> request. This is is a simple and inefficient brute force approach that
>> >> really only suits the simplest Python applications and where only a
>> >> small number of concurrent connection might be expected.
>>
>> >> Any application that provides web services is going to OS block on
>> >> file reading (and writing) and on database access. Using threads is a
>> >> classic and easy way out that carries a lot of baggage. Windows has
>> >> had a way out of this for years with its asynch (or event)
>> >> notification set up through an OVERLAPPED structure.
>>
>> >> Lightttpd makes use of efficient event notification schemes like
>> >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
>> >> Alives.
>>
>> >> No matter how careful one is with threads and processes there always
>> >> appears to be unexpected gotchas. Python has a notorious example, the
>> >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
>> >> there is a single experienced Python user that trusts the GIL.
>>
>> >> John Heenan


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

2010-08-25 Thread mart
Good morning!

You must be so busy! But from what you are saying the process is
pretty much straight forward and you already have a good delivery
system (downloads on web2py.com). If we expand a little on that, we
may be able to settle a few issues quickly enough.

1. Michele's idea is perfect here. A simple bug tracking system built
on your great framework. Simple to start with (but made in such a way
that adding functionality is easy.
1.1. - include the date/time stamp in the version number (I.e. today;s
stable build is versionned: 1.83.2.20100815081630)
1.2. add the version numbers to nightly builds as posted.

2. simple bug tracking app:
a few fields to start with:
* "bug found in:" 
* "category:"  (i.e. web2py
classes, web2py on apache, localization, DB connection, etc... you
would know how to categorize)
" "logged by:" 
* "description:" TEXT field
* " How to reproduce:" TEXT field
* "bug status:" is_bug/is_not_bug
if "is_bug" then "status:" field:
  "will fix for:" date/next major release/etc...
if :is_not_bug:" then: "resolution - description"
* admin (you or web2py test leads can move items from one category to
another if logged against wrong one
* "fix description:" TEXT field

* generate_ticket(): return ticket (number based on <"found in build
number">.loggedOnDate.userID (or something meaningfull)


anyways, whatever data the Form should be getting... nightly build
automation generates good build notes based on those ticket items. and
the Stable build contains the cumulative build notes (from stable
build to stable build). Users are then encouraged to grab latest and
greatest build (if they really want their big fix). This may be a
little easier to track if the bug has already been logged. And, you
have an easier time going through bugs and/or hand off some of this
work to one of your leads (sonce the bug history and criteria are all
in one place). Users have a better time in seeing that the big has
been fixed/will be fixed/rejected without you having to send emails
(some of the onus now goes to the user for status)

This could make things easy for you, I would really consider making
something that integrates all of your requirements in one place/app.
(build/reporting/bug_tracking/source code management)... This would be
a great opportunity to ask of your web2py super stars to come up with
an app that intagrates all of those items (either as one app, or as
multiples with good data sharing capabilities). There are good (and
free openSource bug tracking systems out there - but may be a little
more work to integrate?)... besides nothing like using/promoting you
own great fraework for showcasing :) )

Mart :)

On Aug 25, 9:45 am, mdipierro  wrote:
> we do use googlecode for not. Here is the current (imperfect) process:
>
> 1) people post a question about a possible bug
> 2) somebody checks that it is a bug, usually me
> 3) if the bug does not get fixed in 24h, the original poster opens a
> googlecode ticket
> 4) when the bug is fixed the ticket is closed
>
> because many bugs are dealt with in <24hrs there is no record. Because
> bugs are fixed in trunk and trunk takes a couple of weeks to become
> steable and because most users never upgrade to the latest stable,
> occasionally there are multiple questions related to the same fixed
> bug. I am not sure better workflow management fixes this latter
> problem.
>
> I have not read all messages on this thread carefully yet. Eventually
> I will but I am happy to hear more of your ideas.
>
> On Aug 24, 5: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 sy

[web2py] Re: Setting default groups for app

2010-08-25 Thread Antti
Thanks for your answer. I'll probably go for option 2). I suppose
models are run only once upon startup?

--
Antti

On Aug 25, 5:10 pm, mdipierro  wrote:
> You have two options:
> 1) create a scrpt and run it manually once
>
> web2py.py -S yourapp -M -N -R script.py
>
> 2) use a model like:
>
> if no group exists:
>     create missing groups and permissions
>
> Massimo
>
> On Aug 24, 7:14 am, Antti  wrote:
>
> > Hi,
>
> > What's the best practice in adding default groups and permissions for
> > apps?
>
> > Should I write a script which would add groups and permissions if they
> > do not exist? And how to trigger it?
>
> > cheers,
> > Antti


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

2010-08-25 Thread Michele Comitini
Point 2) is nice for all of us because you (Massimo) are very quick,
but how much does take off of your web2py time?
Would not be better to open the ticket before testing and eventually
close it as "works for me"?
This way someone among the developers  could take care of the ticket
and test it, if he is able to fix it good, he makes a patch
and he closes it when the patch is put in the trunk (by you).  In case
the patch cannot be applied either you have time to fix it
or inform the submitter to fix it.

A slight modified version of the process (very imperfect):

1) people post a question about a possible bug
2) if it looks (without test) like it, you (or a developer) ask them
to open a ticket
3) you or a developer take care of the ticket (becoming the ticket
holder) locking others out
4) the holder tests: if it is not a bug then 6)
5) you fix it in trunk or a developer sends you a patch
5.1) if you cannot apply the patch in trunk then 5) again
6) the ticket holder closes the ticket making a reference to the
revision in trunk.

Point 1) and 2) can be optional? could a user open the ticket right away?

For me a plus of a ticket system would be the automatic assignement of
tickets to developers based on the area of the problem
or some other criteria.

Of course there is some work for Massimo... for instance finding
stalled tickets and bashing lazy developers ;)
One advantage would be that users can search for similar bugs in
googlecode and see that they are already fixed at
some revision and would check that they have updated their copy of
web2py before asking.
Also the changelog of a stable release could include a list of closed
tickets (do not know how on googlecode, but *there must be some
way*!!).

BTW: patch generation should be something with a procedure by itself,
using plain files or others means such as mercurial

mic

2010/8/25 mdipierro :
> we do use googlecode for not. Here is the current (imperfect) process:
>
> 1) people post a question about a possible bug
> 2) somebody checks that it is a bug, usually me
> 3) if the bug does not get fixed in 24h, the original poster opens a
> googlecode ticket
> 4) when the bug is fixed the ticket is closed
>
> because many bugs are dealt with in <24hrs there is no record. Because
> bugs are fixed in trunk and trunk takes a couple of weeks to become
> steable and because most users never upgrade to the latest stable,
> occasionally there are multiple questions related to the same fixed
> bug. I am not sure better workflow management fixes this latter
> problem.
>
> I have not read all messages on this thread carefully yet. Eventually
> I will but I am happy to hear more of your ideas.
>
>
> On Aug 24, 5: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] I feel shame for asking... but I would like to resolve this

2010-08-25 Thread mart
Hi All,

I was thinking that should have any problems here... but I am :(...
So, I have an app that generates templates for the younger violinists.
These templates are based on their violin scale length (distance
between nut & bridge). It will calculate the position makers (those
striped pieces of tape they put on the finger board that tell them
where exactly they put their fingers). The output is a PDF file (pdf
because with a good pdf client, they should be able to turn off
"scaling" for printing purposes - the printed pdf needs to be exact).
I use flex & iFrames, which gives me a html file which I can display
as a separate page, but I really want that page embedded within the
app's layout (if that makes any sense?) . Because I am using
iFrames with Flex (which embeds the PDF), I need to embed the
resulting HTML (not the .swf)

I have tried quite a few things (which you know... broke the app,or
made it do silly things, etc...). Can someone help? :) I'm sure I am
missing something really silly but, I'm not seeing it :(

Thanks,
Mart :)


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

2010-08-25 Thread mart
bug tracking app is available on web2py.com? I think opening a bug
should be the first that happens possible to add validation code
within the bug tracking as a first layer filter (is this /or hast this
ever been a bug ?) or... perhaps an easy way for users for query the
db.bug_history (perhaps optimal in this case?)

Mart :)

On Aug 25, 1:10 pm, Michele Comitini 
wrote:
> Point 2) is nice for all of us because you (Massimo) are very quick,
> but how much does take off of your web2py time?
> Would not be better to open the ticket before testing and eventually
> close it as "works for me"?
> This way someone among the developers  could take care of the ticket
> and test it, if he is able to fix it good, he makes a patch
> and he closes it when the patch is put in the trunk (by you).  In case
> the patch cannot be applied either you have time to fix it
> or inform the submitter to fix it.
>
> A slight modified version of the process (very imperfect):
>
> 1) people post a question about a possible bug
> 2) if it looks (without test) like it, you (or a developer) ask them
> to open a ticket
> 3) you or a developer take care of the ticket (becoming the ticket
> holder) locking others out
> 4) the holder tests: if it is not a bug then 6)
> 5) you fix it in trunk or a developer sends you a patch
> 5.1) if you cannot apply the patch in trunk then 5) again
> 6) the ticket holder closes the ticket making a reference to the
> revision in trunk.
>
> Point 1) and 2) can be optional? could a user open the ticket right away?
>
> For me a plus of a ticket system would be the automatic assignement of
> tickets to developers based on the area of the problem
> or some other criteria.
>
> Of course there is some work for Massimo... for instance finding
> stalled tickets and bashing lazy developers ;)
> One advantage would be that users can search for similar bugs in
> googlecode and see that they are already fixed at
> some revision and would check that they have updated their copy of
> web2py before asking.
> Also the changelog of a stable release could include a list of closed
> tickets (do not know how on googlecode, but *there must be some
> way*!!).
>
> BTW: patch generation should be something with a procedure by itself,
> using plain files or others means such as mercurial
>
> mic
>
> 2010/8/25 mdipierro :
>
>
>
>
>
> > we do use googlecode for not. Here is the current (imperfect) process:
>
> > 1) people post a question about a possible bug
> > 2) somebody checks that it is a bug, usually me
> > 3) if the bug does not get fixed in 24h, the original poster opens a
> > googlecode ticket
> > 4) when the bug is fixed the ticket is closed
>
> > because many bugs are dealt with in <24hrs there is no record. Because
> > bugs are fixed in trunk and trunk takes a couple of weeks to become
> > steable and because most users never upgrade to the latest stable,
> > occasionally there are multiple questions related to the same fixed
> > bug. I am not sure better workflow management fixes this latter
> > problem.
>
> > I have not read all messages on this thread carefully yet. Eventually
> > I will but I am happy to hear more of your ideas.
>
> > On Aug 24, 5: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)...


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

2010-08-25 Thread Alexandre Andrade
Since we can se the web2py tickets as bugs (of our apps), its be nice to
incorporate a management of this tickets, not only registering them.



2010/8/25 mart 

> bug tracking app is available on web2py.com? I think opening a bug
> should be the first that happens possible to add validation code
> within the bug tracking as a first layer filter (is this /or hast this
> ever been a bug ?) or... perhaps an easy way for users for query the
> db.bug_history (perhaps optimal in this case?)
>
> Mart :)
>
> On Aug 25, 1:10 pm, Michele Comitini 
> wrote:
> > Point 2) is nice for all of us because you (Massimo) are very quick,
> > but how much does take off of your web2py time?
> > Would not be better to open the ticket before testing and eventually
> > close it as "works for me"?
> > This way someone among the developers  could take care of the ticket
> > and test it, if he is able to fix it good, he makes a patch
> > and he closes it when the patch is put in the trunk (by you).  In case
> > the patch cannot be applied either you have time to fix it
> > or inform the submitter to fix it.
> >
> > A slight modified version of the process (very imperfect):
> >
> > 1) people post a question about a possible bug
> > 2) if it looks (without test) like it, you (or a developer) ask them
> > to open a ticket
> > 3) you or a developer take care of the ticket (becoming the ticket
> > holder) locking others out
> > 4) the holder tests: if it is not a bug then 6)
> > 5) you fix it in trunk or a developer sends you a patch
> > 5.1) if you cannot apply the patch in trunk then 5) again
> > 6) the ticket holder closes the ticket making a reference to the
> > revision in trunk.
> >
> > Point 1) and 2) can be optional? could a user open the ticket right away?
> >
> > For me a plus of a ticket system would be the automatic assignement of
> > tickets to developers based on the area of the problem
> > or some other criteria.
> >
> > Of course there is some work for Massimo... for instance finding
> > stalled tickets and bashing lazy developers ;)
> > One advantage would be that users can search for similar bugs in
> > googlecode and see that they are already fixed at
> > some revision and would check that they have updated their copy of
> > web2py before asking.
> > Also the changelog of a stable release could include a list of closed
> > tickets (do not know how on googlecode, but *there must be some
> > way*!!).
> >
> > BTW: patch generation should be something with a procedure by itself,
> > using plain files or others means such as mercurial
> >
> > mic
> >
> > 2010/8/25 mdipierro :
> >
> >
> >
> >
> >
> > > we do use googlecode for not. Here is the current (imperfect) process:
> >
> > > 1) people post a question about a possible bug
> > > 2) somebody checks that it is a bug, usually me
> > > 3) if the bug does not get fixed in 24h, the original poster opens a
> > > googlecode ticket
> > > 4) when the bug is fixed the ticket is closed
> >
> > > because many bugs are dealt with in <24hrs there is no record. Because
> > > bugs are fixed in trunk and trunk takes a couple of weeks to become
> > > steable and because most users never upgrade to the latest stable,
> > > occasionally there are multiple questions related to the same fixed
> > > bug. I am not sure better workflow management fixes this latter
> > > problem.
> >
> > > I have not read all messages on this thread carefully yet. Eventually
> > > I will but I am happy to hear more of your ideas.
> >
> > > On Aug 24, 5: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 i

Re: [web2py] Dropdown List with Select

2010-08-25 Thread Jean-Guy
I am not exactly sure of what you are looking for... Better if you send 
specific code of your model, controler and views...


You can Change the ID representation that way :

db.auth_membership.user_id.requires=IS_IN_DB(db,'auth_user.id','%(first_name)s 
%(last_name)s (%(id)s)')


That generate a drop down...


db.auth_membership.user_id.represent=lambda value: "%(first_name)s 
%(last_name)s (%(id)s)" %db.auth_user.id[value]


Not pretty sure of the last one syntax...

That should be in your model... Since it is for the auth_TABLE you have 
to define your table that are not define explicitly by default... Here 
the specific section of the book on the subject : 
http://web2py.com/book/default/chapter/08


Section :


 Customizing |Auth|


At the end for you redirection, I think that you have to make a custom 
jquery script. It could be nice if you develop a script to post it on 
the list, so other will be able to reuse it.


Jonhy



On 2010-08-23 11:01, David wrote:

ow do I pull the different names from the model, with their ID and
build a dropdown that auto selects to the next page?

   




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

2010-08-25 Thread mart
yes, in any bug tracking system, "work on bug" data is provided by
assigned dev user (status/fix description/fix available in build X/
etc.).

Mart :)


On Aug 25, 1:23 pm, Alexandre Andrade 
wrote:
> Since we can se the web2py tickets as bugs (of our apps), its be nice to
> incorporate a management of this tickets, not only registering them.
>
> 2010/8/25 mart 
>
>
>
> > bug tracking app is available on web2py.com? I think opening a bug
> > should be the first that happens possible to add validation code
> > within the bug tracking as a first layer filter (is this /or hast this
> > ever been a bug ?) or... perhaps an easy way for users for query the
> > db.bug_history (perhaps optimal in this case?)
>
> > Mart :)
>
> > On Aug 25, 1:10 pm, Michele Comitini 
> > wrote:
> > > Point 2) is nice for all of us because you (Massimo) are very quick,
> > > but how much does take off of your web2py time?
> > > Would not be better to open the ticket before testing and eventually
> > > close it as "works for me"?
> > > This way someone among the developers  could take care of the ticket
> > > and test it, if he is able to fix it good, he makes a patch
> > > and he closes it when the patch is put in the trunk (by you).  In case
> > > the patch cannot be applied either you have time to fix it
> > > or inform the submitter to fix it.
>
> > > A slight modified version of the process (very imperfect):
>
> > > 1) people post a question about a possible bug
> > > 2) if it looks (without test) like it, you (or a developer) ask them
> > > to open a ticket
> > > 3) you or a developer take care of the ticket (becoming the ticket
> > > holder) locking others out
> > > 4) the holder tests: if it is not a bug then 6)
> > > 5) you fix it in trunk or a developer sends you a patch
> > > 5.1) if you cannot apply the patch in trunk then 5) again
> > > 6) the ticket holder closes the ticket making a reference to the
> > > revision in trunk.
>
> > > Point 1) and 2) can be optional? could a user open the ticket right away?
>
> > > For me a plus of a ticket system would be the automatic assignement of
> > > tickets to developers based on the area of the problem
> > > or some other criteria.
>
> > > Of course there is some work for Massimo... for instance finding
> > > stalled tickets and bashing lazy developers ;)
> > > One advantage would be that users can search for similar bugs in
> > > googlecode and see that they are already fixed at
> > > some revision and would check that they have updated their copy of
> > > web2py before asking.
> > > Also the changelog of a stable release could include a list of closed
> > > tickets (do not know how on googlecode, but *there must be some
> > > way*!!).
>
> > > BTW: patch generation should be something with a procedure by itself,
> > > using plain files or others means such as mercurial
>
> > > mic
>
> > > 2010/8/25 mdipierro :
>
> > > > we do use googlecode for not. Here is the current (imperfect) process:
>
> > > > 1) people post a question about a possible bug
> > > > 2) somebody checks that it is a bug, usually me
> > > > 3) if the bug does not get fixed in 24h, the original poster opens a
> > > > googlecode ticket
> > > > 4) when the bug is fixed the ticket is closed
>
> > > > because many bugs are dealt with in <24hrs there is no record. Because
> > > > bugs are fixed in trunk and trunk takes a couple of weeks to become
> > > > steable and because most users never upgrade to the latest stable,
> > > > occasionally there are multiple questions related to the same fixed
> > > > bug. I am not sure better workflow management fixes this latter
> > > > problem.
>
> > > > I have not read all messages on this thread carefully yet. Eventually
> > > > I will but I am happy to hear more of your ideas.
>
> > > > On Aug 24, 5: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 pa

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

2010-08-25 Thread Michele Comitini
*plugin_wiki*  could be used as a basis for this eventual bugtraker?

2010/8/25 mart :
> yes, in any bug tracking system, "work on bug" data is provided by
> assigned dev user (status/fix description/fix available in build X/
> etc.).
>
> Mart :)
>
>
> On Aug 25, 1:23 pm, Alexandre Andrade 
> wrote:
>> Since we can se the web2py tickets as bugs (of our apps), its be nice to
>> incorporate a management of this tickets, not only registering them.
>>
>> 2010/8/25 mart 
>>
>>
>>
>> > bug tracking app is available on web2py.com? I think opening a bug
>> > should be the first that happens possible to add validation code
>> > within the bug tracking as a first layer filter (is this /or hast this
>> > ever been a bug ?) or... perhaps an easy way for users for query the
>> > db.bug_history (perhaps optimal in this case?)
>>
>> > Mart :)
>>
>> > On Aug 25, 1:10 pm, Michele Comitini 
>> > wrote:
>> > > Point 2) is nice for all of us because you (Massimo) are very quick,
>> > > but how much does take off of your web2py time?
>> > > Would not be better to open the ticket before testing and eventually
>> > > close it as "works for me"?
>> > > This way someone among the developers  could take care of the ticket
>> > > and test it, if he is able to fix it good, he makes a patch
>> > > and he closes it when the patch is put in the trunk (by you).  In case
>> > > the patch cannot be applied either you have time to fix it
>> > > or inform the submitter to fix it.
>>
>> > > A slight modified version of the process (very imperfect):
>>
>> > > 1) people post a question about a possible bug
>> > > 2) if it looks (without test) like it, you (or a developer) ask them
>> > > to open a ticket
>> > > 3) you or a developer take care of the ticket (becoming the ticket
>> > > holder) locking others out
>> > > 4) the holder tests: if it is not a bug then 6)
>> > > 5) you fix it in trunk or a developer sends you a patch
>> > > 5.1) if you cannot apply the patch in trunk then 5) again
>> > > 6) the ticket holder closes the ticket making a reference to the
>> > > revision in trunk.
>>
>> > > Point 1) and 2) can be optional? could a user open the ticket right away?
>>
>> > > For me a plus of a ticket system would be the automatic assignement of
>> > > tickets to developers based on the area of the problem
>> > > or some other criteria.
>>
>> > > Of course there is some work for Massimo... for instance finding
>> > > stalled tickets and bashing lazy developers ;)
>> > > One advantage would be that users can search for similar bugs in
>> > > googlecode and see that they are already fixed at
>> > > some revision and would check that they have updated their copy of
>> > > web2py before asking.
>> > > Also the changelog of a stable release could include a list of closed
>> > > tickets (do not know how on googlecode, but *there must be some
>> > > way*!!).
>>
>> > > BTW: patch generation should be something with a procedure by itself,
>> > > using plain files or others means such as mercurial
>>
>> > > mic
>>
>> > > 2010/8/25 mdipierro :
>>
>> > > > we do use googlecode for not. Here is the current (imperfect) process:
>>
>> > > > 1) people post a question about a possible bug
>> > > > 2) somebody checks that it is a bug, usually me
>> > > > 3) if the bug does not get fixed in 24h, the original poster opens a
>> > > > googlecode ticket
>> > > > 4) when the bug is fixed the ticket is closed
>>
>> > > > because many bugs are dealt with in <24hrs there is no record. Because
>> > > > bugs are fixed in trunk and trunk takes a couple of weeks to become
>> > > > steable and because most users never upgrade to the latest stable,
>> > > > occasionally there are multiple questions related to the same fixed
>> > > > bug. I am not sure better workflow management fixes this latter
>> > > > problem.
>>
>> > > > I have not read all messages on this thread carefully yet. Eventually
>> > > > I will but I am happy to hear more of your ideas.
>>
>> > > > On Aug 24, 5: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

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

2010-08-25 Thread mart
What a great thing! Now we just need to define requirements... Someone
should lead this to avoid problems... (N cooks in one kitchen where N
should = 1) Michele is it? :)

Mart :)

On Aug 25, 1:52 pm, Michele Comitini 
wrote:
> *plugin_wiki*  could be used as a basis for this eventual bugtraker?
>
> 2010/8/25 mart :
>
> > yes, in any bug tracking system, "work on bug" data is provided by
> > assigned dev user (status/fix description/fix available in build X/
> > etc.).
>
> > Mart :)
>
> > On Aug 25, 1:23 pm, Alexandre Andrade 
> > wrote:
> >> Since we can se the web2py tickets as bugs (of our apps), its be nice to
> >> incorporate a management of this tickets, not only registering them.
>
> >> 2010/8/25 mart 
>
> >> > bug tracking app is available on web2py.com? I think opening a bug
> >> > should be the first that happens possible to add validation code
> >> > within the bug tracking as a first layer filter (is this /or hast this
> >> > ever been a bug ?) or... perhaps an easy way for users for query the
> >> > db.bug_history (perhaps optimal in this case?)
>
> >> > Mart :)
>
> >> > On Aug 25, 1:10 pm, Michele Comitini 
> >> > wrote:
> >> > > Point 2) is nice for all of us because you (Massimo) are very quick,
> >> > > but how much does take off of your web2py time?
> >> > > Would not be better to open the ticket before testing and eventually
> >> > > close it as "works for me"?
> >> > > This way someone among the developers  could take care of the ticket
> >> > > and test it, if he is able to fix it good, he makes a patch
> >> > > and he closes it when the patch is put in the trunk (by you).  In case
> >> > > the patch cannot be applied either you have time to fix it
> >> > > or inform the submitter to fix it.
>
> >> > > A slight modified version of the process (very imperfect):
>
> >> > > 1) people post a question about a possible bug
> >> > > 2) if it looks (without test) like it, you (or a developer) ask them
> >> > > to open a ticket
> >> > > 3) you or a developer take care of the ticket (becoming the ticket
> >> > > holder) locking others out
> >> > > 4) the holder tests: if it is not a bug then 6)
> >> > > 5) you fix it in trunk or a developer sends you a patch
> >> > > 5.1) if you cannot apply the patch in trunk then 5) again
> >> > > 6) the ticket holder closes the ticket making a reference to the
> >> > > revision in trunk.
>
> >> > > Point 1) and 2) can be optional? could a user open the ticket right 
> >> > > away?
>
> >> > > For me a plus of a ticket system would be the automatic assignement of
> >> > > tickets to developers based on the area of the problem
> >> > > or some other criteria.
>
> >> > > Of course there is some work for Massimo... for instance finding
> >> > > stalled tickets and bashing lazy developers ;)
> >> > > One advantage would be that users can search for similar bugs in
> >> > > googlecode and see that they are already fixed at
> >> > > some revision and would check that they have updated their copy of
> >> > > web2py before asking.
> >> > > Also the changelog of a stable release could include a list of closed
> >> > > tickets (do not know how on googlecode, but *there must be some
> >> > > way*!!).
>
> >> > > BTW: patch generation should be something with a procedure by itself,
> >> > > using plain files or others means such as mercurial
>
> >> > > mic
>
> >> > > 2010/8/25 mdipierro :
>
> >> > > > we do use googlecode for not. Here is the current (imperfect) 
> >> > > > process:
>
> >> > > > 1) people post a question about a possible bug
> >> > > > 2) somebody checks that it is a bug, usually me
> >> > > > 3) if the bug does not get fixed in 24h, the original poster opens a
> >> > > > googlecode ticket
> >> > > > 4) when the bug is fixed the ticket is closed
>
> >> > > > because many bugs are dealt with in <24hrs there is no record. 
> >> > > > Because
> >> > > > bugs are fixed in trunk and trunk takes a couple of weeks to become
> >> > > > steable and because most users never upgrade to the latest stable,
> >> > > > occasionally there are multiple questions related to the same fixed
> >> > > > bug. I am not sure better workflow management fixes this latter
> >> > > > problem.
>
> >> > > > I have not read all messages on this thread carefully yet. Eventually
> >> > > > I will but I am happy to hear more of your ideas.
>
> >> > > > On Aug 24, 5: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 

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

2010-08-25 Thread Michele Comitini
I was thinking why not Mart?! ;-)

There is no need to rush. I would wait for more feedback and Massimo
ideas on this, in the midtime we can use googlecode better,
while *eventually* starting a web2py centric bugtracker...


2010/8/25 mart :
> What a great thing! Now we just need to define requirements... Someone
> should lead this to avoid problems... (N cooks in one kitchen where N
> should = 1) Michele is it? :)
>
> Mart :)
>
> On Aug 25, 1:52 pm, Michele Comitini 
> wrote:
>> *plugin_wiki*  could be used as a basis for this eventual bugtraker?
>>
>> 2010/8/25 mart :
>>
>> > yes, in any bug tracking system, "work on bug" data is provided by
>> > assigned dev user (status/fix description/fix available in build X/
>> > etc.).
>>
>> > Mart :)
>>
>> > On Aug 25, 1:23 pm, Alexandre Andrade 
>> > wrote:
>> >> Since we can se the web2py tickets as bugs (of our apps), its be nice to
>> >> incorporate a management of this tickets, not only registering them.
>>
>> >> 2010/8/25 mart 
>>
>> >> > bug tracking app is available on web2py.com? I think opening a bug
>> >> > should be the first that happens possible to add validation code
>> >> > within the bug tracking as a first layer filter (is this /or hast this
>> >> > ever been a bug ?) or... perhaps an easy way for users for query the
>> >> > db.bug_history (perhaps optimal in this case?)
>>
>> >> > Mart :)
>>
>> >> > On Aug 25, 1:10 pm, Michele Comitini 
>> >> > wrote:
>> >> > > Point 2) is nice for all of us because you (Massimo) are very quick,
>> >> > > but how much does take off of your web2py time?
>> >> > > Would not be better to open the ticket before testing and eventually
>> >> > > close it as "works for me"?
>> >> > > This way someone among the developers  could take care of the ticket
>> >> > > and test it, if he is able to fix it good, he makes a patch
>> >> > > and he closes it when the patch is put in the trunk (by you).  In case
>> >> > > the patch cannot be applied either you have time to fix it
>> >> > > or inform the submitter to fix it.
>>
>> >> > > A slight modified version of the process (very imperfect):
>>
>> >> > > 1) people post a question about a possible bug
>> >> > > 2) if it looks (without test) like it, you (or a developer) ask them
>> >> > > to open a ticket
>> >> > > 3) you or a developer take care of the ticket (becoming the ticket
>> >> > > holder) locking others out
>> >> > > 4) the holder tests: if it is not a bug then 6)
>> >> > > 5) you fix it in trunk or a developer sends you a patch
>> >> > > 5.1) if you cannot apply the patch in trunk then 5) again
>> >> > > 6) the ticket holder closes the ticket making a reference to the
>> >> > > revision in trunk.
>>
>> >> > > Point 1) and 2) can be optional? could a user open the ticket right 
>> >> > > away?
>>
>> >> > > For me a plus of a ticket system would be the automatic assignement of
>> >> > > tickets to developers based on the area of the problem
>> >> > > or some other criteria.
>>
>> >> > > Of course there is some work for Massimo... for instance finding
>> >> > > stalled tickets and bashing lazy developers ;)
>> >> > > One advantage would be that users can search for similar bugs in
>> >> > > googlecode and see that they are already fixed at
>> >> > > some revision and would check that they have updated their copy of
>> >> > > web2py before asking.
>> >> > > Also the changelog of a stable release could include a list of closed
>> >> > > tickets (do not know how on googlecode, but *there must be some
>> >> > > way*!!).
>>
>> >> > > BTW: patch generation should be something with a procedure by itself,
>> >> > > using plain files or others means such as mercurial
>>
>> >> > > mic
>>
>> >> > > 2010/8/25 mdipierro :
>>
>> >> > > > we do use googlecode for not. Here is the current (imperfect) 
>> >> > > > process:
>>
>> >> > > > 1) people post a question about a possible bug
>> >> > > > 2) somebody checks that it is a bug, usually me
>> >> > > > 3) if the bug does not get fixed in 24h, the original poster opens a
>> >> > > > googlecode ticket
>> >> > > > 4) when the bug is fixed the ticket is closed
>>
>> >> > > > because many bugs are dealt with in <24hrs there is no record. 
>> >> > > > Because
>> >> > > > bugs are fixed in trunk and trunk takes a couple of weeks to become
>> >> > > > steable and because most users never upgrade to the latest stable,
>> >> > > > occasionally there are multiple questions related to the same fixed
>> >> > > > bug. I am not sure better workflow management fixes this latter
>> >> > > > problem.
>>
>> >> > > > I have not read all messages on this thread carefully yet. 
>> >> > > > Eventually
>> >> > > > I will but I am happy to hear more of your ideas.
>>
>> >> > > > On Aug 24, 5: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 :-) ):
>> >> 

[web2py] Re: Web2py and threads

2010-08-25 Thread John Heenan
Even with file reading there is no way the disk drive, its controllers
and various buses can keep up with the CPU.

Hence reading any file from disk will cause the OS to intervene and
block (reading a template view file, controller file or otherwise),
albeit a 'short' time.

Here are two choices.

1) Put the read function in a thread, wait for the thread to unblock
and continue servicing any other threads that are no longer blocked.
This is what web2py does using a Python file read. The OS
automatically provides thread scheduling.

2) Tell the OS to pass a message to an event callback when the OS is
ready. A separate thread is not required if the application chooses to
process its own message queue as the thread in effect simply relays
the message on.

There is of course other blocks: file writing, database access and
network read and write (including from/to the http request PC)

It is tempting to say it is not rocket science.

Anyway the main message is being aware of the plumbing and avoiding
blind religious type fixations is important for long term planning and
scalability issues.

We really need to face up to realities that seeing Python as a black
box type total solution is not healthy.

John Heenan



On Aug 26, 2:27 am, mdipierro  wrote:
> On Aug 25, 11:00 am, Phyo Arkar  wrote:
>
> > Did I Read that reading files inside controller will block web2py , Does it?
>
> No web2py does not block. web2py only locks sessions that means one
> user cannot request two concurrent pages because there would be a race
> condition in saving sessions. Two user can request different pages
> which open the same file unless the file is explicitly locked by your
> code.
>
> > Thats a bad news.. i am doing a file crawler and while crawling ,
> > web2py is blocked even tho the process talke only 25% of 1 out of 4
> > CPUs ..
>
> Tell us more or I cannot help.
>
>
>
> > On 8/25/10, pierreth  wrote:
>
> > > I would appreciate a good reference to understand the concepts you are
> > > talking about. It is something new to me and I don't understand.
>
> > > On 25 août, 11:22, John Heenan  wrote:
> > >> No, nothing that abstract. Using WSGI forces a new thread for each
> > >> request. This is is a simple and inefficient brute force approach that
> > >> really only suits the simplest Python applications and where only a
> > >> small number of concurrent connection might be expected.
>
> > >> Any application that provides web services is going to OS block on
> > >> file reading (and writing) and on database access. Using threads is a
> > >> classic and easy way out that carries a lot of baggage. Windows has
> > >> had a way out of this for years with its asynch (or event)
> > >> notification set up through an OVERLAPPED structure.
>
> > >> Lightttpd makes use of efficient event notification schemes like
> > >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> > >> Alives.
>
> > >> No matter how careful one is with threads and processes there always
> > >> appears to be unexpected gotchas. Python has a notorious example, the
> > >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> > >> there is a single experienced Python user that trusts the GIL.
>
> > >> John Heenan


[web2py] Re: Ajax Long Pooling (comet)

2010-08-25 Thread Candid
My recipe:

- Run the resource extensive function in a separate process.
- Use dedicated comet server for progress bar notifications. I highly
recommend Orbited.

On Aug 25, 11:21 am, Phyo Arkar  wrote:
> Hello Web2py
>
> I am running the resource extensive function , which is extracting
> every archive , parse text out of every file under there and then
> inserting into database.
>
> But i want to make an ajax progressbar , by polling at specific
> interval. But it wont work as web2py
>
> How can i achieve this?
>
> 1) Long Polling , is that supported in web2py ? (rocket supports it)
>
> 2) Fork the function ? how can i achieve this?
>
> 3) May be run it as separate process?


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

2010-08-25 Thread Michele Comitini
why not have a dictionary?

controllers = {'route-me-if-you-can': any_time_you_want}
if lookup misses method name is searched as it is?

The admin interface could expose a way to do it easy.

mic


2010/8/25 Jonathan Lundell :
> On Aug 25, 2010, at 1:42 AM, Kevin wrote:
>
>> It would be safe for the routing code to treat hyphens as underscores
>> when matching for app, controller, or function, though -- since web2py
>> (and python) semantics require that the code itself uses underscores.
>> Of course underscores in the rest of the URL would have to pass
>> through untouched.
>
> Are Python restrictions relevant for applications and controllers? Or just 
> filename restrictions? I'm not sure.
>
>>
>> Reverse translation is not an issue, since I could just do something
>> like:
>>
>> {{= DASH(URL(...)) }}
>>
>> Where DASH replaces all underscores with hyphens (which is acceptable
>> for me, since I don't use any underscores in URLs), though it would be
>> handy to make the routes.py configurable to do that automatically in
>> the URL call itself if I wanted.
>
> It could be an option to URL, I suppose. I'm thinking that you wouldn't want 
> to translate underscores in the query string.
>
>>
>> On Aug 24, 9:46 pm, Jonathan Lundell  wrote:
>>> 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-...
 *http://semicolons.org/post/256699383/friendly-urls
 *http://www.wordsellinc.com/blog/content-optimization/use-hyphens-not-...
>>>
 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: dashes in controller names?

2010-08-25 Thread Cory Coager
Add to the list:

* Hyphens are preferred to underscores for SEO,
http://www.google.com/support/webmasters/bin/answer.py?answer=76329&topic=15261

Can we make this a feature request?


[web2py] Web2Py on lighthttpd fastcgi - The definitive answer.

2010-08-25 Thread Pivert
Hi,

This is for 4h30 that I'm trying to install web2py on my dedicated
ubuntu server 10.04, and I'm really pissed off.

What I want :
Have my remote server installed with lighttpd & fastcgi to server a
fresh install of web2py on port 80, with web2py in /var/www/web2py.

What I did :
I bought the pdf book, and starded there, but without luck : web2py is
working through fastcgi, but no color, like of there is no css
applied. I then started to test ALL examples found on google about
lighttpd config. ALL of them are buggy and immediately refused by
lighttpd at startup. Including the one in the web2py ebook. The
lighttpd.conf from ebook is refused because line 28 uses a = sign,
while it should probably be an =~.

Current result :
Web2Py is working through lighttpd, but no css applied. Only
black&white, no background, ...

My Questions :
- Please send us a basic lighttpd.conf that will successfully server
web2py through /tmp/fcgi.sock.
- Why does the eBook contins the line :
 server.error-handler-404 = "/test.fcgi"
 while /test.fcgi does not exists.

Thanks.


[web2py] Re: Setting default groups for app

2010-08-25 Thread mdipierro
no. they are run at every request but overhead is neglibible

On Aug 25, 11:55 am, Antti  wrote:
> Thanks for your answer. I'll probably go for option 2). I suppose
> models are run only once upon startup?
>
> --
> Antti
>
> On Aug 25, 5:10 pm, mdipierro  wrote:
>
> > You have two options:
> > 1) create a scrpt and run it manually once
>
> > web2py.py -S yourapp -M -N -R script.py
>
> > 2) use a model like:
>
> > if no group exists:
> >     create missing groups and permissions
>
> > Massimo
>
> > On Aug 24, 7:14 am, Antti  wrote:
>
> > > Hi,
>
> > > What's the best practice in adding default groups and permissions for
> > > apps?
>
> > > Should I write a script which would add groups and permissions if they
> > > do not exist? And how to trigger it?
>
> > > cheers,
> > > Antti


Re: [web2py] Re: jqgrid and edit-link

2010-08-25 Thread Johann Spies
> Are you using plugin_jqgrid. If so please use widget jqgrid from
> plugin_wiki.

I don't know how to do it.  All the documentation refers to that usage
within wiki pages. I am not using a wiki in this case.

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


[web2py] Re: Web2py and threads

2010-08-25 Thread mdipierro
call

session._unlock()

if you do not need session locking

On Aug 25, 11:38 am, Phyo Arkar  wrote:
> Yes may be session was locked , thats why
> session.current=processing_path not working
>
> But then again , while processing files i try opening separate page ,
> to other controller , it was waited till the first (file Crawler) page
> finished parsing.
>
> ok i will make a separate thread about this.
>
> On 8/25/10, mdipierro  wrote:
>
>
>
> > On Aug 25, 11:00 am, Phyo Arkar  wrote:
> >> Did I Read that reading files inside controller will block web2py , Does
> >> it?
>
> > No web2py does not block. web2py only locks sessions that means one
> > user cannot request two concurrent pages because there would be a race
> > condition in saving sessions. Two user can request different pages
> > which open the same file unless the file is explicitly locked by your
> > code.
>
> >> Thats a bad news.. i am doing a file crawler and while crawling ,
> >> web2py is blocked even tho the process talke only 25% of 1 out of 4
> >> CPUs ..
>
> > Tell us more or I cannot help.
>
> >> On 8/25/10, pierreth  wrote:
>
> >> > I would appreciate a good reference to understand the concepts you are
> >> > talking about. It is something new to me and I don't understand.
>
> >> > On 25 août, 11:22, John Heenan  wrote:
> >> >> No, nothing that abstract. Using WSGI forces a new thread for each
> >> >> request. This is is a simple and inefficient brute force approach that
> >> >> really only suits the simplest Python applications and where only a
> >> >> small number of concurrent connection might be expected.
>
> >> >> Any application that provides web services is going to OS block on
> >> >> file reading (and writing) and on database access. Using threads is a
> >> >> classic and easy way out that carries a lot of baggage. Windows has
> >> >> had a way out of this for years with its asynch (or event)
> >> >> notification set up through an OVERLAPPED structure.
>
> >> >> Lightttpd makes use of efficient event notification schemes like
> >> >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> >> >> Alives.
>
> >> >> No matter how careful one is with threads and processes there always
> >> >> appears to be unexpected gotchas. Python has a notorious example, the
> >> >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> >> >> there is a single experienced Python user that trusts the GIL.
>
> >> >> John Heenan


[web2py] Re: Web2py and threads

2010-08-25 Thread mdipierro
the time to execute a typical web2py action my server is 10-20ms. The
time to open a file or write a small file is so small that is not
measurable. I am not sure I believe there is any issue here or perhaps
I do not understand the problem. Can you provide a test case?

On Aug 25, 2:11 pm, John Heenan  wrote:
> Even with file reading there is no way the disk drive, its controllers
> and various buses can keep up with the CPU.
>
> Hence reading any file from disk will cause the OS to intervene and
> block (reading a template view file, controller file or otherwise),
> albeit a 'short' time.
>
> Here are two choices.
>
> 1) Put the read function in a thread, wait for the thread to unblock
> and continue servicing any other threads that are no longer blocked.
> This is what web2py does using a Python file read. The OS
> automatically provides thread scheduling.
>
> 2) Tell the OS to pass a message to an event callback when the OS is
> ready. A separate thread is not required if the application chooses to
> process its own message queue as the thread in effect simply relays
> the message on.
>
> There is of course other blocks: file writing, database access and
> network read and write (including from/to the http request PC)
>
> It is tempting to say it is not rocket science.
>
> Anyway the main message is being aware of the plumbing and avoiding
> blind religious type fixations is important for long term planning and
> scalability issues.
>
> We really need to face up to realities that seeing Python as a black
> box type total solution is not healthy.
>
> John Heenan
>
> On Aug 26, 2:27 am, mdipierro  wrote:
>
> > On Aug 25, 11:00 am, Phyo Arkar  wrote:
>
> > > Did I Read that reading files inside controller will block web2py , Does 
> > > it?
>
> > No web2py does not block. web2py only locks sessions that means one
> > user cannot request two concurrent pages because there would be a race
> > condition in saving sessions. Two user can request different pages
> > which open the same file unless the file is explicitly locked by your
> > code.
>
> > > Thats a bad news.. i am doing a file crawler and while crawling ,
> > > web2py is blocked even tho the process talke only 25% of 1 out of 4
> > > CPUs ..
>
> > Tell us more or I cannot help.
>
> > > On 8/25/10, pierreth  wrote:
>
> > > > I would appreciate a good reference to understand the concepts you are
> > > > talking about. It is something new to me and I don't understand.
>
> > > > On 25 août, 11:22, John Heenan  wrote:
> > > >> No, nothing that abstract. Using WSGI forces a new thread for each
> > > >> request. This is is a simple and inefficient brute force approach that
> > > >> really only suits the simplest Python applications and where only a
> > > >> small number of concurrent connection might be expected.
>
> > > >> Any application that provides web services is going to OS block on
> > > >> file reading (and writing) and on database access. Using threads is a
> > > >> classic and easy way out that carries a lot of baggage. Windows has
> > > >> had a way out of this for years with its asynch (or event)
> > > >> notification set up through an OVERLAPPED structure.
>
> > > >> Lightttpd makes use of efficient event notification schemes like
> > > >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> > > >> Alives.
>
> > > >> No matter how careful one is with threads and processes there always
> > > >> appears to be unexpected gotchas. Python has a notorious example, the
> > > >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> > > >> there is a single experienced Python user that trusts the GIL.
>
> > > >> John Heenan


[web2py] Re: Web2Py on lighthttpd fastcgi - The definitive answer.

2010-08-25 Thread mdipierro
I will look into it. perhaps a typo in the book. I did not try
lighttpd myself.
Does this help?

http://web2pyslices.com/main/slices/take_slice/57

On Aug 25, 12:46 pm, Pivert  wrote:
> Hi,
>
> This is for 4h30 that I'm trying to install web2py on my dedicated
> ubuntu server 10.04, and I'm really pissed off.
>
> What I want :
> Have my remote server installed with lighttpd & fastcgi to server a
> fresh install of web2py on port 80, with web2py in /var/www/web2py.
>
> What I did :
> I bought the pdf book, and starded there, but without luck : web2py is
> working through fastcgi, but no color, like of there is no css
> applied. I then started to test ALL examples found on google about
> lighttpd config. ALL of them are buggy and immediately refused by
> lighttpd at startup. Including the one in the web2py ebook. The
> lighttpd.conf from ebook is refused because line 28 uses a = sign,
> while it should probably be an =~.
>
> Current result :
> Web2Py is working through lighttpd, but no css applied. Only
> black&white, no background, ...
>
> My Questions :
> - Please send us a basic lighttpd.conf that will successfully server
> web2py through /tmp/fcgi.sock.
> - Why does the eBook contins the line :
>  server.error-handler-404 = "/test.fcgi"
>  while /test.fcgi does not exists.
>
> Thanks.


[web2py] Re: jqgrid and edit-link

2010-08-25 Thread mdipierro
{{=plugin_wiki.widget('jqgrid',table='tablename')}}

the first argument is the widget name, the other named arguments are
the widgets attributes.

On Aug 25, 3:39 pm, Johann Spies  wrote:
> > Are you using plugin_jqgrid. If so please use widget jqgrid from
> > plugin_wiki.
>
> I don't know how to do it.  All the documentation refers to that usage
> within wiki pages. I am not using a wiki in this case.
>
> Regards
> Johann
> --
>     "Be not deceived; God is not mocked: for whatsoever a
>      man soweth, that shall he also reap."
>                                   Galatians 6:7


Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 1:41 PM, mdipierro wrote:
> 
> call
> 
> session._unlock()
> 
> if you do not need session locking

If you do that (without calling session.forget), what will happen in 
_try_store_on_disk when cPickle.dump(dict(self), response.session_file) is 
called with a None file argument? Or is cPickle.dump cool with that? Or am I 
misreading the logic?


> 
> On Aug 25, 11:38 am, Phyo Arkar  wrote:
>> Yes may be session was locked , thats why
>> session.current=processing_path not working
>> 
>> But then again , while processing files i try opening separate page ,
>> to other controller , it was waited till the first (file Crawler) page
>> finished parsing.
>> 
>> ok i will make a separate thread about this.
>> 
>> On 8/25/10, mdipierro  wrote:
>> 
>> 
>> 
>>> On Aug 25, 11:00 am, Phyo Arkar  wrote:
 Did I Read that reading files inside controller will block web2py , Does
 it?
>> 
>>> No web2py does not block. web2py only locks sessions that means one
>>> user cannot request two concurrent pages because there would be a race
>>> condition in saving sessions. Two user can request different pages
>>> which open the same file unless the file is explicitly locked by your
>>> code.
>> 
 Thats a bad news.. i am doing a file crawler and while crawling ,
 web2py is blocked even tho the process talke only 25% of 1 out of 4
 CPUs ..
>> 
>>> Tell us more or I cannot help.
>> 
 On 8/25/10, pierreth  wrote:
>> 
> I would appreciate a good reference to understand the concepts you are
> talking about. It is something new to me and I don't understand.
>> 
> On 25 août, 11:22, John Heenan  wrote:
>> No, nothing that abstract. Using WSGI forces a new thread for each
>> request. This is is a simple and inefficient brute force approach that
>> really only suits the simplest Python applications and where only a
>> small number of concurrent connection might be expected.
>> 
>> Any application that provides web services is going to OS block on
>> file reading (and writing) and on database access. Using threads is a
>> classic and easy way out that carries a lot of baggage. Windows has
>> had a way out of this for years with its asynch (or event)
>> notification set up through an OVERLAPPED structure.
>> 
>> Lightttpd makes use of efficient event notification schemes like
>> kqueue and epoll. Apache only uses such schemes for listening and Keep-
>> Alives.
>> 
>> No matter how careful one is with threads and processes there always
>> appears to be unexpected gotchas. Python has a notorious example, the
>> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
>> there is a single experienced Python user that trusts the GIL.
>> 
>> John Heenan




[web2py] Re: redirection question

2010-08-25 Thread howesc
i usually hard-code where i want the form to go after accept, but it
sounds like this does not work for you.

what about appending a var to the url that is where to go after:

http://foo.com/app/meetings/editmeeting/123?redir=app/home

would that work for you? (i have not tested if the var persists past
the form submit though, just a thought.

good luck,

cfh

On Aug 23, 7:44 am, "david.waldrop"  wrote:
> I have a basic update form code that is called via a HREF form another
> view and form a menu.  The problem is the redirect to the referrer is
> not working.  I looked in the forums and have tried to debug.  I
> understand the form is posting back to itself which is why the form is
> redirected to itself.  The forums offer several solutions that depend
> on a hidden form element embedded in the calling view which are save
> as request.vars.  I am not sure how to make this work with a menu.  I
> hope there is a clean elegant way to accomplish this.  Any help would
> be apprecaited..
>
> @auth.requires_login()
> def editmeeting():
>     if not request.args:
>         session.flash = 'Invalid parameter'
>         redirect(URL(r=request, c='default',
> f='index'))
>     meeting = db(db.meeting.id == request.args(0)).select()
>     if len(meeting):
>         meeting = meeting[0]
>     else:
>         session.flash = 'Invalid meeting'
>         redirect(URL(r=request,c='default',f='index'))
>     form=SQLFORM(db.meeting,meeting, submit_button='Update Meeting')
>     if form.accepts(request.vars, session):
>         redirect(request.env.http_referer)
>     elif form.errors:
>         response.flash = 'Invalid data.'
>     return dict(form=form)


[web2py] Re: Custom Forms validation

2010-08-25 Thread howesc
I'm a little lazy here, and think you can grab what you need by
looking at https://www.tenthrow.com/register/

(it's a site that i work on, so i'm ok with telling you to look at the
javascript there).  The page is created with a custom form (you can
inspect the HTML to see the custom classes etc), and the javascript
validates that it's a new email address, the password length is met,
and that the passwords match all before submit.

good luck!  and feel free to ask if you still have questions

christian

On Aug 25, 9:04 am, Francisco Costa  wrote:
> Hello,
> I would like to know if you can have ajax validators when using custom
> forms.
>
> I leave here an example of a view to change password:
>
>     {{form=auth.change_password(next=URL(r=request, c='default',
> f='login'))}}
>
>     {{=T('Change Password')}}
>     {{=form.custom.begin}}
>         
>             
>                 {{=T('Old Password:')}}  type="password" value="" name="old_password"
> id="no_table_old_password" class="password">
>             
>             
>                 {{=T('New Password:')}}  type="password" value="" name="new_password"
> id="no_table_new_password" class="password">
>             
>             
>                 {{=T('Verify Password:')}}  type="password" value="" name="new_password2"
> id="no_table_new_password2" class="password">
>             
>                  {{=form.custom.submit}}
>             
>         
>     {{=form.custom.end}}
>
> In this case what i wanted is something that validates the old
> password and that the new and verief password are the same.
>
> Thank you


Re: [web2py] Re: Currency formating

2010-08-25 Thread Bruno Rocha
I solved using temporarily this:

def Moeda(valor, formatado=True):
from locale import setlocale, currency, LC_ALL
try:
setlocale(LC_ALL,'pt_BR.UTF-8')
except:
setlocale(LC_ALL,'portuguese')

if formatado:
return 'R$ %s' % currency(valor, grouping=True, symbol=False)
else:
return currency(valor, grouping=False, symbol=False).replace(',','')


>>> Moeda(1)
R$ 10.000,00

This will be okay until I have more apps running on the same server, now I
have just one.

I am trying to figure out the best way

2010/8/25 Bruno Rocha 

> Massimo,
>
> What is your recomendation to deal with currency in web2py?
>
> 2010/8/25 Bruno Rocha 
>
> Look at
>> http://code.google.com/p/python-money/source/browse/trunk/money/Money.py
>>
>> Python-money does not use "locale"
>>
>> 2010/8/25 mdipierro 
>>
>> web2py cannot support locale because it is not thread safe, If one app
>>> changes the locale it would change it for all apps.
>>>
>>> On Aug 25, 12:07 am, Bruno Rocha  wrote:
>>> > Hi,
>>> >
>>> > Actually, I am using these methods to work with money formating.
>>> >
>>> > some tries with python-money and works very wellhttp://
>>> 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?
>>>
>>
>>
>>
>> --
>>
>> http://rochacbruno.com.br
>>
>
>
>
> --
>
> http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br


[web2py] Re: I feel shame for asking... but I would like to resolve this

2010-08-25 Thread howesc
i don't know flex or any of that.but can you call those tools that
generate the HTML from your controller, get the HTML back and return
that from the controller?

def get_spiffy_html():
  html = my_call_to_magic_stuff_that_makes_html()
  return html

or if you want to embed it in a layout:

def get_spiffy_html():
  html = my_call_to_magic_stuff_that_makes_html()
  return dict(thecode = XML(html))

does something like that work for you?


On Aug 25, 10:13 am, mart  wrote:
> Hi All,
>
> I was thinking that should have any problems here... but I am :(...
> So, I have an app that generates templates for the younger violinists.
> These templates are based on their violin scale length (distance
> between nut & bridge). It will calculate the position makers (those
> striped pieces of tape they put on the finger board that tell them
> where exactly they put their fingers). The output is a PDF file (pdf
> because with a good pdf client, they should be able to turn off
> "scaling" for printing purposes - the printed pdf needs to be exact).
> I use flex & iFrames, which gives me a html file which I can display
> as a separate page, but I really want that page embedded within the
> app's layout (if that makes any sense?) . Because I am using
> iFrames with Flex (which embeds the PDF), I need to embed the
> resulting HTML (not the .swf)
>
> I have tried quite a few things (which you know... broke the app,or
> made it do silly things, etc...). Can someone help? :) I'm sure I am
> missing something really silly but, I'm not seeing it :(
>
> Thanks,
> Mart :)


Re: [web2py] Re: jqgrid and edit-link

2010-08-25 Thread Johann Spies
On 25 August 2010 22:51, mdipierro  wrote:
> {{=plugin_wiki.widget('jqgrid',table='tablename')}}
>
> the first argument is the widget name, the other named arguments are
> the widgets attributes.

Thanks.  My first try did not work.  I will have to read up on what
"the other named arguments"  are supposed to be.  "columns = "  did
not work in this case:
TypeError: jqgrid() got an unexpected keyword argument 'columns'

Regards
Johann


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


Re: [web2py] page layout patterns

2010-08-25 Thread Jean-Guy

Nice post!

J

On 2010-08-25 16:34, mdipierro wrote:

http://designingwebinterfaces.com/designing-web-interfaces-12-screen-patterns
   




Re: [web2py] Re: Web2Py on lighthttpd fastcgi - The definitive answer.

2010-08-25 Thread François Delpierre
YES !

This did it.

There is just a typo about the path to web2py.
After testing all parameters separately, I found that my problem was comming
from the missing line :

include_shell "/usr/share/lighttpd/create-mime.assign.pl"

Thanks a lot !

Regards,


On Wed, Aug 25, 2010 at 10:50 PM, mdipierro  wrote:

> I will look into it. perhaps a typo in the book. I did not try
> lighttpd myself.
> Does this help?
>
> http://web2pyslices.com/main/slices/take_slice/57
>
> On Aug 25, 12:46 pm, Pivert  wrote:
> > Hi,
> >
> > This is for 4h30 that I'm trying to install web2py on my dedicated
> > ubuntu server 10.04, and I'm really pissed off.
> >
> > What I want :
> > Have my remote server installed with lighttpd & fastcgi to server a
> > fresh install of web2py on port 80, with web2py in /var/www/web2py.
> >
> > What I did :
> > I bought the pdf book, and starded there, but without luck : web2py is
> > working through fastcgi, but no color, like of there is no css
> > applied. I then started to test ALL examples found on google about
> > lighttpd config. ALL of them are buggy and immediately refused by
> > lighttpd at startup. Including the one in the web2py ebook. The
> > lighttpd.conf from ebook is refused because line 28 uses a = sign,
> > while it should probably be an =~.
> >
> > Current result :
> > Web2Py is working through lighttpd, but no css applied. Only
> > black&white, no background, ...
> >
> > My Questions :
> > - Please send us a basic lighttpd.conf that will successfully server
> > web2py through /tmp/fcgi.sock.
> > - Why does the eBook contins the line :
> >  server.error-handler-404 = "/test.fcgi"
> >  while /test.fcgi does not exists.
> >
> > Thanks.
>


[web2py] Re: Web2py and threads

2010-08-25 Thread John Heenan
Linux lost a PR war over the exact same issue that I am addressing
now.

The point is being aware of issues surrounding the scalability of
services associated with using far more OS resources than required and
at more risk.

The tiny amount of time a single thread, thread A, may be blocked
during a read is not the point. The OS is still going to block and do
expensive context switches that allow other threads to run before
examining if thread A should be allowed to unblock. If the server is
heavily loaded then it could be quite some time before thread A
unblocks due to the large amount of total time other unblocked thread
consume before they block again.

However in the context of the the Python GIL works, it is is not even
as simple as above because the GIL imposes another layer

In objective tests, using the OS to notify an OS mediated action is
ready beats using multiple threads that just become unblocked. For
example Lightttpd beats Apache when serving static files with lots of
concurrent connections. Lighttpd can serve up to 10,000 concurrent
connections. Lighttpd uses event notification to service http
requests, so allowing Lighttpd to know when the OS is finished with
some action that would block a thread if actioned synchronously.
Apache wastefully uses a separate thread for each separate request and
allows the OS to unblock threads that expect synchronous action..

Years ago there was a big PR war between Windows and Linux. There was
a hell of a lot riding on the outcome of web server scaling tests and
the war got an awful lot of attention in the computer media. Linux had
God like status. The Linux zealots were absolutely convinced tests
would show Linux would beat what they regarded as inferior Windows
bloat and poor design. They had the journalists convinced and everyone
else convinced the tests would be just a formality that would prove
Linux was superior and would formally justify the utter contempt
Windows was held in. Linux advocates got their best people. Linux
lost. After the tests Linux lost its God like status in the media,
really just became another side show and never recovered.

So what went wrong for Linux? Simple I reckon. Microsoft had an API
that allowed the OS to notify a process asynchronously that data was
ready. Linux at the time did not and relied on its antique UNIX select
function to allow threads to block. At small scale there is little
effective difference. However Apache was unable to scale as well as
the Microsoft IIS web server.

John Heenan


On Aug 26, 6:46 am, mdipierro  wrote:
> the time to execute a typical web2py action my server is 10-20ms. The
> time to open a file or write a small file is so small that is not
> measurable. I am not sure I believe there is any issue here or perhaps
> I do not understand the problem. Can you provide a test case?
>
> On Aug 25, 2:11 pm, John Heenan  wrote:
>
> > Even with file reading there is no way the disk drive, its controllers
> > and various buses can keep up with the CPU.
>
> > Hence reading any file from disk will cause the OS to intervene and
> > block (reading a template view file, controller file or otherwise),
> > albeit a 'short' time.
>
> > Here are two choices.
>
> > 1) Put the read function in a thread, wait for the thread to unblock
> > and continue servicing any other threads that are no longer blocked.
> > This is what web2py does using a Python file read. The OS
> > automatically provides thread scheduling.
>
> > 2) Tell the OS to pass a message to an event callback when the OS is
> > ready. A separate thread is not required if the application chooses to
> > process its own message queue as the thread in effect simply relays
> > the message on.
>
> > There is of course other blocks: file writing, database access and
> > network read and write (including from/to the http request PC)
>
> > It is tempting to say it is not rocket science.
>
> > Anyway the main message is being aware of the plumbing and avoiding
> > blind religious type fixations is important for long term planning and
> > scalability issues.
>
> > We really need to face up to realities that seeing Python as a black
> > box type total solution is not healthy.
>
> > John Heenan
>
> > On Aug 26, 2:27 am, mdipierro  wrote:
>
> > > On Aug 25, 11:00 am, Phyo Arkar  wrote:
>
> > > > Did I Read that reading files inside controller will block web2py , 
> > > > Does it?
>
> > > No web2py does not block. web2py only locks sessions that means one
> > > user cannot request two concurrent pages because there would be a race
> > > condition in saving sessions. Two user can request different pages
> > > which open the same file unless the file is explicitly locked by your
> > > code.
>
> > > > Thats a bad news.. i am doing a file crawler and while crawling ,
> > > > web2py is blocked even tho the process talke only 25% of 1 out of 4
> > > > CPUs ..
>
> > > Tell us more or I cannot help.
>
> > > > On 8/25/10, pierreth  wrote:
>
> > > > > I would appreciate a good 

[web2py] Re: WikiYou - Showcase

2010-08-25 Thread GoldenTiger
>>Can you explain how you tested the url mapping in development.  I have
>>a similar architecture and am not sure how to test the url mapping
>>using localhost.

Just point a DNS record to localhost :

localhost.domain.com   A  127.0.0.1



[web2py] Re: dashes in controller names?

2010-08-25 Thread Kevin
On Aug 25, 1:13 pm, Michele Comitini 
wrote:
> why not have a dictionary?
>
> controllers = {'route-me-if-you-can': any_time_you_want}
> if lookup misses method name is searched as it is?

That would be a viable alternative to routes, except it's not
desirable to have to hand-code routes except when you want to do
something 'special' -- hyphens on the web are quickly becoming more
common then underscores.

> > Are Python restrictions relevant for applications and controllers? Or just 
> > filename restrictions? I'm not sure.

Generally speaking, no restrictions are relevant (not even filename
restrictions) except for total URL length (all typical servers have
some maximum URL length that they'll handle, as do browsers).
However, url-encoded paths (like /some%20where/over/there) are to be
avoided at all costs.  Pretty much [a-zA-Z0-9/_~.-] are the characters
that are commonly used in URLs (not counting ?, &, and = for query
strings), with strict lower-case only or camel-case both being trendy
in that order, and with hyphens showing up better underlined links
unlike underscores.

If possible, it's especially good practice provide only URLs that
users can write down easily, such as ,
and especially favoring ones that are self descriptive, like , for obvious reasons (I
personally consider hybridized URLs like  to be junk because there are two unique
identifiers in the URL).


[web2py] Re: Web2py with barcode Reader

2010-08-25 Thread Kevin
A common occurrence is for barcode readers to simply 'type' the
decoded value as if it were a keyboard, if there isn't some (usually
proprietary) software running that steals that input on the driver-api
level.

Note that this also commonly occurs with many magnetic card readers --
no special software needed, as it acts like a USB Human-input-device
by default.

In such a case (assuming the browser window has focus), you can just
read key events on the document object in javascript -- after a
hardcoded input length has been read, or a timeout of say 1 second
since the last 'keypress', you submit an ajax event.  However,
distinguishing between the barcode reader and a *real* keyboard is
something you have to watch out for.  On the other hand, you can
intentionally not distinguish between *real* and barcode-reader
'keyboards', and transparently handle manually typed barcodes when it
won't scan.

The simplest solution is just to make a regular text input that you
give focus to when the page loads so that the user can see the value
that's being scanned.



If you are using proprietary software or whatever, then it does get
really tricky and Alexey and Michele's advice is as good as it gets
unless you want to write a Java applet or ActiveX control, for
example.

On Aug 25, 3:59 am, Michele Comitini 
wrote:
> Is the barcode reader connected on the same machine running web2py?
>
> If yes you just need to create a function in the controller that you
> can call and reads the value and puts it in the session or
> where you need.
> something like this (it will be more complex depending on hw):
>
> def barcoderead:
>      barfile = file('', 'r')
>      code = barfile.read() # blocks  here until data arrives
>      barfile.close()
>      return dict(barcode=code)
>
> You can callit as a normal 
> url:http://your.host.name/barcodeapplication/barcodecontroller/barcoderead
> so you
> can use anything you like for instance ajax
>
> hope that helps!
> mic
>
> 2010/8/25 Neveen Adel :
>
> > Hello,
>
> > Is there a way to connect my  web2py application to barcode reader and
> > then get the data  after passing
> > barcode card into the barcode?
>
> > Thanks in Advance
>
> > Neveen
>
>


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

2010-08-25 Thread Bruno Rocha
http://myblog.com/articles/net-neutrality-and-you

http://myblog.com/ <-- Application + default controller mapped in routes.py
articles/ <-- The function that retrieve articles from db
net-neutrality-and-you <-- request.args(0) | the article slug

where is the problem?

I dont think anybody wants to have one controller for every article, that
should be stored in database, and that can be fetched by the 'slug' in the
same way plugin_wiki does.



2010/8/25 Kevin 

> On Aug 25, 1:13 pm, Michele Comitini 
> wrote:
> > why not have a dictionary?
> >
> > controllers = {'route-me-if-you-can': any_time_you_want}
> > if lookup misses method name is searched as it is?
>
> That would be a viable alternative to routes, except it's not
> desirable to have to hand-code routes except when you want to do
> something 'special' -- hyphens on the web are quickly becoming more
> common then underscores.
>
> > > Are Python restrictions relevant for applications and controllers? Or
> just filename restrictions? I'm not sure.
>
> Generally speaking, no restrictions are relevant (not even filename
> restrictions) except for total URL length (all typical servers have
> some maximum URL length that they'll handle, as do browsers).
> However, url-encoded paths (like /some%20where/over/there) are to be
> avoided at all costs.  Pretty much [a-zA-Z0-9/_~.-] are the characters
> that are commonly used in URLs (not counting ?, &, and = for query
> strings), with strict lower-case only or camel-case both being trendy
> in that order, and with hyphens showing up better underlined links
> unlike underscores.
>
> If possible, it's especially good practice provide only URLs that
> users can write down easily, such as ,
> and especially favoring ones that are self descriptive, like  myblog.com/articles/net-neutrality-and-you>, for obvious reasons (I
> personally consider hybridized URLs like  net-neutrality-and-you> to be junk because there are two unique
> identifiers in the URL).




-- 

http://rochacbruno.com.br


[web2py] Re: I feel shame for asking... but I would like to resolve this

2010-08-25 Thread mart
sweet! thanks :) I will give it go and let you know :)

On Aug 25, 5:07 pm, howesc  wrote:
> i don't know flex or any of that.but can you call those tools that
> generate the HTML from your controller, get the HTML back and return
> that from the controller?
>
> def get_spiffy_html():
>   html = my_call_to_magic_stuff_that_makes_html()
>   return html
>
> or if you want to embed it in a layout:
>
> def get_spiffy_html():
>   html = my_call_to_magic_stuff_that_makes_html()
>   return dict(thecode = XML(html))
>
> does something like that work for you?
>
> On Aug 25, 10:13 am, mart  wrote:
>
> > Hi All,
>
> > I was thinking that should have any problems here... but I am :(...
> > So, I have an app that generates templates for the younger violinists.
> > These templates are based on their violin scale length (distance
> > between nut & bridge). It will calculate the position makers (those
> > striped pieces of tape they put on the finger board that tell them
> > where exactly they put their fingers). The output is a PDF file (pdf
> > because with a good pdf client, they should be able to turn off
> > "scaling" for printing purposes - the printed pdf needs to be exact).
> > I use flex & iFrames, which gives me a html file which I can display
> > as a separate page, but I really want that page embedded within the
> > app's layout (if that makes any sense?) . Because I am using
> > iFrames with Flex (which embeds the PDF), I need to embed the
> > resulting HTML (not the .swf)
>
> > I have tried quite a few things (which you know... broke the app,or
> > made it do silly things, etc...). Can someone help? :) I'm sure I am
> > missing something really silly but, I'm not seeing it :(
>
> > Thanks,
> > Mart :)


[web2py] Re: Trying to multiprocess

2010-08-25 Thread Kevin
Although there are many places where multiprocess'ing could be handy
and efficient, unfortunately string matching is one of those things
that is almost entirely I/O bound.  With I/O bound tasks (particularly
the kind of processing you showed in your example code), you'll be
spending over 90% of your time waiting for the disk to supply the
data.  A couple of characteristics of these kinds of tasks:

* You will get essentially zero tangible total performance improvement
if you have a single hard drive whether you're running single threaded
on a single processor, or 500,000 processes on a super-computer --
it'll all get completed in about the same number of seconds either way
(probably saving a little time going single-threaded).
* On python, I/O bound tasks complete in about the same amount of time
as the equivalent code written in pure ANSI C (see
http://www.pytips.com/2010/5/29/a-quick-md5sum-equivalent-in-python --
take the exact timings there with a grain of salt, but it's a pretty
good real-world example of what you'll see).

So what I would do in your exact situation is to make the equivalent
to strings in pure python (the overhead of calling an external process
many times definitely will be noticeable), and instead just do it with
at most 2 threads (I would go single threaded and only notice about an
estimated 2% increase in the total time required to complete all
processing).

On Aug 20, 6:01 am, Phyo Arkar  wrote:
> well
>
> lets say i have about a thounsand files to be proccessed  .. i need to
> extract text out of them , whatever file type it is (i use Linux
> "strings") command .
>
> i want to do in multi processed way , which works on multi-core pcs too.
>
> this is my current implementation :
>
> import subprocess,shlex
>
> def __forcedParsing(fname):
>         cmd = 'strings "%s"' % (fname)
>         #print cmd
>         args= shlex.split(cmd)
>         try:
>                 sp = subprocess.Popen( args, shell = False, stdout =
> subprocess.PIPE, stderr = subprocess.PIPE )
>                 out, err = sp.communicate()
>         except OSError:
>                 print "Error no %s  Message %s" % 
> (OSError.errno,OSError.message)
>                 pass
>
>         if sp.returncode== 0:
>                 #print "Processed %s" %fname
>                 return out
>
> def parseDocs():
>         rows_to_parse = [i for i in range( 0,len(SESSION.all_docs))]
>         row_ids = [x[0] for x in SESSION.all_docs  ]
>         res=[]
>         for rowID in rows_to_parse:
>
>                 file_id, fname, ftype, dir  = SESSION.all_docs[int( rowID ) ]
>                 fp = os.path.join( dir, fname )
>                 res.append(__forcedParsing(fp))
>
> well the problem is i need output from subprocess so i have to read
> using sp.communicate(). i need that to be multiprocessed (via forking?
> poll?)
>
> so here are my thoughs :
>
> 1) without using fork() ,  could I  do multiple ajax posts by
> iterating the huge list of files at client side to server   , each
> processes will be multi-threaded because of Rocket right? But may this
> suffer performace issue on client side?
>
> 2) Forking Current implementation, and read output via polling?
> subprocess.poll()
>
> any ideas?


[web2py] Re: jqgrid and edit-link

2010-08-25 Thread mdipierro
look into the plugin code modes/plugin_wiki.py

On Aug 25, 4:14 pm, Johann Spies  wrote:
> On 25 August 2010 22:51, mdipierro  wrote:
>
> > {{=plugin_wiki.widget('jqgrid',table='tablename')}}
>
> > the first argument is the widget name, the other named arguments are
> > the widgets attributes.
>
> Thanks.  My first try did not work.  I will have to read up on what
> "the other named arguments"  are supposed to be.  "columns = "  did
> not work in this case:
> TypeError: jqgrid() got an unexpected keyword argument 'columns'
>
> Regards
> Johann
>
> --
>     "Be not deceived; God is not mocked: for whatsoever a
>      man soweth, that shall he also reap."
>                                   Galatians 6:7


[web2py] Re: Web2py and threads

2010-08-25 Thread mdipierro
The problem is only if have two http request from the same client in
the same session

A arrives loads session and unlocks
B arrives loads session and unlocks
A change session and saves it
B changes session and saves it

Nothing breaks but B never sees changes made by A and they are
overwritten by B.
With locks

A arrives loads session
B arrives and waits
A change session and saves it
B loads session (with changes made by A)
B changes session and saves it


On Aug 25, 3:52 pm, Jonathan Lundell  wrote:
> On Aug 25, 2010, at 1:41 PM, mdipierro wrote:
>
>
>
> > call
>
> > session._unlock()
>
> > if you do not need session locking
>
> If you do that (without calling session.forget), what will happen in 
> _try_store_on_disk when cPickle.dump(dict(self), response.session_file) is 
> called with a None file argument? Or is cPickle.dump cool with that? Or am I 
> misreading the logic?
>
>
>
> > On Aug 25, 11:38 am, Phyo Arkar  wrote:
> >> Yes may be session was locked , thats why
> >> session.current=processing_path not working
>
> >> But then again , while processing files i try opening separate page ,
> >> to other controller , it was waited till the first (file Crawler) page
> >> finished parsing.
>
> >> ok i will make a separate thread about this.
>
> >> On 8/25/10, mdipierro  wrote:
>
> >>> On Aug 25, 11:00 am, Phyo Arkar  wrote:
>  Did I Read that reading files inside controller will block web2py , Does
>  it?
>
> >>> No web2py does not block. web2py only locks sessions that means one
> >>> user cannot request two concurrent pages because there would be a race
> >>> condition in saving sessions. Two user can request different pages
> >>> which open the same file unless the file is explicitly locked by your
> >>> code.
>
>  Thats a bad news.. i am doing a file crawler and while crawling ,
>  web2py is blocked even tho the process talke only 25% of 1 out of 4
>  CPUs ..
>
> >>> Tell us more or I cannot help.
>
>  On 8/25/10, pierreth  wrote:
>
> > I would appreciate a good reference to understand the concepts you are
> > talking about. It is something new to me and I don't understand.
>
> > On 25 août, 11:22, John Heenan  wrote:
> >> No, nothing that abstract. Using WSGI forces a new thread for each
> >> request. This is is a simple and inefficient brute force approach that
> >> really only suits the simplest Python applications and where only a
> >> small number of concurrent connection might be expected.
>
> >> Any application that provides web services is going to OS block on
> >> file reading (and writing) and on database access. Using threads is a
> >> classic and easy way out that carries a lot of baggage. Windows has
> >> had a way out of this for years with its asynch (or event)
> >> notification set up through an OVERLAPPED structure.
>
> >> Lightttpd makes use of efficient event notification schemes like
> >> kqueue and epoll. Apache only uses such schemes for listening and Keep-
> >> Alives.
>
> >> No matter how careful one is with threads and processes there always
> >> appears to be unexpected gotchas. Python has a notorious example, the
> >> now fixed 'Beazly Effect' that affected the GIL. Also I don't think
> >> there is a single experienced Python user that trusts the GIL.
>
> >> John Heenan


Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 6:37 PM, mdipierro wrote:
> 
> The problem is only if have two http request from the same client in
> the same session

Thanks for that; I was wondering under which conditions unlocking might be 
permissible (and I'm still not entirely clear, but never mind for now).

My concern is this. Here's unlock:

def _unlock(self, response):
if response and response.session_file:
try:
portalocker.unlock(response.session_file)
response.session_file.close()
del response.session_file  <-
except: ### this should never happen but happens in Windows
pass

Now we save the session file:

def _try_store_on_disk(self, request, response):
if response._dbtable_and_field \
or not response.session_id \
or self._forget:
self._unlock(response)
return
if response.session_new:
# Tests if the session folder exists, if not, create it
session_folder = os.path.dirname(response.session_filename)
response.session_file = open(response.session_filename, 'wb')
portalocker.lock(response.session_file, portalocker.LOCK_EX)
cPickle.dump(dict(self), response.session_file)  
<
self._unlock(response)

But response.session_file is None at this point.

> 
> A arrives loads session and unlocks
> B arrives loads session and unlocks
> A change session and saves it
> B changes session and saves it
> 
> Nothing breaks but B never sees changes made by A and they are
> overwritten by B.
> With locks
> 
> A arrives loads session
> B arrives and waits
> A change session and saves it
> B loads session (with changes made by A)
> B changes session and saves it
> 
> 
> On Aug 25, 3:52 pm, Jonathan Lundell  wrote:
>> On Aug 25, 2010, at 1:41 PM, mdipierro wrote:
>> 
>> 
>> 
>>> call
>> 
>>> session._unlock()
>> 
>>> if you do not need session locking
>> 
>> If you do that (without calling session.forget), what will happen in 
>> _try_store_on_disk when cPickle.dump(dict(self), response.session_file) is 
>> called with a None file argument? Or is cPickle.dump cool with that? Or am I 
>> misreading the logic?
>> 
>> 
>> 
>>> On Aug 25, 11:38 am, Phyo Arkar  wrote:
 Yes may be session was locked , thats why
 session.current=processing_path not working
>> 
 But then again , while processing files i try opening separate page ,
 to other controller , it was waited till the first (file Crawler) page
 finished parsing.
>> 
 ok i will make a separate thread about this.
>> 
 On 8/25/10, mdipierro  wrote:
>> 
> On Aug 25, 11:00 am, Phyo Arkar  wrote:
>> Did I Read that reading files inside controller will block web2py , Does
>> it?
>> 
> No web2py does not block. web2py only locks sessions that means one
> user cannot request two concurrent pages because there would be a race
> condition in saving sessions. Two user can request different pages
> which open the same file unless the file is explicitly locked by your
> code.
>> 
>> Thats a bad news.. i am doing a file crawler and while crawling ,
>> web2py is blocked even tho the process talke only 25% of 1 out of 4
>> CPUs ..
>> 
> Tell us more or I cannot help.
>> 
>> On 8/25/10, pierreth  wrote:
>> 
>>> I would appreciate a good reference to understand the concepts you are
>>> talking about. It is something new to me and I don't understand.
>> 
>>> On 25 août, 11:22, John Heenan  wrote:
 No, nothing that abstract. Using WSGI forces a new thread for each
 request. This is is a simple and inefficient brute force approach that
 really only suits the simplest Python applications and where only a
 small number of concurrent connection might be expected.
>> 
 Any application that provides web services is going to OS block on
 file reading (and writing) and on database access. Using threads is a
 classic and easy way out that carries a lot of baggage. Windows has
 had a way out of this for years with its asynch (or event)
 notification set up through an OVERLAPPED structure.
>> 
 Lightttpd makes use of efficient event notification schemes like
 kqueue and epoll. Apache only uses such schemes for listening and Keep-
 Alives.
>> 
 No matter how careful one is with threads and processes there always
 appears to be unexpected gotchas. Python has a notorious example, the
 now fixed 'Beazly Effect' that affected the GIL. Also I don't think
 there is a single experienced Python user that trusts the GIL.
>> 
 John Heenan




[web2py] Re: IS_IMAGE() broke?

2010-08-25 Thread mdipierro
Please check if this is fixed in trunk and if the comment I added
makes any sense.

Massimo

On Aug 25, 10:59 am, Jonathan Lundell  wrote:
> On Aug 25, 2010, at 8:33 AM, Joe Wakefield wrote:
>
> > I'll do you one better. The problem is in "sqlhtml.py" at lines
> > 909-917. It changes ret=False to ret=True if the field already has a
> > value.
>
> Good catch. This is a case where a comment documenting the intent of this 
> hunk of code would come in handy for those of us reading it. The error is 
> cancelled under certain conditions, but what's the intent?
>
>
>
> > ===
> > ret, errors: False, 
> > new ret:False
> > ===
> > ret, errors: True, 
> > new ret:True
> > new: users.photo.8a5327ab32003765.6c6c616d61732e6a7067.jpg    old:
> > ===
> > ret, errors: False, 
> > new ret:True
> > new: users.photo.b6369c7a23ae4813.312e706e67.png    old: users.photo.
> > 8a5327ab32003765.6c6c616d61732e6a7067.jpg
>
> > On Aug 25, 10:17 am, mdipierro  wrote:
> >> can you help me debug?
>
> >> in gluon/validators.py
>
> >> classIS_IMAGE:
> >>     def __call__(self,value):
> >>        
> >>         except:
> >>             return (value, self.error_message)
>
> >> replace last two lines with
>
> >>         except Exception, e:
> >>             return (value, str(r))
>
> >> what does the error say?
>
> >> On Aug 23, 4: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] Re: Web2py and threads

2010-08-25 Thread mdipierro
This is a bug. I fixed it in trunk. Thanks Jonathan.

On Aug 25, 9:30 pm, Jonathan Lundell  wrote:
> On Aug 25, 2010, at 6:37 PM, mdipierro wrote:
>
>
>
> > The problem is only if have two http request from the same client in
> > the same session
>
> Thanks for that; I was wondering under which conditions unlocking might be 
> permissible (and I'm still not entirely clear, but never mind for now).
>
> My concern is this. Here's unlock:
>
>     def _unlock(self, response):
>         if response and response.session_file:
>             try:
>                 portalocker.unlock(response.session_file)
>                 response.session_file.close()
>                 del response.session_file  <-
>             except: ### this should never happen but happens in Windows
>                 pass
>
> Now we save the session file:
>
>     def _try_store_on_disk(self, request, response):
>         if response._dbtable_and_field \
>                 or not response.session_id \
>                 or self._forget:
>             self._unlock(response)
>             return
>         if response.session_new:
>             # Tests if the session folder exists, if not, create it
>             session_folder = os.path.dirname(response.session_filename)
>             response.session_file = open(response.session_filename, 'wb')
>             portalocker.lock(response.session_file, portalocker.LOCK_EX)
>         cPickle.dump(dict(self), response.session_file)  
> <
>         self._unlock(response)
>
> But response.session_file is None at this point.
>
>
>
> > A arrives loads session and unlocks
> > B arrives loads session and unlocks
> > A change session and saves it
> > B changes session and saves it
>
> > Nothing breaks but B never sees changes made by A and they are
> > overwritten by B.
> > With locks
>
> > A arrives loads session
> > B arrives and waits
> > A change session and saves it
> > B loads session (with changes made by A)
> > B changes session and saves it
>
> > On Aug 25, 3:52 pm, Jonathan Lundell  wrote:
> >> On Aug 25, 2010, at 1:41 PM, mdipierro wrote:
>
> >>> call
>
> >>> session._unlock()
>
> >>> if you do not need session locking
>
> >> If you do that (without calling session.forget), what will happen in 
> >> _try_store_on_disk when cPickle.dump(dict(self), response.session_file) is 
> >> called with a None file argument? Or is cPickle.dump cool with that? Or am 
> >> I misreading the logic?
>
> >>> On Aug 25, 11:38 am, Phyo Arkar  wrote:
>  Yes may be session was locked , thats why
>  session.current=processing_path not working
>
>  But then again , while processing files i try opening separate page ,
>  to other controller , it was waited till the first (file Crawler) page
>  finished parsing.
>
>  ok i will make a separate thread about this.
>
>  On 8/25/10, mdipierro  wrote:
>
> > On Aug 25, 11:00 am, Phyo Arkar  wrote:
> >> Did I Read that reading files inside controller will block web2py , 
> >> Does
> >> it?
>
> > No web2py does not block. web2py only locks sessions that means one
> > user cannot request two concurrent pages because there would be a race
> > condition in saving sessions. Two user can request different pages
> > which open the same file unless the file is explicitly locked by your
> > code.
>
> >> Thats a bad news.. i am doing a file crawler and while crawling ,
> >> web2py is blocked even tho the process talke only 25% of 1 out of 4
> >> CPUs ..
>
> > Tell us more or I cannot help.
>
> >> On 8/25/10, pierreth  wrote:
>
> >>> I would appreciate a good reference to understand the concepts you are
> >>> talking about. It is something new to me and I don't understand.
>
> >>> On 25 août, 11:22, John Heenan  wrote:
>  No, nothing that abstract. Using WSGI forces a new thread for each
>  request. This is is a simple and inefficient brute force approach 
>  that
>  really only suits the simplest Python applications and where only a
>  small number of concurrent connection might be expected.
>
>  Any application that provides web services is going to OS block on
>  file reading (and writing) and on database access. Using threads is a
>  classic and easy way out that carries a lot of baggage. Windows has
>  had a way out of this for years with its asynch (or event)
>  notification set up through an OVERLAPPED structure.
>
>  Lightttpd makes use of efficient event notification schemes like
>  kqueue and epoll. Apache only uses such schemes for listening and 
>  Keep-
>  Alives.
>
>  No matter how careful one is with threads and processes there always
>  appears to be unexpected gotchas. Python has a notorious example, the
>  now fixed 'Beazly Effect' that affected the GIL. Also I don't think
>  there is a si

Re: [web2py] Re: Web2py and threads

2010-08-25 Thread Jonathan Lundell
On Aug 25, 2010, at 7:56 PM, mdipierro wrote:
> 
> This is a bug. I fixed it in trunk. Thanks Jonathan.

It's fixed in the sense that it won't raise an exception. But now how is 
calling _unlock different from calling forget?

> 
> On Aug 25, 9:30 pm, Jonathan Lundell  wrote:
>> On Aug 25, 2010, at 6:37 PM, mdipierro wrote:
>> 
>> 
>> 
>>> The problem is only if have two http request from the same client in
>>> the same session
>> 
>> Thanks for that; I was wondering under which conditions unlocking might be 
>> permissible (and I'm still not entirely clear, but never mind for now).
>> 
>> My concern is this. Here's unlock:
>> 
>> def _unlock(self, response):
>> if response and response.session_file:
>> try:
>> portalocker.unlock(response.session_file)
>> response.session_file.close()
>> del response.session_file  <-
>> except: ### this should never happen but happens in Windows
>> pass
>> 
>> Now we save the session file:
>> 
>> def _try_store_on_disk(self, request, response):
>> if response._dbtable_and_field \
>> or not response.session_id \
>> or self._forget:
>> self._unlock(response)
>> return
>> if response.session_new:
>> # Tests if the session folder exists, if not, create it
>> session_folder = os.path.dirname(response.session_filename)
>> response.session_file = open(response.session_filename, 'wb')
>> portalocker.lock(response.session_file, portalocker.LOCK_EX)
>> cPickle.dump(dict(self), response.session_file)  
>> <
>> self._unlock(response)
>> 
>> But response.session_file is None at this point.
>> 
>> 
>> 
>>> A arrives loads session and unlocks
>>> B arrives loads session and unlocks
>>> A change session and saves it
>>> B changes session and saves it
>> 
>>> Nothing breaks but B never sees changes made by A and they are
>>> overwritten by B.
>>> With locks
>> 
>>> A arrives loads session
>>> B arrives and waits
>>> A change session and saves it
>>> B loads session (with changes made by A)
>>> B changes session and saves it
>> 
>>> On Aug 25, 3:52 pm, Jonathan Lundell  wrote:
 On Aug 25, 2010, at 1:41 PM, mdipierro wrote:
>> 
> call
>> 
> session._unlock()
>> 
> if you do not need session locking
>> 
 If you do that (without calling session.forget), what will happen in 
 _try_store_on_disk when cPickle.dump(dict(self), response.session_file) is 
 called with a None file argument? Or is cPickle.dump cool with that? Or am 
 I misreading the logic?
>> 
> On Aug 25, 11:38 am, Phyo Arkar  wrote:
>> Yes may be session was locked , thats why
>> session.current=processing_path not working
>> 
>> But then again , while processing files i try opening separate page ,
>> to other controller , it was waited till the first (file Crawler) page
>> finished parsing.
>> 
>> ok i will make a separate thread about this.
>> 
>> On 8/25/10, mdipierro  wrote:
>> 
>>> On Aug 25, 11:00 am, Phyo Arkar  wrote:
 Did I Read that reading files inside controller will block web2py , 
 Does
 it?
>> 
>>> No web2py does not block. web2py only locks sessions that means one
>>> user cannot request two concurrent pages because there would be a race
>>> condition in saving sessions. Two user can request different pages
>>> which open the same file unless the file is explicitly locked by your
>>> code.
>> 
 Thats a bad news.. i am doing a file crawler and while crawling ,
 web2py is blocked even tho the process talke only 25% of 1 out of 4
 CPUs ..
>> 
>>> Tell us more or I cannot help.
>> 
 On 8/25/10, pierreth  wrote:
>> 
> I would appreciate a good reference to understand the concepts you are
> talking about. It is something new to me and I don't understand.
>> 
> On 25 août, 11:22, John Heenan  wrote:
>> No, nothing that abstract. Using WSGI forces a new thread for each
>> request. This is is a simple and inefficient brute force approach 
>> that
>> really only suits the simplest Python applications and where only a
>> small number of concurrent connection might be expected.
>> 
>> Any application that provides web services is going to OS block on
>> file reading (and writing) and on database access. Using threads is a
>> classic and easy way out that carries a lot of baggage. Windows has
>> had a way out of this for years with its asynch (or event)
>> notification set up through an OVERLAPPED structure.
>> 
>> Lightttpd makes use of efficient event notification schemes like
>> kqueue and epoll. Apache only uses such schemes for listening and 
>> Keep-
>> Aliv

[web2py] SQLFORM not using newly added record

2010-08-25 Thread Richard
I have a table that references another record of the same table:

db.define_table('topic',
Field('name'),
Field('category', requires=IS_EMPTY_OR(IS_IN_DB(db, 'topic.id', '%
(name)s'))),
)


I then create new records using SQLFORM:

form = SQLFORM(db.topic)
if form.accepts(request.vars, session):
 response.flash = 'New topic created'


This all works, however the newly created record won't appear in the
list of categories when the form is next loaded.
Is there a way to make the form use the newly created category?

My temporary hacky solution is to force a reload with:

form = SQLFORM(db.topic)
if form.accepts(request.vars, session):
response.flash = 'New topic created'
form = SQLFORM(db.topic)


Richard


[web2py] Re: I feel shame for asking... but I would like to resolve this

2010-08-25 Thread Richard
next thread consider setting the subject to something that describes
the problem!


On Aug 26, 10:59 am, mart  wrote:
> sweet! thanks :) I will give it go and let you know :)
>
> On Aug 25, 5:07 pm, howesc  wrote:
>
> > i don't know flex or any of that.but can you call those tools that
> > generate the HTML from your controller, get the HTML back and return
> > that from the controller?
>
> > def get_spiffy_html():
> >   html = my_call_to_magic_stuff_that_makes_html()
> >   return html
>
> > or if you want to embed it in a layout:
>
> > def get_spiffy_html():
> >   html = my_call_to_magic_stuff_that_makes_html()
> >   return dict(thecode = XML(html))
>
> > does something like that work for you?
>
> > On Aug 25, 10:13 am, mart  wrote:
>
> > > Hi All,
>
> > > I was thinking that should have any problems here... but I am :(...
> > > So, I have an app that generates templates for the younger violinists.
> > > These templates are based on their violin scale length (distance
> > > between nut & bridge). It will calculate the position makers (those
> > > striped pieces of tape they put on the finger board that tell them
> > > where exactly they put their fingers). The output is a PDF file (pdf
> > > because with a good pdf client, they should be able to turn off
> > > "scaling" for printing purposes - the printed pdf needs to be exact).
> > > I use flex & iFrames, which gives me a html file which I can display
> > > as a separate page, but I really want that page embedded within the
> > > app's layout (if that makes any sense?) . Because I am using
> > > iFrames with Flex (which embeds the PDF), I need to embed the
> > > resulting HTML (not the .swf)
>
> > > I have tried quite a few things (which you know... broke the app,or
> > > made it do silly things, etc...). Can someone help? :) I'm sure I am
> > > missing something really silly but, I'm not seeing it :(
>
> > > Thanks,
> > > Mart :)


Re: [web2py] Re: Web2py with barcode Reader

2010-08-25 Thread Thadeus Burgess
I use this already in a system that uses a magnetic card reader to
scan various magnetic cards into the system using jQuery and ajax
communications with the server. Alongside some python code to parse
the incoming data using some regex magic to place the data into
variables. So it *can* be done.

This is the jQuery library I used.
http://garetjax.info/articles/2010/01/magnetic-card-jquery/

The basic concept is, a card reader usually types faster than a human
can. Using the card readers start and end sentinels you can
successfully detect a card read if you subscribe to the char_event of
an element (in jquery case, the window object, this way you don't have
to worry about focus).

Barcode readers and magnetic card readers use the same technology.
They basically act as a keyboard to the system, they just type faster
than we ever could =)

--
Thadeus





On Wed, Aug 25, 2010 at 7:48 PM, Kevin  wrote:
> uch a case (assuming the browser window has focus), you can just
> read key events on the document object in javascript -- after a
> hardcoded input length has been read, or a timeout of say 1 second
> since the last 'keypress', you submit an ajax event.  However,
> distinguishing between the barcode reader and a *real* keyboard is
> something you have to watch out for.  On the other hand, you can
> intentionally not distinguish between *real* and barcode-reader
> 'keyboards', and transparently handle manually typed barcodes when it
> won't scan.
>
> The simplest solution is just to make a regular text input that you
> give focus to when the page loads so that the user can see the value
> that's being scanned.
>


[web2py] Will web2py support database view? When?

2010-08-25 Thread heidan
hi,

Is there a way to work with database views using the DAL? I've got a
bunch of views in my database that handle common queries. BUt didn't
see good answers and neither find interface in DAL.

Is there any plan to support database view and when? Anyway accessing
view is performing better than query in controller scripts.

Cheers,
heidan


[web2py] Re: I feel shame for asking... but I would like to resolve this

2010-08-25 Thread mart
definitely

On Aug 26, 12:14 am, Richard  wrote:
> next thread consider setting the subject to something that describes
> the problem!
>
> On Aug 26, 10:59 am, mart  wrote:
>
> > sweet! thanks :) I will give it go and let you know :)
>
> > On Aug 25, 5:07 pm, howesc  wrote:
>
> > > i don't know flex or any of that.but can you call those tools that
> > > generate the HTML from your controller, get the HTML back and return
> > > that from the controller?
>
> > > def get_spiffy_html():
> > >   html = my_call_to_magic_stuff_that_makes_html()
> > >   return html
>
> > > or if you want to embed it in a layout:
>
> > > def get_spiffy_html():
> > >   html = my_call_to_magic_stuff_that_makes_html()
> > >   return dict(thecode = XML(html))
>
> > > does something like that work for you?
>
> > > On Aug 25, 10:13 am, mart  wrote:
>
> > > > Hi All,
>
> > > > I was thinking that should have any problems here... but I am :(...
> > > > So, I have an app that generates templates for the younger violinists.
> > > > These templates are based on their violin scale length (distance
> > > > between nut & bridge). It will calculate the position makers (those
> > > > striped pieces of tape they put on the finger board that tell them
> > > > where exactly they put their fingers). The output is a PDF file (pdf
> > > > because with a good pdf client, they should be able to turn off
> > > > "scaling" for printing purposes - the printed pdf needs to be exact).
> > > > I use flex & iFrames, which gives me a html file which I can display
> > > > as a separate page, but I really want that page embedded within the
> > > > app's layout (if that makes any sense?) . Because I am using
> > > > iFrames with Flex (which embeds the PDF), I need to embed the
> > > > resulting HTML (not the .swf)
>
> > > > I have tried quite a few things (which you know... broke the app,or
> > > > made it do silly things, etc...). Can someone help? :) I'm sure I am
> > > > missing something really silly but, I'm not seeing it :(
>
> > > > Thanks,
> > > > Mart :)