[web2py] Re: FORM with CHEKCBOX and IS_IN_DB

2010-07-27 Thread mdipierro
Try this:

def test2():
posts=db(db.papers.id > 0).select()
def writable(id):
 condition = not posts.find(lambda r: r.id==id).printout
chkposts=[Field('pst_
%s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
for pst in posts]
form=SQLFORM.factory(*chkposts)
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(form=form)

On Jul 26, 1:09 pm, KMax  wrote:
> Hello
> I had table defined:
> db.define_table('papers',
>     Field('printdate','date'),
>     Field('printout','boolean',default=False))
>
> So I need FORM with checkboxes for each printdate, but if printout for
> particular date gets 'True' (mean to app user 'CLOSED FOR ACCEPT NEW
> POST' ) error message printed.
>
> def test2():
>     chkposts=[]
>     posts=db(db.papers.id > 0).select()
>     for pst in posts:
>
> chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_IN_DB(db((db.papers.id
> ==MY_QUESTION  )&(db.papers.printout == False)),'papers.id','%
> (name)s',error_message=T('CLOSED FOR ACCEPT NEW
> POST'))),str(pst.printdate)))
>     chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
>     form=FORM(*[chkposts[num] for num in
> range(len(chkposts))],_name="adcr")
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>     return dict(form=form)
>
> What should I put instead MY_QUESTION to IS_IN_DB get work? I want
> alert on checkbox who corresponding to records with
> db.papers.printout==True
> But checkbox return "on" value and I need name of checked checkbox
> modifyed by .split('_')[-1] -ed
>
> Please advise.
>
> Thank you.
> --
> Maxim


[web2py] Re: Custom Registration form

2010-07-27 Thread mdipierro
You are mixing a SQLFORM (the form in the first two lines) with a FORM
(in the register function). If you want db access you need to insert
the former not the latter. If you want a custom form you should not
use FORM at all, you should just place the {{=form.cutsom.widget}}s in
the view.

On Jul 26, 3:47 pm, elfuego1  wrote:
> In default.py I had defined my registration form
>
> lbl=form.custom.label
> wdgt=form.custom.widget
>
> def register():
>     form=FORM(TABLE(TR(lbl.username), TD(wdgt.username),
>                     TR(lbl.password), TD(wdgt.password),
>                     TR(lbl.first_name), TD(wdgt.first_name),
>                     TR(lbl.last_name), TD(wdgt.last_name),
>                     TR(lbl.phone_no), TD(wdgt.phone_no),
>                     TR("",INPUT(_type="submit",_value="SUBMIT"
>     if form.accepts(request.vars,session):
>         response.flash="Form accepted"
>     elif form.errors:
>         response.flash="Form is invalid"
>     else:
>         response.flash="Please fill the form"
>     return dict(form=form,vars=form.vars)
>
> This submit gives me only information "Form accepted", but actual data
> is not saved into database.
> When I try to add submit button using "form.custom.submit" I recive an
> error:
> AttributeError: 'tuple' object has no attribute 'custom'
>
> When I add email input field using wdgt.email then this line
>
> if form.accepts(request.vars,session):
>
> gives an error:
>
> TypeError: expected string or buffer
>
> I need to know how should I add an email field to the registration
> form, so it would be accepted and how do you add a SUBMIT button to
> the form so the data would be stored in database?


[web2py] Re: Error after a page is deleted in plugin_wiki

2010-07-27 Thread mdipierro
This needs some thought. Pages should disabled not deleted. Good
catch.

On Jul 26, 5:33 pm, Bruno Rocha  wrote:
> I found an error in the model plugin_wiki.
> 1. Create a new page
> 2. make some changes to include entries in the table
> plugin_wiki_page_archive
> 3. Appadmin go through the table .. _archive and view the historic
> 4. Delete the page you created
> 5. Visit again .. _archive through appadmin
>
> I guess that is related to cascate deletions, but in this case the archive
> entry dont have to be deleted.
>
> I'm trying to create a logic to excluding categories of pages that have
> already been excluded from _page table. [1]
>
> [1]http://www.web2pyslices.com/main/slices/take_slice/92
>
> Error traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
> 31.
> 32.
> 33.
> 34.
> 35.
> 36.
> 37.
> 38.
> 39.
>
> Traceback (most recent call last):
>   File "/Users/brunomac/web2pydev/web2py/gluon/restricted.py", line
> 178, in restricted
>     exec ccode in environment
>   File 
> "/Users/brunomac/web2pydev/web2py/applications/rochacbruno/views/appadmin.html"
> , line 156, in
> 
>     {{pass}}
>   File "/Users/brunomac/web2pydev/web2py/gluon/globals.py", line 105, in write
>     self.body.write(xmlescape(data))
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in 
> xmlescape
>     return data.xml()
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
>     """
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in _xml
>     # get the xml for the inner components
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in 
> xmlescape
>     return data.xml()
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
>     """
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in _xml
>     # get the xml for the inner components
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in 
> xmlescape
>     return data.xml()
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
>     """
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in _xml
>     # get the xml for the inner components
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in 
> xmlescape
>     return data.xml()
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
>     """
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in _xml
>     # get the xml for the inner components
>   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in 
> xmlescape
>     return data.xml()
>   File "/Users/brunomac/web2pydev/web2py/gluon/sql.py", line 1467, in
> __getattr__
>     self.__allocate()
>   File "/Users/brunomac/web2pydev/web2py/gluon/sql.py", line 1462, in 
> __allocate
>     raise Exception, "undefined record"
> Exception: undefined record
>
> --
>
> http://rochacbruno.com.br


[web2py] Re: table migration metadata storage location

2010-07-27 Thread mdipierro
It is true, they are not read but I cannot be sure this will remain
the case in the future (although probably yes). I do not have a strong
opinion.

On Jul 26, 7:56 pm, Thadeus Burgess  wrote:
> When migrate = False and fake_migrate = False the .table files are not
> even read from the filesystem, meaning they do not technically *need*
> to exist to run your application.
>
> Running code on production always uses migrate = False except for when
> I run migration scripts which allow the DAL to perform table updates.
> Only the migration script needs access to the .table files.
>
> The question is then, should the .table files used for the production
> server be version controlled? If so, should it be in the same
> repository as the code, or in its own repository just storing the
> migration data?
>
> Where is the proper location for these .table files be stored. I have
> multiple web2py apps that use the same database, and therefore share
> .table files, so they need to exist in a app-agnostic location. Is the
> project folder the proper place for this, or something like
> /metadata/pms/migration/ ? The DAL instance exist in a module,
> therefore any request contexts will not be available.
>
> I'm just curious on what others thoughts are on this.
>
> --
> Thadeus


[web2py] Hide Error on SQLFORM

2010-07-27 Thread Thadeus Burgess
I don't get it

SQLFORM.factory(Field., hideerror=True).

It doesn't do what its supposed to.

How can I make sure that none of my widgets render errors alongside
their own INPUT elements without rewriting everything in sqlhtml?

--
Thadeus


[web2py] How do I secure an RSS feed in my app

2010-07-27 Thread Adi
I wish to make a "secure" RSS (like Gmail RSS feed) - the user must
login before the feed becomes available. How can I implement this in
web2py?

I tried the auth.requires_login decorator but it relies on
redirection. That's not what I want. Please check out Twitter timeline
RSS feed, or Gmail RSS feed - that's the "secure" RSS I'm talking
about.

-- Adi


[web2py] Re: FORM with CHEKCBOX and IS_IN_DB

2010-07-27 Thread KMax
Thank you for promt responce,
Sorry for my dumpness, and possible quite barbarism, but
how it should work?
requires=condition and writable=condition give error NameError: global
name 'condition' is not defined
Where is writable(id) called? and what for it?
condition = not posts.find(lambda r: r.id==id).printout give error
AttributeError: 'Rows' object has no attribute 'printout'
So main idea is use self_made validator?

On 27 июл, 14:06, mdipierro  wrote:
> Try this:
>
> def test2():
>     posts=db(db.papers.id > 0).select()
>     def writable(id):
>          condition = not posts.find(lambda r: r.id==id).printout
>     chkposts=[Field('pst_
> %s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
> for pst in posts]
>     form=SQLFORM.factory(*chkposts)
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>     return dict(form=form)


On 27 июл, 07:06, mdipierro  wrote:
> Try this:
>
> def test2():
>     posts=db(db.papers.id > 0).select()
>     def writable(id):
>          condition = not posts.find(lambda r: r.id==id).printout
>     chkposts=[Field('pst_
> %s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
> for pst in posts]
>     form=SQLFORM.factory(*chkposts)
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>     return dict(form=form)
>
> On Jul 26, 1:09 pm, KMax  wrote:
>
> > Hello
> > I had table defined:
> > db.define_table('papers',
> >     Field('printdate','date'),
> >     Field('printout','boolean',default=False))
>
> > So I need FORM with checkboxes for each printdate, but if printout for
> > particular date gets 'True' (mean to app user 'CLOSED FOR ACCEPT NEW
> > POST' ) error message printed.
>
> > def test2():
> >     chkposts=[]
> >     posts=db(db.papers.id > 0).select()
> >     for pst in posts:
>
> > chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_IN_DB(db((db.papers.id
> > ==MY_QUESTION  )&(db.papers.printout == False)),'papers.id','%
> > (name)s',error_message=T('CLOSED FOR ACCEPT NEW
> > POST'))),str(pst.printdate)))
> >     chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
> >     form=FORM(*[chkposts[num] for num in
> > range(len(chkposts))],_name="adcr")
> >     if form.accepts(request.vars, session):
> >         response.flash = 'form accepted'
> >     return dict(form=form)
>
> > What should I put instead MY_QUESTION to IS_IN_DB get work? I want
> > alert on checkbox who corresponding to records with
> > db.papers.printout==True
> > But checkbox return "on" value and I need name of checked checkbox
> > modifyed by .split('_')[-1] -ed
>
> > Please advise.
>
> > Thank you.
> > --
> > Maxim


[web2py] Re: How do I secure an RSS feed in my app

2010-07-27 Thread Adi
I'll add some more useful information:

Right now what I have is:

- In default.py a method "feed()"
- A file feed.rss in views/default

This allows me to call app/default/feed.rss which is like a public url

However, if I follow the book and add @auth.requires_login to call()
and then do
app/default/call/rss/feed
it doesn't invoke my feed.rss file. Also the decorator uses the
redirection technique (which is good if not best)

What can I do to be able to secure the RSS and make sure my feed.rss
file is used to render the feed?

On Jul 27, 12:51 pm, Adi  wrote:
> I wish to make a "secure" RSS (like Gmail RSS feed) - the user must
> login before the feed becomes available. How can I implement this in
> web2py?
>
> I tried the auth.requires_login decorator but it relies on
> redirection. That's not what I want. Please check out Twitter timeline
> RSS feed, or Gmail RSS feed - that's the "secure" RSS I'm talking
> about.
>
> -- Adi


[web2py] Strange radio button behavior

2010-07-27 Thread Alastair Medford
I was wanting to have horizontal radio buttons in my forms, so I set
about making my own widget. The widget works well, except for one odd
behavior. When I load the form, the first radio button is selected as
desired. But after the form submits, page refreshes etc, the last
radio buttons in the list are selected. IE, rather than defaulting to
the first element selected as it did the first time, it defaults to
the last. As this form will be submitted many times in a row, and the
first option is the most often used, this proves to be a bit of a
pain. I've tried this in multiple browsers to the same effect, so I'm
pretty sure it's happening due to how the code is written. But I'm not
really sure where this behavior is written. Anyone have any ideas?

The code for my modified widget is below:

class RadioWidget_Horizontal(OptionsWidget):

@staticmethod
def widget(field, value, **attributes):
"""
generates an unordered list of radio buttons, which has
a css class radio_list so it can be styled inline.

see also: :meth:`FormWidget.widget`
"""

attr = OptionsWidget._attributes(field, {}, **attributes)
attr['_class'] = attr['_class'] + " radio_list"

if hasattr(field.requires, 'options'):
options = field.requires.options()
else:
raise SyntaxError, 'widget cannot determine options of %s'
% field
opts = [LI(INPUT(_type='radio', _name=field.name,
 requires=attr.get('requires',None),
 hideerror=True, _value=k,
 value=value), v) for (k, v) in options if
str(v)]
if opts:
opts[-1][0]['hideerror'] = False
opts[0][0]['_checked'] = "checked"
return UL(*opts, **attr)


[web2py] Cool online Editor

2010-07-27 Thread Timmie
Hello,
have you seen:
http://etherpad.org/index.html

or demo at: http://doc.etherpad.org/tUrCqk8ZMo

It would be great to have this functionality in plugin_wiki!

What do yoiu think?

Best regards,
Timmie


[web2py] Re: book revision

2010-07-27 Thread Timmie
Hello,
what date do you target as publishing date?

Best regards,
Timmie


Re: [web2py] Strange radio button behavior

2010-07-27 Thread Mathieu Clabaut
Hi Massimo,

 A colleague of mine tell me he sent you a patch to include a horizontal
radio buttons in gluon (similar to the existing horizontal checkboxes).
 Has the patch a chance to make its way to the trunk ?

Best regards,

-Mathieu

On Tue, Jul 27, 2010 at 10:15, Alastair Medford
wrote:

> I was wanting to have horizontal radio buttons in my forms, so I set
> about making my own widget. The widget works well, except for one odd
> behavior. When I load the form, the first radio button is selected as
> desired. But after the form submits, page refreshes etc, the last
> radio buttons in the list are selected. IE, rather than defaulting to
> the first element selected as it did the first time, it defaults to
> the last. As this form will be submitted many times in a row, and the
> first option is the most often used, this proves to be a bit of a
> pain. I've tried this in multiple browsers to the same effect, so I'm
> pretty sure it's happening due to how the code is written. But I'm not
> really sure where this behavior is written. Anyone have any ideas?
>
> The code for my modified widget is below:
>
> class RadioWidget_Horizontal(OptionsWidget):
>
>@staticmethod
>def widget(field, value, **attributes):
>"""
>generates an unordered list of radio buttons, which has
>a css class radio_list so it can be styled inline.
>
>see also: :meth:`FormWidget.widget`
>"""
>
>attr = OptionsWidget._attributes(field, {}, **attributes)
>attr['_class'] = attr['_class'] + " radio_list"
>
>if hasattr(field.requires, 'options'):
>options = field.requires.options()
>else:
>raise SyntaxError, 'widget cannot determine options of %s'
> % field
>opts = [LI(INPUT(_type='radio', _name=field.name,
> requires=attr.get('requires',None),
> hideerror=True, _value=k,
> value=value), v) for (k, v) in options if
> str(v)]
>if opts:
>opts[-1][0]['hideerror'] = False
>opts[0][0]['_checked'] = "checked"
>return UL(*opts, **attr)


[web2py] Re: book revision

2010-07-27 Thread Timmie
Hello,
have you tried Pandoc:
http://johnmacfarlane.net/pandoc/

http://johnmacfarlane.net/pandoc/try

If you consider your markup langauge stable, why not submitting it to
the developer of Pandoc?

Regards,
Timmie


[web2py] Privacy with plugin_wiki

2010-07-27 Thread Timmie
Hello,
I have seen that you use Google Chartin API.

Does this mean that my data is sent to Google for preparing the
charts?

If so, I would recommend searching for a standalone charting lib like
matplotlib.

regards.
Timmie


[web2py] CLI for Application

2010-07-27 Thread James McMillan
I have written a simple application involving a single model and a
single controller. I would also like to provide a CLI version for it.
Is it possible to run the application and be able to interact (through
print / input() or similar) with the controller? It would need to load
the model, then execute the controller.

Thanks,
- James


[web2py] SQLFORM update not working?

2010-07-27 Thread Florian
Hi,

I'm trying web2py and want to create a "product" database and forms.

-displaying all products
-displaying one (in detail) and
-creating a new product

works, but i have problems with the "edit/delete" part. It will show
the filled-out form when calling e.g. product/edit/2 , but submitting
the form won't update the record.
What am I doing wrong?

models/db.py looks like this:
---
db.define_table('product',
Field('added_at', 'datetime', default=request.now, readable=False,
writable=False),
Field('title', 'string'),
Field('ean', 'integer'),
Field('brand', 'string'),
Field('mpn', 'string'),
Field('image', 'upload'),
Field('description', 'text'),
Field('cost_price', 'double'),
Field('sell_price', 'double'),
Field('asin', 'string'))

db.product.ean.requires = IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'product.ean')
db.product.title.requires = IS_NOT_EMPTY()
---

controllers/product.py has this function:
---
def edit():
form = SQLFORM(db.product, request.args(0))
return dict(form=form)
---

and views/product/edit.html:
---
{{extend 'layout.html'}}
{{=T("Edit product")}}
{{=form}}
---

Hope you can help me,

Florian


[web2py] Re: FORM with CHEKCBOX and IS_IN_DB

2010-07-27 Thread KMax
I just solve this by using

db.define_table('papers',
Field('printdate','date'),
Field('printout','boolean',default=False),
Field('oncheck','string',default='on')) # this field for checkbox
value = 'on'

def test1():
chkposts=[]
posts=db(db.papers.id > 0).select()
for pst in posts:
 
chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_NULL_OR(IS_IN_DB(db((db.papers.id
== pst.id ) & (db.papers.printout ==
False)),'papers.oncheck','',error_message=T('ALERT',str(pst.printdate)))
# IS_NULL_OR for unchecked field which are not need to be
validated.
chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
form=FORM(*[chkposts[num] for num in
range(len(chkposts))],_name="adcr")
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(form=form)

Thanks
issue resolve (not quite pure solution, but i am satisfied)


Re: [web2py] Re: book revision

2010-07-27 Thread Thadeus Burgess
And SQLFORM(onvalidate)
--
Thadeus





On Tue, Jul 27, 2010 at 12:52 AM, Thadeus Burgess  wrote:
> IS_IN_SET zero changes and how they work and why it is that way now.
>
> --
> Thadeus
>
>
>
>
>
> On Mon, Jul 26, 2010 at 11:20 PM, Iceberg  wrote:
>> On Jul 24, 5:53am, mdipierro  wrote:
>>> I am revising the book.
>>>
>>> Please list what features are not mentioned in the book or deserve
>>> more space they correctly get.
>>> You suggestions will be appreciated.
>>>
>>> Massimo
>>
>>
>> Not sure whether is already mentioned in this 30-post thread, anyway
>> please include the "parse html" feature. Currently a post is available
>> here. http://web2py.com/AlterEgo/default/show/266
>>
>> Iceberg
>>
>


[web2py] google decided to block all posts today

2010-07-27 Thread mdipierro
... sorry if you are having trouble.


[web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread mdipierro
I am surprised it does not. can you help debug.

Try form.errors.clear()

On Jul 27, 2:29 am, Thadeus Burgess  wrote:
> I don't get it
>
> SQLFORM.factory(Field., hideerror=True).
>
> It doesn't do what its supposed to.
>
> How can I make sure that none of my widgets render errors alongside
> their own INPUT elements without rewriting everything in sqlhtml?
>
> --
> Thadeus


[web2py] Re: Strange radio button behavior

2010-07-27 Thread mdipierro
I thought it was included unless I got confused with a different
patch. Please ask him to resend.

On Jul 27, 3:21 am, Mathieu Clabaut  wrote:
> Hi Massimo,
>
>  A colleague of mine tell me he sent you a patch to include a horizontal
> radio buttons in gluon (similar to the existing horizontal checkboxes).
>  Has the patch a chance to make its way to the trunk ?
>
> Best regards,
>
> -Mathieu
>
> On Tue, Jul 27, 2010 at 10:15, Alastair Medford
> wrote:
>
> > I was wanting to have horizontal radio buttons in my forms, so I set
> > about making my own widget. The widget works well, except for one odd
> > behavior. When I load the form, the first radio button is selected as
> > desired. But after the form submits, page refreshes etc, the last
> > radio buttons in the list are selected. IE, rather than defaulting to
> > the first element selected as it did the first time, it defaults to
> > the last. As this form will be submitted many times in a row, and the
> > first option is the most often used, this proves to be a bit of a
> > pain. I've tried this in multiple browsers to the same effect, so I'm
> > pretty sure it's happening due to how the code is written. But I'm not
> > really sure where this behavior is written. Anyone have any ideas?
>
> > The code for my modified widget is below:
>
> > class RadioWidget_Horizontal(OptionsWidget):
>
> >   �...@staticmethod
> >    def widget(field, value, **attributes):
> >        """
> >        generates an unordered list of radio buttons, which has
> >        a css class radio_list so it can be styled inline.
>
> >        see also: :meth:`FormWidget.widget`
> >        """
>
> >        attr = OptionsWidget._attributes(field, {}, **attributes)
> >        attr['_class'] = attr['_class'] + " radio_list"
>
> >        if hasattr(field.requires, 'options'):
> >            options = field.requires.options()
> >        else:
> >            raise SyntaxError, 'widget cannot determine options of %s'
> > % field
> >        opts = [LI(INPUT(_type='radio', _name=field.name,
> >                         requires=attr.get('requires',None),
> >                         hideerror=True, _value=k,
> >                         value=value), v) for (k, v) in options if
> > str(v)]
> >        if opts:
> >            opts[-1][0]['hideerror'] = False
> >            opts[0][0]['_checked'] = "checked"
> >        return UL(*opts, **attr)


[web2py] Re: Privacy with plugin_wiki

2010-07-27 Thread mdipierro
I will move to jflot

On Jul 27, 3:33 am, Timmie  wrote:
> Hello,
> I have seen that you use Google Chartin API.
>
> Does this mean that my data is sent to Google for preparing the
> charts?
>
> If so, I would recommend searching for a standalone charting lib like
> matplotlib.
>
> regards.
> Timmie


[web2py] Re: SQLFORM update not working?

2010-07-27 Thread mdipierro
This:

def edit():
form = SQLFORM(db.product, request.args(0))
return dict(form=form)

should be

def edit():
form = SQLFORM(db.product, request.args(0))
if form.accepts(request.vars,session): pass
return dict(form=form)

or

def edit():
form = crud.update(db.product, request.args(0))
return dict(form=form)

and this:

  db.product.ean.requires = IS_NOT_EMPTY(),
IS_NOT_IN_DB(db,'product.ean')

can be simplified into

  db.product.ean.requires = IS_NOT_IN_DB(db,'product.ean')

since IS_NOT_IN_DB now checks whether value is empty


On Jul 26, 1:09 pm, Florian  wrote:
> Hi,
>
> I'm trying web2py and want to create a "product" database and forms.
>
> -displaying all products
> -displaying one (in detail) and
> -creating a new product
>
> works, but i have problems with the "edit/delete" part. It will show
> the filled-out form when calling e.g. product/edit/2 , but submitting
> the form won't update the record.
> What am I doing wrong?
>
> models/db.py looks like this:
> ---
> db.define_table('product',
>     Field('added_at', 'datetime', default=request.now, readable=False,
> writable=False),
>     Field('title', 'string'),
>     Field('ean', 'integer'),
>     Field('brand', 'string'),
>     Field('mpn', 'string'),
>     Field('image', 'upload'),
>     Field('description', 'text'),
>     Field('cost_price', 'double'),
>     Field('sell_price', 'double'),
>     Field('asin', 'string'))
>
> db.product.ean.requires = IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> 'product.ean')
> db.product.title.requires = IS_NOT_EMPTY()
> ---
>
> controllers/product.py has this function:
> ---
> def edit():
>     form = SQLFORM(db.product, request.args(0))
>     return dict(form=form)
> ---
>
> and views/product/edit.html:
> ---
> {{extend 'layout.html'}}
> {{=T("Edit product")}}
> {{=form}}
> ---
>
> Hope you can help me,
>
> Florian


[web2py] Re: book revision

2010-07-27 Thread mdipierro
Can you help? I am swamped

On Jul 27, 3:22 am, Timmie  wrote:
> Hello,
> have you tried Pandoc:http://johnmacfarlane.net/pandoc/
>
> http://johnmacfarlane.net/pandoc/try
>
> If you consider your markup langauge stable, why not submitting it to
> the developer of Pandoc?
>
> Regards,
> Timmie


[web2py] Re: book revision

2010-07-27 Thread mdipierro
End of August final.

On Jul 27, 3:18 am, Timmie  wrote:
> Hello,
> what date do you target as publishing date?
>
> Best regards,
> Timmie


[web2py] group memberships on the fly : to auth or not to auth?

2010-07-27 Thread aure
Hi everyone,

I am trying to create an app in which a user can create a group and
invite people to join it.

A member of a group can then add documents to the group. This is not
possible for non members of a group.

My question is:

is the authorisation mechanism described in the book (with decorators
and all...) possible/appropriate for my scenario (groups keep on being
added by users) OR on the contrary is it rather only appropriate for
managing application wide rights (e.g. some managers of the app, plus
some editors...)?

Thanks,
Aurelien


Re: [web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread Thadeus Burgess
There is no possible way it can. Looking through the source code, it
never passes along the extra attributes to anything. The current way
the widgets are implemented never use attributes passed to them.

--
Thadeus





On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  wrote:
> I am surprised it does not. can you help debug.
>
> Try form.errors.clear()
>
> On Jul 27, 2:29 am, Thadeus Burgess  wrote:
>> I don't get it
>>
>> SQLFORM.factory(Field., hideerror=True).
>>
>> It doesn't do what its supposed to.
>>
>> How can I make sure that none of my widgets render errors alongside
>> their own INPUT elements without rewriting everything in sqlhtml?
>>
>> --
>> Thadeus
>


[web2py] Re: SQLite Logging

2010-07-27 Thread Yarin
+1 Think this is the right way to go.  I'm working on the module now,
should have something to show within next couple days..

On Jul 24, 12:04 pm, Iceberg  wrote:
> That way the developer need to implement a dedicate action, perhaps
> protected by authentication, to access log on WEB. It is reasonable
> for public site, but an overkill for small enterprise intranet app.
>
> But there is no need to argue on this, man. We can have both. If Yarin
> gonna implement a module in web2py/gluon/contrib, please do design a
> log_path parameter, which can have a default value as "private". So
> everybody will be happy. :-)
>
> On Jul 24, 11:54pm, mdipierro  wrote:
>
>
>
> > I think the place for this stuff is "private". From a security point
> > of view log files should not by default be exposed to the public.
>
> > On Jul 24, 10:49 am, Iceberg  wrote:
>
> > > Sorry I disagree. No need to take "static" literally. In web2py,
> > > "static" just means the content inside such directory will be served
> > > directly by web2py core, unlike other "dynamic" content served by
> > > app's controller. So it is nothing wrong to serve log file inside
> > > "static", no to mention the byproduct, a good one, that you log files
> > > can be access via HTTP natively.
>
> > > On Jul 24, 11:09pm, Yarin Kessler  wrote:
>
> > > > @Iceberg- Thanks for all the input- I'll review your latest and update 
> > > > the
> > > > code later this weekend.  With respect to log file location though, 
> > > > don't
> > > > think it makes sense to put it in static since it's a file that will be
> > > > written to (i.e. non static).  It may need its own location, a var/ or
> > > > log/...  Massimo, thoughts on this?
>
> > > > On Fri, Jul 23, 2010 at 3:02 PM, Iceberg  wrote:
> > > > > Well done Yarin! Some comments.
>
> > > > > 1. Change those time_expire= into time_expire=None please. The
> > > > > clumsy  trick was my early "invention" before I know the
> > > > > time_expire=None approach.
>
> > > > > 2. My another later improvement is to write the log file at {web2py
> > > > > path}/applications/{your app}/static/app.log
> > > > > so that developer can easily access the log file by
> > > > >http://your_host/your_app/static/app.log
> > > > > Well, you can refer to the attachment for my latest implementation. 
> > > > > Some
> > > > > more trick inside.
>
> > > > > 3. @Massimo, I suggested to include the applog.py into
> > > > > welcome/model/applog.py since day1 I invented this little component. 
> > > > > Only
> > > > > this way people will have an official place to always have the latest 
> > > > > code,
> > > > > rather than dig some not-the-latest post from different places. So 
> > > > > please do
> > > > > consider it this time.
>
> > > > > 4. @Yarin, when last time I said "putting the web2py db instance, 
> > > > > rather
> > > > > than a filename, to initialize your SQLiteHandler() class", I mean 
> > > > > something
> > > > > like:
> > > > >    def _init_sqlite_log(level=logging.DEBUG):
> > > > >        handler = SQLiteHandler( db ) # db is defined by: db =
> > > > > DAL('sqlite://storage.sqlite')
> > > > >        # or
> > > > >        handler = SQLiteHandler( DAL('sqlite://log.sqlite') )
> > > > > There is some more implementation to do, but you get the idea.
>
> > > > > 5. With respect to GAE, this was my "concept  vehicle":
>
> > > > >    if request.env.web2py_runtime_gae: # if running on Google App 
> > > > > Engine
>
> > > > >  handler=logging.handlers.HTTPHandler(request.env.http_host,URL(r=request,f=
> > > > >  'log'))
> > > > >        # assuming there is an optional log action
>
> > > > > but I never test it. I think a practical solution would be implement 
> > > > > some
> > > > > log handler which wraps GAE's own log facility.
>
> > > > > Best regards,
> > > > >                             Iceberg, 2010-Jul-24, 02:35(AM), Sat
>
> > > > > --- Original Message ---
> > > > > From:    Yarin Kessler 
> > > > > To:      Massimo Di Pierro 
> > > > > Cc:      web2py-users , Iceberg 
> > > > > ,
> > > > > Hans , Richard <
> > > > > richar...@gmail.com>, MikeEllis , 
> > > > > cjparsons <
> > > > > cjparso...@yahoo.co.uk>
> > > > > Date:    Fri, 23 Jul 2010 09:56:17 -0400
> > > > > Subject: Re: SQLite Logging
> > > > > ---
>
> > > > > > Glad you like- I'd love to see this as part of the core.  Let me 
> > > > > > know if
> > > > > > there's anything else I can do.
>
> > > > > > >I am not so keen to include the sqlite part because it is too 
> > > > > > >specific
>
> > > > > > Is this because it requires the extra module?  I kept it separate 
> > > > > > because
> > > > > > it's a Python, not web2py, specific class, but we could easily bake 
> > > > > > it
> > > > > into
> > > > > > log.py.
> > > > > > Personally I'm a big fan of SQLite for logging- what would it take 
> > > > > > to
> > > > > make
> > > > > > it less specific and ready for inclusion?
>
> > > > > > >we wo

[web2py] Re: Strange radio button behavior

2010-07-27 Thread _po
Hi Massimo,
I sent you this last week :
I hope the patch is still up to date...

With this patch, radio widget can use 'cols' attribute ; As previously
done for
checkboxes.

Grettings,
PO.


diff -r dcd13ab59569 gluon/sqlhtml.py
--- a/gluon/sqlhtml.py  Tue Jul 20 02:43:46 2010 -0500
+++ b/gluon/sqlhtml.py  Tue Jul 20 10:00:06 2010 +0200
@@ -232,10 +232,25 @@
 else:
 raise SyntaxError, 'widget cannot determine options
of %s' \
 % field
-opts = [TR(INPUT(_type='radio', _name=field.name,
+
+options = [(k, v) for k, v in options if str(v)]
+opts = []
+cols = attributes.get('cols',1)
+totals = len(options)
+mods = totals%cols
+rows = totals/cols
+if mods:
+rows += 1
+
+for r_index in range(rows):
+tds = []
+for k, v in options[r_index*cols:(r_index+1)*cols]:
+tds.append(TD(INPUT(_type='radio', _name=field.name,
  requires=attr.get('requires',None),
  hideerror=True, _value=k,
- value=value), v) for (k, v) in options if
str(v)]
+ value=value), v))
+opts.append(TR(tds))
+
 if opts:
 opts[-1][0][0]['hideerror'] = False
 return TABLE(*opts, **attr)
@@ -1199,3 +1214,4 @@
 components.append(TBODY(*tbody))

 form_factory = SQLFORM.factory # for backward compatibility,
deprecated
+




On 27 juil, 11:15, mdipierro  wrote:
> I thought it was included unless I got confused with a different
> patch. Please ask him to resend.
>
> On Jul 27, 3:21 am, Mathieu Clabaut  wrote:
>
> > Hi Massimo,
>
> >  A colleague of mine tell me he sent you a patch to include a horizontal
> > radio buttons in gluon (similar to the existing horizontal checkboxes).
> >  Has the patch a chance to make its way to the trunk ?
>
> > Best regards,
>
> > -Mathieu
>
> > On Tue, Jul 27, 2010 at 10:15, Alastair Medford
> > wrote:
>
> > > I was wanting to have horizontal radio buttons in my forms, so I set
> > > about making my own widget. The widget works well, except for one odd
> > > behavior. When I load the form, the first radio button is selected as
> > > desired. But after the form submits, page refreshes etc, the last
> > > radio buttons in the list are selected. IE, rather than defaulting to
> > > the first element selected as it did the first time, it defaults to
> > > the last. As this form will be submitted many times in a row, and the
> > > first option is the most often used, this proves to be a bit of a
> > > pain. I've tried this in multiple browsers to the same effect, so I'm
> > > pretty sure it's happening due to how the code is written. But I'm not
> > > really sure where this behavior is written. Anyone have any ideas?
>
> > > The code for my modified widget is below:
>
> > > class RadioWidget_Horizontal(OptionsWidget):
>
> > >   �...@staticmethod
> > >    def widget(field, value, **attributes):
> > >        """
> > >        generates an unordered list of radio buttons, which has
> > >        a css class radio_list so it can be styled inline.
>
> > >        see also: :meth:`FormWidget.widget`
> > >        """
>
> > >        attr = OptionsWidget._attributes(field, {}, **attributes)
> > >        attr['_class'] = attr['_class'] + " radio_list"
>
> > >        if hasattr(field.requires, 'options'):
> > >            options = field.requires.options()
> > >        else:
> > >            raise SyntaxError, 'widget cannot determine options of %s'
> > > % field
> > >        opts = [LI(INPUT(_type='radio', _name=field.name,
> > >                         requires=attr.get('requires',None),
> > >                         hideerror=True, _value=k,
> > >                         value=value), v) for (k, v) in options if
> > > str(v)]
> > >        if opts:
> > >            opts[-1][0]['hideerror'] = False
> > >            opts[0][0]['_checked'] = "checked"
> > >        return UL(*opts, **attr)
>
>


[web2py] Re: multiple checkboxes

2010-07-27 Thread KMax
> But after 
> reading:http://groups.google.com/group/web2py/browse_thread/thread/401b4c1928...,
> I don't think sqlform.factory is able to do what I want it to do.  I
> want to basically display ALL rows of a table given this database so
Actualy FORM(and sqlform.factory i guess) could do any form with any
date, but pesponce should be processed manualy.
Good side of using FORM is native web2py validators for any type form
input.
Thanks.


[web2py] Re: group memberships on the fly : to auth or not to auth?

2010-07-27 Thread mdipierro
It is appropriate for what you need to do.

On Jul 27, 4:40 am, aure  wrote:
> Hi everyone,
>
> I am trying to create an app in which a user can create a group and
> invite people to join it.
>
> A member of a group can then add documents to the group. This is not
> possible for non members of a group.
>
> My question is:
>
> is the authorisation mechanism described in the book (with decorators
> and all...) possible/appropriate for my scenario (groups keep on being
> added by users) OR on the contrary is it rather only appropriate for
> managing application wide rights (e.g. some managers of the app, plus
> some editors...)?
>
> Thanks,
> Aurelien


[web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread mdipierro
It is the INPUT widget that upon serialization displays the errors. I
can see it may be a problem with custom widgets.

On Jul 27, 4:42 am, Thadeus Burgess  wrote:
> There is no possible way it can. Looking through the source code, it
> never passes along the extra attributes to anything. The current way
> the widgets are implemented never use attributes passed to them.
>
> --
> Thadeus
>
> On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  wrote:
> > I am surprised it does not. can you help debug.
>
> > Try form.errors.clear()
>
> > On Jul 27, 2:29 am, Thadeus Burgess  wrote:
> >> I don't get it
>
> >> SQLFORM.factory(Field., hideerror=True).
>
> >> It doesn't do what its supposed to.
>
> >> How can I make sure that none of my widgets render errors alongside
> >> their own INPUT elements without rewriting everything in sqlhtml?
>
> >> --
> >> Thadeus


[web2py] Re: Strange radio button behavior

2010-07-27 Thread mdipierro
email please, indentation is messed up. Thanks.

On Jul 27, 4:37 am, _po  wrote:
> Hi Massimo,
> I sent you this last week :
> I hope the patch is still up to date...
>
> With this patch, radio widget can use 'cols' attribute ; As previously
> done for
> checkboxes.
>
> Grettings,
> PO.
>
> diff -r dcd13ab59569 gluon/sqlhtml.py
> --- a/gluon/sqlhtml.py  Tue Jul 20 02:43:46 2010 -0500
> +++ b/gluon/sqlhtml.py  Tue Jul 20 10:00:06 2010 +0200
> @@ -232,10 +232,25 @@
>              else:
>                  raise SyntaxError, 'widget cannot determine options
> of %s' \
>                      % field
> -        opts = [TR(INPUT(_type='radio', _name=field.name,
> +
> +        options = [(k, v) for k, v in options if str(v)]
> +        opts = []
> +        cols = attributes.get('cols',1)
> +        totals = len(options)
> +        mods = totals%cols
> +        rows = totals/cols
> +        if mods:
> +            rows += 1
> +
> +        for r_index in range(rows):
> +            tds = []
> +            for k, v in options[r_index*cols:(r_index+1)*cols]:
> +                tds.append(TD(INPUT(_type='radio', _name=field.name,
>                           requires=attr.get('requires',None),
>                           hideerror=True, _value=k,
> -                         value=value), v) for (k, v) in options if
> str(v)]
> +                         value=value), v))
> +            opts.append(TR(tds))
> +
>          if opts:
>              opts[-1][0][0]['hideerror'] = False
>          return TABLE(*opts, **attr)
> @@ -1199,3 +1214,4 @@
>          components.append(TBODY(*tbody))
>
>  form_factory = SQLFORM.factory # for backward compatibility,
> deprecated
> +
>
> On 27 juil, 11:15, mdipierro  wrote:
>
> > I thought it was included unless I got confused with a different
> > patch. Please ask him to resend.
>
> > On Jul 27, 3:21 am, Mathieu Clabaut  wrote:
>
> > > Hi Massimo,
>
> > >  A colleague of mine tell me he sent you a patch to include a horizontal
> > > radio buttons in gluon (similar to the existing horizontal checkboxes).
> > >  Has the patch a chance to make its way to the trunk ?
>
> > > Best regards,
>
> > > -Mathieu
>
> > > On Tue, Jul 27, 2010 at 10:15, Alastair Medford
> > > wrote:
>
> > > > I was wanting to have horizontal radio buttons in my forms, so I set
> > > > about making my own widget. The widget works well, except for one odd
> > > > behavior. When I load the form, the first radio button is selected as
> > > > desired. But after the form submits, page refreshes etc, the last
> > > > radio buttons in the list are selected. IE, rather than defaulting to
> > > > the first element selected as it did the first time, it defaults to
> > > > the last. As this form will be submitted many times in a row, and the
> > > > first option is the most often used, this proves to be a bit of a
> > > > pain. I've tried this in multiple browsers to the same effect, so I'm
> > > > pretty sure it's happening due to how the code is written. But I'm not
> > > > really sure where this behavior is written. Anyone have any ideas?
>
> > > > The code for my modified widget is below:
>
> > > > class RadioWidget_Horizontal(OptionsWidget):
>
> > > >   �...@staticmethod
> > > >    def widget(field, value, **attributes):
> > > >        """
> > > >        generates an unordered list of radio buttons, which has
> > > >        a css class radio_list so it can be styled inline.
>
> > > >        see also: :meth:`FormWidget.widget`
> > > >        """
>
> > > >        attr = OptionsWidget._attributes(field, {}, **attributes)
> > > >        attr['_class'] = attr['_class'] + " radio_list"
>
> > > >        if hasattr(field.requires, 'options'):
> > > >            options = field.requires.options()
> > > >        else:
> > > >            raise SyntaxError, 'widget cannot determine options of %s'
> > > > % field
> > > >        opts = [LI(INPUT(_type='radio', _name=field.name,
> > > >                         requires=attr.get('requires',None),
> > > >                         hideerror=True, _value=k,
> > > >                         value=value), v) for (k, v) in options if
> > > > str(v)]
> > > >        if opts:
> > > >            opts[-1][0]['hideerror'] = False
> > > >            opts[0][0]['_checked'] = "checked"
> > > >        return UL(*opts, **attr)


[web2py] Re: group memberships on the fly : to auth or not to auth?

2010-07-27 Thread aure
Thanks, Massimo!

On 27 juil, 12:02, mdipierro  wrote:
> It is appropriate for what you need to do.
>
> On Jul 27, 4:40 am, aure  wrote:
>
> > Hi everyone,
>
> > I am trying to create an app in which a user can create a group and
> > invite people to join it.
>
> > A member of a group can then add documents to the group. This is not
> > possible for non members of a group.
>
> > My question is:
>
> > is the authorisation mechanism described in the book (with decorators
> > and all...) possible/appropriate for my scenario (groups keep on being
> > added by users) OR on the contrary is it rather only appropriate for
> > managing application wide rights (e.g. some managers of the app, plus
> > some editors...)?
>
> > Thanks,
> > Aurelien
>
>


[web2py] sending membership invitations

2010-07-27 Thread aure
Hi everyone,

In an app a user have to send invitations to friends for them to
register on the app, and possibly join a group the sender has created
beforehand.

1. Does someone know about a way to have the app connect to GMail/
Facebook/... bring a list of people to select from, and send an email
to them?

2. What would be a simple way to get a "registration+join_group" link
in the email that works only once (so that  people cannot give it to
someone else after they have used it to register themselves)?

Thanks a lot,
Aurelien


Re: [web2py] Re: Privacy with plugin_wiki

2010-07-27 Thread Stef Mientki


what about protovis ?
http://vis.stanford.edu/protovis/ex/

cheers,
Stef


On 27-07-2010 11:16, mdipierro wrote:
> I will move to jflot
>
> On Jul 27, 3:33 am, Timmie  wrote:
>> Hello,
>> I have seen that you use Google Chartin API.
>>
>> Does this mean that my data is sent to Google for preparing the
>> charts?
>>
>> If so, I would recommend searching for a standalone charting lib like
>> matplotlib.
>>
>> regards.
>> Timmie



[web2py] Re: Privacy with plugin_wiki

2010-07-27 Thread mdipierro
cool. I did not know. May be too heavy for the purpose but I will
look.

Massimo

On Jul 27, 5:26 am, Stef Mientki  wrote:
> what about protovis ?http://vis.stanford.edu/protovis/ex/
>
> cheers,
> Stef
>
> On 27-07-2010 11:16, mdipierro wrote:
>
> > I will move to jflot
>
> > On Jul 27, 3:33 am, Timmie  wrote:
> >> Hello,
> >> I have seen that you use Google Chartin API.
>
> >> Does this mean that my data is sent to Google for preparing the
> >> charts?
>
> >> If so, I would recommend searching for a standalone charting lib like
> >> matplotlib.
>
> >> regards.
> >> Timmie


[web2py] book 3rd edition call of help

2010-07-27 Thread mdipierro
This is very very preliminary:

   http://web2py.com/book2

It is not editable (yet) and I am still adding material but it does
address a lot of issues.
Please use this thread to add comments in particular:

What sections are missing?
What needs to be clarified?
Are there spelling errors?
Are there formatting error?

One more way I could use help: I need all the images done with the old
layout to be redone with the new welcome layout.

Massimo


Re: [web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread Thadeus Burgess
This has been a problem for quite some time, I just did not get around
to complaining about it again until now =)

If I am to use a custom form (which I almost always do). Then I can't
have my form elements going off and rendering their own errors now can
I? Not very enterprisey of SQLFORM to just assume I want to always
display errors automatically.

--
Thadeus





On Tue, Jul 27, 2010 at 5:04 AM, mdipierro  wrote:
> It is the INPUT widget that upon serialization displays the errors. I
> can see it may be a problem with custom widgets.
>
> On Jul 27, 4:42 am, Thadeus Burgess  wrote:
>> There is no possible way it can. Looking through the source code, it
>> never passes along the extra attributes to anything. The current way
>> the widgets are implemented never use attributes passed to them.
>>
>> --
>> Thadeus
>>
>> On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  wrote:
>> > I am surprised it does not. can you help debug.
>>
>> > Try form.errors.clear()
>>
>> > On Jul 27, 2:29 am, Thadeus Burgess  wrote:
>> >> I don't get it
>>
>> >> SQLFORM.factory(Field., hideerror=True).
>>
>> >> It doesn't do what its supposed to.
>>
>> >> How can I make sure that none of my widgets render errors alongside
>> >> their own INPUT elements without rewriting everything in sqlhtml?
>>
>> >> --
>> >> Thadeus
>


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Adi
Wow..good job. Will take a while to review. :)

On Jul 27, 3:49 pm, mdipierro  wrote:
> This is very very preliminary:
>
>    http://web2py.com/book2
>
> It is not editable (yet) and I am still adding material but it does
> address a lot of issues.
> Please use this thread to add comments in particular:
>
> What sections are missing?
> What needs to be clarified?
> Are there spelling errors?
> Are there formatting error?
>
> One more way I could use help: I need all the images done with the old
> layout to be redone with the new welcome layout.
>
> Massimo


[web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread mdipierro
Let me look into this. I am sure there is a way to do it. I just never
use custom forms myself.
Is the problem with your own widgets? Do you assign widgets
explicitely? Can you post an example?

Massimo

On Jul 27, 6:00 am, Thadeus Burgess  wrote:
> This has been a problem for quite some time, I just did not get around
> to complaining about it again until now =)
>
> If I am to use a custom form (which I almost always do). Then I can't
> have my form elements going off and rendering their own errors now can
> I? Not very enterprisey of SQLFORM to just assume I want to always
> display errors automatically.
>
> --
> Thadeus
>
> On Tue, Jul 27, 2010 at 5:04 AM, mdipierro  wrote:
> > It is the INPUT widget that upon serialization displays the errors. I
> > can see it may be a problem with custom widgets.
>
> > On Jul 27, 4:42 am, Thadeus Burgess  wrote:
> >> There is no possible way it can. Looking through the source code, it
> >> never passes along the extra attributes to anything. The current way
> >> the widgets are implemented never use attributes passed to them.
>
> >> --
> >> Thadeus
>
> >> On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  wrote:
> >> > I am surprised it does not. can you help debug.
>
> >> > Try form.errors.clear()
>
> >> > On Jul 27, 2:29 am, Thadeus Burgess  wrote:
> >> >> I don't get it
>
> >> >> SQLFORM.factory(Field., hideerror=True).
>
> >> >> It doesn't do what its supposed to.
>
> >> >> How can I make sure that none of my widgets render errors alongside
> >> >> their own INPUT elements without rewriting everything in sqlhtml?
>
> >> >> --
> >> >> Thadeus


[web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread mdipierro
Until this is resolved this is how I usually handle the situation.

form=SQLFORM()
if form.accepts()
errors,form.errors=form.errors,{}
return dict(form=form,errors=form)

Unless you do this the philosophy is that widgets handle their own
errors and they can be customized by overriding .xml().

On Jul 27, 6:00 am, Thadeus Burgess  wrote:
> This has been a problem for quite some time, I just did not get around
> to complaining about it again until now =)
>
> If I am to use a custom form (which I almost always do). Then I can't
> have my form elements going off and rendering their own errors now can
> I? Not very enterprisey of SQLFORM to just assume I want to always
> display errors automatically.
>
> --
> Thadeus
>
> On Tue, Jul 27, 2010 at 5:04 AM, mdipierro  wrote:
> > It is the INPUT widget that upon serialization displays the errors. I
> > can see it may be a problem with custom widgets.
>
> > On Jul 27, 4:42 am, Thadeus Burgess  wrote:
> >> There is no possible way it can. Looking through the source code, it
> >> never passes along the extra attributes to anything. The current way
> >> the widgets are implemented never use attributes passed to them.
>
> >> --
> >> Thadeus
>
> >> On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  wrote:
> >> > I am surprised it does not. can you help debug.
>
> >> > Try form.errors.clear()
>
> >> > On Jul 27, 2:29 am, Thadeus Burgess  wrote:
> >> >> I don't get it
>
> >> >> SQLFORM.factory(Field., hideerror=True).
>
> >> >> It doesn't do what its supposed to.
>
> >> >> How can I make sure that none of my widgets render errors alongside
> >> >> their own INPUT elements without rewriting everything in sqlhtml?
>
> >> >> --
> >> >> Thadeus


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mdipierro
web2py.com/book was broken into section
web2py.com/book2 is broken into chapters

what is better?
Once printed it will be the same.

On Jul 27, 5:49 am, mdipierro  wrote:
> This is very very preliminary:
>
>    http://web2py.com/book2
>
> It is not editable (yet) and I am still adding material but it does
> address a lot of issues.
> Please use this thread to add comments in particular:
>
> What sections are missing?
> What needs to be clarified?
> Are there spelling errors?
> Are there formatting error?
>
> One more way I could use help: I need all the images done with the old
> layout to be redone with the new welcome layout.
>
> Massimo


[web2py] Re: Custom Registration form

2010-07-27 Thread elfuego1
OK!. Thank you for clarifying THAT.


On 27 Lip, 09:09, mdipierro  wrote:
> You are mixing a SQLFORM (the form in the first two lines) with a FORM
> (in the register function). If you want db access you need to insert
> the former not the latter. If you want a custom form you should not
> use FORM at all, you should just place the {{=form.cutsom.widget}}s in
> the view.
>
> On Jul 26, 3:47 pm, elfuego1  wrote:
>
>
>
> > In default.py I had defined my registration form
>
> > lbl=form.custom.label
> > wdgt=form.custom.widget
>
> > def register():
> >     form=FORM(TABLE(TR(lbl.username), TD(wdgt.username),
> >                     TR(lbl.password), TD(wdgt.password),
> >                     TR(lbl.first_name), TD(wdgt.first_name),
> >                     TR(lbl.last_name), TD(wdgt.last_name),
> >                     TR(lbl.phone_no), TD(wdgt.phone_no),
> >                     TR("",INPUT(_type="submit",_value="SUBMIT"
> >     if form.accepts(request.vars,session):
> >         response.flash="Form accepted"
> >     elif form.errors:
> >         response.flash="Form is invalid"
> >     else:
> >         response.flash="Please fill the form"
> >     return dict(form=form,vars=form.vars)
>
> > This submit gives me only information "Form accepted", but actual data
> > is not saved into database.
> > When I try to add submit button using "form.custom.submit" I recive an
> > error:
> > AttributeError: 'tuple' object has no attribute 'custom'
>
> > When I add email input field using wdgt.email then this line
>
> > if form.accepts(request.vars,session):
>
> > gives an error:
>
> > TypeError: expected string or buffer
>
> > I need to know how should I add an email field to the registration
> > form, so it would be accepted and how do you add a SUBMIT button to
> > the form so the data would be stored in database?


[web2py] SQLFORM update not working?

2010-07-27 Thread Florian
Hi,

I'm trying web2py and want to create a "product" database and forms.

-displaying all products
-displaying one (in detail) and
-creating a new product

works, but i have problems with the "edit/delete" part. It will show
the filled-out form when calling e.g. product/edit/2 , but submitting
the form won't update the record.
What am I doing wrong?

models/db.py looks like this:
---
db.define_table('product',
Field('added_at', 'datetime', default=request.now, readable=False,
writable=False),
Field('title', 'string'),
Field('ean', 'integer'),
Field('brand', 'string'),
Field('mpn', 'string'),
Field('image', 'upload'),
Field('description', 'text'),
Field('cost_price', 'double'),
Field('sell_price', 'double'),
Field('asin', 'string'))

db.product.ean.requires = IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'product.ean')
db.product.title.requires = IS_NOT_EMPTY()
---

controllers/product.py has this function:
---
def edit():
form = SQLFORM(db.product, request.args(0))
return dict(form=form)
---

and views/product/edit.html:
---
{{extend 'layout.html'}}
{{=T("Edit product"}}
{{=form}}
---

Hope you can help me,

Florian


[web2py] Re: SQLFORM update not working?

2010-07-27 Thread Florian
sry for reposting, it somehow didn't show up...


[web2py] Re: SQLFORM update not working?

2010-07-27 Thread Florian
okay, now this works :-) Thanks!

Is inside "form.accepts" the code thats "acts" on the form data, and
that was the reason why it didn't work?

Another problem:
How can I add a "db requirement" so that you can enter a value for
product.ean only if you want to, but when there is one, it has to be
unique (so that an empty field is not caught by IS_NOT_IN_DB() if
there are 2 products with no ean entered?

On 27 Jul., 11:18, mdipierro  wrote:
> This:
>
> def edit():
>     form = SQLFORM(db.product, request.args(0))
>     return dict(form=form)
>
> should be
>
> def edit():
>     form = SQLFORM(db.product, request.args(0))
>     if form.accepts(request.vars,session): pass
>     return dict(form=form)
>
> or
>
> def edit():
>     form = crud.update(db.product, request.args(0))
>     return dict(form=form)
>
> and this:
>
>   db.product.ean.requires = IS_NOT_EMPTY(),
> IS_NOT_IN_DB(db,'product.ean')
>
> can be simplified into
>
>   db.product.ean.requires = IS_NOT_IN_DB(db,'product.ean')
>
> since IS_NOT_IN_DB now checks whether value is empty
>
> On Jul 26, 1:09 pm, Florian  wrote:
>
>
>
> > Hi,
>
> > I'm trying web2py and want to create a "product" database and forms.
>
> > -displaying all products
> > -displaying one (in detail) and
> > -creating a new product
>
> > works, but i have problems with the "edit/delete" part. It will show
> > the filled-out form when calling e.g. product/edit/2 , but submitting
> > the form won't update the record.
> > What am I doing wrong?
>
> > models/db.py looks like this:
> > ---
> > db.define_table('product',
> >     Field('added_at', 'datetime', default=request.now, readable=False,
> > writable=False),
> >     Field('title', 'string'),
> >     Field('ean', 'integer'),
> >     Field('brand', 'string'),
> >     Field('mpn', 'string'),
> >     Field('image', 'upload'),
> >     Field('description', 'text'),
> >     Field('cost_price', 'double'),
> >     Field('sell_price', 'double'),
> >     Field('asin', 'string'))
>
> > db.product.ean.requires = IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> > 'product.ean')
> > db.product.title.requires = IS_NOT_EMPTY()
> > ---
>
> > controllers/product.py has this function:
> > ---
> > def edit():
> >     form = SQLFORM(db.product, request.args(0))
> >     return dict(form=form)
> > ---
>
> > and views/product/edit.html:
> > ---
> > {{extend 'layout.html'}}
> > {{=T("Edit product")}}
> > {{=form}}
> > ---
>
> > Hope you can help me,
>
> > Florian


[web2py] Re: Hide Error on SQLFORM

2010-07-27 Thread mdipierro
I looked into it. What you are trying to do was never supported.
hideerror was a machanism for allowing certain custom widgets to
explicitly hide error or decide where to display them.

I say "was" because I just implemented it the way *I think* you expect
it to work. Works with custom forms as well.

if form.accepts(,hideerror=True): 


On Jul 27, 6:50 am, mdipierro  wrote:
> Until this is resolved this is how I usually handle the situation.
>
> form=SQLFORM()
> if form.accepts()
>     errors,form.errors=form.errors,{}
> return dict(form=form,errors=form)
>
> Unless you do this the philosophy is that widgets handle their own
> errors and they can be customized by overriding .xml().
>
> On Jul 27, 6:00 am, Thadeus Burgess  wrote:
>
> > This has been a problem for quite some time, I just did not get around
> > to complaining about it again until now =)
>
> > If I am to use a custom form (which I almost always do). Then I can't
> > have my form elements going off and rendering their own errors now can
> > I? Not very enterprisey of SQLFORM to just assume I want to always
> > display errors automatically.
>
> > --
> > Thadeus
>
> > On Tue, Jul 27, 2010 at 5:04 AM, mdipierro  wrote:
> > > It is the INPUT widget that upon serialization displays the errors. I
> > > can see it may be a problem with custom widgets.
>
> > > On Jul 27, 4:42 am, Thadeus Burgess  wrote:
> > >> There is no possible way it can. Looking through the source code, it
> > >> never passes along the extra attributes to anything. The current way
> > >> the widgets are implemented never use attributes passed to them.
>
> > >> --
> > >> Thadeus
>
> > >> On Tue, Jul 27, 2010 at 4:13 AM, mdipierro  
> > >> wrote:
> > >> > I am surprised it does not. can you help debug.
>
> > >> > Try form.errors.clear()
>
> > >> > On Jul 27, 2:29 am, Thadeus Burgess  wrote:
> > >> >> I don't get it
>
> > >> >> SQLFORM.factory(Field., hideerror=True).
>
> > >> >> It doesn't do what its supposed to.
>
> > >> >> How can I make sure that none of my widgets render errors alongside
> > >> >> their own INPUT elements without rewriting everything in sqlhtml?
>
> > >> >> --
> > >> >> Thadeus


Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
Not sure if this is related to Rocket or whether a new topic is needed.

This morning I found several OSError reports about "Too many open files" in
a web2py development server that's been running locally for several days.
 The app code isn't doing any explicit file i/o so I don't know what's going
on,  but here are the tracebacks in case someone else is seeing anything
similar.

Mike

Exception in thread Thread-89:
Traceback (most recent call last):
  File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
line 522, in __bootstrap_inner
self.run()
  File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
shell=self.shell)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
line 595, in __init__
errread, errwrite)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
line 1018, in _execute_child
errpipe_read, errpipe_write = os.pipe()
OSError: [Errno 24] Too many open files

ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
  File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
sock = l.accept()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
line 195, in accept
sock, addr = self._sock.accept()
error: [Errno 24] Too many open files

ERROR:root:corrupted file:
/Users/mellis/w2ptip/applications/init/cache/cache.shelve
ERROR:root:Traceback (most recent call last):
  File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in restricted
exec ccode in environment
  File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35, in

auth.define_tables() # creates all needed tables
  File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)')
  File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
  File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
IOError: [Errno 24] Too many open files:
'/Users/mellis/w2ptip/applications/init/databases/sql.log'



On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:

> Thanks everyone, for getting this issue resolved...
> Web2py rocks!
> Cheers, Rahul
>
> On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > Yes , Since from start of web2py , Massimo and Us never recommend to use
> > built-in web2py server at production. They are mainly for development
> > purpose.
> > Since Very start of the project , since Cherrypy , Massimo always Suggest
> to
> > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
> Serious
> > Production Server.
> >
> > Rocket tho tries quite hard to achieve production level Performance with
> all
> > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a chance.
> >
> > On Sat, Jul 24, 2010 at 7:39 PM, Scott  wrote:
> > > Please allow me to preface my comments: I have nothing against Rocket;
> > > my opinions come from years of experience with Java EE deployments.
> >
> > > I think raising the max_threads to 1024 is a good idea.  However, my
> > > opinion is that Rocket alone should not be used for a production
> > > deployment; much as I would not use the built-in Web server in JBoss,
> > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
> > > production would be to use an Apache front-end into Rocket.  Apache is
> > > more battle-hardened in this area, and it's a lot easier to handle DoS
> > > attacks through modules such as mod_evasive.  There are numerous other
> > > benefits too, such as easily enabling gzip compression and allowing
> > > you a better security model through Defense in Depth... but I digress.
> >
> > > On Jul 23, 5:41 pm, mdipierro  wrote:
> > > > On a second thought this open the door to more sever denial of
> service
> > > > attacks than caused by the original problem. How about, until there
> is
> > > > a better under understanding and solution, we just increase
> > > > max_threads from the original 128 to 1024.
> >
> > > > On Jul 22, 11:27 am, Timbo  wrote:
> >
> > > > > Try one quick change for me please...rocketis constructed around
> line
> > > > > 655 in main.py
> >
> > > > > Add a parameter to the constructor call(s):  max_threads=0
> >
> > > > > Please let me know if that affects the problem.
> >
> > > > > -tim
> >
> > > > > On Jul 22, 10:34 am, mdipierro  wrote:
> >
> > > > > > I can reproduce the problem. I did on localhost with two
> different
> > > > > > browsers.
> > > > > > Using firebug I can see it takes 25seconds to download base.css
> (the
> > > > > > problem is not always with the same file).
> > > > > > While I did the test, I also monitored httpserver.log and I find
> that
> > > > > > it NEVER takes more than 1.2ms serve base.css.
> > > > > > This is what the log shows:
> >
> > > > > > 
> > > > > > 127.0.0.1, 2010-07-22 10:16:38, GET,
> /michealellistest/static/images/
> > > > > > header.png, HTTP/1.1, 304, 0.000563
> > > > > > 127.0.0.1

[web2py] Re: rocket performance issues

2010-07-27 Thread mdipierro
Are you opening any files explicitely in your app? Which web2py
version and which Python version are you using?

On Jul 27, 7:33 am, Michael Ellis  wrote:
> Not sure if this is related to Rocket or whether a new topic is needed.
>
> This morning I found several OSError reports about "Too many open files" in
> a web2py development server that's been running locally for several days.
>  The app code isn't doing any explicit file i/o so I don't know what's going
> on,  but here are the tracebacks in case someone else is seeing anything
> similar.
>
> Mike
>
> Exception in thread Thread-89:
> Traceback (most recent call last):
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
> line 522, in __bootstrap_inner
>     self.run()
>   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
>     shell=self.shell)
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> line 595, in __init__
>     errread, errwrite)
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> line 1018, in _execute_child
>     errpipe_read, errpipe_write = os.pipe()
> OSError: [Errno 24] Too many open files
>
> ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
>   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
>     sock = l.accept()
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> line 195, in accept
>     sock, addr = self._sock.accept()
> error: [Errno 24] Too many open files
>
> ERROR:root:corrupted file:
> /Users/mellis/w2ptip/applications/init/cache/cache.shelve
> ERROR:root:Traceback (most recent call last):
>   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35, in
> 
>     auth.define_tables()                         # creates all needed tables
>   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in define_tables
>     format='%(first_name)s %(last_name)s (%(id)s)')
>   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
>   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
> IOError: [Errno 24] Too many open files:
> '/Users/mellis/w2ptip/applications/init/databases/sql.log'
>
> On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:
> > Thanks everyone, for getting this issue resolved...
> > Web2py rocks!
> > Cheers, Rahul
>
> > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > > Yes , Since from start of web2py , Massimo and Us never recommend to use
> > > built-in web2py server at production. They are mainly for development
> > > purpose.
> > > Since Very start of the project , since Cherrypy , Massimo always Suggest
> > to
> > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
> > Serious
> > > Production Server.
>
> > > Rocket tho tries quite hard to achieve production level Performance with
> > all
> > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a chance.
>
> > > On Sat, Jul 24, 2010 at 7:39 PM, Scott  wrote:
> > > > Please allow me to preface my comments: I have nothing against Rocket;
> > > > my opinions come from years of experience with Java EE deployments.
>
> > > > I think raising the max_threads to 1024 is a good idea.  However, my
> > > > opinion is that Rocket alone should not be used for a production
> > > > deployment; much as I would not use the built-in Web server in JBoss,
> > > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
> > > > production would be to use an Apache front-end into Rocket.  Apache is
> > > > more battle-hardened in this area, and it's a lot easier to handle DoS
> > > > attacks through modules such as mod_evasive.  There are numerous other
> > > > benefits too, such as easily enabling gzip compression and allowing
> > > > you a better security model through Defense in Depth... but I digress.
>
> > > > On Jul 23, 5:41 pm, mdipierro  wrote:
> > > > > On a second thought this open the door to more sever denial of
> > service
> > > > > attacks than caused by the original problem. How about, until there
> > is
> > > > > a better under understanding and solution, we just increase
> > > > > max_threads from the original 128 to 1024.
>
> > > > > On Jul 22, 11:27 am, Timbo  wrote:
>
> > > > > > Try one quick change for me please...rocketis constructed around
> > line
> > > > > > 655 in main.py
>
> > > > > > Add a parameter to the constructor call(s):  max_threads=0
>
> > > > > > Please let me know if that affects the problem.
>
> > > > > > -tim
>
> > > > > > On Jul 22, 10:34 am, mdipierro  wrote:
>
> > > > > > > I can reproduce the problem. I did on localhost with two
> > different
> > > > > > > browsers.
> > > > > > > Using firebug I can see it takes 25seconds to download base.css
> > (the
> > > > > > > problem is not always with the same file).
> > > > > > > While I did the t

[web2py] Re: rocket performance issues

2010-07-27 Thread mdipierro
Ignore my previous email I see you are using 2.6 and the problem
is with cron. I think the problem is a cron process that does not end
and keeps restarting. Are you using cron?

On Jul 27, 7:33 am, Michael Ellis  wrote:
> Not sure if this is related to Rocket or whether a new topic is needed.
>
> This morning I found several OSError reports about "Too many open files" in
> a web2py development server that's been running locally for several days.
>  The app code isn't doing any explicit file i/o so I don't know what's going
> on,  but here are the tracebacks in case someone else is seeing anything
> similar.
>
> Mike
>
> Exception in thread Thread-89:
> Traceback (most recent call last):
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
> line 522, in __bootstrap_inner
>     self.run()
>   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
>     shell=self.shell)
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> line 595, in __init__
>     errread, errwrite)
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> line 1018, in _execute_child
>     errpipe_read, errpipe_write = os.pipe()
> OSError: [Errno 24] Too many open files
>
> ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
>   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
>     sock = l.accept()
>   File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> line 195, in accept
>     sock, addr = self._sock.accept()
> error: [Errno 24] Too many open files
>
> ERROR:root:corrupted file:
> /Users/mellis/w2ptip/applications/init/cache/cache.shelve
> ERROR:root:Traceback (most recent call last):
>   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35, in
> 
>     auth.define_tables()                         # creates all needed tables
>   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in define_tables
>     format='%(first_name)s %(last_name)s (%(id)s)')
>   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
>   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
> IOError: [Errno 24] Too many open files:
> '/Users/mellis/w2ptip/applications/init/databases/sql.log'
>
> On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:
> > Thanks everyone, for getting this issue resolved...
> > Web2py rocks!
> > Cheers, Rahul
>
> > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > > Yes , Since from start of web2py , Massimo and Us never recommend to use
> > > built-in web2py server at production. They are mainly for development
> > > purpose.
> > > Since Very start of the project , since Cherrypy , Massimo always Suggest
> > to
> > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
> > Serious
> > > Production Server.
>
> > > Rocket tho tries quite hard to achieve production level Performance with
> > all
> > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a chance.
>
> > > On Sat, Jul 24, 2010 at 7:39 PM, Scott  wrote:
> > > > Please allow me to preface my comments: I have nothing against Rocket;
> > > > my opinions come from years of experience with Java EE deployments.
>
> > > > I think raising the max_threads to 1024 is a good idea.  However, my
> > > > opinion is that Rocket alone should not be used for a production
> > > > deployment; much as I would not use the built-in Web server in JBoss,
> > > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
> > > > production would be to use an Apache front-end into Rocket.  Apache is
> > > > more battle-hardened in this area, and it's a lot easier to handle DoS
> > > > attacks through modules such as mod_evasive.  There are numerous other
> > > > benefits too, such as easily enabling gzip compression and allowing
> > > > you a better security model through Defense in Depth... but I digress.
>
> > > > On Jul 23, 5:41 pm, mdipierro  wrote:
> > > > > On a second thought this open the door to more sever denial of
> > service
> > > > > attacks than caused by the original problem. How about, until there
> > is
> > > > > a better under understanding and solution, we just increase
> > > > > max_threads from the original 128 to 1024.
>
> > > > > On Jul 22, 11:27 am, Timbo  wrote:
>
> > > > > > Try one quick change for me please...rocketis constructed around
> > line
> > > > > > 655 in main.py
>
> > > > > > Add a parameter to the constructor call(s):  max_threads=0
>
> > > > > > Please let me know if that affects the problem.
>
> > > > > > -tim
>
> > > > > > On Jul 22, 10:34 am, mdipierro  wrote:
>
> > > > > > > I can reproduce the problem. I did on localhost with two
> > different
> > > > > > > browsers.
> > > > > > > Using firebug I can see it takes 25seconds to download base.css
> > (the
> > > > > > > probl

Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
Not using cron.




On Tue, Jul 27, 2010 at 8:43 AM, mdipierro  wrote:

> Ignore my previous email I see you are using 2.6 and the problem
> is with cron. I think the problem is a cron process that does not end
> and keeps restarting. Are you using cron?
>
> On Jul 27, 7:33 am, Michael Ellis  wrote:
> > Not sure if this is related to Rocket or whether a new topic is needed.
> >
> > This morning I found several OSError reports about "Too many open files"
> in
> > a web2py development server that's been running locally for several days.
> >  The app code isn't doing any explicit file i/o so I don't know what's
> going
> > on,  but here are the tracebacks in case someone else is seeing anything
> > similar.
> >
> > Mike
> >
> > Exception in thread Thread-89:
> > Traceback (most recent call last):
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
> > line 522, in __bootstrap_inner
> > self.run()
> >   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
> > shell=self.shell)
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > line 595, in __init__
> > errread, errwrite)
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > line 1018, in _execute_child
> > errpipe_read, errpipe_write = os.pipe()
> > OSError: [Errno 24] Too many open files
> >
> > ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
> >   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
> > sock = l.accept()
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> > line 195, in accept
> > sock, addr = self._sock.accept()
> > error: [Errno 24] Too many open files
> >
> > ERROR:root:corrupted file:
> > /Users/mellis/w2ptip/applications/init/cache/cache.shelve
> > ERROR:root:Traceback (most recent call last):
> >   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in
> restricted
> > exec ccode in environment
> >   File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35, in
> > 
> > auth.define_tables() # creates all needed
> tables
> >   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in define_tables
> > format='%(first_name)s %(last_name)s (%(id)s)')
> >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
> >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
> > IOError: [Errno 24] Too many open files:
> > '/Users/mellis/w2ptip/applications/init/databases/sql.log'
> >
> > On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:
> > > Thanks everyone, for getting this issue resolved...
> > > Web2py rocks!
> > > Cheers, Rahul
> >
> > > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > > > Yes , Since from start of web2py , Massimo and Us never recommend to
> use
> > > > built-in web2py server at production. They are mainly for development
> > > > purpose.
> > > > Since Very start of the project , since Cherrypy , Massimo always
> Suggest
> > > to
> > > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
> > > Serious
> > > > Production Server.
> >
> > > > Rocket tho tries quite hard to achieve production level Performance
> with
> > > all
> > > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a
> chance.
> >
> > > > On Sat, Jul 24, 2010 at 7:39 PM, Scott 
> wrote:
> > > > > Please allow me to preface my comments: I have nothing against
> Rocket;
> > > > > my opinions come from years of experience with Java EE deployments.
> >
> > > > > I think raising the max_threads to 1024 is a good idea.  However,
> my
> > > > > opinion is that Rocket alone should not be used for a production
> > > > > deployment; much as I would not use the built-in Web server in
> JBoss,
> > > > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
> > > > > production would be to use an Apache front-end into Rocket.  Apache
> is
> > > > > more battle-hardened in this area, and it's a lot easier to handle
> DoS
> > > > > attacks through modules such as mod_evasive.  There are numerous
> other
> > > > > benefits too, such as easily enabling gzip compression and allowing
> > > > > you a better security model through Defense in Depth... but I
> digress.
> >
> > > > > On Jul 23, 5:41 pm, mdipierro  wrote:
> > > > > > On a second thought this open the door to more sever denial of
> > > service
> > > > > > attacks than caused by the original problem. How about, until
> there
> > > is
> > > > > > a better under understanding and solution, we just increase
> > > > > > max_threads from the original 128 to 1024.
> >
> > > > > > On Jul 22, 11:27 am, Timbo  wrote:
> >
> > > > > > > Try one quick change for me please...rocketis constructed
> around
> > > line
> > > > > > > 655 in main.py
> >
> > > > > > > Add a parameter to the constructor call(s):  max_threads=0
> >
> > > > > > > Please l

Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
I think I can test the cron hypothesis.  I'm running web2py under winpdb.
Normally, I set the fork mode to "parent, auto" so that it doesn't break
when a child process starts. If I change it to manual, it should break next
time a child process is spawned.  What should I look for when that happens?



On Tue, Jul 27, 2010 at 8:49 AM, Michael Ellis wrote:

> Not using cron.
>
>
>
>
> On Tue, Jul 27, 2010 at 8:43 AM, mdipierro wrote:
>
>> Ignore my previous email I see you are using 2.6 and the problem
>> is with cron. I think the problem is a cron process that does not end
>> and keeps restarting. Are you using cron?
>>
>> On Jul 27, 7:33 am, Michael Ellis  wrote:
>> > Not sure if this is related to Rocket or whether a new topic is needed.
>> >
>> > This morning I found several OSError reports about "Too many open files"
>> in
>> > a web2py development server that's been running locally for several
>> days.
>> >  The app code isn't doing any explicit file i/o so I don't know what's
>> going
>> > on,  but here are the tracebacks in case someone else is seeing anything
>> > similar.
>> >
>> > Mike
>> >
>> > Exception in thread Thread-89:
>> > Traceback (most recent call last):
>> >   File
>> >
>> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
>> > line 522, in __bootstrap_inner
>> > self.run()
>> >   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
>> > shell=self.shell)
>> >   File
>> >
>> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
>> > line 595, in __init__
>> > errread, errwrite)
>> >   File
>> >
>> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
>> > line 1018, in _execute_child
>> > errpipe_read, errpipe_write = os.pipe()
>> > OSError: [Errno 24] Too many open files
>> >
>> > ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
>> >   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
>> > sock = l.accept()
>> >   File
>> >
>> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
>> > line 195, in accept
>> > sock, addr = self._sock.accept()
>> > error: [Errno 24] Too many open files
>> >
>> > ERROR:root:corrupted file:
>> > /Users/mellis/w2ptip/applications/init/cache/cache.shelve
>> > ERROR:root:Traceback (most recent call last):
>> >   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in
>> restricted
>> > exec ccode in environment
>> >   File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35,
>> in
>> > 
>> > auth.define_tables() # creates all needed
>> tables
>> >   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in
>> define_tables
>> > format='%(first_name)s %(last_name)s (%(id)s)')
>> >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
>> >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
>> > IOError: [Errno 24] Too many open files:
>> > '/Users/mellis/w2ptip/applications/init/databases/sql.log'
>> >
>> > On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:
>> > > Thanks everyone, for getting this issue resolved...
>> > > Web2py rocks!
>> > > Cheers, Rahul
>> >
>> > > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
>> > > > Yes , Since from start of web2py , Massimo and Us never recommend to
>> use
>> > > > built-in web2py server at production. They are mainly for
>> development
>> > > > purpose.
>> > > > Since Very start of the project , since Cherrypy , Massimo always
>> Suggest
>> > > to
>> > > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
>> > > Serious
>> > > > Production Server.
>> >
>> > > > Rocket tho tries quite hard to achieve production level Performance
>> with
>> > > all
>> > > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a
>> chance.
>> >
>> > > > On Sat, Jul 24, 2010 at 7:39 PM, Scott 
>> wrote:
>> > > > > Please allow me to preface my comments: I have nothing against
>> Rocket;
>> > > > > my opinions come from years of experience with Java EE
>> deployments.
>> >
>> > > > > I think raising the max_threads to 1024 is a good idea.  However,
>> my
>> > > > > opinion is that Rocket alone should not be used for a production
>> > > > > deployment; much as I would not use the built-in Web server in
>> JBoss,
>> > > > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
>> > > > > production would be to use an Apache front-end into Rocket.
>>  Apache is
>> > > > > more battle-hardened in this area, and it's a lot easier to handle
>> DoS
>> > > > > attacks through modules such as mod_evasive.  There are numerous
>> other
>> > > > > benefits too, such as easily enabling gzip compression and
>> allowing
>> > > > > you a better security model through Defense in Depth... but I
>> digress.
>> >
>> > > > > On Jul 23, 5:41 pm, mdipierro  wrote:
>> > > > > > On a second thought this open the door to more sever denial of
>> > > service
>

[web2py] Re: rocket performance issues

2010-07-27 Thread mdipierro
Yet is being called. It is on by default. Try set cron=False at the
bottom of web2py.py

On Jul 27, 7:49 am, Michael Ellis  wrote:
> Not using cron.
>
> On Tue, Jul 27, 2010 at 8:43 AM, mdipierro  wrote:
> > Ignore my previous email I see you are using 2.6 and the problem
> > is with cron. I think the problem is a cron process that does not end
> > and keeps restarting. Are you using cron?
>
> > On Jul 27, 7:33 am, Michael Ellis  wrote:
> > > Not sure if this is related to Rocket or whether a new topic is needed.
>
> > > This morning I found several OSError reports about "Too many open files"
> > in
> > > a web2py development server that's been running locally for several days.
> > >  The app code isn't doing any explicit file i/o so I don't know what's
> > going
> > > on,  but here are the tracebacks in case someone else is seeing anything
> > > similar.
>
> > > Mike
>
> > > Exception in thread Thread-89:
> > > Traceback (most recent call last):
> > >   File
>
> > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
> > > line 522, in __bootstrap_inner
> > >     self.run()
> > >   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
> > >     shell=self.shell)
> > >   File
>
> > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > > line 595, in __init__
> > >     errread, errwrite)
> > >   File
>
> > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > > line 1018, in _execute_child
> > >     errpipe_read, errpipe_write = os.pipe()
> > > OSError: [Errno 24] Too many open files
>
> > > ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
> > >   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
> > >     sock = l.accept()
> > >   File
>
> > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> > > line 195, in accept
> > >     sock, addr = self._sock.accept()
> > > error: [Errno 24] Too many open files
>
> > > ERROR:root:corrupted file:
> > > /Users/mellis/w2ptip/applications/init/cache/cache.shelve
> > > ERROR:root:Traceback (most recent call last):
> > >   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in
> > restricted
> > >     exec ccode in environment
> > >   File "/Users/mellis/w2ptip/applications/init/models/db.py", line 35, in
> > > 
> > >     auth.define_tables()                         # creates all needed
> > tables
> > >   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in define_tables
> > >     format='%(first_name)s %(last_name)s (%(id)s)')
> > >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in define_table
> > >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
> > > IOError: [Errno 24] Too many open files:
> > > '/Users/mellis/w2ptip/applications/init/databases/sql.log'
>
> > > On Tue, Jul 27, 2010 at 2:54 AM, Rahul  wrote:
> > > > Thanks everyone, for getting this issue resolved...
> > > > Web2py rocks!
> > > > Cheers, Rahul
>
> > > > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > > > > Yes , Since from start of web2py , Massimo and Us never recommend to
> > use
> > > > > built-in web2py server at production. They are mainly for development
> > > > > purpose.
> > > > > Since Very start of the project , since Cherrypy , Massimo always
> > Suggest
> > > > to
> > > > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python in
> > > > Serious
> > > > > Production Server.
>
> > > > > Rocket tho tries quite hard to achieve production level Performance
> > with
> > > > all
> > > > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a
> > chance.
>
> > > > > On Sat, Jul 24, 2010 at 7:39 PM, Scott 
> > wrote:
> > > > > > Please allow me to preface my comments: I have nothing against
> > Rocket;
> > > > > > my opinions come from years of experience with Java EE deployments.
>
> > > > > > I think raising the max_threads to 1024 is a good idea.  However,
> > my
> > > > > > opinion is that Rocket alone should not be used for a production
> > > > > > deployment; much as I would not use the built-in Web server in
> > JBoss,
> > > > > > WebLogic, Geronimo, etc. as the front door.  My suggestion for
> > > > > > production would be to use an Apache front-end into Rocket.  Apache
> > is
> > > > > > more battle-hardened in this area, and it's a lot easier to handle
> > DoS
> > > > > > attacks through modules such as mod_evasive.  There are numerous
> > other
> > > > > > benefits too, such as easily enabling gzip compression and allowing
> > > > > > you a better security model through Defense in Depth... but I
> > digress.
>
> > > > > > On Jul 23, 5:41 pm, mdipierro  wrote:
> > > > > > > On a second thought this open the door to more sever denial of
> > > > service
> > > > > > > attacks than caused by the original problem. How about, until
> > there
> > > > is
> > > > > > > a better under understanding and solution, we just increase
> > > > > > > max_threads from

[web2py] Re: OpenID supported with login method

2010-07-27 Thread mdipierro
Sorry for my late replay.

Can you explain what extended_login_form does?

On Jul 25, 12:52 am, keitheis  wrote:
> Hi,
>
> I made theOpenIDsupport for sahana eden. And thanks to Fran Boon, I
> did it most on web2py/gluon/contrib/login_methods . Here is the code:
>
> https://code.launchpad.net/~keitheis/web2py/openid
>
> Fran said that in the long run it's better to have it maintained up
> here.
> So I send it here for the feedback.
>
> Kind Regards,
> Keith Yang


[web2py] Re: global name 'MySQLdb' is not define d

2010-07-27 Thread mdipierro
This is very odd. Can any mod_wsgi expert explain this?

On Jul 25, 3:36 am, oktay  wrote:
> I solved the problem.
> It is strange but in sql.py before
> "self._pool_connection(lambda :MySQLdb.Connection" I add import
> MySQLdb.
> I print some logs from sql.py and the first import in sql.py is not
> processed when running with apache.
> I am not sure why first import is not processed but I solved my
> problem with adding
>
> "import MySQLdb" before MySQLdb.Connection is processed.
>
>            self._pool_connection(lambda : MySQLdb.Connection(
>                    db=db,
>                    user=user,
>                    passwd=passwd,
>                    host=host,
>                    port=int(port),
>                    charset=charset,
>                    ))
>            self._cursor = self._connection.cursor()
>            self._execute = lambda *a, **b: self._cursor.execute(*a,
> **b)
>            self._execute('SET FOREIGN_KEY_CHECKS=1;')
>            self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';")
>
> On 24 Temmuz, 22:58,oktay wrote:
>
> > I will be very glad if you can...
> > Thank you.
>
> > On 24 Temmuz, 22:51, Kenneth  wrote:
>
> > > I´m running web2py on CentOS 5.something. If needed I could send you
> > > my Apache configuration files and others.
>
> > > Kenneth
>
> > > On Jul 24, 8:47 pm,oktay wrote:
>
> > > > Hello again,
>
> > > > I installed PostgreSQL and psycopg2.
> > > > both in the command line for python24 and python26 can import
> > > > psycopg2.
>
> > > > But when I run from apache
> > > > "global name 'psycopg2' is not defined"
> > > > error appears.
>
> > > > Same problem with mysql driver.
>
> > > > apache/python can not find the python db drivers.
> > > > Is it related to wsgi configuration?
>
> > > > Do you have any advice? Where should I check?
>
> > > > Thank you...
>
> > > > On 24 Temmuz, 19:38,oktay wrote:
>
> > > > > Yes, correct.
> > > > > web2y.py (including "import MySQLdb") works both with python2.4 and
> > > > > python2.6.
> > > > > and not working with apache.
>
> > > > > Also I make my wsgi configuration as described 
> > > > > inhttp://web2py.com/book/default/section/11/2
>
> > > > > On 24 Temmuz, 19:32, mdipierro  wrote:
>
> > > > > > So it works when you do
>
> > > > > > python2.6 web2y.py
>
> > > > > > but not when you use apache. is that correct?
>
> > > > > > On Jul 24, 10:58 am,oktay wrote:
>
> > > > > > > Yes, it works with "import MySQLdb" at the top of web2py.py:
>
> > > > > > > web2py Enterprise Web Framework
> > > > > > > Created by Massimo Di Pierro, Copyright 2007-2010
> > > > > > > Version 1.81.5 (2010-07-22 23:56:21)
> > > > > > > Database drivers available: MySQL
> > > > > > > Starting hardcron...
> > > > > > > WARNING:root:GUI not available because Tk library is not installed
>
> > > > > > > On 24 Temmuz, 18:52, mdipierro  wrote:
>
> > > > > > > > As a test, can you try add
>
> > > > > > > >    import MySQLdb
>
> > > > > > > > at the top of web2py.py and run
>
> > > > > > > >    python2.6 web2py.py
>
> > > > > > > > Massimo
>
> > > > > > > > On Jul 24, 10:46 am,oktay wrote:
>
> > > > > > > > > Hello,
>
> > > > > > > > > I am trying to install web2py with apache & mysql.
> > > > > > > > > I checked all the scenarios with the "global name 'MySQLdb' 
> > > > > > > > > is not
> > > > > > > > > defined" subject, but they didn't solve my problem.
>
> > > > > > > > > I am using:
> > > > > > > > > CentOS 5.5
> > > > > > > > > httpd-2.2.3
> > > > > > > > > mysql  5.0.77
> > > > > > > > > Python26
> > > > > > > > > MySQL-python-1.2.3c1
> > > > > > > > > web2py Version 1.81.5
>
> > > > > > > > > Default CentOS 5 python version is 2.4, I installed 2.6.
> > > > > > > > > I can both "import MySQLdb" from python24 & python26 from 
> > > > > > > > > console.
> > > > > > > > > When I run web2py from source like "python ./web2py.py" or 
> > > > > > > > > with
> > > > > > > > > "python26 ./web2py.py"
> > > > > > > > > I can see "Database drivers available: MySQL"
>
> > > > > > > > > I think there is a configuration problem with the python 
> > > > > > > > > libraries I
> > > > > > > > > installed.
>
> > > > > > > > > Do you have any idea? Here is the trace:
>
> > > > > > > > > ---
> > > > > > > > > Traceback (most recent call last):
> > > > > > > > >   File "gluon/restricted.py", line 178, in restricted
> > > > > > > > >     exec ccode in environment
> > > > > > > > >   File "/var/www/web2py/applications/welcome/models/db.py", 
> > > > > > > > > line 1, in
> > > > > > > > > 
> > > > > > > > >     db=SQLDB('mysql://xxx:y...@zzz:3306/aaa')
> > > > > > > > >   File "gluon/sql.py", line 921, in __init__
> > > > > > > > >     self._pool_connection(lambda : MySQLdb.Connection(
> > > > > > > > >   File "gluon/sql.py", line 828, in _pool_connection
> > > > > > > > >     self._connection = f()
> > > > > > > > >   File "gluon/sql.py", line 921, in 
> > > > > > > > >     self._pool_connection(lambda : MySQLdb.Connection(
> > > > > > > > > NameError: glo

[web2py] Re: Privacy with plugin_wiki

2010-07-27 Thread Anthony
Doesn't seem to work in IE yet (at least not the version they're
running on the Protovis site).

http://code.google.com/p/protovis-js/issues/detail?id=15&can=1


On Jul 27, 6:26 am, Stef Mientki  wrote:
> what about protovis ?http://vis.stanford.edu/protovis/ex/
>
> cheers,
> Stef
>
> On 27-07-2010 11:16, mdipierro wrote:
>
>
>
> > I will move to jflot
>
> > On Jul 27, 3:33 am, Timmie  wrote:
> >> Hello,
> >> I have seen that you use Google Chartin API.
>
> >> Does this mean that my data is sent to Google for preparing the
> >> charts?
>
> >> If so, I would recommend searching for a standalone charting lib like
> >> matplotlib.
>
> >> regards.
> >> Timmie- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Frank
I think followings are missing after quick screening, hope it help,

a. in access control section, missing description of reset_passward and setting;
b. in service section,missing how reportlab for web2py deal with web2py
pictures,tables and forms and how deal with the reportlab path difference
between web2py and reportlab;

thanks,

Frank




Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
ok, I'll give that  a shot in a few minutes if I don't get a fork break by
then.  BTW, I verified that cron/crontab is empty in my app.  However it's
not empty in admin and examples:

$ cat admin/cron/crontab
10 * * * * root **applications/admin/cron/expire_sessions.py

$ cat examples/cron/crontab
#0-59/1 * * * * root python /path/to/python/script
#*/1 * * * * root *applications/admin/cron/expire_sessions.py
#*/1*   *   *   *   root *applications/admin/cron/my magic script.py
#*/1*   *   *   *   root **applications/admin/cron/nodb.py
#*/1*   *   *   *   root /tmp/my\ script.py 1 2 3
#*/1*   *   *   *   root "/tmp/my script.py" 456
#...@reboot root *default/preload

Cheers,
Mike


On Tue, Jul 27, 2010 at 8:57 AM, mdipierro  wrote:

> Yet is being called. It is on by default. Try set cron=False at the
> bottom of web2py.py
>
> On Jul 27, 7:49 am, Michael Ellis  wrote:
> > Not using cron.
> >
> > On Tue, Jul 27, 2010 at 8:43 AM, mdipierro 
> wrote:
> > > Ignore my previous email I see you are using 2.6 and the problem
> > > is with cron. I think the problem is a cron process that does not end
> > > and keeps restarting. Are you using cron?
> >
> > > On Jul 27, 7:33 am, Michael Ellis  wrote:
> > > > Not sure if this is related to Rocket or whether a new topic is
> needed.
> >
> > > > This morning I found several OSError reports about "Too many open
> files"
> > > in
> > > > a web2py development server that's been running locally for several
> days.
> > > >  The app code isn't doing any explicit file i/o so I don't know
> what's
> > > going
> > > > on,  but here are the tracebacks in case someone else is seeing
> anything
> > > > similar.
> >
> > > > Mike
> >
> > > > Exception in thread Thread-89:
> > > > Traceback (most recent call last):
> > > >   File
> >
> > >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py",
> > > > line 522, in __bootstrap_inner
> > > > self.run()
> > > >   File "/Users/mellis/w2ptip/gluon/newcron.py", line 206, in run
> > > > shell=self.shell)
> > > >   File
> >
> > >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > > > line 595, in __init__
> > > > errread, errwrite)
> > > >   File
> >
> > >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py",
> > > > line 1018, in _execute_child
> > > > errpipe_read, errpipe_write = os.pipe()
> > > > OSError: [Errno 24] Too many open files
> >
> > > > ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
> > > >   File "/Users/mellis/w2ptip/gluon/rocket.py", line 302, in start
> > > > sock = l.accept()
> > > >   File
> >
> > >
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> > > > line 195, in accept
> > > > sock, addr = self._sock.accept()
> > > > error: [Errno 24] Too many open files
> >
> > > > ERROR:root:corrupted file:
> > > > /Users/mellis/w2ptip/applications/init/cache/cache.shelve
> > > > ERROR:root:Traceback (most recent call last):
> > > >   File "/Users/mellis/w2ptip/gluon/restricted.py", line 178, in
> > > restricted
> > > > exec ccode in environment
> > > >   File "/Users/mellis/w2ptip/applications/init/models/db.py", line
> 35, in
> > > > 
> > > > auth.define_tables() # creates all needed
> > > tables
> > > >   File "/Users/mellis/w2ptip/gluon/tools.py", line 1106, in
> define_tables
> > > > format='%(first_name)s %(last_name)s (%(id)s)')
> > > >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1309, in
> define_table
> > > >   File "/Users/mellis/w2ptip/gluon/sql.py", line 1715, in _create
> > > > IOError: [Errno 24] Too many open files:
> > > > '/Users/mellis/w2ptip/applications/init/databases/sql.log'
> >
> > > > On Tue, Jul 27, 2010 at 2:54 AM, Rahul 
> wrote:
> > > > > Thanks everyone, for getting this issue resolved...
> > > > > Web2py rocks!
> > > > > Cheers, Rahul
> >
> > > > > On Jul 24, 6:25 pm, Phyo Arkar  wrote:
> > > > > > Yes , Since from start of web2py , Massimo and Us never recommend
> to
> > > use
> > > > > > built-in web2py server at production. They are mainly for
> development
> > > > > > purpose.
> > > > > > Since Very start of the project , since Cherrypy , Massimo always
> > > Suggest
> > > > > to
> > > > > > use Apache/Cherokee/LighHTTPD over fcgi/wsgi/uwsgi or mod_python
> in
> > > > > Serious
> > > > > > Production Server.
> >
> > > > > > Rocket tho tries quite hard to achieve production level
> Performance
> > > with
> > > > > all
> > > > > > Cool Comet/Threading Stuff . It still Quite Young .Lets give it a
> > > chance.
> >
> > > > > > On Sat, Jul 24, 2010 at 7:39 PM, Scott 
> > > wrote:
> > > > > > > Please allow me to preface my comments: I have nothing against
> > > Rocket;
> > > > > > > my opinions come from years of experience with Java EE
> deployments.
> >
> > > > > > > I think raising the max_threads to 1024 is a good idea.
>  However,
> > > my
> > > > > 

[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Anthony
Overall, I think I prefer the old approach of dividing into sections.
The new approach involves a lot of scrolling/hunting if you're looking
for something specific or trying to find a search term in a page
returned by a search. On the other hand, in some cases, if you happen
to be reading a whole chapter straight through, having it all on one
page can be convenient (can also be convenient when a search returns
hits across multiple sections within the same chapter).

I suppose an alternative might be to have the TOC expand to show the
section titles (as in the current book) and let the user click on a
section title to jump to that section in the page (maybe add some
"back to top" links within the page).

On Jul 27, 7:51 am, mdipierro  wrote:
> web2py.com/book was broken into section
> web2py.com/book2 is broken into chapters
>
> what is better?
> Once printed it will be the same.
>
> On Jul 27, 5:49 am, mdipierro  wrote:
>
>
>
> > This is very very preliminary:
>
> >    http://web2py.com/book2
>
> > It is not editable (yet) and I am still adding material but it does
> > address a lot of issues.
> > Please use this thread to add comments in particular:
>
> > What sections are missing?
> > What needs to be clarified?
> > Are there spelling errors?
> > Are there formatting error?
>
> > One more way I could use help: I need all the images done with the old
> > layout to be redone with the new welcome layout.
>
> > Massimo- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Anthony
Regardless of which approach is taken, I think it's important to have
a more detailed TOC _somewhere_ (i.e., ability to see a list of
sections within chapters without having to go to the chapter page and
scroll the whole page).

On Jul 27, 9:51 am, Anthony  wrote:
> Overall, I think I prefer the old approach of dividing into sections.
> The new approach involves a lot of scrolling/hunting if you're looking
> for something specific or trying to find a search term in a page
> returned by a search. On the other hand, in some cases, if you happen
> to be reading a whole chapter straight through, having it all on one
> page can be convenient (can also be convenient when a search returns
> hits across multiple sections within the same chapter).
>
> I suppose an alternative might be to have the TOC expand to show the
> section titles (as in the current book) and let the user click on a
> section title to jump to that section in the page (maybe add some
> "back to top" links within the page).
>
> On Jul 27, 7:51 am, mdipierro  wrote:
>
>
>
> > web2py.com/book was broken into section
> > web2py.com/book2 is broken into chapters
>
> > what is better?
> > Once printed it will be the same.
>
> > On Jul 27, 5:49 am, mdipierro  wrote:
>
> > > This is very very preliminary:
>
> > >    http://web2py.com/book2
>
> > > It is not editable (yet) and I am still adding material but it does
> > > address a lot of issues.
> > > Please use this thread to add comments in particular:
>
> > > What sections are missing?
> > > What needs to be clarified?
> > > Are there spelling errors?
> > > Are there formatting error?
>
> > > One more way I could use help: I need all the images done with the old
> > > layout to be redone with the new welcome layout.
>
> > > Massimo- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mdipierro
I agree but that is not the issue now. The issue is content. I am
rewriting the book app using markmin and it allows tagging inside
pages. The current content is already tagged (as you can see from the
floating blobs on the right side of the window). These tags will be
used to create a detailed index.

Massimo


On Jul 27, 8:55 am, Anthony  wrote:
> Regardless of which approach is taken, I think it's important to have
> a more detailed TOC _somewhere_ (i.e., ability to see a list of
> sections within chapters without having to go to the chapter page and
> scroll the whole page).
>
> On Jul 27, 9:51 am, Anthony  wrote:
>
> > Overall, I think I prefer the old approach of dividing into sections.
> > The new approach involves a lot of scrolling/hunting if you're looking
> > for something specific or trying to find a search term in a page
> > returned by a search. On the other hand, in some cases, if you happen
> > to be reading a whole chapter straight through, having it all on one
> > page can be convenient (can also be convenient when a search returns
> > hits across multiple sections within the same chapter).
>
> > I suppose an alternative might be to have the TOC expand to show the
> > section titles (as in the current book) and let the user click on a
> > section title to jump to that section in the page (maybe add some
> > "back to top" links within the page).
>
> > On Jul 27, 7:51 am, mdipierro  wrote:
>
> > > web2py.com/book was broken into section
> > > web2py.com/book2 is broken into chapters
>
> > > what is better?
> > > Once printed it will be the same.
>
> > > On Jul 27, 5:49 am, mdipierro  wrote:
>
> > > > This is very very preliminary:
>
> > > >    http://web2py.com/book2
>
> > > > It is not editable (yet) and I am still adding material but it does
> > > > address a lot of issues.
> > > > Please use this thread to add comments in particular:
>
> > > > What sections are missing?
> > > > What needs to be clarified?
> > > > Are there spelling errors?
> > > > Are there formatting error?
>
> > > > One more way I could use help: I need all the images done with the old
> > > > layout to be redone with the new welcome layout.
>
> > > > Massimo- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -


[web2py] Re: Mail function not working

2010-07-27 Thread Andrew Buchan
Thanks, but I tried that, along with a number of other port settings,
using smtp as prefix etc... Has anyone els managed to get this working
from a windows server?

On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
> > mail.settings.server= '192.168.200.43:25'
>
>  add port


[web2py] Re: Mail function not working

2010-07-27 Thread mdipierro
Is 192.168.200.43:25 the windows box itself or an external unix box?
In the first case, do you have an email server running on windows?
On unix this works because you have postfix but windows does not come
with one.
You may want to use an external smpt server like google.

On Jul 27, 9:00 am, Andrew Buchan  wrote:
> Thanks, but I tried that, along with a number of other port settings,
> using smtp as prefix etc... Has anyone els managed to get this working
> from a windows server?
>
> On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
>
> > > mail.settings.server= '192.168.200.43:25'
>
> >  add port


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Anthony
Sorry, I guess I don't understand the question then. What are the
consequences of breaking into sections vs. chapters?

On Jul 27, 9:58 am, mdipierro  wrote:
> I agree but that is not the issue now. The issue is content. I am
> rewriting the book app using markmin and it allows tagging inside
> pages. The current content is already tagged (as you can see from the
> floating blobs on the right side of the window). These tags will be
> used to create a detailed index.
>
> Massimo
>
> On Jul 27, 8:55 am, Anthony  wrote:
>
>
>
> > Regardless of which approach is taken, I think it's important to have
> > a more detailed TOC _somewhere_ (i.e., ability to see a list of
> > sections within chapters without having to go to the chapter page and
> > scroll the whole page).
>
> > On Jul 27, 9:51 am, Anthony  wrote:
>
> > > Overall, I think I prefer the old approach of dividing into sections.
> > > The new approach involves a lot of scrolling/hunting if you're looking
> > > for something specific or trying to find a search term in a page
> > > returned by a search. On the other hand, in some cases, if you happen
> > > to be reading a whole chapter straight through, having it all on one
> > > page can be convenient (can also be convenient when a search returns
> > > hits across multiple sections within the same chapter).
>
> > > I suppose an alternative might be to have the TOC expand to show the
> > > section titles (as in the current book) and let the user click on a
> > > section title to jump to that section in the page (maybe add some
> > > "back to top" links within the page).
>
> > > On Jul 27, 7:51 am, mdipierro  wrote:
>
> > > > web2py.com/book was broken into section
> > > > web2py.com/book2 is broken into chapters
>
> > > > what is better?
> > > > Once printed it will be the same.
>
> > > > On Jul 27, 5:49 am, mdipierro  wrote:
>
> > > > > This is very very preliminary:
>
> > > > >    http://web2py.com/book2
>
> > > > > It is not editable (yet) and I am still adding material but it does
> > > > > address a lot of issues.
> > > > > Please use this thread to add comments in particular:
>
> > > > > What sections are missing?
> > > > > What needs to be clarified?
> > > > > Are there spelling errors?
> > > > > Are there formatting error?
>
> > > > > One more way I could use help: I need all the images done with the old
> > > > > layout to be redone with the new welcome layout.
>
> > > > > Massimo- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


Re: [web2py] CLI for Application

2010-07-27 Thread Bruno Rocha
You can do that with xml-rpc or SOAP

2010/7/26 James McMillan 

> I have written a simple application involving a single model and a
> single controller. I would also like to provide a CLI version for it.
> Is it possible to run the application and be able to interact (through
> print / input() or similar) with the controller? It would need to load
> the model, then execute the controller.
>
> Thanks,
> - James




-- 

http://rochacbruno.com.br


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mdipierro
It is me who did not explain it well.

One thing is content. (main issue now)
One thing is browsing. (chapters vs sections, affects how I store the
data, so I'd like to settle asap, that is why I asked)
One thing is searching. (you have a valid point, I am working on it, I
think it will work well whether we use chapters or sections, the
important issue is to tag the content and that is done).

Massimo


On Jul 27, 9:22 am, Anthony  wrote:
> Sorry, I guess I don't understand the question then. What are the
> consequences of breaking into sections vs. chapters?
>
> On Jul 27, 9:58 am, mdipierro  wrote:
>
> > I agree but that is not the issue now. The issue is content. I am
> > rewriting the book app using markmin and it allows tagging inside
> > pages. The current content is already tagged (as you can see from the
> > floating blobs on the right side of the window). These tags will be
> > used to create a detailed index.
>
> > Massimo
>
> > On Jul 27, 8:55 am, Anthony  wrote:
>
> > > Regardless of which approach is taken, I think it's important to have
> > > a more detailed TOC _somewhere_ (i.e., ability to see a list of
> > > sections within chapters without having to go to the chapter page and
> > > scroll the whole page).
>
> > > On Jul 27, 9:51 am, Anthony  wrote:
>
> > > > Overall, I think I prefer the old approach of dividing into sections.
> > > > The new approach involves a lot of scrolling/hunting if you're looking
> > > > for something specific or trying to find a search term in a page
> > > > returned by a search. On the other hand, in some cases, if you happen
> > > > to be reading a whole chapter straight through, having it all on one
> > > > page can be convenient (can also be convenient when a search returns
> > > > hits across multiple sections within the same chapter).
>
> > > > I suppose an alternative might be to have the TOC expand to show the
> > > > section titles (as in the current book) and let the user click on a
> > > > section title to jump to that section in the page (maybe add some
> > > > "back to top" links within the page).
>
> > > > On Jul 27, 7:51 am, mdipierro  wrote:
>
> > > > > web2py.com/book was broken into section
> > > > > web2py.com/book2 is broken into chapters
>
> > > > > what is better?
> > > > > Once printed it will be the same.
>
> > > > > On Jul 27, 5:49 am, mdipierro  wrote:
>
> > > > > > This is very very preliminary:
>
> > > > > >    http://web2py.com/book2
>
> > > > > > It is not editable (yet) and I am still adding material but it does
> > > > > > address a lot of issues.
> > > > > > Please use this thread to add comments in particular:
>
> > > > > > What sections are missing?
> > > > > > What needs to be clarified?
> > > > > > Are there spelling errors?
> > > > > > Are there formatting error?
>
> > > > > > One more way I could use help: I need all the images done with the 
> > > > > > old
> > > > > > layout to be redone with the new welcome layout.
>
> > > > > > Massimo- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -


Re: [web2py] Re: Mail function not working

2010-07-27 Thread Andrew Buchan
Massimo,

192.168.200.43 is a different windows box setup as a domino server, and the
smtplib example in original post works fine connecting to that server. The
windows box hosting the web2py application will not normally be connected to
the internet, so I can't go using google's smtp.
If I recall from the event log on domino (which I do not have access to
myself), the connection seems to be established but then dropped. Perhaps
the header is not in a correct format?

Andrew.

On Tue, Jul 27, 2010 at 3:06 PM, mdipierro  wrote:

> Is 192.168.200.43:25 the windows box itself or an external unix box?
> In the first case, do you have an email server running on windows?
> On unix this works because you have postfix but windows does not come
> with one.
> You may want to use an external smpt server like google.
>
> On Jul 27, 9:00 am, Andrew Buchan  wrote:
> > Thanks, but I tried that, along with a number of other port settings,
> > using smtp as prefix etc... Has anyone els managed to get this working
> > from a windows server?
> >
> > On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
> >
> > > > mail.settings.server= '192.168.200.43:25'
> >
> > >  add port
>


[web2py] Re: CLI for Application

2010-07-27 Thread mdipierro
yes, decorate function with

@service.xmlrpc

the rest is explained in the book

On Jul 27, 9:24 am, Bruno Rocha  wrote:
> You can do that with xml-rpc or SOAP
>
> 2010/7/26 James McMillan 
>
> > I have written a simple application involving a single model and a
> > single controller. I would also like to provide a CLI version for it.
> > Is it possible to run the application and be able to interact (through
> > print / input() or similar) with the controller? It would need to load
> > the model, then execute the controller.
>
> > Thanks,
> > - James
>
> --
>
> http://rochacbruno.com.br


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread Anthony
Perhaps this is still being worked on, but the index tags floating on
the right aren't lining up with the relevant page content. Each tag is
shifted down from where it should be, and the further down the page
the greater the shifting (after some scrolling, the relevant content
is no longer even on the same screen with the tag). This happens in
IE8 and Chrome on Windows 7.

On Jul 27, 6:49 am, mdipierro  wrote:
> This is very very preliminary:
>
>    http://web2py.com/book2
>
> It is not editable (yet) and I am still adding material but it does
> address a lot of issues.
> Please use this thread to add comments in particular:
>
> What sections are missing?
> What needs to be clarified?
> Are there spelling errors?
> Are there formatting error?
>
> One more way I could use help: I need all the images done with the old
> layout to be redone with the new welcome layout.
>
> Massimo


[web2py] Re: cPickle large object causes web2py to crash

2010-07-27 Thread topher.baron
There is a potential of having more than one of these objects, and
they are not shared across users.  I've just implemented a cache.ram
solution, but I don't think I quite understand how the time_expire
works.

These objects are trees.  This is how I've implemented the cache.ram
solution:

def getTree( p ):
return cache.ram( p['treeId'], lambda:None, time_expire = None )

def clearTreeCache( p ):
cache.ram.clear( regex = p['treeId'] )

def storeTree( p ) :
cache.ram( p['treeId'], lambda:p['tree'], None )

Is this a reasonable implementation ?

As for cPickle, I'm not sure what the problem is.  The reason I
believe is a file size problem is because I am able to pickle smaller
objects, whereas the exception is thrown when I attempt to  do it on a
larger object.  I'd be happy to copy the OSX exception dialogue if
that would help.  Also, I will try to pickle the object here :
os.path.join(request.folder,'private') and let you know what happens.
Thanks.

On Jul 27, 1:53 am, mdipierro  wrote:
> If you have only one such objects, shared between all users than
> cache.ram may be a solution.
>
> I am surprised cPickle fails since the data is not so large. Are you
> sure it is a file size problem? Is it possible that the object simply
> contains unpicklable references?
>
> try store it on the filesystem in the
> os.path.join(request.folder,'private') folder.
>
> > 937984 Bytes is the size of the file when I pickle a large object to a
> > file.  This is protocol 0.  When I attempted to use protocol 2, it
> > failed.
>
> > I recently realized that the session itself is pickled, so I tried to
> > simply add the object to the session to see what would happen.  Same
> > result.
>
> > I'm dealing with large hierarchical data and would prefer to keep the
> > data in the session.  However, it looks like this might not be
> > feasible for large amounts of data.  What about increasing the memory
> > block for web2py?
>
> > I'm thinking my other option would be to keep it in cache.ram and in
> > the database.  What do you think?
>
> > On Jul 22, 5:37 pm, mdipierro  wrote:
>
> > > How big is the pickled file?
>
> > > On Jul 22, 5:08 pm, "topher.baron"  wrote:
>
> > > > web2py community,
>
> > > > I'm currently implementing a web application on localhost running OS
> > > > 10.6.4.  When I cPickle.dump a large object to the /tmp directory,
> > > > web2py crashes.  The same operations work with smaller objects.
>
> > > > Does this mean I need to increase the heap?  If so, how do I do this?
> > > > If not, any suggestions?
>
> > > > Thanks in advance.


[web2py] Re: Mail function not working

2010-07-27 Thread Adi
Have you tried using telnet to verify your server and mail are
correctly configured?

Try this:

c:\> telnet 192.168.200.43 25
ehlo
mail from:the...@h**a.com
recpt to: t...@h***a.com
data
This is a test message

The recipient should be something valid. If this sends out email from
your Windows server then the smtp relay is working. In that case
please attach ehlo output. If this doesn't send out email, then the
problem is not with your web2py code, but with your mail setup
somewhere.

-- Adi

On Jul 27, 7:29 pm, Andrew Buchan  wrote:
> Massimo,
>
> 192.168.200.43 is a different windows box setup as a domino server, and the
> smtplib example in original post works fine connecting to that server. The
> windows box hosting the web2py application will not normally be connected to
> the internet, so I can't go using google's smtp.
> If I recall from the event log on domino (which I do not have access to
> myself), the connection seems to be established but then dropped. Perhaps
> the header is not in a correct format?
>
> Andrew.
>
>
>
> On Tue, Jul 27, 2010 at 3:06 PM, mdipierro  wrote:
> > Is 192.168.200.43:25 the windows box itself or an external unix box?
> > In the first case, do you have an email server running on windows?
> > On unix this works because you have postfix but windows does not come
> > with one.
> > You may want to use an external smpt server like google.
>
> > On Jul 27, 9:00 am, Andrew Buchan  wrote:
> > > Thanks, but I tried that, along with a number of other port settings,
> > > using smtp as prefix etc... Has anyone els managed to get this working
> > > from a windows server?
>
> > > On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
>
> > > > > mail.settings.server= '192.168.200.43:25'
>
> > > >  add port


Re: [web2py] Re: book 3rd edition call of help

2010-07-27 Thread Jonathan Lundell
On Jul 27, 2010, at 4:51 AM, mdipierro wrote:

> web2py.com/book was broken into section
> web2py.com/book2 is broken into chapters
> 
> what is better?
> Once printed it will be the same.

Offhand I'd say chapters, so I can use my browser-native search more 
effectively.

In that case, it might be that some existing chapters that treat more than one 
subject could be split.

[web2py] Re: Can not send verification email

2010-07-27 Thread mattynoce
i did a slightly different fix in tools.py, starting on line 537:

if attachments:
result =
mail.send_mail(sender=self.settings.sender, to=to,
subject=subject,
body=text, html=html,
attachments=attachments)
else:
# fix starts here
if html:
result =
mail.send_mail(sender=self.settings.sender, to=to,
subject=subject,
body=text, html=html)
else:
result =
mail.send_mail(sender=self.settings.sender, to=to,
subject=subject,
body=text)

massimo, can something like this be put into trunk? i was able to fix
all of my own emails in code, but the one causing the error for me is
the standard verification email which seems to have ceased to work for
gae.

thanks,

matt

On Jul 11, 11:58 am, MikeEllis  wrote:
> Solved, or at least hacked well enough for the time being :-)
>
> --enable_sendmail did the trick.  It needs to be entered in the app
> launch
> settings in the GAE Launcher:
>
> * stop the app
> * double-click app in listing
> * enter --enable_sendmail in the Launcher settings "extra flags" field
> * restart the app
>
> Here's the blog post that put me on the right track:
>
> http://blog.docuverse.com/2009/01/30/google-app-engine-launcher-options/
>
> Cheers,
> Mike
>
> On Jul 11, 12:20 pm, MikeEllis  wrote:
>
> > I just modified my tools.py as follows:
>
> >             elif self.settings.server == 'gae':
> >                 logging.warn("using gae mail server")
> >                 from google.appengine.api import mail
> >                 attachments = attachments and
> > [(a.my_filename,a.my_payload) for a in attachments]
>
> >                 ## gae mailer chokes on empty attachments or html
> >                 extra = dict(html=html, attachments=attachments)
> >                 for k in extra.keys():
> >                     if not extra[k]: extra.pop(k)
>
> >                 result = mail.send_mail(sender=self.settings.sender,
> > to=to,
> >                                         subject=subject, body=text,
> > **extra)
> >                 logging.warn("result of mail.send_mail() is
> > %s"%repr(result))
>
> > This fixed the exceptions associated with empty attachments and html,
> > but no mail is being sent when testing under GAE Launcher, apparently
> > because something else needs to be done to enable it.  Here's what's
> > showing up in the console log:
>
> > WARNING  2010-07-11 15:57:04,413 tools.py:535] using gae mail server
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:84] MailService.Send
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:85]   From:
> > myaddr...@gmail.com
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:88]   To:
> > myaddr...@gmail.com
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:97]   Subject:Email
> > verification
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:100]   Body:
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:101]     Content-type:
> > text/plain
> > INFO     2010-07-11 15:57:04,416 mail_stub.py:102]     Data length:
> > 132
> > INFO     2010-07-11 15:57:04,417 mail_stub.py:207] You are not
> > currently sending out realemail.  If you have sendmail installed you
> > can use it by using the server with --enable_sendmail
> > WARNING  2010-07-11 15:57:04,417 tools.py:545] result of
> > mail.send_mail() is None
>
> > Since it's the gae server, I'm not sure if the bit about --
> > enable_sendmail is relevant, but clearly something is not set up
> > correctly.  Any ideas?
>
> > I'm running GAE SDK 1.3.5 and  web2py 1.92 on OS X 10.6.4
>
> > BTW, I'm wondering if the default registration page should be amended
> > to allow retrying theemailnotification when attempting to register
> > an unverified address that's already in the db. Having to use the
> > admin interface to delete the address each time while debugging mail
> > settings is time-consuming.
>
> > Thanks,
> > Mike
>
> > On Jun 19, 11:12 am, Larry  wrote:
>
> > > Peter,
>
> > > This code looks good to me. I will adopt the same for now.
>
> > > Larry
>
> > > On Jun 19, 12:37 am, pecos1046  wrote:
>
> > > > Hi Larry:
>
> > > > Looking at your suggestion, I made a code change in tools.py and mail
> > > > with gae works well. Here my patch - so far so good, I wonder when it
> > > > will backfire.
>
> > > >           elif self.settings.server == 'gae':
> > > >                 from google.appengine.api import mail
> > > >                 attachments = attachments and
> > > > [(a.my_filename,a.my_payload) for a in attachments]
>
> > > >                 if attachments and html:
> > > >                     result =
> > > > mail.send_mail(sender=self.settings.sender, to=to,
> > > >                                         subject=subject, body=text,
> > > > html=html,
> > > 

Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Jonathan Lundell
On Jul 27, 2010, at 5:33 AM, Michael Ellis wrote:

> This morning I found several OSError reports about "Too many open files" in a 
> web2py development server that's been running locally for several days.  The 
> app code isn't doing any explicit file i/o so I don't know what's going on,  
> but here are the tracebacks in case someone else is seeing anything similar.

The first thing to do is to use lsof (try: man lsof) to see what's being opened.

[web2py] Re: Mail function not working

2010-07-27 Thread Adi
Since you're able to use smtplib my suggestion is invalid (I didn't
read carefully enough last time)

Once I faced this problem, and the ehlo output did not have AUTH
(which means AUTH was not enabled on the mail server), and all I did
was remove mail.settings.login line and it started working. Maybe this
will help.

-- Adi

On Jul 27, 8:13 pm, Adi  wrote:
> Have you tried using telnet to verify your server and mail are
> correctly configured?
>
> Try this:
>
> c:\> telnet 192.168.200.43 25
> ehlo
> mail from:the...@h**a.com
> recpt to: t...@h***a.com
> data
> This is a test message
>
> The recipient should be something valid. If this sends out email from
> your Windows server then the smtp relay is working. In that case
> please attach ehlo output. If this doesn't send out email, then the
> problem is not with your web2py code, but with your mail setup
> somewhere.
>
> -- Adi
>
> On Jul 27, 7:29 pm, Andrew Buchan  wrote:
>
>
>
> > Massimo,
>
> > 192.168.200.43 is a different windows box setup as a domino server, and the
> > smtplib example in original post works fine connecting to that server. The
> > windows box hosting the web2py application will not normally be connected to
> > the internet, so I can't go using google's smtp.
> > If I recall from the event log on domino (which I do not have access to
> > myself), the connection seems to be established but then dropped. Perhaps
> > the header is not in a correct format?
>
> > Andrew.
>
> > On Tue, Jul 27, 2010 at 3:06 PM, mdipierro  wrote:
> > > Is 192.168.200.43:25 the windows box itself or an external unix box?
> > > In the first case, do you have an email server running on windows?
> > > On unix this works because you have postfix but windows does not come
> > > with one.
> > > You may want to use an external smpt server like google.
>
> > > On Jul 27, 9:00 am, Andrew Buchan  wrote:
> > > > Thanks, but I tried that, along with a number of other port settings,
> > > > using smtp as prefix etc... Has anyone els managed to get this working
> > > > from a windows server?
>
> > > > On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
>
> > > > > > mail.settings.server= '192.168.200.43:25'
>
> > > > >  add port


Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
Thanks, Jonathan. That's a good suggestion.

I last restarted the app a couple of hours ago.  ps reports 4 processes that
match 'web2py'.  Grepping for each pid in lsof shows nothing extraordinary.
 Each process has 80-90 files open. The vast majority are libraries (.so).
 There are a few chr files and about 10 pipes associated with each pid.

I'll check again in a few hours and see if the numbers are increasing.

Cheers,
Mike


On Tue, Jul 27, 2010 at 11:23 AM, Jonathan Lundell wrote:

> On Jul 27, 2010, at 5:33 AM, Michael Ellis wrote:
>
> > This morning I found several OSError reports about "Too many open files"
> in a web2py development server that's been running locally for several days.
>  The app code isn't doing any explicit file i/o so I don't know what's going
> on,  but here are the tracebacks in case someone else is seeing anything
> similar.
>
> The first thing to do is to use lsof (try: man lsof) to see what's being
> opened.


[web2py] Re: cPickle large object causes web2py to crash

2010-07-27 Thread mdipierro
Yes but
def storeTree( p ) :
cache.ram( p['treeId'], lambda:p['tree'], time_expire=0 )

and make sure p['treeId'] does not contain symbols that have a regex
meaning {}[]()=_*\.

On Jul 27, 10:12 am, "topher.baron"  wrote:
> There is a potential of having more than one of these objects, and
> they are not shared across users.  I've just implemented a cache.ram
> solution, but I don't think I quite understand how the time_expire
> works.
>
> These objects are trees.  This is how I've implemented the cache.ram
> solution:
>
> def getTree( p ):
>     return cache.ram( p['treeId'], lambda:None, time_expire = None )
>
> def clearTreeCache( p ):
>     cache.ram.clear( regex = p['treeId'] )
>
> def storeTree( p ) :
>     cache.ram( p['treeId'], lambda:p['tree'], None )
>
> Is this a reasonable implementation ?
>
> As for cPickle, I'm not sure what the problem is.  The reason I
> believe is a file size problem is because I am able to pickle smaller
> objects, whereas the exception is thrown when I attempt to  do it on a
> larger object.  I'd be happy to copy the OSX exception dialogue if
> that would help.  Also, I will try to pickle the object here :
> os.path.join(request.folder,'private') and let you know what happens.
> Thanks.
>
> On Jul 27, 1:53 am, mdipierro  wrote:
>
> > If you have only one such objects, shared between all users than
> > cache.ram may be a solution.
>
> > I am surprised cPickle fails since the data is not so large. Are you
> > sure it is a file size problem? Is it possible that the object simply
> > contains unpicklable references?
>
> > try store it on the filesystem in the
> > os.path.join(request.folder,'private') folder.
>
> > > 937984 Bytes is the size of the file when I pickle a large object to a
> > > file.  This is protocol 0.  When I attempted to use protocol 2, it
> > > failed.
>
> > > I recently realized that the session itself is pickled, so I tried to
> > > simply add the object to the session to see what would happen.  Same
> > > result.
>
> > > I'm dealing with large hierarchical data and would prefer to keep the
> > > data in the session.  However, it looks like this might not be
> > > feasible for large amounts of data.  What about increasing the memory
> > > block for web2py?
>
> > > I'm thinking my other option would be to keep it in cache.ram and in
> > > the database.  What do you think?
>
> > > On Jul 22, 5:37 pm, mdipierro  wrote:
>
> > > > How big is the pickled file?
>
> > > > On Jul 22, 5:08 pm, "topher.baron"  wrote:
>
> > > > > web2py community,
>
> > > > > I'm currently implementing a web application on localhost running OS
> > > > > 10.6.4.  When I cPickle.dump a large object to the /tmp directory,
> > > > > web2py crashes.  The same operations work with smaller objects.
>
> > > > > Does this mean I need to increase the heap?  If so, how do I do this?
> > > > > If not, any suggestions?
>
> > > > > Thanks in advance.


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mdipierro
For example?

On Jul 27, 10:20 am, Jonathan Lundell  wrote:
> On Jul 27, 2010, at 4:51 AM, mdipierro wrote:
>
> > web2py.com/book was broken into section
> > web2py.com/book2 is broken into chapters
>
> > what is better?
> > Once printed it will be the same.
>
> Offhand I'd say chapters, so I can use my browser-native search more 
> effectively.
>
> In that case, it might be that some existing chapters that treat more than 
> one subject could be split.


[web2py] Re: Can not send verification email

2010-07-27 Thread mdipierro
in trunk now

On Jul 27, 10:21 am, mattynoce  wrote:
> i did a slightly different fix in tools.py, starting on line 537:
>
>                 if attachments:
>                     result =
> mail.send_mail(sender=self.settings.sender, to=to,
>                                             subject=subject,
> body=text, html=html,
>                                             attachments=attachments)
>                 else:
>                     # fix starts here
>                     if html:
>                         result =
> mail.send_mail(sender=self.settings.sender, to=to,
>                                                 subject=subject,
> body=text, html=html)
>                     else:
>                         result =
> mail.send_mail(sender=self.settings.sender, to=to,
>                                                 subject=subject,
> body=text)
>
> massimo, can something like this be put into trunk? i was able to fix
> all of my own emails in code, but the one causing the error for me is
> the standard verification email which seems to have ceased to work for
> gae.
>
> thanks,
>
> matt
>
> On Jul 11, 11:58 am, MikeEllis  wrote:
>
> > Solved, or at least hacked well enough for the time being :-)
>
> > --enable_sendmail did the trick.  It needs to be entered in the app
> > launch
> > settings in the GAE Launcher:
>
> > * stop the app
> > * double-click app in listing
> > * enter --enable_sendmail in the Launcher settings "extra flags" field
> > * restart the app
>
> > Here's the blog post that put me on the right track:
>
> >http://blog.docuverse.com/2009/01/30/google-app-engine-launcher-options/
>
> > Cheers,
> > Mike
>
> > On Jul 11, 12:20 pm, MikeEllis  wrote:
>
> > > I just modified my tools.py as follows:
>
> > >             elif self.settings.server == 'gae':
> > >                 logging.warn("using gae mail server")
> > >                 from google.appengine.api import mail
> > >                 attachments = attachments and
> > > [(a.my_filename,a.my_payload) for a in attachments]
>
> > >                 ## gae mailer chokes on empty attachments or html
> > >                 extra = dict(html=html, attachments=attachments)
> > >                 for k in extra.keys():
> > >                     if not extra[k]: extra.pop(k)
>
> > >                 result = mail.send_mail(sender=self.settings.sender,
> > > to=to,
> > >                                         subject=subject, body=text,
> > > **extra)
> > >                 logging.warn("result of mail.send_mail() is
> > > %s"%repr(result))
>
> > > This fixed the exceptions associated with empty attachments and html,
> > > but no mail is being sent when testing under GAE Launcher, apparently
> > > because something else needs to be done to enable it.  Here's what's
> > > showing up in the console log:
>
> > > WARNING  2010-07-11 15:57:04,413 tools.py:535] using gae mail server
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:84] MailService.Send
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:85]   From:
> > > myaddr...@gmail.com
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:88]   To:
> > > myaddr...@gmail.com
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:97]   Subject:Email
> > > verification
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:100]   Body:
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:101]     Content-type:
> > > text/plain
> > > INFO     2010-07-11 15:57:04,416 mail_stub.py:102]     Data length:
> > > 132
> > > INFO     2010-07-11 15:57:04,417 mail_stub.py:207] You are not
> > > currently sending out realemail.  If you have sendmail installed you
> > > can use it by using the server with --enable_sendmail
> > > WARNING  2010-07-11 15:57:04,417 tools.py:545] result of
> > > mail.send_mail() is None
>
> > > Since it's the gae server, I'm not sure if the bit about --
> > > enable_sendmail is relevant, but clearly something is not set up
> > > correctly.  Any ideas?
>
> > > I'm running GAE SDK 1.3.5 and  web2py 1.92 on OS X 10.6.4
>
> > > BTW, I'm wondering if the default registration page should be amended
> > > to allow retrying theemailnotification when attempting to register
> > > an unverified address that's already in the db. Having to use the
> > > admin interface to delete the address each time while debugging mail
> > > settings is time-consuming.
>
> > > Thanks,
> > > Mike
>
> > > On Jun 19, 11:12 am, Larry  wrote:
>
> > > > Peter,
>
> > > > This code looks good to me. I will adopt the same for now.
>
> > > > Larry
>
> > > > On Jun 19, 12:37 am, pecos1046  wrote:
>
> > > > > Hi Larry:
>
> > > > > Looking at your suggestion, I made a code change in tools.py and mail
> > > > > with gae works well. Here my patch - so far so good, I wonder when it
> > > > > will backfire.
>
> > > > >           elif self.settings.server == 'gae':
> > > > >                 from google.appengine.api import mail
> > > > >                 attachments = attachments and
> > > > > [(a.my_filename,a.my_payload) for a

Re: [web2py] Re: Mail function not working

2010-07-27 Thread Andrew Buchan
Well it works from smtplib called from within web2py, so the server does
actually work. Can't actually seem to type in what you suggested into
telnet, that is an abomination of a command-line interface!!! :-)
So I'm thinking it must be something in the difference between web2py's mail
and smtplib's implementations...


On Tue, Jul 27, 2010 at 4:13 PM, Adi  wrote:

> Have you tried using telnet to verify your server and mail are
> correctly configured?
>
> Try this:
>
> c:\> telnet 192.168.200.43 25
> ehlo
> mail from:the...@h**a.com
> recpt to: t...@h***a.com
> data
> This is a test message
>
> The recipient should be something valid. If this sends out email from
> your Windows server then the smtp relay is working. In that case
> please attach ehlo output. If this doesn't send out email, then the
> problem is not with your web2py code, but with your mail setup
> somewhere.
>
> -- Adi
>
> On Jul 27, 7:29 pm, Andrew Buchan  wrote:
> > Massimo,
> >
> > 192.168.200.43 is a different windows box setup as a domino server, and
> the
> > smtplib example in original post works fine connecting to that server.
> The
> > windows box hosting the web2py application will not normally be connected
> to
> > the internet, so I can't go using google's smtp.
> > If I recall from the event log on domino (which I do not have access to
> > myself), the connection seems to be established but then dropped. Perhaps
> > the header is not in a correct format?
> >
> > Andrew.
> >
> >
> >
> > On Tue, Jul 27, 2010 at 3:06 PM, mdipierro 
> wrote:
> > > Is 192.168.200.43:25 the windows box itself or an external unix box?
> > > In the first case, do you have an email server running on windows?
> > > On unix this works because you have postfix but windows does not come
> > > with one.
> > > You may want to use an external smpt server like google.
> >
> > > On Jul 27, 9:00 am, Andrew Buchan  wrote:
> > > > Thanks, but I tried that, along with a number of other port settings,
> > > > using smtp as prefix etc... Has anyone els managed to get this
> working
> > > > from a windows server?
> >
> > > > On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
> >
> > > > > > mail.settings.server= '192.168.200.43:25'
> >
> > > > >  add port
>


[web2py] Re: rocket performance issues

2010-07-27 Thread mdipierro
The picture is too small. Anything interesting in there?

On Jul 27, 11:01 am, Michael Ellis  wrote:
> Thanks for the info about sloth. I may try it later.  It was pretty easy to
> get what I needed with ipython:
>
> procs = !ps ax | grep "web2py"
> pids = [r[0] for r in procs.fields()[0:-2]]
> for p in pids:
>      print p
>      !lsof | grep $p | wc
>
> On Tue, Jul 27, 2010 at 11:50 AM, Jonathan Lundell wrote:
>
> > On Jul 27, 2010, at 8:23 AM, Jonathan Lundell wrote:
>
> > On Jul 27, 2010, at 5:33 AM, Michael Ellis wrote:
>
> > This morning I found several OSError reports about "Too many open files" in
> > a web2py development server that's been running locally for several days.
> >  The app code isn't doing any explicit file i/o so I don't know what's going
> > on,  but here are the tracebacks in case someone else is seeing anything
> > similar.
>
> > The first thing to do is to use lsof (try: man lsof) to see what's being
> > opened.
>
> > I just noticed a graphical interface to lsof that looks pretty nice:
>
> > Sloth 1.5 - Displays all open files in use by an app. 
> > (Free)
> > 7/27/10 5:09 AM
> > MacUpdate 
> > Sloth 1.5
> > 
> > *Sloth* is a program that displays a list of all open files in use by all
> > the applications your user account is running on the system—this list
> > includes IP and Unix sockets, character devices and directories, and is
> > generated by the 'lsof' command. This list is presented along with the names
> > of applications using the file and their process IDs. This makes it easy to
> > monitor what applications are 'locking' which files. Sloth is a graphical
> > interface front-end to 'lsof', a powerful unix tool.
>
> > WHAT'S NEW
> > Version 1.4:
>
> >    - Column sorting, column rearrangement
> >    - Copy/Drag and drop
> >    - Several bug fixes
> >    - Various interface refinements
>
> > REQUIREMENTS
> > Mac OS X 10.4 or later.
>
> > PRICE
> > Free
>
> > DEVELOPER
> > Sveinbjorn Thordarson 
>
> > DOWNLOADS
> > 6080
>
> > DOWNLOAD NOW (110 
> > K)
>
> > More information 
>
>
>
>  14230_sm.png
> 68KViewDownload


[web2py] Re: Mail function not working

2010-07-27 Thread mdipierro
Please help us debug this... look into line 555 of gluon/tools.py

server =
smtplib.SMTP(*self.settings.server.split(':'))
if self.settings.login != None:
if self.settings.tls:
server.ehlo()
server.starttls()
server.ehlo()
server.login(*self.settings.login.split(':'))
result = server.sendmail(self.settings.sender, to,
payload.as_string())
server.quit()

add some print statements. Where does it fail? how?


On Jul 27, 11:07 am, Andrew Buchan  wrote:
> Well it works from smtplib called from within web2py, so the server does
> actually work. Can't actually seem to type in what you suggested into
> telnet, that is an abomination of a command-line interface!!! :-)
> So I'm thinking it must be something in the difference between web2py's mail
> and smtplib's implementations...
>
> On Tue, Jul 27, 2010 at 4:13 PM, Adi  wrote:
> > Have you tried using telnet to verify your server and mail are
> > correctly configured?
>
> > Try this:
>
> > c:\> telnet 192.168.200.43 25
> > ehlo
> > mail from:the...@h**a.com
> > recpt to: t...@h***a.com
> > data
> > This is a test message
>
> > The recipient should be something valid. If this sends out email from
> > your Windows server then the smtp relay is working. In that case
> > please attach ehlo output. If this doesn't send out email, then the
> > problem is not with your web2py code, but with your mail setup
> > somewhere.
>
> > -- Adi
>
> > On Jul 27, 7:29 pm, Andrew Buchan  wrote:
> > > Massimo,
>
> > > 192.168.200.43 is a different windows box setup as a domino server, and
> > the
> > > smtplib example in original post works fine connecting to that server.
> > The
> > > windows box hosting the web2py application will not normally be connected
> > to
> > > the internet, so I can't go using google's smtp.
> > > If I recall from the event log on domino (which I do not have access to
> > > myself), the connection seems to be established but then dropped. Perhaps
> > > the header is not in a correct format?
>
> > > Andrew.
>
> > > On Tue, Jul 27, 2010 at 3:06 PM, mdipierro 
> > wrote:
> > > > Is 192.168.200.43:25 the windows box itself or an external unix box?
> > > > In the first case, do you have an email server running on windows?
> > > > On unix this works because you have postfix but windows does not come
> > > > with one.
> > > > You may want to use an external smpt server like google.
>
> > > > On Jul 27, 9:00 am, Andrew Buchan  wrote:
> > > > > Thanks, but I tried that, along with a number of other port settings,
> > > > > using smtp as prefix etc... Has anyone els managed to get this
> > working
> > > > > from a windows server?
>
> > > > > On Jul 22, 12:11 pm, Vasile Ermicioi  wrote:
>
> > > > > > > mail.settings.server= '192.168.200.43:25'
>
> > > > > >  add port


Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Michael Ellis
Sorry, what I sent was very large (~750K each). Didn't realize GoogleGroups
would reduce it  to a thumbnail.  I'll try to forward the original message
directly to you ...



On Tue, Jul 27, 2010 at 12:07 PM, mdipierro  wrote:

> The picture is too small. Anything interesting in there?
>
> On Jul 27, 11:01 am, Michael Ellis  wrote:
> > Thanks for the info about sloth. I may try it later.  It was pretty easy
> to
> > get what I needed with ipython:
> >
> > procs = !ps ax | grep "web2py"
> > pids = [r[0] for r in procs.fields()[0:-2]]
> > for p in pids:
> >  print p
> >  !lsof | grep $p | wc
> >
> > On Tue, Jul 27, 2010 at 11:50 AM, Jonathan Lundell  >wrote:
> >
> > > On Jul 27, 2010, at 8:23 AM, Jonathan Lundell wrote:
> >
> > > On Jul 27, 2010, at 5:33 AM, Michael Ellis wrote:
> >
> > > This morning I found several OSError reports about "Too many open
> files" in
> > > a web2py development server that's been running locally for several
> days.
> > >  The app code isn't doing any explicit file i/o so I don't know what's
> going
> > > on,  but here are the tracebacks in case someone else is seeing
> anything
> > > similar.
> >
> > > The first thing to do is to use lsof (try: man lsof) to see what's
> being
> > > opened.
> >
> > > I just noticed a graphical interface to lsof that looks pretty nice:
> >
> > > Sloth 1.5 - Displays all open files in use by an app. (Free)<
> http://feedproxy.google.com/~r/macupdate/~3/q-i76jy2bk8/sloth>
> > > 7/27/10 5:09 AM
> > > MacUpdate 
> > > Sloth 1.5
> > > 
> > > *Sloth* is a program that displays a list of all open files in use by
> all
> > > the applications your user account is running on the system—this list
> > > includes IP and Unix sockets, character devices and directories, and is
> > > generated by the 'lsof' command. This list is presented along with the
> names
> > > of applications using the file and their process IDs. This makes it
> easy to
> > > monitor what applications are 'locking' which files. Sloth is a
> graphical
> > > interface front-end to 'lsof', a powerful unix tool.
> >
> > > WHAT'S NEW
> > > Version 1.4:
> >
> > >- Column sorting, column rearrangement
> > >- Copy/Drag and drop
> > >- Several bug fixes
> > >- Various interface refinements
> >
> > > REQUIREMENTS
> > > Mac OS X 10.4 or later.
> >
> > > PRICE
> > > Free
> >
> > > DEVELOPER
> > > Sveinbjorn Thordarson 
> >
> > > DOWNLOADS
> > > 6080
> >
> > > DOWNLOAD NOW (110 K)<
> http://www.macupdate.com/download.php/14230%20sloth.zip>
> >
> > > More information 
> >
> >
> >
> >  14230_sm.png
> > 68KViewDownload


Re: [web2py] Re: rocket performance issues

2010-07-27 Thread Jonathan Lundell
On Jul 27, 2010, at 9:01 AM, Michael Ellis wrote:

> Thanks for the info about sloth. I may try it later.  It was pretty easy to 
> get what I needed with ipython:
> 
> procs = !ps ax | grep "web2py"
> pids = [r[0] for r in procs.fields()[0:-2]]
> for p in pids:
>  print p
>  !lsof | grep $p | wc
> 

Also: sudo launchctl limit maxfiles

I see 256 by default. The second limit is the "hard limit", beyond which you 
can't configure (unlimited in this case).

http://serverfault.com/questions/15564/where-are-the-default-ulimits-specified-on-os-x-10-5

[web2py] now this is c...@_ol

2010-07-27 Thread mdipierro
http://github.com/saucelabs/monocle#readme

simple yet effective


[web2py] How about LOAD(..., loading='loading...')?

2010-07-27 Thread Iceberg
Hi Massimo,

So far the LOAD(...) hardcode the loading message as "loading...". I
suggest to make it customizable. Such as:

def LOAD(..., loading='loading...'):
blah blah

This way, developer has a chance to do i18n by:
LOAD(..., loading='say_loading_in_chinese')
or a fancy one:
LOAD(..., loading=IMG(_src='/loading_animation.gif'))

By the way, LOAD(...) has seemingly no document in web2py.com/book
yet.

Regards,
Iceberg


Re: [web2py] Re: where to put helper functions?

2010-07-27 Thread Mathieu Clabaut
But then note that you have to pass as arguments to your helpers objects
that are otherwise directly available in models and controllers, like : db,
request, response, T, auth,...
-Mathieu

On Mon, Jul 26, 2010 at 21:03, Iceberg  wrote:

> Put your helpers into modules, then use local_import(...). See also:
> http://web2py.com/book/default/search?search=local_import
>
> (Sent from my thinkpad)
>
> On Jul 27, 1:02am, rochacbruno  wrote:
> > I dont think it is the right way, but I use to create a config.py and a
> helper.py in my models.
> >
> > The classes, methods, functions defined in model are available to
> cobtroller and views.
> >
> > But I think the best way is creating external modules.
> >
> > Sent from my iPhone
> >
> > On 26/07/2010, at 13:04, VP  wrote:
> >
> >
> >
> > > I have a bunch of functions that are not meant to be exposed (via URL)
> > > but rather to be helping out with things (and to be called by
> > > functions defined in controllers).  Where do I put these?  And how do
> > > I import them into controllers?
> >
> > > I tried to place them in private or modules, but it doesn't seem to
> > > work (I can't import them in controllers).
> >
> > > Thanks.
>


Re: [web2py] Re: book 3rd edition call of help

2010-07-27 Thread Jonathan Lundell
On Jul 27, 2010, at 9:03 AM, mdipierro wrote:

> For example?

Forms & Validators is pretty long. 

I could see breaking out CRUD. Right now that's not too much, but I'm hoping 
that the CRUD section will grow.

Perhaps Validators could be its own chapter, leaving just a top-level overview 
in the Forms chapter explaining how validators relate to forms, but not 
describing each validator in detail.

That reminds me of an old suggestion: that the manual have reference chapters 
or appendixes. So there'd be an appendix on validators, with a table of the 
details. One on fields. One on widgets. Then the main body chapters would have 
tutorial and generic material, but not the detailed reference.

This solves two problem. 1) it makes the main chapters a little shorter, and 2) 
it makes the reference material easier to find, which would be handy for 
day-to-day programming.

> 
> On Jul 27, 10:20 am, Jonathan Lundell  wrote:
>> On Jul 27, 2010, at 4:51 AM, mdipierro wrote:
>> 
>>> web2py.com/book was broken into section
>>> web2py.com/book2 is broken into chapters
>> 
>>> what is better?
>>> Once printed it will be the same.
>> 
>> Offhand I'd say chapters, so I can use my browser-native search more 
>> effectively.
>> 
>> In that case, it might be that some existing chapters that treat more than 
>> one subject could be split.




[web2py] database cannot be modified anymore : migration between v1.44 & current.

2010-07-27 Thread Lionel Barret
Hi all,

We are moving our app from one host to the other.

We used v1.44 on our old host, the new one use the current version.

And as I test the new host, I discovered our database cannot be
updated/written to anymore.

It can be read, though as the site does work, and the admin app does
display the db content.

I tested with our app and the admin app.

I get the same error in both case :

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
exec ccode in environment
  File "/srv/Web/www/web2py/applications/g2009_current/controllers/
appadmin.py", line 281, in 
  File "gluon/globals.py", line 96, in 
self._caller = lambda f: f()
  File "/srv/Web/www/web2py/applications/g2009_current/controllers/
appadmin.py", line 103, in insert
if form.accepts(request.vars, session):
  File "gluon/sqlhtml.py", line 1029, in accepts
self.vars.id = self.table.insert(**fields)
  File "gluon/sql.py", line 1933, in insert
query = self._insert(**fields)
  File "gluon/sql.py", line 1913, in _insert
value = value[:field.length]
TypeError: slice indices must be integers or None or have an __index__
method

Any ideas ? Massimo ?


Re: [web2py] Re: where to put helper functions?

2010-07-27 Thread Jonathan Lundell
On Jul 27, 2010, at 9:26 AM, Mathieu Clabaut wrote:

> But then note that you have to pass as arguments to your helpers objects that 
> are otherwise directly available in models and controllers, like : db, 
> request, response, T, auth,...

Or import them. I wrote a module to give me a nicer interface to DataTables. It 
starts out:

from gluon.html import TABLE, THEAD, TBODY, TFOOT, TR, TD, TH, XML


> -Mathieu
> 
> On Mon, Jul 26, 2010 at 21:03, Iceberg  wrote:
> Put your helpers into modules, then use local_import(...). See also:
> http://web2py.com/book/default/search?search=local_import
> 
> (Sent from my thinkpad)
> 
> On Jul 27, 1:02am, rochacbruno  wrote:
> > I dont think it is the right way, but I use to create a config.py and a 
> > helper.py in my models.
> >
> > The classes, methods, functions defined in model are available to 
> > cobtroller and views.
> >
> > But I think the best way is creating external modules.
> >
> > Sent from my iPhone
> >
> > On 26/07/2010, at 13:04, VP  wrote:
> >
> >
> >
> > > I have a bunch of functions that are not meant to be exposed (via URL)
> > > but rather to be helping out with things (and to be called by
> > > functions defined in controllers).  Where do I put these?  And how do
> > > I import them into controllers?
> >
> > > I tried to place them in private or modules, but it doesn't seem to
> > > work (I can't import them in controllers).
> >
> > > Thanks.
> 




[web2py] Re: database cannot be modified anymore : migration between v1.44 & current.

2010-07-27 Thread mdipierro
One of your fields has a length=None. Change it to a value or (better)
set the type to 'text'.

Massimo

On Jul 27, 11:26 am, Lionel Barret  wrote:
> Hi all,
>
> We are moving our app from one host to the other.
>
> We used v1.44 on our old host, the new one use the current version.
>
> And as I test the new host, I discovered our database cannot be
> updated/written to anymore.
>
> It can be read, though as the site does work, and the admin app does
> display the db content.
>
> I tested with our app and the admin app.
>
> I get the same error in both case :
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> appadmin.py", line 281, in 
>   File "gluon/globals.py", line 96, in 
>     self._caller = lambda f: f()
>   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> appadmin.py", line 103, in insert
>     if form.accepts(request.vars, session):
>   File "gluon/sqlhtml.py", line 1029, in accepts
>     self.vars.id = self.table.insert(**fields)
>   File "gluon/sql.py", line 1933, in insert
>     query = self._insert(**fields)
>   File "gluon/sql.py", line 1913, in _insert
>     value = value[:field.length]
> TypeError: slice indices must be integers or None or have an __index__
> method
>
> Any ideas ? Massimo ?


[web2py] Re: database cannot be modified anymore : migration between v1.44 & current.

2010-07-27 Thread mdipierro
P.S. you problem is 2 years old. You may also want to replace SQLField
with Field and SQLDB with DAL for aesthetic reasons.

On Jul 27, 11:31 am, mdipierro  wrote:
> One of your fields has a length=None. Change it to a value or (better)
> set the type to 'text'.
>
> Massimo
>
> On Jul 27, 11:26 am, Lionel Barret  wrote:
>
> > Hi all,
>
> > We are moving our app from one host to the other.
>
> > We used v1.44 on our old host, the new one use the current version.
>
> > And as I test the new host, I discovered our database cannot be
> > updated/written to anymore.
>
> > It can be read, though as the site does work, and the admin app does
> > display the db content.
>
> > I tested with our app and the admin app.
>
> > I get the same error in both case :
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 178, in restricted
> >     exec ccode in environment
> >   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> > appadmin.py", line 281, in 
> >   File "gluon/globals.py", line 96, in 
> >     self._caller = lambda f: f()
> >   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> > appadmin.py", line 103, in insert
> >     if form.accepts(request.vars, session):
> >   File "gluon/sqlhtml.py", line 1029, in accepts
> >     self.vars.id = self.table.insert(**fields)
> >   File "gluon/sql.py", line 1933, in insert
> >     query = self._insert(**fields)
> >   File "gluon/sql.py", line 1913, in _insert
> >     value = value[:field.length]
> > TypeError: slice indices must be integers or None or have an __index__
> > method
>
> > Any ideas ? Massimo ?


Re: [web2py] Re: where to put helper functions?

2010-07-27 Thread Mathieu Clabaut
On Tue, Jul 27, 2010 at 18:30, Jonathan Lundell  wrote:

> On Jul 27, 2010, at 9:26 AM, Mathieu Clabaut wrote:
>
> But then note that you have to pass as arguments to your helpers objects
> that are otherwise directly available in models and controllers, like : db,
> request, response, T, auth,...
>
>
> Or import them. I wrote a module to give me a nicer interface to
> DataTables. It starts out:
>
> from gluon.html import TABLE, THEAD, TBODY, TFOOT, TR, TD, TH, XML
>

Is there something similar  for db, request, and others ?

-Mathieu


[web2py] Re: OpenID supported with login method

2010-07-27 Thread keitheis
No problem.

It extends the built-in login form with external login form.

Like the bottom of the slice 
http://www.web2pyslices.com/main/slices/take_slice/28

Pic http://www.web2pyslices.com/main/static/share/images/rpxembedlocal.JPG

Maybe I should name it embedded_auth_form or something else.

Hope it's not too confusing.


On Jul 27, 8:59 pm, mdipierro  wrote:
> Sorry for my late replay.
>
> Can you explain what extended_login_form does?
>
> On Jul 25, 12:52 am, keitheis  wrote:> Hi,
>
> > I made theOpenIDsupport for sahana eden. And thanks to Fran Boon, I
> > did it most on web2py/gluon/contrib/login_methods . Here is the code:
>
> >https://code.launchpad.net/~keitheis/web2py/openid
>
> > Fran said that in the long run it's better to have it maintained up
> > here.
> > So I send it here for the feedback.
>
> > Kind Regards,
> > Keith Yang


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mwolfe02
I'd vote for CHAPTERS as well, with the previously mentioned caveat
that searches would need to be able to jump to the relevant section(s)
within a chapter.

Also, I think a fixed (ie, non-scrolling and always on-screen) sidebar
with the current chapter's section table of contents allowing easy
navigation within the chapter would be better than a bunch of 'Back to
Top' links (although it wouldn't hurt to include those for those who
prefer that type of navigation).

As a relatively new user of web2py (<1 month) I have found the section
breaks frustrating at times.  I usually know which chapter a topic
belongs in, but can't always figure out specifically what section it
should be in.  Here's a quick example:

I was trying to find the function ._lastsql.  I remembered reading
about it early on when I had read most of the DAL chapter in a single
shot, but couldn't remember where I'd seen it or what the function
name was.  Since I couldn't remember the function name, I couldn't
perform an effective search.  So I went to the sections that seemed
most likely to have the info:

- 6.7. How to see SQL
- 6.5. Query, Set, Rows
- 6.2. Connection Strings
- 6.3. DAL, Table, Field

I finally gave up and then remembered that I had used the function in
some of my very early code.  I checked my code, found the function
named ._lastsql, then did a search in the book for lastsql, and was
still skeptical when I saw that it was actually in 6.4 Migrations.

My point is if I could have just scrolled top to bottom of the entire
DAL chapter I probably would have found what I was looking for.

On Jul 27, 11:20 am, Jonathan Lundell  wrote:
> On Jul 27, 2010, at 4:51 AM, mdipierro wrote:
>
> > web2py.com/book was broken into section
> > web2py.com/book2 is broken into chapters
>
> > what is better?
> > Once printed it will be the same.
>
> Offhand I'd say chapters, so I can use my browser-native search more 
> effectively.
>
> In that case, it might be that some existing chapters that treat more than 
> one subject could be split.


[web2py] Re: OpenID supported with login method

2010-07-27 Thread mdipierro
+1. I am thinking about inclusion

On Jul 27, 11:37 am, keitheis  wrote:
> No problem.
>
> It extends the built-in login form with external login form.
>
> Like the bottom of the 
> slicehttp://www.web2pyslices.com/main/slices/take_slice/28
>
> Pichttp://www.web2pyslices.com/main/static/share/images/rpxembedlocal.JPG
>
> Maybe I should name it embedded_auth_form or something else.
>
> Hope it's not too confusing.
>
> On Jul 27, 8:59 pm, mdipierro  wrote:
>
> > Sorry for my late replay.
>
> > Can you explain what extended_login_form does?
>
> > On Jul 25, 12:52 am, keitheis  wrote:> Hi,
>
> > > I made theOpenIDsupport for sahana eden. And thanks to Fran Boon, I
> > > did it most on web2py/gluon/contrib/login_methods . Here is the code:
>
> > >https://code.launchpad.net/~keitheis/web2py/openid
>
> > > Fran said that in the long run it's better to have it maintained up
> > > here.
> > > So I send it here for the feedback.
>
> > > Kind Regards,
> > > Keith Yang


[web2py] Re: book 3rd edition call of help

2010-07-27 Thread mdipierro
oops!

On Jul 27, 11:37 am, mwolfe02  wrote:
> I'd vote for CHAPTERS as well, with the previously mentioned caveat
> that searches would need to be able to jump to the relevant section(s)
> within a chapter.
>
> Also, I think a fixed (ie, non-scrolling and always on-screen) sidebar
> with the current chapter's section table of contents allowing easy
> navigation within the chapter would be better than a bunch of 'Back to
> Top' links (although it wouldn't hurt to include those for those who
> prefer that type of navigation).
>
> As a relatively new user of web2py (<1 month) I have found the section
> breaks frustrating at times.  I usually know which chapter a topic
> belongs in, but can't always figure out specifically what section it
> should be in.  Here's a quick example:
>
> I was trying to find the function ._lastsql.  I remembered reading
> about it early on when I had read most of the DAL chapter in a single
> shot, but couldn't remember where I'd seen it or what the function
> name was.  Since I couldn't remember the function name, I couldn't
> perform an effective search.  So I went to the sections that seemed
> most likely to have the info:
>
> - 6.7. How to see SQL
> - 6.5. Query, Set, Rows
> - 6.2. Connection Strings
> - 6.3. DAL, Table, Field
>
> I finally gave up and then remembered that I had used the function in
> some of my very early code.  I checked my code, found the function
> named ._lastsql, then did a search in the book for lastsql, and was
> still skeptical when I saw that it was actually in 6.4 Migrations.
>
> My point is if I could have just scrolled top to bottom of the entire
> DAL chapter I probably would have found what I was looking for.
>
> On Jul 27, 11:20 am, Jonathan Lundell  wrote:
>
> > On Jul 27, 2010, at 4:51 AM, mdipierro wrote:
>
> > > web2py.com/book was broken into section
> > > web2py.com/book2 is broken into chapters
>
> > > what is better?
> > > Once printed it will be the same.
>
> > Offhand I'd say chapters, so I can use my browser-native search more 
> > effectively.
>
> > In that case, it might be that some existing chapters that treat more than 
> > one subject could be split.


[web2py] Re: database cannot be modified anymore : migration between v1.44 & current.

2010-07-27 Thread Lionel Barret
Sorry to be slow but I don't get it.

This is what I did :
* changed the sqldb to dal
* changed the sqlfield to field
* check that the params were good (the "text" type you mention).

tested on this table, defined in db.py :
--
db.define_table('product_pages',
Field('title', 'string', length="128"),
Field('text', 'text'))

db.product_pages.title.requires = IS_NOT_EMPTY()
db.product_pages.text.requires  = IS_NOT_EMPTY()
---
I still get the error whe trying to update the table. I use the
appadmin.

What's wrong ?

L.



On Jul 27, 6:32 pm, mdipierro  wrote:
> P.S. you problem is 2 years old. You may also want to replace SQLField
> with Field and SQLDB with DAL for aesthetic reasons.
>
> On Jul 27, 11:31 am, mdipierro  wrote:
>
> > One of your fields has a length=None. Change it to a value or (better)
> > set the type to 'text'.
>
> > Massimo
>
> > On Jul 27, 11:26 am, Lionel Barret  wrote:
>
> > > Hi all,
>
> > > We are moving our app from one host to the other.
>
> > > We used v1.44 on our old host, the new one use the current version.
>
> > > And as I test the new host, I discovered our database cannot be
> > > updated/written to anymore.
>
> > > It can be read, though as the site does work, and the admin app does
> > > display the db content.
>
> > > I tested with our app and the admin app.
>
> > > I get the same error in both case :
>
> > > Traceback (most recent call last):
> > >   File "gluon/restricted.py", line 178, in restricted
> > >     exec ccode in environment
> > >   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> > > appadmin.py", line 281, in 
> > >   File "gluon/globals.py", line 96, in 
> > >     self._caller = lambda f: f()
> > >   File "/srv/Web/www/web2py/applications/g2009_current/controllers/
> > > appadmin.py", line 103, in insert
> > >     if form.accepts(request.vars, session):
> > >   File "gluon/sqlhtml.py", line 1029, in accepts
> > >     self.vars.id = self.table.insert(**fields)
> > >   File "gluon/sql.py", line 1933, in insert
> > >     query = self._insert(**fields)
> > >   File "gluon/sql.py", line 1913, in _insert
> > >     value = value[:field.length]
> > > TypeError: slice indices must be integers or None or have an __index__
> > > method
>
> > > Any ideas ? Massimo ?


[web2py] Re: advice on ListProperty

2010-07-27 Thread howesc
i too think that would be great.  is that getting to DB specific for
the DAL?

cfh

On Jul 25, 10:17 pm, Thadeus Burgess  wrote:
> Yes.
>
> Just go the extra half a mile and add it for every database that will
> use a table behind the scenes.
>
> --
> Thadeus
>
> On Sun, Jul 25, 2010 at 6:17 PM, mdipierro  wrote:
> > GAE has a ListPropery and IS_IN_DB(...,multiple=True) does not use it
> > but uses '|2|34|45|' instead for portability over relational databases
> > and GAE.
>
> > Should there be a web2py type 'list' that hides all of this and uses
> > ListProperty on GAE and provides simpler query syntax in this case?
>
> > Massimo


  1   2   >