[web2py] Re: Using Jython with web2py

2010-11-29 Thread pierreth
On Nov 29, 1:39 am, mdipierro  wrote:
> please let us know if things work or do not work. We have not tested
> web2py with jython much,
>
> Massimo
>

Well, I won't dig that much in Jython with web2py for the moment. In a
longer term interest, I would like to be able to use web2py in a Java
infrastructure with Hibernate. I think it might be a really nice tool
for prototyping in the enterprise world.

Also I would like to use web2py with sqlalchemy with Python Spring. I
see the mix of the three as a potential solution for the enterprise
world too.

In fact, I don't understand that you labeled web2py as an "Enterprise
Web Framework". Without wanting to offend you, I see web2py as a
"pragmatic, agile and extensible web framework for fast development".
I think web2py as a too tight coupling for enterprise development. DAL
in not a real ORM and it does not make it easy to apply domain driven
design. Add the fact that the web2py book is mixing presentation with
the control, I think web2py is favoring pragmatism over abstraction.
It is not bad by itself but it conflicts with my vision of the
enterprise way.

I would appreciate your comments.

Pierre


Re: [web2py] Re: XMLRPC

2010-11-29 Thread Branko Vukelic
On Mon, Nov 29, 2010 at 8:52 AM, Branko Vukelic  wrote:
> Thanks. Thats this mean one can run multiple services using the same
> controller method?

I guess not.

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] JSONRPC notes

2010-11-29 Thread Branko Vukelic
Some notes I'd like to share. Comments and advice most welcome!

web2py supports JSONRPC 1.1 (and not 2.0 which is still a proposal).
This means there is no support for keyword arguments at this moment.
To work around this you can pass your methods a single argument which
is a dict, and parse the dict yourself. For example:

# in your controller
def mymethod(params):
param1 = params.get('key1', defaultvalue) # defaultvalue is optional
param2 = params.get('key2')
...
# do something with params and calculate result
return result

In your javascript code, send JSONRPC request as:

{"version": "1.1", "method": "mymethod",
"params": [{"key1": "val1", "key2": 2, ... "keyN": "valN"}],
id="someid"}

As you can see, the dict (object) is wrapped inside an array and array
has a single member.

Another note. You must include the id key. It can be anything, but
it's important to check that the same id is returned from the server.
I'm not sure if this prevents any security holes (I guess not), but at
least it doesn't open any new ones if you check it. So the whole
boilerplate for handling response would be:

if (response.id == idKey && response.error == null) {
callback(response);
}
else {
DEBUG('JSONRPC error');
errback(response);
}

The ``idKey`` variable is some random key I generate before every
JSONRPC call, and I check that the response contains the same key.
``response.error`` is a non-null value if there is an error, so it's
also good to check that before firing the callback.

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Using Jython with web2py

2010-11-29 Thread pierreth
On Nov 29, 1:39 am, mdipierro  wrote:
> please let us know if things work or do not work. We have not tested
> web2py with jython much,
>
> Massimo
>

Well, I won't dig that much in Jython with web2py for the moment. In a
longer term interest, I would like to be able to use web2py in a Java
infrastructure with Hibernate. I think it might be a really nice tool
for prototyping in the enterprise world.

Also I would like to use web2py with sqlalchemy with Python Spring. I
see the mix of the three as a potential solution for the enterprise
world too.

In fact, I don't understand that you labeled web2py as an "Enterprise
Web Framework". Without wanting to offend you, I see web2py as a
"pragmatic, agile and extensible web framework for fast development".
I think web2py as a too tight coupling for enterprise development. DAL
in not a real ORM and it does not make it easy to apply domain driven
design. Add the fact that the web2py book is mixing presentation with
the control, I think web2py is favoring pragmatism over abstraction.
It is not bad by itself but it conflicts with my vision of the
enterprise way.

I would appreciate your comments.

Pierre


[web2py] Tweaking JSON

2010-11-29 Thread Lorin Rivers
I need to change the JSON output I get from this:
[{"FreezeTime": "2010-11-08 21:00", "Irrad_avg": 605.00}, {"FreezeTime": 
"2010-11-08 21:01", "Irrad_avg": 600.66}]

to something more like this:

[['2010-11-08 21:00',605.00], ['2010-11-08 21:01',600.66]]

At the moment I'm using the simplejson.dumps method as explained in The Book 
.

What should I do?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] Re: Using Jython with web2py

2010-11-29 Thread pierreth
On Nov 29, 1:39 am, mdipierro  wrote:
> please let us know if things work or do not work. We have not tested
> web2py with jython much,
>
> Massimo
>

Well, I won't dig that much in Jython with web2py for the moment. In a
longer term interest, I would like to be able to use web2py in a Java
infrastructure with Hibernate. I think it might be a really nice tool
for prototyping in the enterprise world.

Also I would like to use web2py with sqlalchemy with Python Spring. I
see the mix of the three as a potential solution for the enterprise
world too.

In fact, I don't understand that you labeled web2py as an "Enterprise
Web Framework". Without wanting to offend you, I see web2py as a
"pragmatic, agile and extensible web framework for fast development".
I think web2py as a too tight coupling for enterprise development. DAL
in not a real ORM and it does not make it easy to apply domain driven
design. Add the fact that the web2py book is mixing presentation with
the control, I think web2py is favoring pragmatism over abstraction.
It is not bad by itself but it conflicts with my vision of the
enterprise way.

I would appreciate your comments.

Pierre


[web2py] Forms and their customisation

2010-11-29 Thread Emceha
Here is my controller code:

def dodaj_artykul():
form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
return dict(form=form)

I see that textarea always has cols=40 and rows=10 - I wanted to
change that value but I haven't found any straight forward example to
do it using CRUD only?

Should I use SQLFORM?

Thanks


Re: [web2py] Forms and their customisation

2010-11-29 Thread Daniel Gonzalez
Hi, 

Checkout the chapter 7 of the book, specially this part:
http://web2py.com/book/default/chapter/07#Custom-forms

Regards
Daniel

El lun, 29-11-2010 a las 02:11 -0800, Emceha escribió:
> Here is my controller code:
> 
> def dodaj_artykul():
> form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> return dict(form=form)
> 
> I see that textarea always has cols=40 and rows=10 - I wanted to
> change that value but I haven't found any straight forward example to
> do it using CRUD only?
> 
> Should I use SQLFORM?
> 
> Thanks




[web2py] Re: Forms and their customisation

2010-11-29 Thread Emceha
Thanks Daniel for prompt reply,

I've read chapter 7 already, also did some google search - but I was
wondering if there is easier way to do it - (with less code and maybe
just passing some parameters on crud.create as it's not really
customization I want to do - I would call it more like forms settings)

Marcin

On Nov 29, 11:17 am, Daniel Gonzalez  wrote:
> Hi,
>
> Checkout the chapter 7 of the book, specially this 
> part:http://web2py.com/book/default/chapter/07#Custom-forms
>
> Regards
> Daniel
>
> El lun, 29-11-2010 a las 02:11 -0800, Emceha escribió:
>
>
>
>
>
>
>
> > Here is my controller code:
>
> > def dodaj_artykul():
> >     form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> >     return dict(form=form)
>
> > I see that textarea always has cols=40 and rows=10 - I wanted to
> > change that value but I haven't found any straight forward example to
> > do it using CRUD only?
>
> > Should I use SQLFORM?
>
> > Thanks


Re: [web2py] Tweaking JSON

2010-11-29 Thread Branko Vukelic
On Mon, Nov 29, 2010 at 9:53 AM, Lorin Rivers  wrote:
> I need to change the JSON output I get from this:
> [{"FreezeTime": "2010-11-08 21:00", "Irrad_avg": 605.00}, {"FreezeTime": 
> "2010-11-08 21:01", "Irrad_avg": 600.66}]
>
> to something more like this:
>
> [['2010-11-08 21:00',605.00], ['2010-11-08 21:01',600.66]]

Suppose all your data is in a list called ``yourdata``, and yorudata
is a list of dicts:

return [[d.get('FreezeTime'), d.get('Irrad_avg')] for d in yourdata]

You can use either the get method as I did, or the subscript notation:

return [[d['FreezeTime'], d['Irrad_avg']] for d in yourdata]

Difference is that get will assign ``None`` if a key doesn't exist,
while subscript notation will raise an exception. It depends on how
certain you can be about existence of the keys.

You can read more about list comprehensions here:

http://docs.python.org/tutorial/datastructures.html#list-comprehensions


-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: Forms and their customisation

2010-11-29 Thread Daniel Gonzalez
I dont know if this could work for you:

def dodaj_artykul():
   db.artykuly.textareafield.represent = lambda k: TEXTAREA(value=k,
_cols=100, _rows=100)
   form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
   return dict(form=form)



I don't know how this could affect the functionlity of the form, because the 
name of the textarea can change. You can try with passing another attribute to 
the TEXTAREA helper: (_name="some_name")

But I don't know if web2py will search later for that name to process the form, 
you can search in the source code of the processed form to see what name gives 
web2py to the field, and use it.

I hope that this is what are you looking for.



El lun, 29-11-2010 a las 02:27 -0800, Emceha escribió:
> Thanks Daniel for prompt reply,
> 
> I've read chapter 7 already, also did some google search - but I was
> wondering if there is easier way to do it - (with less code and maybe
> just passing some parameters on crud.create as it's not really
> customization I want to do - I would call it more like forms settings)
> 
> Marcin
> 
> On Nov 29, 11:17 am, Daniel Gonzalez  wrote:
> > Hi,
> >
> > Checkout the chapter 7 of the book, specially this 
> > part:http://web2py.com/book/default/chapter/07#Custom-forms
> >
> > Regards
> > Daniel
> >
> > El lun, 29-11-2010 a las 02:11 -0800, Emceha escribió:
> >
> >
> >
> >
> >
> >
> >
> > > Here is my controller code:
> >
> > > def dodaj_artykul():
> > > form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> > > return dict(form=form)
> >
> > > I see that textarea always has cols=40 and rows=10 - I wanted to
> > > change that value but I haven't found any straight forward example to
> > > do it using CRUD only?
> >
> > > Should I use SQLFORM?
> >
> > > Thanks




[web2py] Re: Web2py book - virtual fields section improvements

2010-11-29 Thread Adi
Any comments?

On Nov 25, 10:49 am, Adi  wrote:
> Hi all,
>
> I spent hours yesterday trying to implement virtual fields correctly
> following the book, and based on that I found some behaviour which
> could be better explained.
>
> Reference:http://web2py.com/book/default/chapter/06#Virtual-Fields
> web2py version: 1.88.2
>
> 1. Selecting a virtual field like a normal field in select() part of
> the query will throw a KeyError. However, the virtual field is still
> getting selected.
>
> 2. This part:
>
> class MyVirtualFields(object):
> ...
> db.mytable.virtualfields.append(MyVirtualFields())
>
> should come before the db.select for the virtual fields to be
> selected. The model is a good place for this part of the code. This is
> in slight contrast to the second code example where
> rows.setvirtualfields(...) is called after the rows are selected. The
> difference is slightly confusing.
>
> 3. Using the lazy loading techniques makes it impossible to select the
> virtual fields directly in a query. You will need to iterate through
> the selected rows and explicitly extract the
> row.mytable.myvirtualfield() as shown in example. The need to loop
> through the rows again (against using the rows directly in say, an
> SQLTable) may not really be desirable in a web2py app situation, and
> should not be considered the general use case.
>
> Please correct me if anything here is wrong. The point is that I spent
> a lot of time and trial-error methods to figure this out, which we can
> avoid for other people if we explain this part better in the book.


[web2py] Autoroutes and.static files

2010-11-29 Thread rochacbruno
HI, I am trying to use autoroutes for the first time, what I want is my site 
running in127.0.0.1:8080/index instead of127.0.0.1:8080/app/default/index

I tried the autoroutes and routes.conf explained in another thread here but i 
didn't figure out how to make the access to static files. 

I am using web2py 1.89.5 all functions as /index and /user  are working well, 

 But my static files are unreachable.

127.0.0.1:8080/index works ok, but show no images that I included with 

127.0.0.1:8080/static/image.png does not works too, and I cannot access in old 
way /app/static/image.png

Something is missing in routes_out?

My routes.conf is

START CODE 
127.0.0.1 /blouweb/default
---END CODE 

My routes.py is

---START CODE---

try: config=open('routes.conf','r').read()
except: config=''

def auto_in(apps):
routes=[
('/robots.txt','/blouweb/static/robots.txt'),
('/favicon.ico','/blouweb/static/favicon.ico'),
('/admin$anything','/admin$anything'),
]
for a,b in [x.strip().split() for x in apps.split('\n') if x.strip() and 
not x.strip().startswith('#')]:
if not b.startswith('/'): b='/'+b
if b.endswith('/'): b=b[:-1]
app = b.split('/')[1]
routes+=[
('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
('.*:https?://(.*\.)?%s:$method /static/$anything' % 
a,'%s/static/$anything' % app),
('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % 
a,'%s/appadmin/$anything' % app),
('.*:https?://(.*\.)?%s:$method /$anything' % a,'%s/$anything' % 
b), 
]
return routes

def auto_out(apps):
routes=[]
for a,b in [x.strip().split() for x in apps.split('\n') if x.strip() and 
not x.strip().startswith('#')]:
if not b.startswith('/'): b='/'+b
if b.endswith('/'): b=b[:-1]
app = b.split('/')[1]
routes+=[
('%s/static/$anything' % app,'/static/$anything'),
('%s/appadmin/$anything' % app, '/appadmin/$anything'),
('%s/$anything' % b, '/$anything'),
]
return routes

routes_in=auto_in(config)
routes_out=auto_out(config)
---END CODE ---

How to access static files?

-- 

Bruno Rocha
http://about.me/rochacbruno/bio

Enviado via iPhone

[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
That's it I'll try it
thanks a lot!


On 29 nov, 00:48, mdipierro  wrote:
> I assume you are trying to build a hierarchial tree of articles and
> you want them all from the parent.
>
> I would do this something like this:
>
> db.define_table('article',Field('f_parent','reference
> article'),Field('title'))
>
> def index():
>     rows = dict((r.id,r) for r in db(db.article).select())
>     for id,row in rows.items(): row.children=[]
>     for id,row in rows.items():
>         if row.f_parent==0: root=row
>         else: rows[row.f_parent].append(row)
>     def tree(row):
>         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> row.children])))
>     return tree(root)
>
> On Nov 28, 5:00 pm, JmiXIII  wrote:
>
> > Hello,
>
> > I'm facing I guess a well known programming problem. It is not really
> > related to web2by, but since I'm using web2py I hope somebody here can
> > help.
>
> > Here is my controller :
>
> > def global_view():
> >     parents = db(~(db.t_article.id==db.t_list.f_article)).select()
> >     tree={}
> >     for parent in parents:
> >         tree[parent.t_article.id]={}
> >         sublevel=db(parent.t_article.id==db.t_list.f_parent).select()
> >         for son in sublevel:
> >             tree[parent.t_article.id][son.f_article]=son.f_article
> >             tree[parent.t_article.id][son.f_article]={}
> >             sublevel2=db(son.f_article==db.t_list.f_parent).select()
> >             for son2 in sublevel2:
> >                 tree[parent.t_article.id][son.f_article]
> > [son2.f_article]=son2.f_article
> >                 tree[parent.t_article.id][son.f_article][son2.f_article]={}
> >     return dict(tree=tree)
>
> > So in fact I'd like to go on for son3, son4, based on the same model
> > as sublevel2... until sublevelx=None.
> > I guess I should use some kind of recursive or loop function.
> > I've read different things using right and left variable for
> > hierarchical tree, but it seems to me that it is possible to build a
> > loop in my controller without modifying my model.
>
> > Hope I do not disturb this groupes with this kind of question.
>
>


[web2py] Re: Forms and their customisation

2010-11-29 Thread mr.freeze
You can do:
form = crud.create(db.table)
textarea = form.element('textarea')
textarea['_rows'] = 50
textarea['_cols'] = 50

form.element will grab the first matching element. If you want to be
more specific you can do:
form.element('textarea',_id='table_field')

On Nov 29, 4:11 am, Emceha  wrote:
> Here is my controller code:
>
> def dodaj_artykul():
>     form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
>     return dict(form=form)
>
> I see that textarea always has cols=40 and rows=10 - I wanted to
> change that value but I haven't found any straight forward example to
> do it using CRUD only?
>
> Should I use SQLFORM?
>
> Thanks


[web2py] Re: Forms and their customisation

2010-11-29 Thread mr.freeze
You can also use a widget:

def textarea_widget(f,v):
inp = SQLFORM.widgets.text.widget(f,v)
inp['_cols'] = 50
inp['_rows'] = 50
return inp

db.table.field.widget = textarea_widget


On Nov 29, 5:39 am, "mr.freeze"  wrote:
> You can do:
> form = crud.create(db.table)
> textarea = form.element('textarea')
> textarea['_rows'] = 50
> textarea['_cols'] = 50
>
> form.element will grab the first matching element. If you want to be
> more specific you can do:
> form.element('textarea',_id='table_field')
>
> On Nov 29, 4:11 am, Emceha  wrote:
>
> > Here is my controller code:
>
> > def dodaj_artykul():
> >     form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> >     return dict(form=form)
>
> > I see that textarea always has cols=40 and rows=10 - I wanted to
> > change that value but I haven't found any straight forward example to
> > do it using CRUD only?
>
> > Should I use SQLFORM?
>
> > Thanks
>
>


[web2py] Re: Forms and their customisation

2010-11-29 Thread Emceha
Thanks Daniel for hint.

Unfortunately it looks like db object doesn't have textareafield
attribute:

google_appengine/web2py/gluon/sql.py", line 1703, in __getattr__
return dict.__getitem__(self,key)
KeyError: 'textareafield'

That's what I'm getting now :(

On Nov 29, 11:43 am, Daniel Gonzalez  wrote:
> I dont know if this could work for you:
>
> def dodaj_artykul():
>    db.artykuly.textareafield.represent = lambda k: TEXTAREA(value=k,
> _cols=100, _rows=100)
>    form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
>    return dict(form=form)
>
> I don't know how this could affect the functionlity of the form, because the 
> name of the textarea can change. You can try with passing another attribute 
> to the TEXTAREA helper: (_name="some_name")
>
> But I don't know if web2py will search later for that name to process the 
> form, you can search in the source code of the processed form to see what 
> name gives web2py to the field, and use it.
>
> I hope that this is what are you looking for.
>
> El lun, 29-11-2010 a las 02:27 -0800, Emceha escribió:
>
>
>
>
>
>
>
> > Thanks Daniel for prompt reply,
>
> > I've read chapter 7 already, also did some google search - but I was
> > wondering if there is easier way to do it - (with less code and maybe
> > just passing some parameters on crud.create as it's not really
> > customization I want to do - I would call it more like forms settings)
>
> > Marcin
>
> > On Nov 29, 11:17 am, Daniel Gonzalez  wrote:
> > > Hi,
>
> > > Checkout the chapter 7 of the book, specially this 
> > > part:http://web2py.com/book/default/chapter/07#Custom-forms
>
> > > Regards
> > > Daniel
>
> > > El lun, 29-11-2010 a las 02:11 -0800, Emceha escribió:
>
> > > > Here is my controller code:
>
> > > > def dodaj_artykul():
> > > >     form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> > > >     return dict(form=form)
>
> > > > I see that textarea always has cols=40 and rows=10 - I wanted to
> > > > change that value but I haven't found any straight forward example to
> > > > do it using CRUD only?
>
> > > > Should I use SQLFORM?
>
> > > > Thanks


Re: [web2py] Re: Forms and their customisation

2010-11-29 Thread Daniel Gonzalez
Hi,
when i said:

db.artykuly.textareafield.represent

I want to say that "textareafield" was your field in the definition of
your db.

Like:

db.define_table('artykuly',
Field('yourtextareafield', 'text')

I said that because i didn't know how your field is named :)

Anyway, mr.freeze has sent a better solution than mine :)

Regards
Daniel

El lun, 29-11-2010 a las 04:02 -0800, Emceha escribió:
> Thanks Daniel for hint.
> 
> Unfortunately it looks like db object doesn't have textareafield
> attribute:
> 
> google_appengine/web2py/gluon/sql.py", line 1703, in __getattr__
> return dict.__getitem__(self,key)
> KeyError: 'textareafield'
> 
> That's what I'm getting now :(
> 
> On Nov 29, 11:43 am, Daniel Gonzalez  wrote:
> > I dont know if this could work for you:
> >
> > def dodaj_artykul():
> >db.artykuly.textareafield.represent = lambda k: TEXTAREA(value=k,
> > _cols=100, _rows=100)
> >form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> >return dict(form=form)
> >
> > I don't know how this could affect the functionlity of the form, because 
> > the name of the textarea can change. You can try with passing another 
> > attribute to the TEXTAREA helper: (_name="some_name")
> >
> > But I don't know if web2py will search later for that name to process the 
> > form, you can search in the source code of the processed form to see what 
> > name gives web2py to the field, and use it.
> >
> > I hope that this is what are you looking for.
> >
> > El lun, 29-11-2010 a las 02:27 -0800, Emceha escribió:
> >
> >
> >
> >
> >
> >
> >
> > > Thanks Daniel for prompt reply,
> >
> > > I've read chapter 7 already, also did some google search - but I was
> > > wondering if there is easier way to do it - (with less code and maybe
> > > just passing some parameters on crud.create as it's not really
> > > customization I want to do - I would call it more like forms settings)
> >
> > > Marcin
> >
> > > On Nov 29, 11:17 am, Daniel Gonzalez  wrote:
> > > > Hi,
> >
> > > > Checkout the chapter 7 of the book, specially this 
> > > > part:http://web2py.com/book/default/chapter/07#Custom-forms
> >
> > > > Regards
> > > > Daniel
> >
> > > > El lun, 29-11-2010 a las 02:11 -0800, Emceha escribió:
> >
> > > > > Here is my controller code:
> >
> > > > > def dodaj_artykul():
> > > > > form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> > > > > return dict(form=form)
> >
> > > > > I see that textarea always has cols=40 and rows=10 - I wanted to
> > > > > change that value but I haven't found any straight forward example to
> > > > > do it using CRUD only?
> >
> > > > > Should I use SQLFORM?
> >
> > > > > Thanks




[web2py] Re: Forms and their customisation

2010-11-29 Thread Emceha
Thanks :) both work great :)

Marcin

On Nov 29, 12:44 pm, "mr.freeze"  wrote:
> You can also use a widget:
>
> def textarea_widget(f,v):
>     inp = SQLFORM.widgets.text.widget(f,v)
>     inp['_cols'] = 50
>     inp['_rows'] = 50
>     return inp
>
> db.table.field.widget = textarea_widget
>
> On Nov 29, 5:39 am, "mr.freeze"  wrote:
>
>
>
>
>
>
>
> > You can do:
> > form = crud.create(db.table)
> > textarea = form.element('textarea')
> > textarea['_rows'] = 50
> > textarea['_cols'] = 50
>
> > form.element will grab the first matching element. If you want to be
> > more specific you can do:
> > form.element('textarea',_id='table_field')
>
> > On Nov 29, 4:11 am, Emceha  wrote:
>
> > > Here is my controller code:
>
> > > def dodaj_artykul():
> > >     form=crud.create(db.artykuly,next='pokaz_artykul/[id]')
> > >     return dict(form=form)
>
> > > I see that textarea always has cols=40 and rows=10 - I wanted to
> > > change that value but I haven't found any straight forward example to
> > > do it using CRUD only?
>
> > > Should I use SQLFORM?
>
> > > Thanks


[web2py] Problem with linking 2 pages

2010-11-29 Thread Eleni
I started learning how to use web2py a few days ago and I don't
understand how we can link 2 pages with each other.
I want to link the index page with 3 other sub-pages. I tried to do as
the example (default/first and default second) but I failed because I
dont want to create 2 other pages with a link but to connect the index
itself .
To make it more clear: we have the index page which is like this:
HELLO
 
* 1
 
* 2
 
* 3

and when we push a number to go to another page.

Thanx a lot


[web2py] Re: XMLRPC

2010-11-29 Thread mdipierro
yes

@service.xmlrpc
@service.jsonrpc
def f(a,b): return a+b

On Nov 29, 2:19 am, Branko Vukelic  wrote:
> On Mon, Nov 29, 2010 at 8:52 AM, Branko Vukelic  wrote:
> > Thanks. Thats this mean one can run multiple services using the same
> > controller method?
>
> I guess not.
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


[web2py] Re: Using Jython with web2py

2010-11-29 Thread mdipierro
Why all your messages are always posted 2 or 3 times? We should try
fix that.

On Nov 29, 2:58 am, pierreth  wrote:
> On Nov 29, 1:39 am, mdipierro  wrote:
>
> > please let us know if things work or do not work. We have not tested
> > web2py with jython much,
>
> > Massimo
>
> Well, I won't dig that much in Jython with web2py for the moment. In a
> longer term interest, I would like to be able to use web2py in a Java
> infrastructure with Hibernate. I think it might be a really nice tool
> for prototyping in the enterprise world.
>
> Also I would like to use web2py with sqlalchemy with Python Spring. I
> see the mix of the three as a potential solution for the enterprise
> world too.
>
> In fact, I don't understand that you labeled web2py as an "Enterprise
> Web Framework". Without wanting to offend you, I see web2py as a
> "pragmatic, agile and extensible web framework for fast development".
> I think web2py as a too tight coupling for enterprise development. DAL
> in not a real ORM and it does not make it easy to apply domain driven
> design. Add the fact that the web2py book is mixing presentation with
> the control, I think web2py is favoring pragmatism over abstraction.
> It is not bad by itself but it conflicts with my vision of the
> enterprise way.
>
> I would appreciate your comments.
>
> Pierre


[web2py] Re: Web2py book - virtual fields section improvements

2010-11-29 Thread mdipierro
Honestly I do not think there is any reason to use "lazy" virtual
fields.

If you have virtual fields, they are always part of the select. What
is the problem? you want to filter them out in tables? Than you should
use the SQLTABLE(...,fields=[...]) attribute.

Massimo

On Nov 24, 11:49 pm, Adi  wrote:
> Hi all,
>
> I spent hours yesterday trying to implement virtual fields correctly
> following the book, and based on that I found some behaviour which
> could be better explained.
>
> Reference:http://web2py.com/book/default/chapter/06#Virtual-Fields
> web2py version: 1.88.2
>
> 1. Selecting a virtual field like a normal field in select() part of
> the query will throw a KeyError. However, the virtual field is still
> getting selected.
>
> 2. This part:
>
> class MyVirtualFields(object):
> ...
> db.mytable.virtualfields.append(MyVirtualFields())
>
> should come before the db.select for the virtual fields to be
> selected. The model is a good place for this part of the code. This is
> in slight contrast to the second code example where
> rows.setvirtualfields(...) is called after the rows are selected. The
> difference is slightly confusing.
>
> 3. Using the lazy loading techniques makes it impossible to select the
> virtual fields directly in a query. You will need to iterate through
> the selected rows and explicitly extract the
> row.mytable.myvirtualfield() as shown in example. The need to loop
> through the rows again (against using the rows directly in say, an
> SQLTable) may not really be desirable in a web2py app situation, and
> should not be considered the general use case.
>
> Please correct me if anything here is wrong. The point is that I spent
> a lot of time and trial-error methods to figure this out, which we can
> avoid for other people if we explain this part better in the book.


[web2py] Re: Autoroutes and.static files

2010-11-29 Thread mdipierro
http://.../static/filename?
does it not work?

On Nov 29, 5:25 am, rochacbruno  wrote:
> HI, I am trying to use autoroutes for the first time, what I want is my site 
> running in127.0.0.1:8080/index instead of127.0.0.1:8080/app/default/index
>
> I tried the autoroutes and routes.conf explained in another thread here but i 
> didn't figure out how to make the access to static files.
>
> I am using web2py 1.89.5 all functions as /index and /user  are working well,
>
>  But my static files are unreachable.
>
> 127.0.0.1:8080/index works ok, but show no images that I included with  src=URL('static','image.png')>
>
> 127.0.0.1:8080/static/image.png does not works too, and I cannot access in 
> old way /app/static/image.png
>
> Something is missing in routes_out?
>
> My routes.conf is
>
> START CODE 
> 127.0.0.1 /blouweb/default
> ---END CODE 
>
> My routes.py is
>
> ---START CODE---
>
> try: config=open('routes.conf','r').read()
> except: config=''
>
> def auto_in(apps):
>     routes=[
>         ('/robots.txt','/blouweb/static/robots.txt'),
>         ('/favicon.ico','/blouweb/static/favicon.ico'),
>         ('/admin$anything','/admin$anything'),
>         ]
>     for a,b in [x.strip().split() for x in apps.split('\n') if x.strip() and 
> not x.strip().startswith('#')]:
>         if not b.startswith('/'): b='/'+b
>         if b.endswith('/'): b=b[:-1]
>         app = b.split('/')[1]
>         routes+=[
>             ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
>             ('.*:https?://(.*\.)?%s:$method /static/$anything' % 
> a,'%s/static/$anything' % app),
>             ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % 
> a,'%s/appadmin/$anything' % app),
>             ('.*:https?://(.*\.)?%s:$method /$anything' % a,'%s/$anything' % 
> b),
>             ]
>     return routes
>
> def auto_out(apps):
>     routes=[]
>     for a,b in [x.strip().split() for x in apps.split('\n') if x.strip() and 
> not x.strip().startswith('#')]:
>         if not b.startswith('/'): b='/'+b
>         if b.endswith('/'): b=b[:-1]
>         app = b.split('/')[1]
>         routes+=[
>             ('%s/static/$anything' % app,'/static/$anything'),
>             ('%s/appadmin/$anything' % app, '/appadmin/$anything'),
>             ('%s/$anything' % b, '/$anything'),
>             ]
>     return routes
>
> routes_in=auto_in(config)
> routes_out=auto_out(config)
> ---END CODE ---
>
> How to access static files?
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio
>
> Enviado via iPhone


Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Bruno Rocha
Not working here,

I have an image called image.png in /static

without autoroutes I can access with
http://127.0.0.1:8080/blouweb/static/image.png

with autotoutes I can't access with http://127.0.0.1:8080/static/image.png

2010/11/29 mdipierro 

> http://.../static/filename?
> does it not work?
>
> On Nov 29, 5:25 am, rochacbruno  wrote:
> > HI, I am trying to use autoroutes for the first time, what I want is my
> site running in127.0.0.1:8080/index instead
> of127.0.0.1:8080/app/default/index
> >
> > I tried the autoroutes and routes.conf explained in another thread here
> but i didn't figure out how to make the access to static files.
> >
> > I am using web2py 1.89.5 all functions as /index and /user  are working
> well,
> >
> >  But my static files are unreachable.
> >
> > 127.0.0.1:8080/index works ok, but show no images that I included with
> 
> >
> > 127.0.0.1:8080/static/image.png does not works too, and I cannot access
> in old way /app/static/image.png
> >
> > Something is missing in routes_out?
> >
> > My routes.conf is
> >
> > START CODE 
> > 127.0.0.1 /blouweb/default
> > ---END CODE 
> >
> > My routes.py is
> >
> > ---START CODE---
> >
> > try: config=open('routes.conf','r').read()
> > except: config=''
> >
> > def auto_in(apps):
> > routes=[
> > ('/robots.txt','/blouweb/static/robots.txt'),
> > ('/favicon.ico','/blouweb/static/favicon.ico'),
> > ('/admin$anything','/admin$anything'),
> > ]
> > for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
> and not x.strip().startswith('#')]:
> > if not b.startswith('/'): b='/'+b
> > if b.endswith('/'): b=b[:-1]
> > app = b.split('/')[1]
> > routes+=[
> > ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
> > ('.*:https?://(.*\.)?%s:$method /static/$anything' %
> a,'%s/static/$anything' % app),
> > ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
> a,'%s/appadmin/$anything' % app),
> > ('.*:https?://(.*\.)?%s:$method /$anything' %
> a,'%s/$anything' % b),
> > ]
> > return routes
> >
> > def auto_out(apps):
> > routes=[]
> > for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
> and not x.strip().startswith('#')]:
> > if not b.startswith('/'): b='/'+b
> > if b.endswith('/'): b=b[:-1]
> > app = b.split('/')[1]
> > routes+=[
> > ('%s/static/$anything' % app,'/static/$anything'),
> > ('%s/appadmin/$anything' % app, '/appadmin/$anything'),
> > ('%s/$anything' % b, '/$anything'),
> > ]
> > return routes
> >
> > routes_in=auto_in(config)
> > routes_out=auto_out(config)
> > ---END CODE ---
> >
> > How to access static files?
> >
> > --
> >
> > Bruno Rochahttp://about.me/rochacbruno/bio
> >
> > Enviado via iPhone




-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: Problem with linking 2 pages

2010-11-29 Thread mdipierro
say you have

# in controllers/default.py
def page1(): return dict()
def page2(): return dict()

# in views/default/page1.html

  
  Any html you like here
  link to page2
  




On Nov 29, 4:52 am, Eleni  wrote:
> I started learning how to use web2py a few days ago and I don't
> understand how we can link 2 pages with each other.
> I want to link the index page with 3 other sub-pages. I tried to do as
> the example (default/first and default second) but I failed because I
> dont want to create 2 other pages with a link but to connect the index
> itself .
> To make it more clear: we have the index page which is like this:
> HELLO
>
> * 1
>
> * 2
>
> * 3
>
> and when we push a number to go to another page.
>
> Thanx a lot


[web2py] Re: Autoroutes and.static files

2010-11-29 Thread mdipierro
I am going to need some help with debugging. In main.py, after
rewrite.select(environ)

can you log the values of
1) rewrite.thread.routes.routes_in
2) rewrite.thread.routes.routes_out
3) environ['PATH_INFO']

when you call /static/image.png?

massimo

On Nov 29, 8:19 am, Bruno Rocha  wrote:
> Not working here,
>
> I have an image called image.png in /static
>
> without autoroutes I can access 
> withhttp://127.0.0.1:8080/blouweb/static/image.png
>
> with autotoutes I can't access withhttp://127.0.0.1:8080/static/image.png
>
> 2010/11/29 mdipierro 
>
>
>
> >http://.../static/filename?
> > does it not work?
>
> > On Nov 29, 5:25 am, rochacbruno  wrote:
> > > HI, I am trying to use autoroutes for the first time, what I want is my
> > site running in127.0.0.1:8080/index instead
> > of127.0.0.1:8080/app/default/index
>
> > > I tried the autoroutes and routes.conf explained in another thread here
> > but i didn't figure out how to make the access to static files.
>
> > > I am using web2py 1.89.5 all functions as /index and /user  are working
> > well,
>
> > >  But my static files are unreachable.
>
> > > 127.0.0.1:8080/index works ok, but show no images that I included with
> > 
>
> > > 127.0.0.1:8080/static/image.png does not works too, and I cannot access
> > in old way /app/static/image.png
>
> > > Something is missing in routes_out?
>
> > > My routes.conf is
>
> > > START CODE 
> > > 127.0.0.1 /blouweb/default
> > > ---END CODE 
>
> > > My routes.py is
>
> > > ---START CODE---
>
> > > try: config=open('routes.conf','r').read()
> > > except: config=''
>
> > > def auto_in(apps):
> > >     routes=[
> > >         ('/robots.txt','/blouweb/static/robots.txt'),
> > >         ('/favicon.ico','/blouweb/static/favicon.ico'),
> > >         ('/admin$anything','/admin$anything'),
> > >         ]
> > >     for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
> > and not x.strip().startswith('#')]:
> > >         if not b.startswith('/'): b='/'+b
> > >         if b.endswith('/'): b=b[:-1]
> > >         app = b.split('/')[1]
> > >         routes+=[
> > >             ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
> > >             ('.*:https?://(.*\.)?%s:$method /static/$anything' %
> > a,'%s/static/$anything' % app),
> > >             ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
> > a,'%s/appadmin/$anything' % app),
> > >             ('.*:https?://(.*\.)?%s:$method /$anything' %
> > a,'%s/$anything' % b),
> > >             ]
> > >     return routes
>
> > > def auto_out(apps):
> > >     routes=[]
> > >     for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
> > and not x.strip().startswith('#')]:
> > >         if not b.startswith('/'): b='/'+b
> > >         if b.endswith('/'): b=b[:-1]
> > >         app = b.split('/')[1]
> > >         routes+=[
> > >             ('%s/static/$anything' % app,'/static/$anything'),
> > >             ('%s/appadmin/$anything' % app, '/appadmin/$anything'),
> > >             ('%s/$anything' % b, '/$anything'),
> > >             ]
> > >     return routes
>
> > > routes_in=auto_in(config)
> > > routes_out=auto_out(config)
> > > ---END CODE ---
>
> > > How to access static files?
>
> > > --
>
> > > Bruno Rochahttp://about.me/rochacbruno/bio
>
> > > Enviado via iPhone
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Using swedish special characters åäö

2010-11-29 Thread Mirek Zvolský
> Swedish special characters...
> But when sending them to a CSV file and opening it in Excel are not
> shown correctly.

Here my code (functions in controller). I'm not sure if this is
correct solution, but it works for me. I think response header
'Content-Type' with 'utf-8' is important.
My code was tested for czech language and czech localized Excel,
however I hope it will work for swedish too, because swedish is some
kind of czech language?

Note, that there is bug in Opera browser at this time. Opera download/
saves the file correctly to disk, however with Open button the oldest
from saved csv files go to open. Regardless, if you use same name, or
if you change it (as in following code, where I add current time to
the filename). So you have to delete older file earlier, or just Save
it and open it in Excel from the disk, not directly from browser.
Other browser behaves correctly.

def excel():
import StringIO
sIO = StringIO.StringIO()
rsTable = db().select(db.tablename.ALL)
rsTable.export_to_csv_file(sIO, null='', delimiter='|')
__responseHeaders('exportedtable' +
datetime.datetime.now().strftime('_%Y%m%d_%H%M%S') + '.csv')
cFileContent = sIO.getvalue()
sIO.close()
return cFileContent

def __responseHeaders(fName=None):
response.headers['Content-Type'] = 'text/csv; charset=utf-8'
# duplicita s gluon\main.py, ale Expires se tam dělá pomocí time
objektu
response.headers['Cache-Control'] = 'no-store, no-cache, must-
revalidate, post-check=0, pre-check=0'
#response.headers['Cache-Control'] = 'no-cache, private, no-store,
must-revalidate, max-stale=0, post-check=0, pre-check=0'
response.headers['Expires'] =
datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')  #
Tue, 02 Nov 2010 08:15:33 GMT
   # nebo lze .Expires = -1
response.headers['Pragma'] = 'no-cache'
if fName:
response.headers['Content-disposition'] = 'attachment;
filename="' + fName + '"'


[web2py] Double invert

2010-11-29 Thread iiijjjiii
Does it make sense to modify the gluon.sql Expression __invert__
method so a double invert is possible.

Currently this produces an error:

print db().select(db.person.name, orderby=~~db.person.name)

ProgrammingError: (1064, "You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'DESC' at line 1")

The cause of the error is obvious when you look at the SQL query.

SELECT person.name FROM person ORDER BY person.name DESC DESC

The second invert adds an additional 'DESC' which makes the query
invalid.

I tried this and it worked.

def __invert__(self):
if str(self)[-5:] == ' DESC':
return Expression(str(self)[:-5], None, None)
else:
return Expression(str(self) + ' DESC', None, None)

To explain why a double invert is useful, I have a function that
returns the rows from a query and the order of the rows is determined
by parameters.

def people(order_expr, reverse=False)
if False:
orderby = order_expr
else:
orderby = ~order_expr
return db().select(db.person.ALL, orderby=order_by)

It is used in a report. Each field in the report has a default order
expression. The default order direction for most fields is ascending,
but for some fields, eg updated_on, the default order is more
intuitive as descending. The report will allow the user to switch the
direction with a click. The code simply toggles the reverse parameter.
I'd like the function to handle any of these combinations.

people(db.person.name)
people(db.person.name, reverse=True)
people(~db.person.updated_on)
people(~db.person.updated_on, reverse=True)

I am not familiar with the web2py code enough to be aware of the
effects of changing the __invert__ so my suggestion might have some
unwanted results. Hopefully others can provide input.


[web2py] Re: Double invert

2010-11-29 Thread mdipierro
This should be automatic behavior in the new dal (dal.py).
I do not think it is work spending time changing this in the current
dal (sql.py).

Massimo

On Nov 29, 9:09 am, iiijjjiii  wrote:
> Does it make sense to modify the gluon.sql Expression __invert__
> method so a double invert is possible.
>
> Currently this produces an error:
>
>     print db().select(db.person.name, orderby=~~db.person.name)
>
>     ProgrammingError: (1064, "You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'DESC' at line 1")
>
> The cause of the error is obvious when you look at the SQL query.
>
>     SELECT person.name FROM person ORDER BY person.name DESC DESC
>
> The second invert adds an additional 'DESC' which makes the query
> invalid.
>
> I tried this and it worked.
>
>     def __invert__(self):
>         if str(self)[-5:] == ' DESC':
>             return Expression(str(self)[:-5], None, None)
>         else:
>             return Expression(str(self) + ' DESC', None, None)
>
> To explain why a double invert is useful, I have a function that
> returns the rows from a query and the order of the rows is determined
> by parameters.
>
>     def people(order_expr, reverse=False)
>         if False:
>             orderby = order_expr
>         else:
>             orderby = ~order_expr
>         return db().select(db.person.ALL, orderby=order_by)
>
> It is used in a report. Each field in the report has a default order
> expression. The default order direction for most fields is ascending,
> but for some fields, eg updated_on, the default order is more
> intuitive as descending. The report will allow the user to switch the
> direction with a click. The code simply toggles the reverse parameter.
> I'd like the function to handle any of these combinations.
>
>     people(db.person.name)
>     people(db.person.name, reverse=True)
>     people(~db.person.updated_on)
>     people(~db.person.updated_on, reverse=True)
>
> I am not familiar with the web2py code enough to be aware of the
> effects of changing the __invert__ so my suggestion might have some
> unwanted results. Hopefully others can provide input.


[web2py] JSON into a html view

2010-11-29 Thread Lorin Rivers
How do I insert the results of a function into an html view as JSON?

Specifically I need a javascript variable in the view to include my JSON.
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] Orbited with web2py

2010-11-29 Thread salbefe
Hello,

I need to push some content in my website in 'real time'. I'm asking
if someone had tried orbited (http://orbited.org/). After reading this
post: Integrating Orbited with Web App Frameworks (http://orbited.org/
blog/2008/09/integrating-orbited-with-web-app-frameworks/) it seems
that it should not be any problem of integration with web2py (using
STOMP and RabbitMQ).

Anyway, I would like to known if someone had used it and if it could
post an example.


Thank you in advance


[web2py] onvalidation valid for every form button?

2010-11-29 Thread António Ramos
Hello
i want to use a form and want to use the onvalidation to call a function.
My question is ,
Is the submit button the only way to trigger the onvalidation event ?
I ask this because i want 2 buttons, the first submits with var=1 and the
second submit with var=2

How can i use this 2 buttons instead of submit and still trigger
onvalidation?


Best regards
António


[web2py] Re: onvalidation valid for every form button?

2010-11-29 Thread DenesL

Since you are submitting to the same controller I don't see a problem,
onvalidation will run (or not if there are form.errors) in both cases.


On Nov 29, 11:33 am, António Ramos  wrote:
> Hello
> i want to use a form and want to use the onvalidation to call a function.
> My question is ,
> Is the submit button the only way to trigger the onvalidation event ?
> I ask this because i want 2 buttons, the first submits with var=1 and the
> second submit with var=2
>
> How can i use this 2 buttons instead of submit and still trigger
> onvalidation?
>
> Best regards
> António


[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
Hello,

here is what I did:
db.define_table('article',
Field('f_parent','reference article'),
Field('title'))

##
def index():
rows = dict((r.id,r) for r in db(db.article).select())
for id,row in rows.items(): row.children=[]
for id,row in rows.items():
if row.f_parent==1: root=row
else: rows[row.f_parent].append(row)
def tree(row):
return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
row.children]))
return tree(root)
##

Here are the articles
article.id  article.f_parentarticle.title
1   1   Racine
2   1   Branche1
3   1   Branche2


It gives me the following error :

Traceback (most recent call last):
  File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
\restricted.py", line 188, in restricted
exec ccode in environment
  File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
test/controllers/default.py", line 66, in 
  File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
\globals.py", line 96, in 
self._caller = lambda f: f()
  File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
test/controllers/default.py", line 60, in index
else: rows[row.f_parent].append(row)
  File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
\sql.py", line 742, in __getattr__
return dict.__getitem__(self,key)
KeyError: 'append'

T tried to modify :
else: rows[row.f_parent].append(row)
with
else: rows[row.children].append(row)
as it seems we're trying to build a list of children.
Yet i get another error : TypeError: list objects are unhashable

Can anybody help me ?


On 29 nov, 12:27, JmiXIII  wrote:
> That's it I'll try it
> thanks a lot!
>
> On 29 nov, 00:48, mdipierro  wrote:
>
> > I assume you are trying to build a hierarchial tree of articles and
> > you want them all from the parent.
>
> > I would do this something like this:
>
> > db.define_table('article',Field('f_parent','reference
> > article'),Field('title'))
>
> > def index():
> >     rows = dict((r.id,r) for r in db(db.article).select())
> >     for id,row in rows.items(): row.children=[]
> >     for id,row in rows.items():
> >         if row.f_parent==0: root=row
> >         else: rows[row.f_parent].append(row)
> >     def tree(row):
> >         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> > row.children])))
> >     return tree(root)
>
> > On Nov 28, 5:00 pm, JmiXIII  wrote:
>
> > > Hello,
>
> > > I'm facing I guess a well known programming problem. It is not really
> > > related to web2by, but since I'm using web2py I hope somebody here can
> > > help.
>
> > > Here is my controller :
>
> > > def global_view():
> > >     parents = db(~(db.t_article.id==db.t_list.f_article)).select()
> > >     tree={}
> > >     for parent in parents:
> > >         tree[parent.t_article.id]={}
> > >         sublevel=db(parent.t_article.id==db.t_list.f_parent).select()
> > >         for son in sublevel:
> > >             tree[parent.t_article.id][son.f_article]=son.f_article
> > >             tree[parent.t_article.id][son.f_article]={}
> > >             sublevel2=db(son.f_article==db.t_list.f_parent).select()
> > >             for son2 in sublevel2:
> > >                 tree[parent.t_article.id][son.f_article]
> > > [son2.f_article]=son2.f_article
> > >                 
> > > tree[parent.t_article.id][son.f_article][son2.f_article]={}
> > >     return dict(tree=tree)
>
> > > So in fact I'd like to go on for son3, son4, based on the same model
> > > as sublevel2... until sublevelx=None.
> > > I guess I should use some kind of recursive or loop function.
> > > I've read different things using right and left variable for
> > > hierarchical tree, but it seems to me that it is possible to build a
> > > loop in my controller without modifying my model.
>
> > > Hope I do not disturb this groupes with this kind of question.
>
>


[web2py] Re: Using Jython with web2py

2010-11-29 Thread pierreth
On Nov 29, 8:53 am, mdipierro  wrote:
> Why all your messages are always posted 2 or 3 times? We should try
> fix that.

Sorry for this. I click the refresh button after a post for see what
are the replies. This post back the same message again (I thought the
interface would be smart enough to reject the double post but it is
not the case). I will avoid to do it again. It seems the Google
interface does not do a redirect after the post to avoid this
situation. The real solution is for Google to add a redirect after a
post.


Re: [web2py] Re: Using swedish special characters å äö

2010-11-29 Thread Kenneth Lundström

Hello Mirek,

thank you for your example. In my case it didn´t help. If I look at the 
file in Notepad åäö are shown correctly by when opening the file by 
dubble clicking it opens Excel but åäö aren´t shown correctly, for some 
reason Excel uses "wrong" charset, if I import the file to Excel with 
wizard I can select correct charset adn everything is shown correctly.


But customer want´s to make as easy as possible to open the file. Maybe 
I have to scan all texts and replace åäö with another special character 
that opens correctly in Excel.


I wrote åäö in Excel and saved it as an CSV, when looking at the file in 
notepad I can find out what character to replace with.



Kenneth

def __responseHeaders(fName=None):
 response.headers['Content-Type'] = 'text/csv; charset=utf-8'
 # duplicita s gluon\main.py, ale Expires se tam dělá pomocí time
objektu
 response.headers['Cache-Control'] = 'no-store, no-cache, must-
revalidate, post-check=0, pre-check=0'
 #response.headers['Cache-Control'] = 'no-cache, private, no-store,
must-revalidate, max-stale=0, post-check=0, pre-check=0'
 response.headers['Expires'] =
datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')  #
Tue, 02 Nov 2010 08:15:33 GMT
# nebo lze .Expires = -1
 response.headers['Pragma'] = 'no-cache'
 if fName:
 response.headers['Content-disposition'] = 'attachment;
filename="' + fName + '"'




Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Jonathan Lundell
On Nov 29, 2010, at 6:30 AM, mdipierro wrote:
> 
> I am going to need some help with debugging. In main.py, after
> rewrite.select(environ)
> 
> can you log the values of
> 1) rewrite.thread.routes.routes_in
> 2) rewrite.thread.routes.routes_out
> 3) environ['PATH_INFO']
> 
> when you call /static/image.png?

I think it ought to be possible to adapt the doctests from the stock routes.py 
to the autoroutes version; that'd make this kind of testing a little easier.

BTW, it seems to me that files like robots.txt and favicon.ico ought to be 
per-domain, and not global.

> 
> massimo
> 
> On Nov 29, 8:19 am, Bruno Rocha  wrote:
>> Not working here,
>> 
>> I have an image called image.png in /static
>> 
>> without autoroutes I can access 
>> withhttp://127.0.0.1:8080/blouweb/static/image.png
>> 
>> with autotoutes I can't access withhttp://127.0.0.1:8080/static/image.png
>> 
>> 2010/11/29 mdipierro 
>> 
>> 
>> 
>>> http://.../static/filename?
>>> does it not work?
>> 
>>> On Nov 29, 5:25 am, rochacbruno  wrote:
 HI, I am trying to use autoroutes for the first time, what I want is my
>>> site running in127.0.0.1:8080/index instead
>>> of127.0.0.1:8080/app/default/index
>> 
 I tried the autoroutes and routes.conf explained in another thread here
>>> but i didn't figure out how to make the access to static files.
>> 
 I am using web2py 1.89.5 all functions as /index and /user  are working
>>> well,
>> 
  But my static files are unreachable.
>> 
 127.0.0.1:8080/index works ok, but show no images that I included with
>>> 
>> 
 127.0.0.1:8080/static/image.png does not works too, and I cannot access
>>> in old way /app/static/image.png
>> 
 Something is missing in routes_out?
>> 
 My routes.conf is
>> 
 START CODE 
 127.0.0.1 /blouweb/default
 ---END CODE 
>> 
 My routes.py is
>> 
 ---START CODE---
>> 
 try: config=open('routes.conf','r').read()
 except: config=''
>> 
 def auto_in(apps):
 routes=[
 ('/robots.txt','/blouweb/static/robots.txt'),
 ('/favicon.ico','/blouweb/static/favicon.ico'),
 ('/admin$anything','/admin$anything'),
 ]
 for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
>>> and not x.strip().startswith('#')]:
 if not b.startswith('/'): b='/'+b
 if b.endswith('/'): b=b[:-1]
 app = b.split('/')[1]
 routes+=[
 ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
 ('.*:https?://(.*\.)?%s:$method /static/$anything' %
>>> a,'%s/static/$anything' % app),
 ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
>>> a,'%s/appadmin/$anything' % app),
 ('.*:https?://(.*\.)?%s:$method /$anything' %
>>> a,'%s/$anything' % b),
 ]
 return routes
>> 
 def auto_out(apps):
 routes=[]
 for a,b in [x.strip().split() for x in apps.split('\n') if x.strip()
>>> and not x.strip().startswith('#')]:
 if not b.startswith('/'): b='/'+b
 if b.endswith('/'): b=b[:-1]
 app = b.split('/')[1]
 routes+=[
 ('%s/static/$anything' % app,'/static/$anything'),
 ('%s/appadmin/$anything' % app, '/appadmin/$anything'),
 ('%s/$anything' % b, '/$anything'),
 ]
 return routes
>> 
 routes_in=auto_in(config)
 routes_out=auto_out(config)
 ---END CODE ---
>> 
 How to access static files?
>> 
 --
>> 
 Bruno Rochahttp://about.me/rochacbruno/bio
>> 
 Enviado via iPhone
>> 
>> --
>> 
>> Bruno Rochahttp://about.me/rochacbruno/bio




[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread mdipierro
my bad

def index():
rows = dict((r.id,r) for r in db(db.article).select())
for id,row in rows.items(): row.children=[]
for id,row in rows.items():
if row.f_parent==1: root=row
else: rows[row.f_parent].children.append(row)
def tree(row):
return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
row.children]))
return tree(root)

On Nov 29, 11:06 am, JmiXIII  wrote:
> Hello,
>
> here is what I did:
> db.define_table('article',
>     Field('f_parent','reference article'),
>     Field('title'))
>
> ##
> def index():
>     rows = dict((r.id,r) for r in db(db.article).select())
>     for id,row in rows.items(): row.children=[]
>     for id,row in rows.items():
>         if row.f_parent==1: root=row
>         else: rows[row.f_parent].append(row)
>     def tree(row):
>         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> row.children]))
>     return tree(root)
> ##
>
> Here are the articles
> article.id      article.f_parent        article.title
> 1       1       Racine
> 2       1       Branche1
> 3       1       Branche2
>
> It gives me the following error :
>
> Traceback (most recent call last):
>   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> \restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
> test/controllers/default.py", line 66, in 
>   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> \globals.py", line 96, in 
>     self._caller = lambda f: f()
>   File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
> test/controllers/default.py", line 60, in index
>     else: rows[row.f_parent].append(row)
>   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> \sql.py", line 742, in __getattr__
>     return dict.__getitem__(self,key)
> KeyError: 'append'
>
> T tried to modify :
>         else: rows[row.f_parent].append(row)
> with
>         else: rows[row.children].append(row)
> as it seems we're trying to build a list of children.
> Yet i get another error : TypeError: list objects are unhashable
>
> Can anybody help me ?
>
> On 29 nov, 12:27, JmiXIII  wrote:
>
> > That's it I'll try it
> > thanks a lot!
>
> > On 29 nov, 00:48, mdipierro  wrote:
>
> > > I assume you are trying to build a hierarchial tree of articles and
> > > you want them all from the parent.
>
> > > I would do this something like this:
>
> > > db.define_table('article',Field('f_parent','reference
> > > article'),Field('title'))
>
> > > def index():
> > >     rows = dict((r.id,r) for r in db(db.article).select())
> > >     for id,row in rows.items(): row.children=[]
> > >     for id,row in rows.items():
> > >         if row.f_parent==0: root=row
> > >         else: rows[row.f_parent].append(row)
> > >     def tree(row):
> > >         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> > > row.children])))
> > >     return tree(root)
>
> > > On Nov 28, 5:00 pm, JmiXIII  wrote:
>
> > > > Hello,
>
> > > > I'm facing I guess a well known programming problem. It is not really
> > > > related to web2by, but since I'm using web2py I hope somebody here can
> > > > help.
>
> > > > Here is my controller :
>
> > > > def global_view():
> > > >     parents = db(~(db.t_article.id==db.t_list.f_article)).select()
> > > >     tree={}
> > > >     for parent in parents:
> > > >         tree[parent.t_article.id]={}
> > > >         sublevel=db(parent.t_article.id==db.t_list.f_parent).select()
> > > >         for son in sublevel:
> > > >             tree[parent.t_article.id][son.f_article]=son.f_article
> > > >             tree[parent.t_article.id][son.f_article]={}
> > > >             sublevel2=db(son.f_article==db.t_list.f_parent).select()
> > > >             for son2 in sublevel2:
> > > >                 tree[parent.t_article.id][son.f_article]
> > > > [son2.f_article]=son2.f_article
> > > >                 
> > > > tree[parent.t_article.id][son.f_article][son2.f_article]={}
> > > >     return dict(tree=tree)
>
> > > > So in fact I'd like to go on for son3, son4, based on the same model
> > > > as sublevel2... until sublevelx=None.
> > > > I guess I should use some kind of recursive or loop function.
> > > > I've read different things using right and left variable for
> > > > hierarchical tree, but it seems to me that it is possible to build a
> > > > loop in my controller without modifying my model.
>
> > > > Hope I do not disturb this groupes with this kind of question.
>
>


[web2py] Re: Using Jython with web2py

2010-11-29 Thread mdipierro
For me Enterprise means:
- easy to use (low startup costs)
- always backward compatible (worth the investment)
- enterprise = business + non-profit; enterprise != large bloated
bussiness

I do not disagree with your definition: "pragmatic, agile and
extensible web framework for fast development".



On Nov 29, 2:58 am, pierreth  wrote:
> On Nov 29, 1:39 am, mdipierro  wrote:
>
> > please let us know if things work or do not work. We have not tested
> > web2py with jython much,
>
> > Massimo
>
> Well, I won't dig that much in Jython with web2py for the moment. In a
> longer term interest, I would like to be able to use web2py in a Java
> infrastructure with Hibernate. I think it might be a really nice tool
> for prototyping in the enterprise world.
>
> Also I would like to use web2py with sqlalchemy with Python Spring. I
> see the mix of the three as a potential solution for the enterprise
> world too.
>
> In fact, I don't understand that you labeled web2py as an "Enterprise
> Web Framework". Without wanting to offend you, I see web2py as a
> "pragmatic, agile and extensible web framework for fast development".
> I think web2py as a too tight coupling for enterprise development. DAL
> in not a real ORM and it does not make it easy to apply domain driven
> design. Add the fact that the web2py book is mixing presentation with
> the control, I think web2py is favoring pragmatism over abstraction.
> It is not bad by itself but it conflicts with my vision of the
> enterprise way.
>
> I would appreciate your comments.
>
> Pierre


[web2py] Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The project I'm working on has hired a consultant who is now recommending .Net 
in place of web2py or even rails.

What's the 'largest' scale web2py is known to perform well on?

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] Re: Scalability of web2py?

2010-11-29 Thread mdipierro
You achieve scalability by replicating the web server behind a load
balancer. This is documented in the book, chapter 11, using HAProxy.
All frameworks work the same way in this respect. web2py has no
intrinsic limitations. The bottle neck is the database connection. All
frameworks have the same problem. You can replicate the database too
and web2py supports multiple database clients with Round-Robin.

On a small VPS, web2py in average, should execute one page in 20ms.
Depending on how many requests/second you need you can determine how
many servers you need.

web2py apps run on Google App Engine and that means arbitrary
scalability as long as you can live with the constraints imposed by
the Google datastore (these limitations will go away as soon as Google
releases MySQL in the cloud, which they announced some time ago).

Please ask the consultant: which .NET feature makes it scale any
better than web2py or Rails? If he explains we can address it more
specifically.

Massimo

On Nov 29, 11:56 am, Lorin Rivers  wrote:
> The project I'm working on has hired a consultant who is now recommending 
> .Net in place of web2py or even rails.
>
> What's the 'largest' scale web2py is known to perform well on?
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


[web2py] Re: JSONRPC notes

2010-11-29 Thread ron_m
I would guess the id is so you can pair up the response if you had
more than one request outstanding in an AJAX situation?

On Nov 29, 12:39 am, Branko Vukelic  wrote:
> Some notes I'd like to share. Comments and advice most welcome!
>
> web2py supports JSONRPC 1.1 (and not 2.0 which is still a proposal).
> This means there is no support for keyword arguments at this moment.
> To work around this you can pass your methods a single argument which
> is a dict, and parse the dict yourself. For example:
>
>     # in your controller
>     def mymethod(params):
>         param1 = params.get('key1', defaultvalue) # defaultvalue is optional
>         param2 = params.get('key2')
>         ...
>         # do something with params and calculate result
>         return result
>
> In your javascript code, send JSONRPC request as:
>
>     {"version": "1.1", "method": "mymethod",
>     "params": [{"key1": "val1", "key2": 2, ... "keyN": "valN"}],
>     id="someid"}
>
> As you can see, the dict (object) is wrapped inside an array and array
> has a single member.
>
> Another note. You must include the id key. It can be anything, but
> it's important to check that the same id is returned from the server.
> I'm not sure if this prevents any security holes (I guess not), but at
> least it doesn't open any new ones if you check it. So the whole
> boilerplate for handling response would be:
>
>     if (response.id == idKey && response.error == null) {
>         callback(response);
>     }
>     else {
>         DEBUG('JSONRPC error');
>         errback(response);
>     }
>
> The ``idKey`` variable is some random key I generate before every
> JSONRPC call, and I check that the response contains the same key.
> ``response.error`` is a non-null value if there is an error, so it's
> also good to check that before firing the callback.
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
We're looking at utility scale deployments with thousands of nodes reporting 
data back to the server. That and the ability to compile .NET.

On Nov 29, 2010, at 12:05 , mdipierro wrote:

> You achieve scalability by replicating the web server behind a load
> balancer. This is documented in the book, chapter 11, using HAProxy.
> All frameworks work the same way in this respect. web2py has no
> intrinsic limitations. The bottle neck is the database connection. All
> frameworks have the same problem. You can replicate the database too
> and web2py supports multiple database clients with Round-Robin.
> 
> On a small VPS, web2py in average, should execute one page in 20ms.
> Depending on how many requests/second you need you can determine how
> many servers you need.
> 
> web2py apps run on Google App Engine and that means arbitrary
> scalability as long as you can live with the constraints imposed by
> the Google datastore (these limitations will go away as soon as Google
> releases MySQL in the cloud, which they announced some time ago).
> 
> Please ask the consultant: which .NET feature makes it scale any
> better than web2py or Rails? If he explains we can address it more
> specifically.
> 
> Massimo
> 
> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>> The project I'm working on has hired a consultant who is now recommending 
>> .Net in place of web2py or even rails.
>> 
>> What's the 'largest' scale web2py is known to perform well on?
>> 
>> --
>> Lorin Rivers
>> Mosasaur: Killer Technical Marketing 
>> 
>> 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] Re: Scalability of web2py?

2010-11-29 Thread Julio Schwarzbeck
And this without considering "vendor lock-in". web2py can run on a
variety of platforms such as windows, macs. Linux and others, same
goes for the selection of the back-end database. Much more flexibility
under web2py in my opinion and prototyping is much faster in python.

On Nov 29, 10:05 am, mdipierro  wrote:
> You achieve scalability by replicating the web server behind a load
> balancer. This is documented in the book, chapter 11, using HAProxy.
> All frameworks work the same way in this respect. web2py has no
> intrinsic limitations. The bottle neck is the database connection. All
> frameworks have the same problem. You can replicate the database too
> and web2py supports multiple database clients with Round-Robin.
>
> On a small VPS, web2py in average, should execute one page in 20ms.
> Depending on how many requests/second you need you can determine how
> many servers you need.
>
> web2py apps run on Google App Engine and that means arbitrary
> scalability as long as you can live with the constraints imposed by
> the Google datastore (these limitations will go away as soon as Google
> releases MySQL in the cloud, which they announced some time ago).
>
> Please ask the consultant: which .NET feature makes it scale any
> better than web2py or Rails? If he explains we can address it more
> specifically.
>
> Massimo
>
> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>
>
>
> > The project I'm working on has hired a consultant who is now recommending 
> > .Net in place of web2py or even rails.
>
> > What's the 'largest' scale web2py is known to perform well on?
>
> > --
> > Lorin Rivers
> > Mosasaur: Killer Technical Marketing 
> > 
> > 512/203.3198 (m)


Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Bruno Rocha
main.py
--start--
rewrite.select(environ)
print '_'*40,'routes_in','_'*40
print rewrite.thread.routes.routes_in
print '_'*40,'routes_out','_'*40
print rewrite.thread.routes.routes_out
print '_'*40,'PATH_INFO','_'*40
print environ['PATH_INFO']
---end---

executing web2py and accesing http://127.0.0.1:8000/static/img/logo.png that
returns
invalid request

rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.89.5 (2010-11-21 22:12:54)
Database drivers available: SQLite3
Starting hardcron...
please visit:
http://127.0.0.1:8000
use "kill -SIGTERM 15282" to shutdown the web2py server
 routes_in

[(<_sre.SRE_Pattern object at 0x1011ed770>, '/blouweb/static/robots.txt'),
(<_sre.SRE_Pattern object at 0x1011f5a60>, '/blouweb/static/favicon.ico'),
(<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
(<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
(<_sre.SRE_Pattern object at 0x101513080>, 'blouweb/static/\\g'),
(<_sre.SRE_Pattern object at 0x101514900>,
'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
0x1015125a0>, '/blouweb/default/\\g')]
 routes_out

[(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
(<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
(<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
 PATH_INFO

/static/img/logo.png




2010/11/29 mdipierro 

> I am going to need some help with debugging. In main.py, after
> rewrite.select(environ)
>
> can you log the values of
> 1) rewrite.thread.routes.routes_in
> 2) rewrite.thread.routes.routes_out
> 3) environ['PATH_INFO']
>
> when you call /static/image.png?
>
> massimo
>
> On Nov 29, 8:19 am, Bruno Rocha  wrote:
> > Not working here,
> >
> > I have an image called image.png in /static
> >
> > without autoroutes I can access withhttp://
> 127.0.0.1:8080/blouweb/static/image.png
> >
> > with autotoutes I can't access withhttp://
> 127.0.0.1:8080/static/image.png
> >
> > 2010/11/29 mdipierro 
> >
> >
> >
> > >http://.../static/filename?
> > > does it not work?
> >
> > > On Nov 29, 5:25 am, rochacbruno  wrote:
> > > > HI, I am trying to use autoroutes for the first time, what I want is
> my
> > > site running in127.0.0.1:8080/index instead
> > > of127.0.0.1:8080/app/default/index
> >
> > > > I tried the autoroutes and routes.conf explained in another thread
> here
> > > but i didn't figure out how to make the access to static files.
> >
> > > > I am using web2py 1.89.5 all functions as /index and /user  are
> working
> > > well,
> >
> > > >  But my static files are unreachable.
> >
> > > > 127.0.0.1:8080/index works ok, but show no images that I included
> with
> > > 
> >
> > > > 127.0.0.1:8080/static/image.png does not works too, and I cannot
> access
> > > in old way /app/static/image.png
> >
> > > > Something is missing in routes_out?
> >
> > > > My routes.conf is
> >
> > > > START CODE 
> > > > 127.0.0.1 /blouweb/default
> > > > ---END CODE 
> >
> > > > My routes.py is
> >
> > > > ---START CODE---
> >
> > > > try: config=open('routes.conf','r').read()
> > > > except: config=''
> >
> > > > def auto_in(apps):
> > > > routes=[
> > > > ('/robots.txt','/blouweb/static/robots.txt'),
> > > > ('/favicon.ico','/blouweb/static/favicon.ico'),
> > > > ('/admin$anything','/admin$anything'),
> > > > ]
> > > > for a,b in [x.strip().split() for x in apps.split('\n') if
> x.strip()
> > > and not x.strip().startswith('#')]:
> > > > if not b.startswith('/'): b='/'+b
> > > > if b.endswith('/'): b=b[:-1]
> > > > app = b.split('/')[1]
> > > > routes+=[
> > > > ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
> > > > ('.*:https?://(.*\.)?%s:$method /static/$anything' %
> > > a,'%s/static/$anything' % app),
> > > > ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
> > > a,'%s/appadmin/$anything' % app),
> > > > ('.*:https?://(.*\.)?%s:$method /$anything' %
> > > a,'%s/$anything' % b),
> > > > ]
> > > > return routes
> >
> > > > def auto_out(apps):
> > > > routes=[]
> > > > for a,b in [x.strip().split() for x in apps.split('\n') if
> x.strip()
> > > and not x.strip().startswith('#')]:
> > > > if not b.startswith('/'): b='/'+b
> > > > if b.endswith('/'): b=b[:-1]
> > > > app = b.split('/')[1]
> > > > routes+=[
> > > > ('%s/static/$anything' % app,'/static/$anything'),
> > > > ('%s/appadmin/$anything' % app, '/appadmin/$anything'),
> > > > ('%s/$anything' % b, '/$anything'),
> > > 

Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
Unfortunately, the killing argument is "we know .NET will scale to thousands of 
nodes, blah, blah, blah".

This from (a guy who's smart and I respect, honestly) who uses his brand-new 
top-of-the-line 17" MBP to run Windows VMs in Parallels.

On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:

> And this without considering "vendor lock-in". web2py can run on a
> variety of platforms such as windows, macs. Linux and others, same
> goes for the selection of the back-end database. Much more flexibility
> under web2py in my opinion and prototyping is much faster in python.
> 
> On Nov 29, 10:05 am, mdipierro  wrote:
>> You achieve scalability by replicating the web server behind a load
>> balancer. This is documented in the book, chapter 11, using HAProxy.
>> All frameworks work the same way in this respect. web2py has no
>> intrinsic limitations. The bottle neck is the database connection. All
>> frameworks have the same problem. You can replicate the database too
>> and web2py supports multiple database clients with Round-Robin.
>> 
>> On a small VPS, web2py in average, should execute one page in 20ms.
>> Depending on how many requests/second you need you can determine how
>> many servers you need.
>> 
>> web2py apps run on Google App Engine and that means arbitrary
>> scalability as long as you can live with the constraints imposed by
>> the Google datastore (these limitations will go away as soon as Google
>> releases MySQL in the cloud, which they announced some time ago).
>> 
>> Please ask the consultant: which .NET feature makes it scale any
>> better than web2py or Rails? If he explains we can address it more
>> specifically.
>> 
>> Massimo
>> 
>> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>> 
>> 
>> 
>>> The project I'm working on has hired a consultant who is now recommending 
>>> .Net in place of web2py or even rails.
>> 
>>> What's the 'largest' scale web2py is known to perform well on?
>> 
>>> --
>>> Lorin Rivers
>>> Mosasaur: Killer Technical Marketing 
>>> 
>>> 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] checkbox in crud.read

2010-11-29 Thread Richard Vézina
Hello,

I would like to know how to render a none active check box in crud.read
form.

Thanks


Richard


[web2py] Re: Scalability of web2py?

2010-11-29 Thread ron_m
Beware the consultant that only recommends what they know about. :-)

Sounds like early optimisation attempts by the consultant if you ask
me. You have to do a traffic analysis on the network - sounds like
these are scales at remote locations - how often do they report in,
how much information per transaction, how much database activity per
transaction? My belief is either the network or the database will be
the real limiting factor. Worrying about whether or not the code is
compiled at this point is blowing smoke IMHO with 2GHz+ 4 core Nehalem
Xeons running $300 or $400 at most. CPU hardware is ridiculously
cheap. On the busiest system I am looking after I have trouble pushing
one core to 20% and I am moving 8 frames/sec of 704x480 pixel JPEG
camera video from 24 cameras to disk, each camera generates about 1
GByte of data per hour to put it in perspective. This is all done in
Python layered over the C/C++ library gstreamer which is admittedly
nothing to do with web2py but worth mentioning because of the
languages used. The reason Python can be so fast is all the heavy
lifting is done in C with the excellent integration to C libraries
Python provides. Same thing goes for when you hit the database. I come
from a Java background prior to Python and know what a pain JNI can be
which is why Java types try to do it all in Java. With .Net you are in
a similar environment to Java and have to do all the programming
boilerplate other than what they can generate for you. Expect
somewhere around 10x lines of code comparing .Net or Java to Python.

A far more important consideration is what does the  programming team
know and is efficient working in. Having worked in both Java and
Python I can say with a certainty Python is like the walls have been
knocked down dealing with collections for example. Not meaning to
start any religious wars about languages but at age 59 I think I am
officially an old fart, I have been in the industry since 1977 and
have kept up to date with the technology else I would still be looking
for Fortran jobs. :-)

Ron

On Nov 29, 10:20 am, Julio Schwarzbeck  wrote:
> And this without considering "vendor lock-in". web2py can run on a
> variety of platforms such as windows, macs. Linux and others, same
> goes for the selection of the back-end database. Much more flexibility
> under web2py in my opinion and prototyping is much faster in python.
>
> On Nov 29, 10:05 am, mdipierro  wrote:
>
> > You achieve scalability by replicating the web server behind a load
> > balancer. This is documented in the book, chapter 11, using HAProxy.
> > All frameworks work the same way in this respect. web2py has no
> > intrinsic limitations. The bottle neck is the database connection. All
> > frameworks have the same problem. You can replicate the database too
> > and web2py supports multiple database clients with Round-Robin.
>
> > On a small VPS, web2py in average, should execute one page in 20ms.
> > Depending on how many requests/second you need you can determine how
> > many servers you need.
>
> > web2py apps run on Google App Engine and that means arbitrary
> > scalability as long as you can live with the constraints imposed by
> > the Google datastore (these limitations will go away as soon as Google
> > releases MySQL in the cloud, which they announced some time ago).
>
> > Please ask the consultant: which .NET feature makes it scale any
> > better than web2py or Rails? If he explains we can address it more
> > specifically.
>
> > Massimo
>
> > On Nov 29, 11:56 am, Lorin Rivers  wrote:
>
> > > The project I'm working on has hired a consultant who is now recommending 
> > > .Net in place of web2py or even rails.
>
> > > What's the 'largest' scale web2py is known to perform well on?
>
> > > --
> > > Lorin Rivers
> > > Mosasaur: Killer Technical Marketing 
> > > 
> > > 512/203.3198 (m)
>
>


[web2py] Re: Autoroutes and.static files

2010-11-29 Thread mdipierro
One things I see is that these two lines are wrong:

('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%s/
static/$anything' % app),
('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
a,'%s/appadmin/$anything' % app),

should be

('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%/
s/static/$anything' % app),
('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % a,'/
%s/appadmin/$anything' % app),

but I am not sure this is causing your problem. Somehow your route_in
is not matched.

On Nov 29, 12:21 pm, Bruno Rocha  wrote:
> main.py
> --start--
>             rewrite.select(environ)
>                 print '_'*40,'routes_in','_'*40
>                 print rewrite.thread.routes.routes_in
>                 print '_'*40,'routes_out','_'*40
>                 print rewrite.thread.routes.routes_out
>                 print '_'*40,'PATH_INFO','_'*40
>                 print environ['PATH_INFO']
> ---end---
>
> executing web2py and accesinghttp://127.0.0.1:8000/static/img/logo.pngthat
> returns
> invalid request
>
> rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.89.5 (2010-11-21 22:12:54)
> Database drivers available: SQLite3
> Starting hardcron...
> please visit:http://127.0.0.1:8000
> use "kill -SIGTERM 15282" to shutdown the web2py server
>  routes_in
> 
> [(<_sre.SRE_Pattern object at 0x1011ed770>, '/blouweb/static/robots.txt'),
> (<_sre.SRE_Pattern object at 0x1011f5a60>, '/blouweb/static/favicon.ico'),
> (<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
> (<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
> (<_sre.SRE_Pattern object at 0x101513080>, 'blouweb/static/\\g'),
> (<_sre.SRE_Pattern object at 0x101514900>,
> 'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
> 0x1015125a0>, '/blouweb/default/\\g')]
>  routes_out
> 
> [(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
> (<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
> (<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
>  PATH_INFO
> 
> /static/img/logo.png
>
> 2010/11/29 mdipierro 
>
>
>
> > I am going to need some help with debugging. In main.py, after
> > rewrite.select(environ)
>
> > can you log the values of
> > 1) rewrite.thread.routes.routes_in
> > 2) rewrite.thread.routes.routes_out
> > 3) environ['PATH_INFO']
>
> > when you call /static/image.png?
>
> > massimo
>
> > On Nov 29, 8:19 am, Bruno Rocha  wrote:
> > > Not working here,
>
> > > I have an image called image.png in /static
>
> > > without autoroutes I can access withhttp://
> > 127.0.0.1:8080/blouweb/static/image.png
>
> > > with autotoutes I can't access withhttp://
> > 127.0.0.1:8080/static/image.png
>
> > > 2010/11/29 mdipierro 
>
> > > >http://.../static/filename?
> > > > does it not work?
>
> > > > On Nov 29, 5:25 am, rochacbruno  wrote:
> > > > > HI, I am trying to use autoroutes for the first time, what I want is
> > my
> > > > site running in127.0.0.1:8080/index instead
> > > > of127.0.0.1:8080/app/default/index
>
> > > > > I tried the autoroutes and routes.conf explained in another thread
> > here
> > > > but i didn't figure out how to make the access to static files.
>
> > > > > I am using web2py 1.89.5 all functions as /index and /user  are
> > working
> > > > well,
>
> > > > >  But my static files are unreachable.
>
> > > > > 127.0.0.1:8080/index works ok, but show no images that I included
> > with
> > > > 
>
> > > > > 127.0.0.1:8080/static/image.png does not works too, and I cannot
> > access
> > > > in old way /app/static/image.png
>
> > > > > Something is missing in routes_out?
>
> > > > > My routes.conf is
>
> > > > > START CODE 
> > > > > 127.0.0.1 /blouweb/default
> > > > > ---END CODE 
>
> > > > > My routes.py is
>
> > > > > ---START CODE---
>
> > > > > try: config=open('routes.conf','r').read()
> > > > > except: config=''
>
> > > > > def auto_in(apps):
> > > > >     routes=[
> > > > >         ('/robots.txt','/blouweb/static/robots.txt'),
> > > > >         ('/favicon.ico','/blouweb/static/favicon.ico'),
> > > > >         ('/admin$anything','/admin$anything'),
> > > > >         ]
> > > > >     for a,b in [x.strip().split() for x in apps.split('\n') if
> > x.strip()
> > > > and not x.strip().startswith('#')]:
> > > > >         if not b.startswith('/'): b='/'+b
> > > > >         if b.endswith('/'): b=b[:-1]
> > > > >         app = b.split('/')[1]
> > > > >         routes+=[
> > > > >             ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
> > > > >             ('.*:https?://(.*\.)?%s:$method /static/$anything' %
> > > > a,'%s/static/$anything' % app),
> > > > >             ('.*:https?://(.*\.)?%s:$met

Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Jonathan Lundell
On Nov 29, 2010, at 11:31 AM, mdipierro wrote:
> 
> One things I see is that these two lines are wrong:
> 
>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%s/
> static/$anything' % app),
>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
> a,'%s/appadmin/$anything' % app),
> 
> should be
> 
>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%/
> s/static/$anything' % app),
>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % a,'/
> %s/appadmin/$anything' % app),
> 
> but I am not sure this is causing your problem. Somehow your route_in
> is not matched.

If that's not it, try turning on rewrite logging.

> 
> On Nov 29, 12:21 pm, Bruno Rocha  wrote:
>> main.py
>> --start--
>> rewrite.select(environ)
>> print '_'*40,'routes_in','_'*40
>> print rewrite.thread.routes.routes_in
>> print '_'*40,'routes_out','_'*40
>> print rewrite.thread.routes.routes_out
>> print '_'*40,'PATH_INFO','_'*40
>> print environ['PATH_INFO']
>> ---end---
>> 
>> executing web2py and accesinghttp://127.0.0.1:8000/static/img/logo.pngthat
>> returns
>> invalid request
>> 
>> rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
>> web2py Enterprise Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2010
>> Version 1.89.5 (2010-11-21 22:12:54)
>> Database drivers available: SQLite3
>> Starting hardcron...
>> please visit:http://127.0.0.1:8000
>> use "kill -SIGTERM 15282" to shutdown the web2py server
>>  routes_in
>> 
>> [(<_sre.SRE_Pattern object at 0x1011ed770>, '/blouweb/static/robots.txt'),
>> (<_sre.SRE_Pattern object at 0x1011f5a60>, '/blouweb/static/favicon.ico'),
>> (<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
>> (<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
>> (<_sre.SRE_Pattern object at 0x101513080>, 'blouweb/static/\\g'),
>> (<_sre.SRE_Pattern object at 0x101514900>,
>> 'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
>> 0x1015125a0>, '/blouweb/default/\\g')]
>>  routes_out
>> 
>> [(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
>> (<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
>> (<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
>>  PATH_INFO
>> 
>> /static/img/logo.png
>> 
>> 2010/11/29 mdipierro 
>> 
>> 
>> 
>>> I am going to need some help with debugging. In main.py, after
>>> rewrite.select(environ)
>> 
>>> can you log the values of
>>> 1) rewrite.thread.routes.routes_in
>>> 2) rewrite.thread.routes.routes_out
>>> 3) environ['PATH_INFO']
>> 
>>> when you call /static/image.png?
>> 
>>> massimo
>> 
>>> On Nov 29, 8:19 am, Bruno Rocha  wrote:
 Not working here,
>> 
 I have an image called image.png in /static
>> 
 without autoroutes I can access withhttp://
>>> 127.0.0.1:8080/blouweb/static/image.png
>> 
 with autotoutes I can't access withhttp://
>>> 127.0.0.1:8080/static/image.png
>> 
 2010/11/29 mdipierro 
>> 
> http://.../static/filename?
> does it not work?
>> 
> On Nov 29, 5:25 am, rochacbruno  wrote:
>> HI, I am trying to use autoroutes for the first time, what I want is
>>> my
> site running in127.0.0.1:8080/index instead
> of127.0.0.1:8080/app/default/index
>> 
>> I tried the autoroutes and routes.conf explained in another thread
>>> here
> but i didn't figure out how to make the access to static files.
>> 
>> I am using web2py 1.89.5 all functions as /index and /user  are
>>> working
> well,
>> 
>>  But my static files are unreachable.
>> 
>> 127.0.0.1:8080/index works ok, but show no images that I included
>>> with
> 
>> 
>> 127.0.0.1:8080/static/image.png does not works too, and I cannot
>>> access
> in old way /app/static/image.png
>> 
>> Something is missing in routes_out?
>> 
>> My routes.conf is
>> 
>> START CODE 
>> 127.0.0.1 /blouweb/default
>> ---END CODE 
>> 
>> My routes.py is
>> 
>> ---START CODE---
>> 
>> try: config=open('routes.conf','r').read()
>> except: config=''
>> 
>> def auto_in(apps):
>> routes=[
>> ('/robots.txt','/blouweb/static/robots.txt'),
>> ('/favicon.ico','/blouweb/static/favicon.ico'),
>> ('/admin$anything','/admin$anything'),
>> ]
>> for a,b in [x.strip().split() for x in apps.split('\n') if
>>> x.strip()
> and not x.strip().startswith('#')]:
>> if not b.startswith('/'): b='/'+b
>> if b.endswith('/'): b=b[:-1]
>> app = b.split('/')[1]
>> routes+=[
>> ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
>> ('.*:https?://(.*\.)?

[web2py] Re: Scalability of web2py?

2010-11-29 Thread ron_m
Sticking my nose in one more time :-)

Another consideration for system choice is uptime loss for patch
maintenance. From the tiny bit of information so far, the data
collection off these scales may have to be nearly real time - web
system down = nothing moves in the field. Is that true? I am having a
vision of highways dpartment truck scales or something like that. Then
you will have to design for fail-over so machines can be patched.

A very common architecture in the securities trading business is to do
as little as possible on the front end except ingest the data and get
it into a queue with persistence, for example RabbitMQ. Then process
the downstream data with multiple systems as needed to deal with the
throughput. RabbitMQ is written in Erlang which has high availability
built in because of the way it is architected. The Erlang language,
libraries and OTP the queue system came out of Ericsson and their
Swedish telco switch business, I tend to believe they know what they
are talking about when it comes to high availability. RabbitMQ is
built on top of that. This is readily available on Ubuntu as a
standard install package. There are Python interfaces and I believe
orbited discussed recently does STOMP protocol as an interface into
RabbitMQ or ActiveMQ. At this point I may sound like I am guilty of
trying to design your system and am jumping ahead of knowing the true
requirements. :-) I am just pointing out other considerations and
products all readily available in the open source domain that may be
worth looking at. Once you are forced onto the .Net platform the
alternatives are much more restrictive. I am also not looking for a
job, I have too much to do right now. :-/

Cheers, hope you end up with something workable that will solve the
problem.

Ron


On Nov 29, 11:00 am, ron_m  wrote:
> Beware the consultant that only recommends what they know about. :-)
>
> Sounds like early optimisation attempts by the consultant if you ask
> me. You have to do a traffic analysis on the network - sounds like
> these are scales at remote locations - how often do they report in,
> how much information per transaction, how much database activity per
> transaction? My belief is either the network or the database will be
> the real limiting factor. Worrying about whether or not the code is
> compiled at this point is blowing smoke IMHO with 2GHz+ 4 core Nehalem
> Xeons running $300 or $400 at most. CPU hardware is ridiculously
> cheap. On the busiest system I am looking after I have trouble pushing
> one core to 20% and I am moving 8 frames/sec of 704x480 pixel JPEG
> camera video from 24 cameras to disk, each camera generates about 1
> GByte of data per hour to put it in perspective. This is all done in
> Python layered over the C/C++ library gstreamer which is admittedly
> nothing to do with web2py but worth mentioning because of the
> languages used. The reason Python can be so fast is all the heavy
> lifting is done in C with the excellent integration to C libraries
> Python provides. Same thing goes for when you hit the database. I come
> from a Java background prior to Python and know what a pain JNI can be
> which is why Java types try to do it all in Java. With .Net you are in
> a similar environment to Java and have to do all the programming
> boilerplate other than what they can generate for you. Expect
> somewhere around 10x lines of code comparing .Net or Java to Python.
>
> A far more important consideration is what does the  programming team
> know and is efficient working in. Having worked in both Java and
> Python I can say with a certainty Python is like the walls have been
> knocked down dealing with collections for example. Not meaning to
> start any religious wars about languages but at age 59 I think I am
> officially an old fart, I have been in the industry since 1977 and
> have kept up to date with the technology else I would still be looking
> for Fortran jobs. :-)
>
> Ron
>
> On Nov 29, 10:20 am, Julio Schwarzbeck  wrote:
>
> > And this without considering "vendor lock-in". web2py can run on a
> > variety of platforms such as windows, macs. Linux and others, same
> > goes for the selection of the back-end database. Much more flexibility
> > under web2py in my opinion and prototyping is much faster in python.
>
> > On Nov 29, 10:05 am, mdipierro  wrote:
>
> > > You achieve scalability by replicating the web server behind a load
> > > balancer. This is documented in the book, chapter 11, using HAProxy.
> > > All frameworks work the same way in this respect. web2py has no
> > > intrinsic limitations. The bottle neck is the database connection. All
> > > frameworks have the same problem. You can replicate the database too
> > > and web2py supports multiple database clients with Round-Robin.
>
> > > On a small VPS, web2py in average, should execute one page in 20ms.
> > > Depending on how many requests/second you need you can determine how
> > > many servers you need.
>
> > > web2py apps run on G

[web2py] Re: Scalability of web2py?

2010-11-29 Thread mdipierro
Some political considerations (which may be wrong and off topic and
improper)...

Here is a problem with external consultants. They make more per hours
than the average employees. They get hired because of their specific
expertise to tell you what the boss wants to say but he prefers
somebody else to say (so he does not take the responsibility for
saying it).

You cannot win this argument on technical merits. I would dismiss this
argument and point to Google as a scalability example and it is not
written in .net. I would address the real concern... you push web2py
therefore you are a single point of failure. If you leave who takes
care of this software? Not a problem with .net, they can always hire a
consultant.

I would stress that using web2py is good for rapid prototyping and it
will allow the company to have a test product much sooner than
with .net and at much lower cost. Once the prototype is built you will
be in a better situation to assess whether web2py or .net is the best
tool for the job. If you start developing in .net you will have higher
startup costs and limited flexibility to change the specs. web2py code
is much more compact and readable than .net code and it will be easier
to train other people to work with it and learn how it works than
with .net. Tell them experts4solutions.com can sell them long term
support contracts and code review.

The scalability bottle neck is the database. Offer something to the
consultant. .net uses mssql. If he claims mssql scales well for your
case, web2py will use mssql.

If mssql does not scale well with web2py you have other options and do
not need to rewrite code.

You can always reuse most of the design (html, js, css, images).

Management costs. I am sure you can make the case it costs less to run
linux vps than windows ones (although I have no experience with the
latter).

Massimo

On Nov 29, 12:49 pm, Lorin Rivers  wrote:
> Unfortunately, the killing argument is "we know .NET will scale to thousands 
> of nodes, blah, blah, blah".
>
> This from (a guy who's smart and I respect, honestly) who uses his brand-new 
> top-of-the-line 17" MBP to run Windows VMs in Parallels.
>
> On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
>
>
>
> > And this without considering "vendor lock-in". web2py can run on a
> > variety of platforms such as windows, macs. Linux and others, same
> > goes for the selection of the back-end database. Much more flexibility
> > under web2py in my opinion and prototyping is much faster in python.
>
> > On Nov 29, 10:05 am, mdipierro  wrote:
> >> You achieve scalability by replicating the web server behind a load
> >> balancer. This is documented in the book, chapter 11, using HAProxy.
> >> All frameworks work the same way in this respect. web2py has no
> >> intrinsic limitations. The bottle neck is the database connection. All
> >> frameworks have the same problem. You can replicate the database too
> >> and web2py supports multiple database clients with Round-Robin.
>
> >> On a small VPS, web2py in average, should execute one page in 20ms.
> >> Depending on how many requests/second you need you can determine how
> >> many servers you need.
>
> >> web2py apps run on Google App Engine and that means arbitrary
> >> scalability as long as you can live with the constraints imposed by
> >> the Google datastore (these limitations will go away as soon as Google
> >> releases MySQL in the cloud, which they announced some time ago).
>
> >> Please ask the consultant: which .NET feature makes it scale any
> >> better than web2py or Rails? If he explains we can address it more
> >> specifically.
>
> >> Massimo
>
> >> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>
> >>> The project I'm working on has hired a consultant who is now recommending 
> >>> .Net in place of web2py or even rails.
>
> >>> What's the 'largest' scale web2py is known to perform well on?
>
> >>> --
> >>> Lorin Rivers
> >>> Mosasaur: Killer Technical Marketing 
> >>> 
> >>> 512/203.3198 (m)
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Michele Comitini
@Lorin

Ask the consultant which architectures and languages he knows and let
him make a table of advantages and pitfalls of each.
You will be able to take your decisions then

A solution that fits for any problems does not exist, but theorical
scalability is a non issue on many frameworks.
Indeed programmers can make such errors that can make run slow even
the most powerful system :)

To scale .NET well you must run on OS' that scale well, so you better
run .NET on Mono and choose a proper OS.
Scalability is not only a matter of application framework, systems
like Linux allows you to put new nodes fast with no
licensing fights, you can make 1000s VMs in seconds, you cannot do
that on commercial OS'.
Also if database is involved that is another critical point for
scalability, commercial DBs scale at high cost.

mic


2010/11/29 ron_m :
> Beware the consultant that only recommends what they know about. :-)
>
> Sounds like early optimisation attempts by the consultant if you ask
> me. You have to do a traffic analysis on the network - sounds like
> these are scales at remote locations - how often do they report in,
> how much information per transaction, how much database activity per
> transaction? My belief is either the network or the database will be
> the real limiting factor. Worrying about whether or not the code is
> compiled at this point is blowing smoke IMHO with 2GHz+ 4 core Nehalem
> Xeons running $300 or $400 at most. CPU hardware is ridiculously
> cheap. On the busiest system I am looking after I have trouble pushing
> one core to 20% and I am moving 8 frames/sec of 704x480 pixel JPEG
> camera video from 24 cameras to disk, each camera generates about 1
> GByte of data per hour to put it in perspective. This is all done in
> Python layered over the C/C++ library gstreamer which is admittedly
> nothing to do with web2py but worth mentioning because of the
> languages used. The reason Python can be so fast is all the heavy
> lifting is done in C with the excellent integration to C libraries
> Python provides. Same thing goes for when you hit the database. I come
> from a Java background prior to Python and know what a pain JNI can be
> which is why Java types try to do it all in Java. With .Net you are in
> a similar environment to Java and have to do all the programming
> boilerplate other than what they can generate for you. Expect
> somewhere around 10x lines of code comparing .Net or Java to Python.
>
> A far more important consideration is what does the  programming team
> know and is efficient working in. Having worked in both Java and
> Python I can say with a certainty Python is like the walls have been
> knocked down dealing with collections for example. Not meaning to
> start any religious wars about languages but at age 59 I think I am
> officially an old fart, I have been in the industry since 1977 and
> have kept up to date with the technology else I would still be looking
> for Fortran jobs. :-)
>
> Ron
>
> On Nov 29, 10:20 am, Julio Schwarzbeck  wrote:
>> And this without considering "vendor lock-in". web2py can run on a
>> variety of platforms such as windows, macs. Linux and others, same
>> goes for the selection of the back-end database. Much more flexibility
>> under web2py in my opinion and prototyping is much faster in python.
>>
>> On Nov 29, 10:05 am, mdipierro  wrote:
>>
>> > You achieve scalability by replicating the web server behind a load
>> > balancer. This is documented in the book, chapter 11, using HAProxy.
>> > All frameworks work the same way in this respect. web2py has no
>> > intrinsic limitations. The bottle neck is the database connection. All
>> > frameworks have the same problem. You can replicate the database too
>> > and web2py supports multiple database clients with Round-Robin.
>>
>> > On a small VPS, web2py in average, should execute one page in 20ms.
>> > Depending on how many requests/second you need you can determine how
>> > many servers you need.
>>
>> > web2py apps run on Google App Engine and that means arbitrary
>> > scalability as long as you can live with the constraints imposed by
>> > the Google datastore (these limitations will go away as soon as Google
>> > releases MySQL in the cloud, which they announced some time ago).
>>
>> > Please ask the consultant: which .NET feature makes it scale any
>> > better than web2py or Rails? If he explains we can address it more
>> > specifically.
>>
>> > Massimo
>>
>> > On Nov 29, 11:56 am, Lorin Rivers  wrote:
>>
>> > > The project I'm working on has hired a consultant who is now 
>> > > recommending .Net in place of web2py or even rails.
>>
>> > > What's the 'largest' scale web2py is known to perform well on?
>>
>> > > --
>> > > Lorin Rivers
>> > > Mosasaur: Killer Technical Marketing 
>> > > 
>> > > 512/203.3198 (m)
>>
>>


[web2py] SQLForm.factory and identic fields names in differents tables

2010-11-29 Thread Richard Vézina
Hello,

I would use a single form for different table that has relation. The problem
it that those table are really similar. What should I do to avoid this
problem? Is it possible?

Here the model

db.define_table('client',
Field('name'),
Field('title'),
Field('date','date'))
db.define_table('address',
   Field('client',db.client,writable=False,readable=False),
   Field('street'),
   Field('city'),
   Field('title'),
   Field('date','date'))

Controller :

def register():
   form=SQLFORM.factory(db.client,db.address)
   if form.accepts(request.vars):
   id = db.client.insert(**db.client._filter_fields(form.vars))
   form.vars.client=id
   id = db.address.insert(**db.address._filter_fields(form.vars))
   response.flash='Thanks for filling the form'
   return dict(form=form)



What does : _filter_fields(form.vars)

Does it get id value only or all the fields value store in form.vars?

Richard


[web2py] Re: Orbited with web2py

2010-11-29 Thread Candid
I use orbited in one of my company's in-house web2py applications. It
works great. I did not have to integrate it with web2py though - I use
it as a completely independent message broker. There are some python
scripts that run in background and process some stuff and send
notifications to browser through orbited built-in stomp server. I
think I used this tutorial to get started:
http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/

On Nov 29, 11:16 am, salbefe  wrote:
> Hello,
>
> I need to push some content in my website in 'real time'. I'm asking
> if someone had tried orbited (http://orbited.org/). After reading this
> post: Integrating Orbited with Web App Frameworks (http://orbited.org/
> blog/2008/09/integrating-orbited-with-web-app-frameworks/) it seems
> that it should not be any problem of integration with web2py (using
> STOMP and RabbitMQ).
>
> Anyway, I would like to known if someone had used it and if it could
> post an example.
>
> Thank you in advance


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The good news is that the guy who hired ME picked web2py in the first place…

On Nov 29, 2010, at 13:51 , mdipierro wrote:

> Some political considerations (which may be wrong and off topic and
> improper)...
> 
> Here is a problem with external consultants. They make more per hours
> than the average employees. They get hired because of their specific
> expertise to tell you what the boss wants to say but he prefers
> somebody else to say (so he does not take the responsibility for
> saying it).
> 
> You cannot win this argument on technical merits. I would dismiss this
> argument and point to Google as a scalability example and it is not
> written in .net. I would address the real concern... you push web2py
> therefore you are a single point of failure. If you leave who takes
> care of this software? Not a problem with .net, they can always hire a
> consultant.
> 
> I would stress that using web2py is good for rapid prototyping and it
> will allow the company to have a test product much sooner than
> with .net and at much lower cost. Once the prototype is built you will
> be in a better situation to assess whether web2py or .net is the best
> tool for the job. If you start developing in .net you will have higher
> startup costs and limited flexibility to change the specs. web2py code
> is much more compact and readable than .net code and it will be easier
> to train other people to work with it and learn how it works than
> with .net. Tell them experts4solutions.com can sell them long term
> support contracts and code review.
> 
> The scalability bottle neck is the database. Offer something to the
> consultant. .net uses mssql. If he claims mssql scales well for your
> case, web2py will use mssql.
> 
> If mssql does not scale well with web2py you have other options and do
> not need to rewrite code.
> 
> You can always reuse most of the design (html, js, css, images).
> 
> Management costs. I am sure you can make the case it costs less to run
> linux vps than windows ones (although I have no experience with the
> latter).
> 
> Massimo

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Bruno Rocha
Thanks! that works!

should fix this in scripts/autoroutes.py

2010/11/29 mdipierro 

> One things I see is that these two lines are wrong:
>
>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%s/
> static/$anything' % app),
>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
> a,'%s/appadmin/$anything' % app),
>
> should be
>
>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%/
> s/static/$anything' % app),
>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % a,'/
> %s/appadmin/$anything' % app),
>
> but I am not sure this is causing your problem. Somehow your route_in
> is not matched.
>
> On Nov 29, 12:21 pm, Bruno Rocha  wrote:
> > main.py
> > --start--
> > rewrite.select(environ)
> > print '_'*40,'routes_in','_'*40
> > print rewrite.thread.routes.routes_in
> > print '_'*40,'routes_out','_'*40
> > print rewrite.thread.routes.routes_out
> > print '_'*40,'PATH_INFO','_'*40
> > print environ['PATH_INFO']
> > ---end---
> >
> > executing web2py and accesinghttp://
> 127.0.0.1:8000/static/img/logo.pngthat
> > returns
> > invalid request
> >
> > rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.89.5 (2010-11-21 22:12:54)
> > Database drivers available: SQLite3
> > Starting hardcron...
> > please visit:http://127.0.0.1:8000
> > use "kill -SIGTERM 15282" to shutdown the web2py server
> >  routes_in
> > 
> > [(<_sre.SRE_Pattern object at 0x1011ed770>,
> '/blouweb/static/robots.txt'),
> > (<_sre.SRE_Pattern object at 0x1011f5a60>,
> '/blouweb/static/favicon.ico'),
> > (<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
> > (<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
> > (<_sre.SRE_Pattern object at 0x101513080>,
> 'blouweb/static/\\g'),
> > (<_sre.SRE_Pattern object at 0x101514900>,
> > 'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
> > 0x1015125a0>, '/blouweb/default/\\g')]
> >  routes_out
> > 
> > [(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
> > (<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
> > (<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
> >  PATH_INFO
> > 
> > /static/img/logo.png
> >
> > 2010/11/29 mdipierro 
> >
> >
> >
> > > I am going to need some help with debugging. In main.py, after
> > > rewrite.select(environ)
> >
> > > can you log the values of
> > > 1) rewrite.thread.routes.routes_in
> > > 2) rewrite.thread.routes.routes_out
> > > 3) environ['PATH_INFO']
> >
> > > when you call /static/image.png?
> >
> > > massimo
> >
> > > On Nov 29, 8:19 am, Bruno Rocha  wrote:
> > > > Not working here,
> >
> > > > I have an image called image.png in /static
> >
> > > > without autoroutes I can access withhttp://
> > > 127.0.0.1:8080/blouweb/static/image.png
> >
> > > > with autotoutes I can't access withhttp://
> > > 127.0.0.1:8080/static/image.png
> >
> > > > 2010/11/29 mdipierro 
> >
> > > > >http://.../static/filename?
> > > > > does it not work?
> >
> > > > > On Nov 29, 5:25 am, rochacbruno  wrote:
> > > > > > HI, I am trying to use autoroutes for the first time, what I want
> is
> > > my
> > > > > site running in127.0.0.1:8080/index instead
> > > > > of127.0.0.1:8080/app/default/index
> >
> > > > > > I tried the autoroutes and routes.conf explained in another
> thread
> > > here
> > > > > but i didn't figure out how to make the access to static files.
> >
> > > > > > I am using web2py 1.89.5 all functions as /index and /user  are
> > > working
> > > > > well,
> >
> > > > > >  But my static files are unreachable.
> >
> > > > > > 127.0.0.1:8080/index works ok, but show no images that I
> included
> > > with
> > > > > 
> >
> > > > > > 127.0.0.1:8080/static/image.png does not works too, and I cannot
> > > access
> > > > > in old way /app/static/image.png
> >
> > > > > > Something is missing in routes_out?
> >
> > > > > > My routes.conf is
> >
> > > > > > START CODE 
> > > > > > 127.0.0.1 /blouweb/default
> > > > > > ---END CODE 
> >
> > > > > > My routes.py is
> >
> > > > > > ---START CODE---
> >
> > > > > > try: config=open('routes.conf','r').read()
> > > > > > except: config=''
> >
> > > > > > def auto_in(apps):
> > > > > > routes=[
> > > > > > ('/robots.txt','/blouweb/static/robots.txt'),
> > > > > > ('/favicon.ico','/blouweb/static/favicon.ico'),
> > > > > > ('/admin$anything','/admin$anything'),
> > > > > > ]
> > > > > > for a,b in [x.strip().split() for x in apps.split('\n') if
> > > x.strip()
> > > > > and not x.strip().startswith('#')]:
> > > > > > if not b.sta

Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Michele Comitini
great!

2010/11/29 Lorin Rivers :
> The good news is that the guy who hired ME picked web2py in the first place…
>
> On Nov 29, 2010, at 13:51 , mdipierro wrote:
>
>> Some political considerations (which may be wrong and off topic and
>> improper)...
>>
>> Here is a problem with external consultants. They make more per hours
>> than the average employees. They get hired because of their specific
>> expertise to tell you what the boss wants to say but he prefers
>> somebody else to say (so he does not take the responsibility for
>> saying it).
>>
>> You cannot win this argument on technical merits. I would dismiss this
>> argument and point to Google as a scalability example and it is not
>> written in .net. I would address the real concern... you push web2py
>> therefore you are a single point of failure. If you leave who takes
>> care of this software? Not a problem with .net, they can always hire a
>> consultant.
>>
>> I would stress that using web2py is good for rapid prototyping and it
>> will allow the company to have a test product much sooner than
>> with .net and at much lower cost. Once the prototype is built you will
>> be in a better situation to assess whether web2py or .net is the best
>> tool for the job. If you start developing in .net you will have higher
>> startup costs and limited flexibility to change the specs. web2py code
>> is much more compact and readable than .net code and it will be easier
>> to train other people to work with it and learn how it works than
>> with .net. Tell them experts4solutions.com can sell them long term
>> support contracts and code review.
>>
>> The scalability bottle neck is the database. Offer something to the
>> consultant. .net uses mssql. If he claims mssql scales well for your
>> case, web2py will use mssql.
>>
>> If mssql does not scale well with web2py you have other options and do
>> not need to rewrite code.
>>
>> You can always reuse most of the design (html, js, css, images).
>>
>> Management costs. I am sure you can make the case it costs less to run
>> linux vps than windows ones (although I have no experience with the
>> latter).
>>
>> Massimo
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)
>
>
>


Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Bruno Rocha
Thats my working solution:

http://snipt.net/rochacbruno/routespy

http://snipt.net/rochacbruno/routesconf

2010/11/29 Bruno Rocha 

> Thanks! that works!
>
> should fix this in scripts/autoroutes.py
>
> 2010/11/29 mdipierro 
>
>> One things I see is that these two lines are wrong:
>>
>>
>>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%s/
>> static/$anything' % app),
>>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
>> a,'%s/appadmin/$anything' % app),
>>
>> should be
>>
>>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%/
>> s/static/$anything' % app),
>>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % a,'/
>> %s/appadmin/$anything' % app),
>>
>> but I am not sure this is causing your problem. Somehow your route_in
>> is not matched.
>>
>> On Nov 29, 12:21 pm, Bruno Rocha  wrote:
>> > main.py
>> > --start--
>> > rewrite.select(environ)
>> > print '_'*40,'routes_in','_'*40
>> > print rewrite.thread.routes.routes_in
>> > print '_'*40,'routes_out','_'*40
>> > print rewrite.thread.routes.routes_out
>> > print '_'*40,'PATH_INFO','_'*40
>> > print environ['PATH_INFO']
>> > ---end---
>> >
>> > executing web2py and accesinghttp://
>> 127.0.0.1:8000/static/img/logo.pngthat
>> > returns
>> > invalid request
>> >
>> > rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
>> > web2py Enterprise Web Framework
>> > Created by Massimo Di Pierro, Copyright 2007-2010
>> > Version 1.89.5 (2010-11-21 22:12:54)
>> > Database drivers available: SQLite3
>> > Starting hardcron...
>> > please visit:http://127.0.0.1:8000
>> > use "kill -SIGTERM 15282" to shutdown the web2py server
>> >  routes_in
>> > 
>> > [(<_sre.SRE_Pattern object at 0x1011ed770>,
>> '/blouweb/static/robots.txt'),
>> > (<_sre.SRE_Pattern object at 0x1011f5a60>,
>> '/blouweb/static/favicon.ico'),
>> > (<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
>> > (<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
>> > (<_sre.SRE_Pattern object at 0x101513080>,
>> 'blouweb/static/\\g'),
>> > (<_sre.SRE_Pattern object at 0x101514900>,
>> > 'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
>> > 0x1015125a0>, '/blouweb/default/\\g')]
>> >  routes_out
>> > 
>> > [(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
>> > (<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
>> > (<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
>> >  PATH_INFO
>> > 
>> > /static/img/logo.png
>> >
>> > 2010/11/29 mdipierro 
>> >
>> >
>> >
>> > > I am going to need some help with debugging. In main.py, after
>> > > rewrite.select(environ)
>> >
>> > > can you log the values of
>> > > 1) rewrite.thread.routes.routes_in
>> > > 2) rewrite.thread.routes.routes_out
>> > > 3) environ['PATH_INFO']
>> >
>> > > when you call /static/image.png?
>> >
>> > > massimo
>> >
>> > > On Nov 29, 8:19 am, Bruno Rocha  wrote:
>> > > > Not working here,
>> >
>> > > > I have an image called image.png in /static
>> >
>> > > > without autoroutes I can access withhttp://
>> > > 127.0.0.1:8080/blouweb/static/image.png
>> >
>> > > > with autotoutes I can't access withhttp://
>> > > 127.0.0.1:8080/static/image.png
>> >
>> > > > 2010/11/29 mdipierro 
>> >
>> > > > >http://.../static/filename?
>> > > > > does it not work?
>> >
>> > > > > On Nov 29, 5:25 am, rochacbruno  wrote:
>> > > > > > HI, I am trying to use autoroutes for the first time, what I
>> want is
>> > > my
>> > > > > site running in127.0.0.1:8080/index instead
>> > > > > of127.0.0.1:8080/app/default/index
>> >
>> > > > > > I tried the autoroutes and routes.conf explained in another
>> thread
>> > > here
>> > > > > but i didn't figure out how to make the access to static files.
>> >
>> > > > > > I am using web2py 1.89.5 all functions as /index and /user  are
>> > > working
>> > > > > well,
>> >
>> > > > > >  But my static files are unreachable.
>> >
>> > > > > > 127.0.0.1:8080/index works ok, but show no images that I
>> included
>> > > with
>> > > > > 
>> >
>> > > > > > 127.0.0.1:8080/static/image.png does not works too, and I
>> cannot
>> > > access
>> > > > > in old way /app/static/image.png
>> >
>> > > > > > Something is missing in routes_out?
>> >
>> > > > > > My routes.conf is
>> >
>> > > > > > START CODE 
>> > > > > > 127.0.0.1 /blouweb/default
>> > > > > > ---END CODE 
>> >
>> > > > > > My routes.py is
>> >
>> > > > > > ---START CODE---
>> >
>> > > > > > try: config=open('routes.conf','r').read()
>> > > > > > except: config=''
>> >
>> > > > > > def auto_in(apps):
>> > > > > > routes=[
>> > > > > > ('/robots.txt','/blouweb/static/robots.txt'),
>> > > > > > ('/favic

[web2py] IS_IN_SET inside INPUT

2010-11-29 Thread CesarBustios
Hi, im trying to use the IS_IN_SET requirement in a form, i'm using:

form = FORM('Campaña ',
  INPUT(_type='text', _name='name',
requires=IS_IN_SET(['A', 'B', 'C'])),
  INPUT(_type='submit'))

I'm not sure this is the right code, can you help me out please?

Thanks!


[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
Works fine , thanks
I saw it was a recurrent question, maybe you should add this in the
book

On 29 nov, 18:51, mdipierro  wrote:
> my bad
>
> def index():
>     rows = dict((r.id,r) for r in db(db.article).select())
>     for id,row in rows.items(): row.children=[]
>     for id,row in rows.items():
>         if row.f_parent==1: root=row
>         else: rows[row.f_parent].children.append(row)
>     def tree(row):
>         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> row.children]))
>     return tree(root)
>
> On Nov 29, 11:06 am, JmiXIII  wrote:
>
> > Hello,
>
> > here is what I did:
> > db.define_table('article',
> >     Field('f_parent','reference article'),
> >     Field('title'))
>
> > ##
> > def index():
> >     rows = dict((r.id,r) for r in db(db.article).select())
> >     for id,row in rows.items(): row.children=[]
> >     for id,row in rows.items():
> >         if row.f_parent==1: root=row
> >         else: rows[row.f_parent].append(row)
> >     def tree(row):
> >         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> > row.children]))
> >     return tree(root)
> > ##
>
> > Here are the articles
> > article.id      article.f_parent        article.title
> > 1       1       Racine
> > 2       1       Branche1
> > 3       1       Branche2
>
> > It gives me the following error :
>
> > Traceback (most recent call last):
> >   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> > \restricted.py", line 188, in restricted
> >     exec ccode in environment
> >   File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
> > test/controllers/default.py", line 66, in 
> >   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> > \globals.py", line 96, in 
> >     self._caller = lambda f: f()
> >   File "C:/Documents and Settings/sylvain/Bureau/web2py2/applications/
> > test/controllers/default.py", line 60, in index
> >     else: rows[row.f_parent].append(row)
> >   File "C:\Documents and Settings\sylvain\Bureau\web2py2\gluon
> > \sql.py", line 742, in __getattr__
> >     return dict.__getitem__(self,key)
> > KeyError: 'append'
>
> > T tried to modify :
> >         else: rows[row.f_parent].append(row)
> > with
> >         else: rows[row.children].append(row)
> > as it seems we're trying to build a list of children.
> > Yet i get another error : TypeError: list objects are unhashable
>
> > Can anybody help me ?
>
> > On 29 nov, 12:27, JmiXIII  wrote:
>
> > > That's it I'll try it
> > > thanks a lot!
>
> > > On 29 nov, 00:48, mdipierro  wrote:
>
> > > > I assume you are trying to build a hierarchial tree of articles and
> > > > you want them all from the parent.
>
> > > > I would do this something like this:
>
> > > > db.define_table('article',Field('f_parent','reference
> > > > article'),Field('title'))
>
> > > > def index():
> > > >     rows = dict((r.id,r) for r in db(db.article).select())
> > > >     for id,row in rows.items(): row.children=[]
> > > >     for id,row in rows.items():
> > > >         if row.f_parent==0: root=row
> > > >         else: rows[row.f_parent].append(row)
> > > >     def tree(row):
> > > >         return DIV(H1(row.title),UL(*[LI(tree(child)) for child in
> > > > row.children])))
> > > >     return tree(root)
>
> > > > On Nov 28, 5:00 pm, JmiXIII  wrote:
>
> > > > > Hello,
>
> > > > > I'm facing I guess a well known programming problem. It is not really
> > > > > related to web2by, but since I'm using web2py I hope somebody here can
> > > > > help.
>
> > > > > Here is my controller :
>
> > > > > def global_view():
> > > > >     parents = db(~(db.t_article.id==db.t_list.f_article)).select()
> > > > >     tree={}
> > > > >     for parent in parents:
> > > > >         tree[parent.t_article.id]={}
> > > > >         sublevel=db(parent.t_article.id==db.t_list.f_parent).select()
> > > > >         for son in sublevel:
> > > > >             tree[parent.t_article.id][son.f_article]=son.f_article
> > > > >             tree[parent.t_article.id][son.f_article]={}
> > > > >             sublevel2=db(son.f_article==db.t_list.f_parent).select()
> > > > >             for son2 in sublevel2:
> > > > >                 tree[parent.t_article.id][son.f_article]
> > > > > [son2.f_article]=son2.f_article
> > > > >                 
> > > > > tree[parent.t_article.id][son.f_article][son2.f_article]={}
> > > > >     return dict(tree=tree)
>
> > > > > So in fact I'd like to go on for son3, son4, based on the same model
> > > > > as sublevel2... until sublevelx=None.
> > > > > I guess I should use some kind of recursive or loop function.
> > > > > I've read different things using right and left variable for
> > > > > hierarchical tree, but it seems to me that it is possible to build a
> > > > > loop in my controller without modifying my model.
>
> > > > > Hope I do not disturb this groupes with this kind of question.
>
>


[web2py] Re: Double invert

2010-11-29 Thread DenesL

So far I have not needed this but it sounds logical.
And an easy patch as given.

e = ~db.person.name
e is an expression meaning "person.name DESC"

so e = ~e
should be "person.name"
not "person.name DESC DESC"

+1 from me

Denes.

On Nov 29, 10:17 am, mdipierro  wrote:
> This should be automatic behavior in the new dal (dal.py).
> I do not think it is work spending time changing this in the current
> dal (sql.py).
>
> Massimo
>
> On Nov 29, 9:09 am, iiijjjiii  wrote:
>
> > Does it make sense to modify the gluon.sql Expression __invert__
> > method so a double invert is possible.
>
> > Currently this produces an error:
>
> >     print db().select(db.person.name, orderby=~~db.person.name)
>
> >     ProgrammingError: (1064, "You have an error in your SQL syntax;
> > check the manual that corresponds to your MySQL server version for the
> > right syntax to use near 'DESC' at line 1")
>
> > The cause of the error is obvious when you look at the SQL query.
>
> >     SELECT person.name FROM person ORDER BY person.name DESC DESC
>
> > The second invert adds an additional 'DESC' which makes the query
> > invalid.
>
> > I tried this and it worked.
>
> >     def __invert__(self):
> >         if str(self)[-5:] == ' DESC':
> >             return Expression(str(self)[:-5], None, None)
> >         else:
> >             return Expression(str(self) + ' DESC', None, None)
>
> > To explain why a double invert is useful, I have a function that
> > returns the rows from a query and the order of the rows is determined
> > by parameters.
>
> >     def people(order_expr, reverse=False)
> >         if False:
> >             orderby = order_expr
> >         else:
> >             orderby = ~order_expr
> >         return db().select(db.person.ALL, orderby=order_by)
>
> > It is used in a report. Each field in the report has a default order
> > expression. The default order direction for most fields is ascending,
> > but for some fields, eg updated_on, the default order is more
> > intuitive as descending. The report will allow the user to switch the
> > direction with a click. The code simply toggles the reverse parameter.
> > I'd like the function to handle any of these combinations.
>
> >     people(db.person.name)
> >     people(db.person.name, reverse=True)
> >     people(~db.person.updated_on)
> >     people(~db.person.updated_on, reverse=True)
>
> > I am not familiar with the web2py code enough to be aware of the
> > effects of changing the __invert__ so my suggestion might have some
> > unwanted results. Hopefully others can provide input.
>
>


[web2py] Re: IS_IN_SET inside INPUT

2010-11-29 Thread DenesL

The IS_IN_SET looks good, but 'Campana' is not an HTML element.


On Nov 29, 3:50 pm, CesarBustios  wrote:
> Hi, im trying to use the IS_IN_SET requirement in a form, i'm using:
>
> form = FORM('Campaña ',
>               INPUT(_type='text', _name='name',
> requires=IS_IN_SET(['A', 'B', 'C'])),
>               INPUT(_type='submit'))
>
> I'm not sure this is the right code, can you help me out please?
>
> Thanks!


[web2py] Re: IS_IN_SET inside INPUT

2010-11-29 Thread CesarBustios
I want to make a dropdown list.

regs=db(db.Campana.id > 0).select(orderby='nombre')
form = FORM('Campaña: ',
  SELECT([c.nombre for c in regs],
_name='camp'),
  INPUT(_type='submit', _value='Mostrar'))

This worked fine :)

On 29 nov, 16:16, DenesL  wrote:
> The IS_IN_SET looks good, but 'Campana' is not an HTML element.
>
> On Nov 29, 3:50 pm, CesarBustios  wrote:
>
>
>
>
>
>
>
> > Hi, im trying to use the IS_IN_SET requirement in a form, i'm using:
>
> > form = FORM('Campaña ',
> >               INPUT(_type='text', _name='name',
> > requires=IS_IN_SET(['A', 'B', 'C'])),
> >               INPUT(_type='submit'))
>
> > I'm not sure this is the right code, can you help me out please?
>
> > Thanks!


[web2py] Re: IS_IN_SET inside INPUT

2010-11-29 Thread mdipierro
I would go for

form = SQLFORM.factory(Field('name',requires=IS_IN_SET(['A', 'B',
'C'])))


On Nov 29, 2:50 pm, CesarBustios  wrote:
> Hi, im trying to use the IS_IN_SET requirement in a form, i'm using:
>
> form = FORM('Campaña ',
>               INPUT(_type='text', _name='name',
> requires=IS_IN_SET(['A', 'B', 'C'])),
>               INPUT(_type='submit'))
>
> I'm not sure this is the right code, can you help me out please?
>
> Thanks!



[web2py] Re: Double invert

2010-11-29 Thread mdipierro
I apologize for my too quick previous dismissal. On a second thought
this is a good idea. Your patch is in trunk.

massimo

On Nov 29, 9:09 am, iiijjjiii  wrote:
> Does it make sense to modify the gluon.sql Expression __invert__
> method so a double invert is possible.
>
> Currently this produces an error:
>
>     print db().select(db.person.name, orderby=~~db.person.name)
>
>     ProgrammingError: (1064, "You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'DESC' at line 1")
>
> The cause of the error is obvious when you look at the SQL query.
>
>     SELECT person.name FROM person ORDER BY person.name DESC DESC
>
> The second invert adds an additional 'DESC' which makes the query
> invalid.
>
> I tried this and it worked.
>
>     def __invert__(self):
>         if str(self)[-5:] == ' DESC':
>             return Expression(str(self)[:-5], None, None)
>         else:
>             return Expression(str(self) + ' DESC', None, None)
>
> To explain why a double invert is useful, I have a function that
> returns the rows from a query and the order of the rows is determined
> by parameters.
>
>     def people(order_expr, reverse=False)
>         if False:
>             orderby = order_expr
>         else:
>             orderby = ~order_expr
>         return db().select(db.person.ALL, orderby=order_by)
>
> It is used in a report. Each field in the report has a default order
> expression. The default order direction for most fields is ascending,
> but for some fields, eg updated_on, the default order is more
> intuitive as descending. The report will allow the user to switch the
> direction with a click. The code simply toggles the reverse parameter.
> I'd like the function to handle any of these combinations.
>
>     people(db.person.name)
>     people(db.person.name, reverse=True)
>     people(~db.person.updated_on)
>     people(~db.person.updated_on, reverse=True)
>
> I am not familiar with the web2py code enough to be aware of the
> effects of changing the __invert__ so my suggestion might have some
> unwanted results. Hopefully others can provide input.


Re: [web2py] Re: Autoroutes and.static files

2010-11-29 Thread Bruno Rocha
I made changes to routes_out too.

2010/11/29 Bruno Rocha 

> Thats my working solution:
>
> http://snipt.net/rochacbruno/routespy
>
> http://snipt.net/rochacbruno/routesconf
>
> 2010/11/29 Bruno Rocha 
>
> Thanks! that works!
>>
>> should fix this in scripts/autoroutes.py
>>
>> 2010/11/29 mdipierro 
>>
>>> One things I see is that these two lines are wrong:
>>>
>>>
>>>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%s/
>>> static/$anything' % app),
>>>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
>>> a,'%s/appadmin/$anything' % app),
>>>
>>> should be
>>>
>>>('.*:https?://(.*\.)?%s:$method /static/$anything' % a,'%/
>>> s/static/$anything' % app),
>>>('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % a,'/
>>> %s/appadmin/$anything' % app),
>>>
>>> but I am not sure this is causing your problem. Somehow your route_in
>>> is not matched.
>>>
>>> On Nov 29, 12:21 pm, Bruno Rocha  wrote:
>>> > main.py
>>> > --start--
>>> > rewrite.select(environ)
>>> > print '_'*40,'routes_in','_'*40
>>> > print rewrite.thread.routes.routes_in
>>> > print '_'*40,'routes_out','_'*40
>>> > print rewrite.thread.routes.routes_out
>>> > print '_'*40,'PATH_INFO','_'*40
>>> > print environ['PATH_INFO']
>>> > ---end---
>>> >
>>> > executing web2py and accesinghttp://
>>> 127.0.0.1:8000/static/img/logo.pngthat
>>> > returns
>>> > invalid request
>>> >
>>> > rochacbruno-2:web2py brunomac$ python web2py.py -a 1234
>>> > web2py Enterprise Web Framework
>>> > Created by Massimo Di Pierro, Copyright 2007-2010
>>> > Version 1.89.5 (2010-11-21 22:12:54)
>>> > Database drivers available: SQLite3
>>> > Starting hardcron...
>>> > please visit:http://127.0.0.1:8000
>>> > use "kill -SIGTERM 15282" to shutdown the web2py server
>>> >  routes_in
>>> > 
>>> > [(<_sre.SRE_Pattern object at 0x1011ed770>,
>>> '/blouweb/static/robots.txt'),
>>> > (<_sre.SRE_Pattern object at 0x1011f5a60>,
>>> '/blouweb/static/favicon.ico'),
>>> > (<_sre.SRE_Pattern object at 0x101509df0>, '/admin\\g'),
>>> > (<_sre.SRE_Pattern object at 0x1011effe0>, '/blouweb/default'),
>>> > (<_sre.SRE_Pattern object at 0x101513080>,
>>> 'blouweb/static/\\g'),
>>> > (<_sre.SRE_Pattern object at 0x101514900>,
>>> > 'blouweb/appadmin/\\g'), (<_sre.SRE_Pattern object at
>>> > 0x1015125a0>, '/blouweb/default/\\g')]
>>> >  routes_out
>>> > 
>>> > [(<_sre.SRE_Pattern object at 0x1015126d0>, '/static/\\g'),
>>> > (<_sre.SRE_Pattern object at 0x1011efd70>, '/appadmin/\\g'),
>>> > (<_sre.SRE_Pattern object at 0x101514790>, '/\\g')]
>>> >  PATH_INFO
>>> > 
>>> > /static/img/logo.png
>>> >
>>> > 2010/11/29 mdipierro 
>>> >
>>> >
>>> >
>>> > > I am going to need some help with debugging. In main.py, after
>>> > > rewrite.select(environ)
>>> >
>>> > > can you log the values of
>>> > > 1) rewrite.thread.routes.routes_in
>>> > > 2) rewrite.thread.routes.routes_out
>>> > > 3) environ['PATH_INFO']
>>> >
>>> > > when you call /static/image.png?
>>> >
>>> > > massimo
>>> >
>>> > > On Nov 29, 8:19 am, Bruno Rocha  wrote:
>>> > > > Not working here,
>>> >
>>> > > > I have an image called image.png in /static
>>> >
>>> > > > without autoroutes I can access withhttp://
>>> > > 127.0.0.1:8080/blouweb/static/image.png
>>> >
>>> > > > with autotoutes I can't access withhttp://
>>> > > 127.0.0.1:8080/static/image.png
>>> >
>>> > > > 2010/11/29 mdipierro 
>>> >
>>> > > > >http://.../static/filename?
>>> > > > > does it not work?
>>> >
>>> > > > > On Nov 29, 5:25 am, rochacbruno  wrote:
>>> > > > > > HI, I am trying to use autoroutes for the first time, what I
>>> want is
>>> > > my
>>> > > > > site running in127.0.0.1:8080/index instead
>>> > > > > of127.0.0.1:8080/app/default/index
>>> >
>>> > > > > > I tried the autoroutes and routes.conf explained in another
>>> thread
>>> > > here
>>> > > > > but i didn't figure out how to make the access to static files.
>>> >
>>> > > > > > I am using web2py 1.89.5 all functions as /index and /user  are
>>> > > working
>>> > > > > well,
>>> >
>>> > > > > >  But my static files are unreachable.
>>> >
>>> > > > > > 127.0.0.1:8080/index works ok, but show no images that I
>>> included
>>> > > with
>>> > > > > 
>>> >
>>> > > > > > 127.0.0.1:8080/static/image.png does not works too, and I
>>> cannot
>>> > > access
>>> > > > > in old way /app/static/image.png
>>> >
>>> > > > > > Something is missing in routes_out?
>>> >
>>> > > > > > My routes.conf is
>>> >
>>> > > > > > START CODE 
>>> > > > > > 127.0.0.1 /blouweb/default
>>> > > > > > ---END CODE 
>>> >
>>> > > > > > My routes.py is
>>> >
>>> > > > > > ---START CODE---
>>> >
>>> > > > > > try: config=open('

[web2py] Re: Scalability of web2py?

2010-11-29 Thread ron_m
:-)

On Nov 29, 12:33 pm, Lorin Rivers  wrote:
> The good news is that the guy who hired ME picked web2py in the first place…
>
> On Nov 29, 2010, at 13:51 , mdipierro wrote:
>
>
>
> > Some political considerations (which may be wrong and off topic and
> > improper)...
>
> > Here is a problem with external consultants. They make more per hours
> > than the average employees. They get hired because of their specific
> > expertise to tell you what the boss wants to say but he prefers
> > somebody else to say (so he does not take the responsibility for
> > saying it).
>
> > You cannot win this argument on technical merits. I would dismiss this
> > argument and point to Google as a scalability example and it is not
> > written in .net. I would address the real concern... you push web2py
> > therefore you are a single point of failure. If you leave who takes
> > care of this software? Not a problem with .net, they can always hire a
> > consultant.
>
> > I would stress that using web2py is good for rapid prototyping and it
> > will allow the company to have a test product much sooner than
> > with .net and at much lower cost. Once the prototype is built you will
> > be in a better situation to assess whether web2py or .net is the best
> > tool for the job. If you start developing in .net you will have higher
> > startup costs and limited flexibility to change the specs. web2py code
> > is much more compact and readable than .net code and it will be easier
> > to train other people to work with it and learn how it works than
> > with .net. Tell them experts4solutions.com can sell them long term
> > support contracts and code review.
>
> > The scalability bottle neck is the database. Offer something to the
> > consultant. .net uses mssql. If he claims mssql scales well for your
> > case, web2py will use mssql.
>
> > If mssql does not scale well with web2py you have other options and do
> > not need to rewrite code.
>
> > You can always reuse most of the design (html, js, css, images).
>
> > Management costs. I am sure you can make the case it costs less to run
> > linux vps than windows ones (although I have no experience with the
> > latter).
>
> > Massimo
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


Re: [web2py] Beginner Auth problem

2010-11-29 Thread appydev
Greetings.

As above. I wanted to build a registration form to fill two tables,
auth_user and teacher.

I use SQLFORM.factory (table1, table2) to create the form.
http://www.web2pyslices.com/main/slices/take_slice/102 to fill the tables.
And auth.settings.actions_disabled = ['register'] to disable the
registration form created by default.
(Thanks again to massimo and to mr.freeze)

But later I realized that this way is no longer created a new group to
contain the user, automatically.
As is indicated by:
auth.settings.create_user_groups = True

My question is:

Is there any other functionality that is lost when working as I am doing?
Am I doing my application less secure, creating myself my registration form?


[web2py] Re: Beginner Auth problem

2010-11-29 Thread mdipierro
Lots.

this

form=SQLFORM.factory (table1, table2)
form.accepts(...)

will not do any database IO

On Nov 29, 4:28 pm, appydev  wrote:
> Greetings.
>
> As above. I wanted to build a registration form to fill two tables,
> auth_user and teacher.
>
> I use SQLFORM.factory (table1, table2) to create the 
> form.http://www.web2pyslices.com/main/slices/take_slice/102to fill the tables.
> And auth.settings.actions_disabled = ['register'] to disable the
> registration form created by default.
> (Thanks again to massimo and to mr.freeze)
>
> But later I realized that this way is no longer created a new group to
> contain the user, automatically.
> As is indicated by:
> auth.settings.create_user_groups = True
>
> My question is:
>
> Is there any other functionality that is lost when working as I am doing?
> Am I doing my application less secure, creating myself my registration form?


Re: [web2py] Re: JSONRPC notes

2010-11-29 Thread Branko Vukelic
On Mon, Nov 29, 2010 at 7:12 PM, ron_m  wrote:
> I would guess the id is so you can pair up the response if you had
> more than one request outstanding in an AJAX situation?

Yes. If you're doing multiple request asynchronously, that is also
useful. Of course, you cannot omit the ``id`` parameter, since it's
required by JSONRPC specs, and web2py will raise a key error.

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Scalability of web2py?

2010-11-29 Thread Christopher Steel
+1

I agree, Web2py is excellent for low cost prototyping, much less
than .NET and you will actually have something that works...

I hear that these guys can kick one out in under a month ->
http://experts4solutions.com/

; )

Chris

On Nov 29, 2:51 pm, mdipierro  wrote:
> Some political considerations (which may be wrong and off topic and
> improper)...
>
> Here is a problem with external consultants. They make more per hours
> than the average employees. They get hired because of their specific
> expertise to tell you what the boss wants to say but he prefers
> somebody else to say (so he does not take the responsibility for
> saying it).
>
> You cannot win this argument on technical merits. I would dismiss this
> argument and point to Google as a scalability example and it is not
> written in .net. I would address the real concern... you push web2py
> therefore you are a single point of failure. If you leave who takes
> care of this software? Not a problem with .net, they can always hire a
> consultant.
>
> I would stress that using web2py is good for rapid prototyping and it
> will allow the company to have a test product much sooner than
> with .net and at much lower cost. Once the prototype is built you will
> be in a better situation to assess whether web2py or .net is the best
> tool for the job. If you start developing in .net you will have higher
> startup costs and limited flexibility to change the specs. web2py code
> is much more compact and readable than .net code and it will be easier
> to train other people to work with it and learn how it works than
> with .net. Tell them experts4solutions.com can sell them long term
> support contracts and code review.
>
> The scalability bottle neck is the database. Offer something to the
> consultant. .net uses mssql. If he claims mssql scales well for your
> case, web2py will use mssql.
>
> If mssql does not scale well with web2py you have other options and do
> not need to rewrite code.
>
> You can always reuse most of the design (html, js, css, images).
>
> Management costs. I am sure you can make the case it costs less to run
> linux vps than windows ones (although I have no experience with the
> latter).
>
> Massimo
>
> On Nov 29, 12:49 pm, Lorin Rivers  wrote:> 
> Unfortunately, the killing argument is "we know .NET will scale to thousands 
> of nodes, blah, blah, blah".
>
> > This from (a guy who's smart and I respect, honestly) who uses his 
> > brand-new top-of-the-line 17" MBP to run Windows VMs in Parallels.
>
> > On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
>
> > > And this without considering "vendor lock-in". web2py can run on a
> > > variety of platforms such as windows, macs. Linux and others, same
> > > goes for the selection of the back-end database. Much more flexibility
> > > under web2py in my opinion and prototyping is much faster in python.
>
> > > On Nov 29, 10:05 am, mdipierro  wrote:
> > >> You achieve scalability by replicating the web server behind a load
> > >> balancer. This is documented in the book, chapter 11, using HAProxy.
> > >> All frameworks work the same way in this respect. web2py has no
> > >> intrinsic limitations. The bottle neck is the database connection. All
> > >> frameworks have the same problem. You can replicate the database too
> > >> and web2py supports multiple database clients with Round-Robin.
>
> > >> On a small VPS, web2py in average, should execute one page in 20ms.
> > >> Depending on how many requests/second you need you can determine how
> > >> many servers you need.
>
> > >> web2py apps run on Google App Engine and that means arbitrary
> > >> scalability as long as you can live with the constraints imposed by
> > >> the Google datastore (these limitations will go away as soon as Google
> > >> releases MySQL in the cloud, which they announced some time ago).
>
> > >> Please ask the consultant: which .NET feature makes it scale any
> > >> better than web2py or Rails? If he explains we can address it more
> > >> specifically.
>
> > >> Massimo
>
> > >> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>
> > >>> The project I'm working on has hired a consultant who is now 
> > >>> recommending .Net in place of web2py or even rails.
>
> > >>> What's the 'largest' scale web2py is known to perform well on?
>
> > >>> --
> > >>> Lorin Rivers
> > >>> Mosasaur: Killer Technical Marketing 
> > >>> 
> > >>> 512/203.3198 (m)
>
> > --
> > Lorin Rivers
> > Mosasaur: Killer Technical Marketing 
> > 
> > 512/203.3198 (m)


[web2py] Re: Double invert

2010-11-29 Thread iiijjjiii
Thanks for the quick response. Very much appreciated!
Cheers,
Jim Karsten

On Nov 29, 4:34 pm, mdipierro  wrote:
> I apologize for my too quick previous dismissal. On a second thought
> this is a good idea. Your patch is in trunk.
>
> massimo
>


Re: [web2py] Re: Beginner Auth problem

2010-11-29 Thread appydev
Massimo apology, no understand.

Sorry if poorly formulated question, do not speak English and use google to
translate.

The registration form I made. working, and stored in the database correctly.

My doubts began when I realized I lost functionality with respect to the
registration form by default.

also not to create a group for new users[1], Is there any other
functionality that is lost when working as I am doing?
Am I doing my application less secure, creating myself my registration form?

___

1  Authorization

Once a new user is registered, a new group is created to contain the user.
The role of the new user is conventionally "user_[id]" where [id] is the id
of the newly created id. The creation of the group can be disabled with

auth.settings.create_user_groups = False

although we do not suggest doing so.




2010/11/29 mdipierro 

> Lots.
>
> this
>
> form=SQLFORM.factory (table1, table2)
> form.accepts(...)
>
> will not do any database IO
>
> On Nov 29, 4:28 pm, appydev  wrote:
> > Greetings.
> >
> > As above. I wanted to build a registration form to fill two tables,
> > auth_user and teacher.
> >
> > I use SQLFORM.factory (table1, table2) to create the form.
> http://www.web2pyslices.com/main/slices/take_slice/102to fill the tables.
> > And auth.settings.actions_disabled = ['register'] to disable the
> > registration form created by default.
> > (Thanks again to massimo and to mr.freeze)
> >
> > But later I realized that this way is no longer created a new group to
> > contain the user, automatically.
> > As is indicated by:
> > auth.settings.create_user_groups = True
> >
> > My question is:
> >
> > Is there any other functionality that is lost when working as I am doing?
> > Am I doing my application less secure, creating myself my registration
> form?
>


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Branko Vukelic
We know .NET will scale to thousands of nodes IF you write the .NET
code right. If you write crappy code (and that's inevitable if you
don't like .NET or you don't know .NET), it will not only NOT run on
thousands of nodes, but will probably crash all of them.

Having said that... if they can help you write better code on .NET
than you currently write in web2py, the above argument turns on you.

On Mon, Nov 29, 2010 at 7:49 PM, Lorin Rivers  wrote:
> Unfortunately, the killing argument is "we know .NET will scale to thousands 
> of nodes, blah, blah, blah".
>
> This from (a guy who's smart and I respect, honestly) who uses his brand-new 
> top-of-the-line 17" MBP to run Windows VMs in Parallels.
>
> On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
>
>> And this without considering "vendor lock-in". web2py can run on a
>> variety of platforms such as windows, macs. Linux and others, same
>> goes for the selection of the back-end database. Much more flexibility
>> under web2py in my opinion and prototyping is much faster in python.
>>
>> On Nov 29, 10:05 am, mdipierro  wrote:
>>> You achieve scalability by replicating the web server behind a load
>>> balancer. This is documented in the book, chapter 11, using HAProxy.
>>> All frameworks work the same way in this respect. web2py has no
>>> intrinsic limitations. The bottle neck is the database connection. All
>>> frameworks have the same problem. You can replicate the database too
>>> and web2py supports multiple database clients with Round-Robin.
>>>
>>> On a small VPS, web2py in average, should execute one page in 20ms.
>>> Depending on how many requests/second you need you can determine how
>>> many servers you need.
>>>
>>> web2py apps run on Google App Engine and that means arbitrary
>>> scalability as long as you can live with the constraints imposed by
>>> the Google datastore (these limitations will go away as soon as Google
>>> releases MySQL in the cloud, which they announced some time ago).
>>>
>>> Please ask the consultant: which .NET feature makes it scale any
>>> better than web2py or Rails? If he explains we can address it more
>>> specifically.
>>>
>>> Massimo
>>>
>>> On Nov 29, 11:56 am, Lorin Rivers  wrote:
>>>
>>>
>>>
 The project I'm working on has hired a consultant who is now recommending 
 .Net in place of web2py or even rails.
>>>
 What's the 'largest' scale web2py is known to perform well on?
>>>
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing 
 
 512/203.3198 (m)
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)
>
>
>



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: XMLRPC

2010-11-29 Thread Branko Vukelic
Yup. I definitely mistyped something when I checked the first time.

On Tue, Nov 30, 2010 at 12:59 AM, Branko Vukelic  wrote:
> Hm... I thought I tried that. Might have misses something. I'll check again.
>
> On Mon, Nov 29, 2010 at 2:51 PM, mdipierro  wrote:
>> yes
>>
>> @service.xmlrpc
>> @service.jsonrpc
>> def f(a,b): return a+b
>>
>> On Nov 29, 2:19 am, Branko Vukelic  wrote:
>>> On Mon, Nov 29, 2010 at 8:52 AM, Branko Vukelic  wrote:
>>> > Thanks. Thats this mean one can run multiple services using the same
>>> > controller method?
>>>
>>> I guess not.
>>>
>>> --
>>> Branko Vukelić
>>>
>>> bg.bra...@gmail.com
>>> stu...@brankovukelic.com
>>>
>>> Check out my blog:http://www.brankovukelic.com/
>>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>>> Registered Linux user #438078 (http://counter.li.org/)
>>> I hang out on identi.ca:http://identi.ca/foxbunny
>>>
>>> Gimp Brushmakers Guildhttp://bit.ly/gbg-group
>
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The number of people that can write code better than I can is close to the 
number of people who CAN write code…

On Nov 29, 2010, at 17:08 , Branko Vukelic wrote:

> We know .NET will scale to thousands of nodes IF you write the .NET
> code right. If you write crappy code (and that's inevitable if you
> don't like .NET or you don't know .NET), it will not only NOT run on
> thousands of nodes, but will probably crash all of them.
> 
> Having said that... if they can help you write better code on .NET
> than you currently write in web2py, the above argument turns on you.
> 
> On Mon, Nov 29, 2010 at 7:49 PM, Lorin Rivers  wrote:
>> Unfortunately, the killing argument is "we know .NET will scale to thousands 
>> of nodes, blah, blah, blah".
>> 
>> This from (a guy who's smart and I respect, honestly) who uses his brand-new 
>> top-of-the-line 17" MBP to run Windows VMs in Parallels.
>> 
>> On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
>> 
>>> And this without considering "vendor lock-in". web2py can run on a
>>> variety of platforms such as windows, macs. Linux and others, same
>>> goes for the selection of the back-end database. Much more flexibility
>>> under web2py in my opinion and prototyping is much faster in python.
>>> 
>>> On Nov 29, 10:05 am, mdipierro  wrote:
 You achieve scalability by replicating the web server behind a load
 balancer. This is documented in the book, chapter 11, using HAProxy.
 All frameworks work the same way in this respect. web2py has no
 intrinsic limitations. The bottle neck is the database connection. All
 frameworks have the same problem. You can replicate the database too
 and web2py supports multiple database clients with Round-Robin.
 
 On a small VPS, web2py in average, should execute one page in 20ms.
 Depending on how many requests/second you need you can determine how
 many servers you need.
 
 web2py apps run on Google App Engine and that means arbitrary
 scalability as long as you can live with the constraints imposed by
 the Google datastore (these limitations will go away as soon as Google
 releases MySQL in the cloud, which they announced some time ago).
 
 Please ask the consultant: which .NET feature makes it scale any
 better than web2py or Rails? If he explains we can address it more
 specifically.
 
 Massimo
 
 On Nov 29, 11:56 am, Lorin Rivers  wrote:
 
 
 
> The project I'm working on has hired a consultant who is now recommending 
> .Net in place of web2py or even rails.
 
> What's the 'largest' scale web2py is known to perform well on?
 
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)
>> 
>> --
>> Lorin Rivers
>> Mosasaur: Killer Technical Marketing 
>> 
>> 512/203.3198 (m)
>> 
>> 
>> 
> 
> 
> 
> -- 
> Branko Vukelić
> 
> bg.bra...@gmail.com
> stu...@brankovukelic.com
> 
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
> 
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




Re: [web2py] Re: XMLRPC

2010-11-29 Thread Branko Vukelic
Hm... I thought I tried that. Might have misses something. I'll check again.

On Mon, Nov 29, 2010 at 2:51 PM, mdipierro  wrote:
> yes
>
> @service.xmlrpc
> @service.jsonrpc
> def f(a,b): return a+b
>
> On Nov 29, 2:19 am, Branko Vukelic  wrote:
>> On Mon, Nov 29, 2010 at 8:52 AM, Branko Vukelic  wrote:
>> > Thanks. Thats this mean one can run multiple services using the same
>> > controller method?
>>
>> I guess not.
>>
>> --
>> Branko Vukelić
>>
>> bg.bra...@gmail.com
>> stu...@brankovukelic.com
>>
>> Check out my blog:http://www.brankovukelic.com/
>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> Registered Linux user #438078 (http://counter.li.org/)
>> I hang out on identi.ca:http://identi.ca/foxbunny
>>
>> Gimp Brushmakers Guildhttp://bit.ly/gbg-group



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: Orbited with web2py

2010-11-29 Thread Albert Abril
What differences has Orbited with Comet? Or is it related?


On Mon, Nov 29, 2010 at 9:27 PM, Candid  wrote:

> I use orbited in one of my company's in-house web2py applications. It
> works great. I did not have to integrate it with web2py though - I use
> it as a completely independent message broker. There are some python
> scripts that run in background and process some stuff and send
> notifications to browser through orbited built-in stomp server. I
> think I used this tutorial to get started:
>
> http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/
>
> On Nov 29, 11:16 am, salbefe  wrote:
> > Hello,
> >
> > I need to push some content in my website in 'real time'. I'm asking
> > if someone had tried orbited (http://orbited.org/). After reading this
> > post: Integrating Orbited with Web App Frameworks (http://orbited.org/
> > blog/2008/09/integrating-orbited-with-web-app-frameworks/) it seems
> > that it should not be any problem of integration with web2py (using
> > STOMP and RabbitMQ).
> >
> > Anyway, I would like to known if someone had used it and if it could
> > post an example.
> >
> > Thank you in advance
>


Re: [web2py] Re: Orbited with web2py

2010-11-29 Thread Albert Abril
What difference has Orbited with Comet? or is it related?
http://en.wikipedia.org/wiki/Comet_(programming)

On Mon, Nov 29, 2010 at 9:27 PM, Candid  wrote:

> I use orbited in one of my company's in-house web2py applications. It
> works great. I did not have to integrate it with web2py though - I use
> it as a completely independent message broker. There are some python
> scripts that run in background and process some stuff and send
> notifications to browser through orbited built-in stomp server. I
> think I used this tutorial to get started:
>
> http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/
>
> On Nov 29, 11:16 am, salbefe  wrote:
> > Hello,
> >
> > I need to push some content in my website in 'real time'. I'm asking
> > if someone had tried orbited (http://orbited.org/). After reading this
> > post: Integrating Orbited with Web App Frameworks (http://orbited.org/
> > blog/2008/09/integrating-orbited-with-web-app-frameworks/) it seems
> > that it should not be any problem of integration with web2py (using
> > STOMP and RabbitMQ).
> >
> > Anyway, I would like to known if someone had used it and if it could
> > post an example.
> >
> > Thank you in advance
>


[web2py] session files, what's in it, how can they be read ?

2010-11-29 Thread Stef Mientki
hello,

session files, what's in it, how can they be read ?
and how is the name of the file generated ?

thanks,
Stef


Re: [web2py] Re: Orbited with web2py

2010-11-29 Thread Jonathan Lundell
On Nov 29, 2010, at 4:32 PM, Albert Abril wrote:
> What difference has Orbited with Comet? or is it related?
> 

Related: http://www.oscon.com/oscon2008/public/schedule/detail/3048

[web2py] Re: session files, what's in it, how can they be read ?

2010-11-29 Thread mdipierro
They are pickle objects. empty by default. The names is generated in
gluon/globals.py line 291

response.session_id = '%s-%s' % (client, uuid)

Massimo


On Nov 29, 6:45 pm, Stef Mientki  wrote:
> hello,
>
> session files, what's in it, how can they be read ?
> and how is the name of the file generated ?
>
> thanks,
> Stef


[web2py] Is there a way within the web2py DAL to create an alternate/secondary surrogate key on the fly?

2010-11-29 Thread SaltyCow
Hello,

I'm new to web2py, so I hope that my first question isn't too crazy.

Perhaps I shouldn't even be trying to do this in the DAL (or at all),
but what I would like to do is create auto-incrementing unique fields
for certain tables, but I do not necessarily want them to be primary
keys.

For example, I have a table "quote" and I would like to be able to
refer to a given quote as something like "Q13". The actual primary
key (id) of the row for that quote may be just plain "3", but it's not
convenient to refer to a quote that way in emails, etc.

I tried to create a computed field using the id of the row, such that
the field would be equal to 'Q' + (id + 10). I tried about 50
permutations of lambda to make this work with no luck, but I'm
thinking now that it's probably the wrong approach.

Any advice would be greatly appreciated.

>Jeff





[web2py] accessible_query implement in GAE.

2010-11-29 Thread appydev
Greetings

Is there any way to do something like this in GAE?

rows = db (auth.accessible_query ('read', db.mytable)). select
(db.mytable.ALL)

Thanks


Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Jason Brower
You may be suprised how good you are.  Especially in such short time you
can improve.  I went from barely scraping up web-pages to some pretty
impressive intra-net sites in just a few months.
.Net will eventually teach you how not to code.  It makes you truly
appriciate web2py.
It's tough to have persuade people that have a big bully behind them.  I
know the feeling, but if you can develop the prototype and you do it
right, you win.  Besides, I wonder if this consultant is coding at all.
His skills to code is directly relative to the statements he makes, at
least to me.
BR,
Jason

On Mon, 2010-11-29 at 18:09 -0600, Lorin Rivers wrote:

> The number of people that can write code better than I can is close to the 
> number of people who CAN write code…
> 
> On Nov 29, 2010, at 17:08 , Branko Vukelic wrote:
> 
> > We know .NET will scale to thousands of nodes IF you write the .NET
> > code right. If you write crappy code (and that's inevitable if you
> > don't like .NET or you don't know .NET), it will not only NOT run on
> > thousands of nodes, but will probably crash all of them.
> > 
> > Having said that... if they can help you write better code on .NET
> > than you currently write in web2py, the above argument turns on you.
> > 
> > On Mon, Nov 29, 2010 at 7:49 PM, Lorin Rivers  wrote:
> >> Unfortunately, the killing argument is "we know .NET will scale to 
> >> thousands of nodes, blah, blah, blah".
> >> 
> >> This from (a guy who's smart and I respect, honestly) who uses his 
> >> brand-new top-of-the-line 17" MBP to run Windows VMs in Parallels.
> >> 
> >> On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
> >> 
> >>> And this without considering "vendor lock-in". web2py can run on a
> >>> variety of platforms such as windows, macs. Linux and others, same
> >>> goes for the selection of the back-end database. Much more flexibility
> >>> under web2py in my opinion and prototyping is much faster in python.
> >>> 
> >>> On Nov 29, 10:05 am, mdipierro  wrote:
>  You achieve scalability by replicating the web server behind a load
>  balancer. This is documented in the book, chapter 11, using HAProxy.
>  All frameworks work the same way in this respect. web2py has no
>  intrinsic limitations. The bottle neck is the database connection. All
>  frameworks have the same problem. You can replicate the database too
>  and web2py supports multiple database clients with Round-Robin.
>  
>  On a small VPS, web2py in average, should execute one page in 20ms.
>  Depending on how many requests/second you need you can determine how
>  many servers you need.
>  
>  web2py apps run on Google App Engine and that means arbitrary
>  scalability as long as you can live with the constraints imposed by
>  the Google datastore (these limitations will go away as soon as Google
>  releases MySQL in the cloud, which they announced some time ago).
>  
>  Please ask the consultant: which .NET feature makes it scale any
>  better than web2py or Rails? If he explains we can address it more
>  specifically.
>  
>  Massimo
>  
>  On Nov 29, 11:56 am, Lorin Rivers  wrote:
>  
>  
>  
> > The project I'm working on has hired a consultant who is now 
> > recommending .Net in place of web2py or even rails.
>  
> > What's the 'largest' scale web2py is known to perform well on?
>  
> > --
> > Lorin Rivers
> > Mosasaur: Killer Technical Marketing 
> > 
> > 512/203.3198 (m)
> >> 
> >> --
> >> Lorin Rivers
> >> Mosasaur: Killer Technical Marketing 
> >> 
> >> 512/203.3198 (m)
> >> 
> >> 
> >> 
> > 
> > 
> > 
> > -- 
> > Branko Vukelić
> > 
> > bg.bra...@gmail.com
> > stu...@brankovukelic.com
> > 
> > Check out my blog: http://www.brankovukelic.com/
> > Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> > Registered Linux user #438078 (http://counter.li.org/)
> > I hang out on identi.ca: http://identi.ca/foxbunny
> > 
> > Gimp Brushmakers Guild
> > http://bit.ly/gbg-group
> 




Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Jason Brower
I did prototype in 2.5 weeks that would have taken months on Apache
Tomcat (what they were currently using).
And the company was massive, KONE.  The content had to handle thousands
of requests, work with 2 database times and lots of XML, and be easy to
use and expand.  I am not there now, but to this day they have always
been impress with how fast I was able to code. (I am still buddies with
the guys.)
BR,
Jason

On Mon, 2010-11-29 at 14:46 -0800, Christopher Steel wrote:

> +1
> 
> I agree, Web2py is excellent for low cost prototyping, much less
> than .NET and you will actually have something that works...
> 
> I hear that these guys can kick one out in under a month ->
> http://experts4solutions.com/
> 
> ; )
> 
> Chris
> 
> On Nov 29, 2:51 pm, mdipierro  wrote:
> > Some political considerations (which may be wrong and off topic and
> > improper)...
> >
> > Here is a problem with external consultants. They make more per hours
> > than the average employees. They get hired because of their specific
> > expertise to tell you what the boss wants to say but he prefers
> > somebody else to say (so he does not take the responsibility for
> > saying it).
> >
> > You cannot win this argument on technical merits. I would dismiss this
> > argument and point to Google as a scalability example and it is not
> > written in .net. I would address the real concern... you push web2py
> > therefore you are a single point of failure. If you leave who takes
> > care of this software? Not a problem with .net, they can always hire a
> > consultant.
> >
> > I would stress that using web2py is good for rapid prototyping and it
> > will allow the company to have a test product much sooner than
> > with .net and at much lower cost. Once the prototype is built you will
> > be in a better situation to assess whether web2py or .net is the best
> > tool for the job. If you start developing in .net you will have higher
> > startup costs and limited flexibility to change the specs. web2py code
> > is much more compact and readable than .net code and it will be easier
> > to train other people to work with it and learn how it works than
> > with .net. Tell them experts4solutions.com can sell them long term
> > support contracts and code review.
> >
> > The scalability bottle neck is the database. Offer something to the
> > consultant. .net uses mssql. If he claims mssql scales well for your
> > case, web2py will use mssql.
> >
> > If mssql does not scale well with web2py you have other options and do
> > not need to rewrite code.
> >
> > You can always reuse most of the design (html, js, css, images).
> >
> > Management costs. I am sure you can make the case it costs less to run
> > linux vps than windows ones (although I have no experience with the
> > latter).
> >
> > Massimo
> >
> > On Nov 29, 12:49 pm, Lorin Rivers  wrote:> 
> > Unfortunately, the killing argument is "we know .NET will scale to 
> > thousands of nodes, blah, blah, blah".
> >
> > > This from (a guy who's smart and I respect, honestly) who uses his 
> > > brand-new top-of-the-line 17" MBP to run Windows VMs in Parallels.
> >
> > > On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
> >
> > > > And this without considering "vendor lock-in". web2py can run on a
> > > > variety of platforms such as windows, macs. Linux and others, same
> > > > goes for the selection of the back-end database. Much more flexibility
> > > > under web2py in my opinion and prototyping is much faster in python.
> >
> > > > On Nov 29, 10:05 am, mdipierro  wrote:
> > > >> You achieve scalability by replicating the web server behind a load
> > > >> balancer. This is documented in the book, chapter 11, using HAProxy.
> > > >> All frameworks work the same way in this respect. web2py has no
> > > >> intrinsic limitations. The bottle neck is the database connection. All
> > > >> frameworks have the same problem. You can replicate the database too
> > > >> and web2py supports multiple database clients with Round-Robin.
> >
> > > >> On a small VPS, web2py in average, should execute one page in 20ms.
> > > >> Depending on how many requests/second you need you can determine how
> > > >> many servers you need.
> >
> > > >> web2py apps run on Google App Engine and that means arbitrary
> > > >> scalability as long as you can live with the constraints imposed by
> > > >> the Google datastore (these limitations will go away as soon as Google
> > > >> releases MySQL in the cloud, which they announced some time ago).
> >
> > > >> Please ask the consultant: which .NET feature makes it scale any
> > > >> better than web2py or Rails? If he explains we can address it more
> > > >> specifically.
> >
> > > >> Massimo
> >
> > > >> On Nov 29, 11:56 am, Lorin Rivers  wrote:
> >
> > > >>> The project I'm working on has hired a consultant who is now 
> > > >>> recommending .Net in place of web2py or even rails.
> >
> > > >>> What's the 'largest' scale web2py is known to perform well on?
> >
> > > >>> --
> > > >>> Lorin 

[web2py] Re: T with variables

2010-11-29 Thread Richard
That translate app relies on writing to the file system to update a
language file.
What about for Google App Engine, where file writes are not allowed?
Is it possible to store translations in the database instead?


On Nov 27, 4:33 am, mdipierro  wrote:
> I see. There is this very old app:http://web2py.com/appliances/default/show/9
>
> that allows users permissions only totranslate.
>
> It should be revamped and:
> 1) change the edit language page to the new one
> 2) integrate with auth
> 3) allow administrator to assign languages to auth_users
>
> It is a 1h job to a skilled web2py programmer. It would be nice to
> have this functionality.
> It is in my queue but my todo queue is long today so I will take help
> with this one.
>
> adopt this appliance!
>
> massimo
>
> On Nov 26, 11:27 am, Carlos  wrote:
>
> > Hi Massimo,
>
> > I believe the T.set_current_languages you propose refers to viewing
> > the website in a specific language for a certain user.
>
> > What I'm asking for is a way to edit the language files (as regular
> >webapps, not appadmin) with authorization, e.g. userA can only edit
> > 'en' language, userB can only edit 'es' language, and so on.
>
> > Such that we can assign the "translator" role to users for specific
> > languages.
>
> > Thanks,
>
> >    Carlos
>
> > On Nov 25, 9:58 pm, mdipierro  wrote:
>
> > > yes. Make a custom auth_user table with an extra 'language' field and
> > > then do
>
> > > if auth.user: T.set_current_language(auth.user.language)
>
> > > On Nov 25, 12:06 pm, Carlos  wrote:
>
> > > > Thanks Massimo.
>
> > > > Btw is it possible to update the language files viawebapps with
> > > > authorization (e.g. userA can only update english, userB only spanish,
> > > > and so on)?.
>
> > > >    Carlos
>
> > > > On Nov 25, 11:33 am, mdipierro  wrote:
>
> > > > > This is a good idea. All you need to do is:
>
> > > > > T.current_languages=[]
>
> > > > > in this way even english will require translation.
>
> > > > > Massimo
>
> > > > > On Nov 25, 11:30 am, Carlos  wrote:
>
> > > > > > Hi,
>
> > > > > > Please let me know if the following makes sense:
>
> > > > > > I want to implement internationalization using always keys (codes) 
> > > > > > for
> > > > > > all T() occurrences, instead of using strings corresponding to one
> > > > > > specific default language.
>
> > > > > > I believe this is necessary (please correct me if I'm wrong) in the
> > > > > > following scenario: if I use 'en' as the default language and I wan 
> > > > > > to
> > > > > > use T('please enter your info'), then I cantranslatethis string to
> > > > > > all other languages, BUT what would happen if I need to change the
> > > > > > translated string in english (e.g. from "please enter your info" to
> > > > > > "please type your info")?, then all other languages for that 
> > > > > > specific
> > > > > > translation will be gone (out or sync), correct?.
>
> > > > > > If we use keys/codes (instead of a default language), and require to
> > > > > >translateALL languages (including 'en'), then I could make this
> > > > > > change without affecting all other languages, right?.
>
> > > > > > Do you see any problems with this approach?, do you have any
> > > > > > recommendations?.
>
> > > > > > Thanks,
>
> > > > > >    Carlos
>
> > > > > > On Nov 25, 10:36 am, mdipierro  wrote:
>
> > > > > > > Not for T(variable) since variable is only defined at runtime.
>
> > > > > > > On Nov 25, 10:24 am, Carlos  wrote:
>
> > > > > > > > Hi Massimo,
>
> > > > > > > > Thanks, it now works ok with T.force.
>
> > > > > > > > Is there a way to automatically update multiple language files 
> > > > > > > > at once
> > > > > > > > with all these lazy T's?.
>
> > > > > > > >    Carlos
>
> > > > > > > > On Nov 25, 10:00 am, mdipierro  wrote:
>
> > > > > > > > > Update all languages will not catch this because this can 
> > > > > > > > > only be
> > > > > > > > > caught at run-time. The string should be added in the 
> > > > > > > > > language file
> > > > > > > > > when you run the action (and the browser set to the language 
> > > > > > > > > needing
> > > > > > > > > translation).
>
> > > > > > > > > try again, check the language file timestamp. If the file is 
> > > > > > > > > not being
> > > > > > > > > updated, may be a permission issue.
>
> > > > > > > > > On Nov 25, 9:48 am, Carlos  wrote:
>
> > > > > > > > > > Hi,
>
> > > > > > > > > > I am trying to make internationalization work with 
> > > > > > > > > > variables, in my
> > > > > > > > > > local environment on Win7, with web2py 1.89.1.
>
> > > > > > > > > > For reference I have the following test controller:
>
> > > > > > > > > > def xyz():
> > > > > > > > > >     x = 'xyz'
> > > > > > > > > >     return T(x)
>
> > > > > > > > > > But after calling that method, when I look at any of the 
> > > > > > > > > > language
> > > > > > > > > > files, the string 'xyz' is not there, even after executing 
> > > > > > > > > > "update all
> > > > > > > > > > languages".
>
> > > > > > > > 

[web2py] Any web2py/python web developers in Salt Lake City?

2010-11-29 Thread cadrentes
I've been learning but too slowly to put together the application I
envision, not my main job...looking for someone who can help.


[web2py] Re: accessible_query implement in GAE.

2010-11-29 Thread mdipierro
Not yet.

On Nov 29, 9:38 pm, appydev  wrote:
> Greetings
>
> Is there any way to do something like this in GAE?
>
> rows = db (auth.accessible_query ('read', db.mytable)). select
> (db.mytable.ALL)
>
> Thanks


[web2py] Re: Scalability of web2py?

2010-11-29 Thread mdipierro
I second!

On Nov 29, 10:31 pm, Jason Brower  wrote:
> You may be suprised how good you are.  Especially in such short time you
> can improve.  I went from barely scraping up web-pages to some pretty
> impressive intra-net sites in just a few months.
> .Net will eventually teach you how not to code.  It makes you truly
> appriciate web2py.
> It's tough to have persuade people that have a big bully behind them.  I
> know the feeling, but if you can develop the prototype and you do it
> right, you win.  Besides, I wonder if this consultant is coding at all.
> His skills to code is directly relative to the statements he makes, at
> least to me.
> BR,
> Jason
>
> On Mon, 2010-11-29 at 18:09 -0600, Lorin Rivers wrote:
> > The number of people that can write code better than I can is close to the 
> > number of people who CAN write code…
>
> > On Nov 29, 2010, at 17:08 , Branko Vukelic wrote:
>
> > > We know .NET will scale to thousands of nodes IF you write the .NET
> > > code right. If you write crappy code (and that's inevitable if you
> > > don't like .NET or you don't know .NET), it will not only NOT run on
> > > thousands of nodes, but will probably crash all of them.
>
> > > Having said that... if they can help you write better code on .NET
> > > than you currently write in web2py, the above argument turns on you.
>
> > > On Mon, Nov 29, 2010 at 7:49 PM, Lorin Rivers  
> > > wrote:
> > >> Unfortunately, the killing argument is "we know .NET will scale to 
> > >> thousands of nodes, blah, blah, blah".
>
> > >> This from (a guy who's smart and I respect, honestly) who uses his 
> > >> brand-new top-of-the-line 17" MBP to run Windows VMs in Parallels.
>
> > >> On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
>
> > >>> And this without considering "vendor lock-in". web2py can run on a
> > >>> variety of platforms such as windows, macs. Linux and others, same
> > >>> goes for the selection of the back-end database. Much more flexibility
> > >>> under web2py in my opinion and prototyping is much faster in python.
>
> > >>> On Nov 29, 10:05 am, mdipierro  wrote:
> >  You achieve scalability by replicating the web server behind a load
> >  balancer. This is documented in the book, chapter 11, using HAProxy.
> >  All frameworks work the same way in this respect. web2py has no
> >  intrinsic limitations. The bottle neck is the database connection. All
> >  frameworks have the same problem. You can replicate the database too
> >  and web2py supports multiple database clients with Round-Robin.
>
> >  On a small VPS, web2py in average, should execute one page in 20ms.
> >  Depending on how many requests/second you need you can determine how
> >  many servers you need.
>
> >  web2py apps run on Google App Engine and that means arbitrary
> >  scalability as long as you can live with the constraints imposed by
> >  the Google datastore (these limitations will go away as soon as Google
> >  releases MySQL in the cloud, which they announced some time ago).
>
> >  Please ask the consultant: which .NET feature makes it scale any
> >  better than web2py or Rails? If he explains we can address it more
> >  specifically.
>
> >  Massimo
>
> >  On Nov 29, 11:56 am, Lorin Rivers  wrote:
>
> > > The project I'm working on has hired a consultant who is now 
> > > recommending .Net in place of web2py or even rails.
>
> > > What's the 'largest' scale web2py is known to perform well on?
>
> > > --
> > > Lorin Rivers
> > > Mosasaur: Killer Technical Marketing 
> > > 
> > > 512/203.3198 (m)
>
> > >> --
> > >> Lorin Rivers
> > >> Mosasaur: Killer Technical Marketing 
> > >> 
> > >> 512/203.3198 (m)
>
> > > --
> > > Branko Vukelić
>
> > > bg.bra...@gmail.com
> > > stu...@brankovukelic.com
>
> > > Check out my blog:http://www.brankovukelic.com/
> > > Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> > > Registered Linux user #438078 (http://counter.li.org/)
> > > I hang out on identi.ca:http://identi.ca/foxbunny
>
> > > Gimp Brushmakers Guild
> > >http://bit.ly/gbg-group
>
>


[web2py] Re: Is there a way within the web2py DAL to create an alternate/secondary surrogate key on the fly?

2010-11-29 Thread cjrh
On Nov 30, 1:37 am, SaltyCow  wrote:
> For example, I have a table "quote" and I would like to be able to
> refer to a given quote as something like "Q13". The actual primary
> key (id) of the row for that quote may be just plain "3", but it's not
> convenient to refer to a quote that way in emails, etc.

I had to do something similar recently: auto-create a "password"-like
key in a record (created as a sub-component of uuid.uuid4()), but only
on record creation.  The problem with compute() is that it runs every
time a record is updated, and the dict passed to the compute()
function does not contain the current value of the field being
computed, so you can't monitor that for deciding whether or not to
create a new one.

OTOH, if you're always going to base your number on the PK, then the
PK will never change and therefore compute() should be fine, because
your compute function will always calculate the same output for a
given record.

Perhaps something like this:

Field('myfield', compute=lambda d: 'Q' + str(d['id'] + 1))

(Post your code for your compute() function implementation)

In the end, for my scenario, we just wrote a custom validator.  I
don't have the code handy right now, but the book description of
validators is reasonable, so that should be enough to get you started
if compute() is insufficient for your needs.


[web2py] xml advise

2010-11-29 Thread Johann Spies
I have been busy with web2py for about a year and I am learning every day.
I am also a newby as far as xml-processing is concerned.  So I would like
advice about the way to go with the following setup:

I want to import xml-data collected through a soap client into a database.
This will involve several tables and thousands of complicated
bibliographical records.

I can process the xml-data outside web2py and import the processed data at a
later stage or I can do the soap queries from web2py and handle the
processing  of the data there.

I have experimented a little with python-soap and suds en after many trials
and errors I have a working SOAP client using suds.

Now my questions:

1. What is the best strategy to integrate this process with web2py?
2. Which python-xml-tools (and I see there are a lot) are preferable in my
situation.
3. Can I use suds from within web2py?

Regards
Johann




-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: xml advise

2010-11-29 Thread mdipierro
Mind that web2py has built-in soap implementation

web2py/gluon/contrib/pysimplesoap/

and you can create services with

@service.soap(...)
def f(a,b): return a+b

Mariano is the expert on this.

On Nov 30, 1:24 am, Johann Spies  wrote:
> I have been busy with web2py for about a year and I am learning every day.
> I am also a newby as far as xml-processing is concerned.  So I would like
> advice about the way to go with the following setup:
>
> I want to import xml-data collected through a soap client into a database.
> This will involve several tables and thousands of complicated
> bibliographical records.
>
> I can process the xml-data outside web2py and import the processed data at a
> later stage or I can do the soap queries from web2py and handle the
> processing  of the data there.
>
> I have experimented a little with python-soap and suds en after many trials
> and errors I have a working SOAP client using suds.
>
> Now my questions:
>
> 1. What is the best strategy to integrate this process with web2py?
> 2. Which python-xml-tools (and I see there are a lot) are preferable in my
> situation.
> 3. Can I use suds from within web2py?
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a


[web2py] Re: Orbited with web2py

2010-11-29 Thread salbefe
Thanks Candid !

It's a really good post to get started.


On 29 nov, 22:27, Candid  wrote:
> I use orbited in one of my company's in-house web2py applications. It
> works great. I did not have to integrate it with web2py though - I use
> it as a completely independent message broker. There are some python
> scripts that run in background and process some stuff and send
> notifications to browser through orbited built-in stomp server. I
> think I used this tutorial to get 
> started:http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-...
>
> On Nov 29, 11:16 am, salbefe  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I need to push some content in my website in 'real time'. I'm asking
> > if someone had tried orbited (http://orbited.org/). After reading this
> > post: Integrating Orbited with Web App Frameworks (http://orbited.org/
> > blog/2008/09/integrating-orbited-with-web-app-frameworks/) it seems
> > that it should not be any problem of integration with web2py (using
> > STOMP and RabbitMQ).
>
> > Anyway, I would like to known if someone had used it and if it could
> > post an example.
>
> > Thank you in advance


Re: [web2py] Re: xml advise

2010-11-29 Thread Johann Spies
On 30 November 2010 09:30, mdipierro  wrote:

> Mind that web2py has built-in soap implementation
>
> web2py/gluon/contrib/pysimplesoap/
>
> and you can create services with
>
> @service.soap(...)
> def f(a,b): return a+b
>
> Mariano is the expert on this.
>
>
Thanks.  At this stage I am only interested in the client-side of SOAP.  I
will look at pysimplesoap and wait for Mariano's reaction.

Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a