[web2py] Re: Is anyone using MongoDB with web2py?

2010-05-08 Thread David Marko
Thank you for your response. I still have the problem with the
connection object to MongoDB as stated in my first post. Where to put
the lines establishing the connection?

-
If I put the code below into db.py, each request causes the new
connection opened to MongoDB what mean that after 500 requests to my
app, there are 500 separate connections I can see on MongoDB console.

>>> from pymongo import Connection
>>> connection = Connection()

Where to put the connection code to have some pooling mechanism so
connection is shared among requests?
-

David

On 9 kvě, 05:43, Yarko Tymciurak  wrote:
> On May 8, 12:40 pm, David Marko  wrote:
>
> > Yes, I know, but you should be able to use it without DAL using
> > pymongo as a primary MongoDB python driver. And thats where my
> > question goes.
>
> If you want to experiement, and get a start, I suggest you write your
> scaffolding app without / with minimal data, and see if you can live
> with just using FORM, and managing your own validation.  That would be
> a first step.
>
> Then, - if you kept your scaffolding data really basic,  it should be
> easy to shift to pyMongo - your queries are going to be quite
> different so that is probably the next piece of work you will have: to
> manage how you make reasonably compact queries that work, and look
> "familiar".
>
> Next, I imagine you will tackle managing the validation on those
> queries, and tying that into your forms.
>
> By then, you might as well adapt things that look like the SQLFORMS,
> possibly borrowing, rewriting them
>
> Of course, this will all be much easier once someone has blazed this
> trail, and you will have at least a head start on a NoDAL environment.
>
> As long as you take it in small steps, you will at least see what
> you're in for.
>
> Let us know how your excursions go!
>
> Regards,
> - Yarko
>
>
>
>
>
> > David
>
> > On 8 kvě, 19:22, Pystar  wrote:
>
> > > For now, Web2py's DAL doesnt support NoSQL databases. I think Massimo
> > > can tell us more on the status of the DAL rewrite and when it would be
> > > possible.
>
> > > On May 8, 5:59 pm, David Marko  wrote:
>
> > > > Is anyone using MongoDB with web2py? How do you 'share' connection
> > > > object in your app when using pymongo?
>
> > > > If I put the code below into db.py, each request causes the new
> > > > connection opened to MongoDB what mean that after 500 requests to my
> > > > app, there are 500 separate connections I can see on MongoDB console.
>
> > > > >>> from pymongo import Connection
> > > > >>> connection = Connection()
>
> > > > Where to put the connection code to have some pooling mechanism so
> > > > connection is shared among requests?
>
> > > > David


Re: [web2py] Re: Why not session['key'] ?

2010-05-08 Thread Thadeus Burgess
The reason is

session.button1 returns None if the key is not found whereas
session['button1'] raises an exception when the key is not found.

This is typically python behavior.

--
Thadeus





On Sat, May 8, 2010 at 11:44 PM, ionel  wrote:
> I think I found a bug.
>
> Traceback (most recent call last):
>  File "G:\dev\proj\python\web2py\gluon\restricted.py", line 178, in
> restricted
>    exec ccode in environment
>  File "G:\dev\proj\python\web2py\applications\myapp/views\default/
> index.html", line 97, in 
>  KeyError: 'button1'
>
> If you don't have any session file in the session folder
> session['button1'] it is not working, but session.button1 it does.
> You need to delete all the session files to replicate the bug.
>
> Thanks.
>
> ionel
>
>
> On May 9, 12:05 am, ionel  wrote:
>> Mea culpa!
>>
>> Yes, they are equivalent. My key was empty... sorry. I think I'm
>> tired...
>>
>> Thank you very much.
>>
>> ionel
>>
>> On May 8, 11:27 pm, mdipierro  wrote:
>>
>> > They should be equivalent. Can you show the traceback?
>>
>> > On May 8, 9:54 pm, ionel  wrote:
>>
>> > > But I allready did that... and its working...
>>
>> > > Something like that:
>>
>> > > if not session.c:
>> > >     c = MyClass()
>> > >     session.c = c
>> > > else:
>> > >     c = session.c
>>
>> > > But my question was why I cannot use session['c'] instead of session.c
>>
>> > > Thank you!
>>
>> > > i
>>
>> > > On May 8, 9:31 pm, mdipierro  wrote:
>>
>> > > > You cannot store your own classes in the session because the session
>> > > > is retrieved before your own classes are defined. You can only store
>> > > > in session primitive types. You can serialize your objects yourself.
>>
>> > > > On May 8, 7:30 pm, ionel  wrote:
>>
>> > > > > Hello,
>>
>> > > > > I'd like to have something like that:
>>
>> > > > > class MyClass():
>> > > > >    def __init__(self, id)
>> > > > >        self.id = id
>>
>> > > > > c = MyClass('some_id')
>>
>> > > > > session[c.id] = c
>>
>> > > > > I do not see a solution for this.
>> > > > > Can somebody help me?
>>
>> > > > > Thanks.
>>
>> > > > > i.
>


[web2py] Re: Why not session['key'] ?

2010-05-08 Thread ionel
I think I found a bug.

Traceback (most recent call last):
  File "G:\dev\proj\python\web2py\gluon\restricted.py", line 178, in
restricted
exec ccode in environment
  File "G:\dev\proj\python\web2py\applications\myapp/views\default/
index.html", line 97, in 
  KeyError: 'button1'

If you don't have any session file in the session folder
session['button1'] it is not working, but session.button1 it does.
You need to delete all the session files to replicate the bug.

Thanks.

ionel


On May 9, 12:05 am, ionel  wrote:
> Mea culpa!
>
> Yes, they are equivalent. My key was empty... sorry. I think I'm
> tired...
>
> Thank you very much.
>
> ionel
>
> On May 8, 11:27 pm, mdipierro  wrote:
>
> > They should be equivalent. Can you show the traceback?
>
> > On May 8, 9:54 pm, ionel  wrote:
>
> > > But I allready did that... and its working...
>
> > > Something like that:
>
> > > if not session.c:
> > >     c = MyClass()
> > >     session.c = c
> > > else:
> > >     c = session.c
>
> > > But my question was why I cannot use session['c'] instead of session.c
>
> > > Thank you!
>
> > > i
>
> > > On May 8, 9:31 pm, mdipierro  wrote:
>
> > > > You cannot store your own classes in the session because the session
> > > > is retrieved before your own classes are defined. You can only store
> > > > in session primitive types. You can serialize your objects yourself.
>
> > > > On May 8, 7:30 pm, ionel  wrote:
>
> > > > > Hello,
>
> > > > > I'd like to have something like that:
>
> > > > > class MyClass():
> > > > >    def __init__(self, id)
> > > > >        self.id = id
>
> > > > > c = MyClass('some_id')
>
> > > > > session[c.id] = c
>
> > > > > I do not see a solution for this.
> > > > > Can somebody help me?
>
> > > > > Thanks.
>
> > > > > i.


[web2py] Re: Why not session['key'] ?

2010-05-08 Thread ionel
Mea culpa!

Yes, they are equivalent. My key was empty... sorry. I think I'm
tired...

Thank you very much.

ionel


On May 8, 11:27 pm, mdipierro  wrote:
> They should be equivalent. Can you show the traceback?
>
> On May 8, 9:54 pm, ionel  wrote:
>
> > But I allready did that... and its working...
>
> > Something like that:
>
> > if not session.c:
> >     c = MyClass()
> >     session.c = c
> > else:
> >     c = session.c
>
> > But my question was why I cannot use session['c'] instead of session.c
>
> > Thank you!
>
> > i
>
> > On May 8, 9:31 pm, mdipierro  wrote:
>
> > > You cannot store your own classes in the session because the session
> > > is retrieved before your own classes are defined. You can only store
> > > in session primitive types. You can serialize your objects yourself.
>
> > > On May 8, 7:30 pm, ionel  wrote:
>
> > > > Hello,
>
> > > > I'd like to have something like that:
>
> > > > class MyClass():
> > > >    def __init__(self, id)
> > > >        self.id = id
>
> > > > c = MyClass('some_id')
>
> > > > session[c.id] = c
>
> > > > I do not see a solution for this.
> > > > Can somebody help me?
>
> > > > Thanks.
>
> > > > i.


[web2py] Re: Calculation error

2010-05-08 Thread greenpoise
Ok, Will try. Thanks



On May 8, 11:39 pm, mdipierro  wrote:
> P.S. perhaps this should be changed. Decimal is not used very much and
> not supported well on sqlite at all. I would use float.
>
> On May 8, 10:38 pm, mdipierro  wrote:
>
> > There are two problems:
> > 1)  order is reserved keyword.
> > 2) decimal types are treated as string internally and there for
> > compute should be
>
> > db.order.tipgranted.compute=lambda r:
> > float(r['totalsale'])*float(r['tipvalue'])
>
> > or better
>
> > db.order.tipgranted.compute=lambda r:
> > decimal.Decimal(r['totalsale'])*decimal.Decimal(r['tipvalue'])
>
> > On May 8, 10:00 pm, greenpoise  wrote:
>
> > > Model:
>
> > > db.define_table('order',
> > >     Field('employee',db.person),
> > >     Field('tablenumber'),
> > >     Field('ordernumber'),
> > >     Field('orderdate','date'),
> > >     Field('totalsale', 'decimal(10,2)'),
> > >     Field('tipgranted', 'decimal(10,2)',default=None, update=None,
> > > readable=False),
> > >     Field('tipvalue','decimal(10,2)',default='0.15'),)
>
> > > @auth.requires_login()
> > > def show_orders():
> > >     db.order.tipgranted.compute=lambda r:
> > > r['totalsale']*r['tipvalue']
> > >     form=crud.create(db.order)
>
> > > orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumber)
> > >     return dict(employee=employee,orders=orders,form=form)
>
> > > thanks
>
> > > On May 8, 10:54 pm, mdipierro  wrote:
>
> > > > Can you show us the model and the action that triggers this?
>
> > > > On May 8, 9:49 pm, greenpoise  wrote:
>
> > > > > Can someone help me. I am trying to do a simple calculation of fields.
> > > > > Fields are defined as decimal in db.py and here is the calculation:
>
> > > > >     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> > > > > error: TypeError: can't multiply sequence by non-int of type 'float'


[web2py] Re: Is anyone using MongoDB with web2py?

2010-05-08 Thread Yarko Tymciurak
On May 8, 12:40 pm, David Marko  wrote:
> Yes, I know, but you should be able to use it without DAL using
> pymongo as a primary MongoDB python driver. And thats where my
> question goes.

If you want to experiement, and get a start, I suggest you write your
scaffolding app without / with minimal data, and see if you can live
with just using FORM, and managing your own validation.  That would be
a first step.

Then, - if you kept your scaffolding data really basic,  it should be
easy to shift to pyMongo - your queries are going to be quite
different so that is probably the next piece of work you will have: to
manage how you make reasonably compact queries that work, and look
"familiar".

Next, I imagine you will tackle managing the validation on those
queries, and tying that into your forms.

By then, you might as well adapt things that look like the SQLFORMS,
possibly borrowing, rewriting them

Of course, this will all be much easier once someone has blazed this
trail, and you will have at least a head start on a NoDAL environment.

As long as you take it in small steps, you will at least see what
you're in for.

Let us know how your excursions go!

Regards,
- Yarko
>
> David
>
> On 8 kvě, 19:22, Pystar  wrote:
>
> > For now, Web2py's DAL doesnt support NoSQL databases. I think Massimo
> > can tell us more on the status of the DAL rewrite and when it would be
> > possible.
>
> > On May 8, 5:59 pm, David Marko  wrote:
>
> > > Is anyone using MongoDB with web2py? How do you 'share' connection
> > > object in your app when using pymongo?
>
> > > If I put the code below into db.py, each request causes the new
> > > connection opened to MongoDB what mean that after 500 requests to my
> > > app, there are 500 separate connections I can see on MongoDB console.
>
> > > >>> from pymongo import Connection
> > > >>> connection = Connection()
>
> > > Where to put the connection code to have some pooling mechanism so
> > > connection is shared among requests?
>
> > > David


[web2py] Re: Calculation error

2010-05-08 Thread mdipierro
P.S. perhaps this should be changed. Decimal is not used very much and
not supported well on sqlite at all. I would use float.

On May 8, 10:38 pm, mdipierro  wrote:
> There are two problems:
> 1)  order is reserved keyword.
> 2) decimal types are treated as string internally and there for
> compute should be
>
> db.order.tipgranted.compute=lambda r:
> float(r['totalsale'])*float(r['tipvalue'])
>
> or better
>
> db.order.tipgranted.compute=lambda r:
> decimal.Decimal(r['totalsale'])*decimal.Decimal(r['tipvalue'])
>
> On May 8, 10:00 pm, greenpoise  wrote:
>
> > Model:
>
> > db.define_table('order',
> >     Field('employee',db.person),
> >     Field('tablenumber'),
> >     Field('ordernumber'),
> >     Field('orderdate','date'),
> >     Field('totalsale', 'decimal(10,2)'),
> >     Field('tipgranted', 'decimal(10,2)',default=None, update=None,
> > readable=False),
> >     Field('tipvalue','decimal(10,2)',default='0.15'),)
>
> > @auth.requires_login()
> > def show_orders():
> >     db.order.tipgranted.compute=lambda r:
> > r['totalsale']*r['tipvalue']
> >     form=crud.create(db.order)
>
> > orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumber)
> >     return dict(employee=employee,orders=orders,form=form)
>
> > thanks
>
> > On May 8, 10:54 pm, mdipierro  wrote:
>
> > > Can you show us the model and the action that triggers this?
>
> > > On May 8, 9:49 pm, greenpoise  wrote:
>
> > > > Can someone help me. I am trying to do a simple calculation of fields.
> > > > Fields are defined as decimal in db.py and here is the calculation:
>
> > > >     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> > > > error: TypeError: can't multiply sequence by non-int of type 'float'
>
>


[web2py] Re: Calculation error

2010-05-08 Thread mdipierro
There are two problems:
1)  order is reserved keyword.
2) decimal types are treated as string internally and there for
compute should be

db.order.tipgranted.compute=lambda r:
float(r['totalsale'])*float(r['tipvalue'])

or better

db.order.tipgranted.compute=lambda r:
decimal.Decimal(r['totalsale'])*decimal.Decimal(r['tipvalue'])


On May 8, 10:00 pm, greenpoise  wrote:
> Model:
>
> db.define_table('order',
>     Field('employee',db.person),
>     Field('tablenumber'),
>     Field('ordernumber'),
>     Field('orderdate','date'),
>     Field('totalsale', 'decimal(10,2)'),
>     Field('tipgranted', 'decimal(10,2)',default=None, update=None,
> readable=False),
>     Field('tipvalue','decimal(10,2)',default='0.15'),)
>
> @auth.requires_login()
> def show_orders():
>     db.order.tipgranted.compute=lambda r:
> r['totalsale']*r['tipvalue']
>     form=crud.create(db.order)
>
> orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumber)
>     return dict(employee=employee,orders=orders,form=form)
>
> thanks
>
> On May 8, 10:54 pm, mdipierro  wrote:
>
> > Can you show us the model and the action that triggers this?
>
> > On May 8, 9:49 pm, greenpoise  wrote:
>
> > > Can someone help me. I am trying to do a simple calculation of fields.
> > > Fields are defined as decimal in db.py and here is the calculation:
>
> > >     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> > > error: TypeError: can't multiply sequence by non-int of type 'float'
>
>


[web2py] Re: Calculation error

2010-05-08 Thread Iceberg
Is that possibly because the default value of tipvalue is a string
'0.15'? Try use float 0.15 instead.

--
Iceberg

On May9, 11:00am, greenpoise  wrote:
> Model:
>
> db.define_table('order',
>     Field('employee',db.person),
>     Field('tablenumber'),
>     Field('ordernumber'),
>     Field('orderdate','date'),
>     Field('totalsale', 'decimal(10,2)'),
>     Field('tipgranted', 'decimal(10,2)',default=None, update=None,
> readable=False),
>     Field('tipvalue','decimal(10,2)',default='0.15'),)
>
> @auth.requires_login()
> def show_orders():
>     db.order.tipgranted.compute=lambda r:
> r['totalsale']*r['tipvalue']
>     form=crud.create(db.order)
>
> orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumb 
> er)
>     return dict(employee=employee,orders=orders,form=form)
>
> thanks
>
> On May 8, 10:54 pm, mdipierro  wrote:
>
>
>
> > Can you show us the model and the action that triggers this?
>
> > On May 8, 9:49 pm, greenpoise  wrote:
>
> > > Can someone help me. I am trying to do a simple calculation of fields.
> > > Fields are defined as decimal in db.py and here is the calculation:
>
> > >     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> > > error: TypeError: can't multiply sequence by non-int of type 'float'


[web2py] Re: Why not session['key'] ?

2010-05-08 Thread mdipierro
They should be equivalent. Can you show the traceback?

On May 8, 9:54 pm, ionel  wrote:
> But I allready did that... and its working...
>
> Something like that:
>
> if not session.c:
>     c = MyClass()
>     session.c = c
> else:
>     c = session.c
>
> But my question was why I cannot use session['c'] instead of session.c
>
> Thank you!
>
> i
>
> On May 8, 9:31 pm, mdipierro  wrote:
>
> > You cannot store your own classes in the session because the session
> > is retrieved before your own classes are defined. You can only store
> > in session primitive types. You can serialize your objects yourself.
>
> > On May 8, 7:30 pm, ionel  wrote:
>
> > > Hello,
>
> > > I'd like to have something like that:
>
> > > class MyClass():
> > >    def __init__(self, id)
> > >        self.id = id
>
> > > c = MyClass('some_id')
>
> > > session[c.id] = c
>
> > > I do not see a solution for this.
> > > Can somebody help me?
>
> > > Thanks.
>
> > > i.
>
>


[web2py] Re: Calculation error

2010-05-08 Thread greenpoise
Model:

db.define_table('order',
Field('employee',db.person),
Field('tablenumber'),
Field('ordernumber'),
Field('orderdate','date'),
Field('totalsale', 'decimal(10,2)'),
Field('tipgranted', 'decimal(10,2)',default=None, update=None,
readable=False),
Field('tipvalue','decimal(10,2)',default='0.15'),)


@auth.requires_login()
def show_orders():
db.order.tipgranted.compute=lambda r:
r['totalsale']*r['tipvalue']
form=crud.create(db.order)
 
orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumber)
return dict(employee=employee,orders=orders,form=form)


thanks


On May 8, 10:54 pm, mdipierro  wrote:
> Can you show us the model and the action that triggers this?
>
> On May 8, 9:49 pm, greenpoise  wrote:
>
> > Can someone help me. I am trying to do a simple calculation of fields.
> > Fields are defined as decimal in db.py and here is the calculation:
>
> >     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> > error: TypeError: can't multiply sequence by non-int of type 'float'


[web2py] Re: Calculation error

2010-05-08 Thread mdipierro
Can you show us the model and the action that triggers this?

On May 8, 9:49 pm, greenpoise  wrote:
> Can someone help me. I am trying to do a simple calculation of fields.
> Fields are defined as decimal in db.py and here is the calculation:
>
>     db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']
>
> error: TypeError: can't multiply sequence by non-int of type 'float'


[web2py] Re: Why not session['key'] ?

2010-05-08 Thread ionel
But I allready did that... and its working...

Something like that:

if not session.c:
c = MyClass()
session.c = c
else:
c = session.c

But my question was why I cannot use session['c'] instead of session.c

Thank you!

i

On May 8, 9:31 pm, mdipierro  wrote:
> You cannot store your own classes in the session because the session
> is retrieved before your own classes are defined. You can only store
> in session primitive types. You can serialize your objects yourself.
>
> On May 8, 7:30 pm, ionel  wrote:
>
> > Hello,
>
> > I'd like to have something like that:
>
> > class MyClass():
> >    def __init__(self, id)
> >        self.id = id
>
> > c = MyClass('some_id')
>
> > session[c.id] = c
>
> > I do not see a solution for this.
> > Can somebody help me?
>
> > Thanks.
>
> > i.


[web2py] Calculation error

2010-05-08 Thread greenpoise
Can someone help me. I am trying to do a simple calculation of fields.
Fields are defined as decimal in db.py and here is the calculation:


db.order.tipgranted.compute=lambda r: r['totalsale']*r['tipvalue']

error: TypeError: can't multiply sequence by non-int of type 'float'


Re: [web2py] Re: New to web app development -- is web2py a good choice

2010-05-08 Thread Miguel Lopes
Yeah! shows how conservative I am :-)


On Fri, May 7, 2010 at 10:10 PM, mdipierro  wrote:

> > Massimo already answered this. But I've been using web2py from the
> > beginning, have a site running on it with absolutely no problems.
> Upgrading
> > to a new release is as simple as (well just import you old app in a new
> > release) -
>
> No. It is simpler. There is a button in admin on the right [upgrade
> now]. you do not need to download or unzip anything any more.
>


[web2py] Re: Why not session['key'] ?

2010-05-08 Thread mdipierro
You cannot store your own classes in the session because the session
is retrieved before your own classes are defined. You can only store
in session primitive types. You can serialize your objects yourself.

On May 8, 7:30 pm, ionel  wrote:
> Hello,
>
> I'd like to have something like that:
>
> class MyClass():
>    def __init__(self, id)
>        self.id = id
>
> c = MyClass('some_id')
>
> session[c.id] = c
>
> I do not see a solution for this.
> Can somebody help me?
>
> Thanks.
>
> i.


[web2py] Re: how to use easy_install

2010-05-08 Thread mdipierro
If you are running web2py binary (web2py.exe) you cannot use
easy_insall. to use easy_install you need to
1) download and install python 2.5 or 2.6
2) download and distutil for python 2.5 or 2.6 (this gives you
easy_install)
3) download are run web2py source (web2py.py)
4) download any other package you want with easy_install

On May 8, 5:55 pm, jayveesea  wrote:
> hello.  i just downloaded web2py (for windows) unzipped it and
> launched web2py in console like this...
> web2py.exe -S welcome
>
> now i am trying to add a module.  and i try this command...
> "easy_install ipython" or "easy_install numpy"
>
> ...but it does not like it and i get the following...
>      File "", line 1
>      easy_install numpy
>      Syntax Error: invalid syntax
>
> any thoughts?  i am new to both web2py and Python.
>
> thanks,
> j


[web2py] Why not session['key'] ?

2010-05-08 Thread ionel
Hello,

I'd like to have something like that:

class MyClass():
   def __init__(self, id)
   self.id = id

c = MyClass('some_id')

session[c.id] = c

I do not see a solution for this.
Can somebody help me?

Thanks.

i.


[web2py] how to use easy_install

2010-05-08 Thread jayveesea
hello.  i just downloaded web2py (for windows) unzipped it and
launched web2py in console like this...
web2py.exe -S welcome

now i am trying to add a module.  and i try this command...
"easy_install ipython" or "easy_install numpy"

...but it does not like it and i get the following...
 File "", line 1
 easy_install numpy
 Syntax Error: invalid syntax

any thoughts?  i am new to both web2py and Python.

thanks,
j


Re: [web2py] is row.update(name='someone') really works??

2010-05-08 Thread Vasile Ermicioi
web2py is always backward compatible, you can use either row.update or
row.update_record
but if you use db(db.cdsdata.id>0).select('extracted') you can't use
update_record because your rows didn't received an id from db
so you ca use any of this

rows=db(db.cdsdata.id>0).select()
rows=db(db.cdsdata.id>0).select(db.cdsdata.ALL)

or  just id and extracted if you are not going to use other fields

rows=db(db.cdsdata.id>0).select(db.cdsdata.id, db.cdsdata.extracted)


[web2py] Re: Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
Looks like the error is being raised in this block of rewrite.py.. is
this due to an attempt to interact with the file system?

def load(routes='routes.py'):
symbols = {}
if not os.path.exists(routes):
return
try:
routesfp = open(routes, 'r')
exec routesfp.read() in symbols
routesfp.close()
logging.info('URL rewrite is on. configuration in %s' %
routes)
except SyntaxError, e:
routesfp.close()
logging.error('Your %s has a syntax error. ' % routes + \
  'Please fix it before you restart web2py')
raise e

On May 8, 5:24 pm, Dane  wrote:
> I tried this. It works locally, but still having problems when
> deployed. Now I'm getting a 500.
>
> Here's the traceback:
>
> : invalid syntax (, line 1)
> Traceback (most recent call last):
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/
> gaehandler.py", line 42, in 
>     import gluon.main
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
> main.py", line 105, in 
>     rewrite.load()
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
> rewrite.py", line 45, in load
>     raise e
>
> On May 8, 5:05 pm, mdipierro  wrote:
>
> > Can you try?
>
> > routes_in = ((/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > On May 8, 11:58 am, Dane  wrote:
>
> > > Hello,
>
> > > In my routes.py file, I have this line:
>
> > > routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > > Working locally, if I go tohttp://localhost:8080/crossdomain.xml,
> > > the file is there.
>
> > > However, when I upload to google app 
> > > engine,http://www.mydomain.appspot.com/crossdomain.xml
> > > gives a 404. The rest of the deployed app is working fine.
>
> > > Any ideas?
>
> > > Thanks,
>
> > > Dane


[web2py] Re: New to web app development -- is web2py a good choice

2010-05-08 Thread weheh
Interesting observation, Thadeus. Who knows how accurate, but it
resonates with me. According to one of the Django developers, Django
was designed with the notion that designers and engineers don't mix,
so the templating language and syntax are different from the server-
side db interface and business logic, which is python, I believe. I'm
conjecturing because when I heard that in a lecture, I decided that
instant that I wouldn't be using Django.

Web2py, on the other hand, is consistent in its use of python
througout, so one person can, indeed, do it all. Web2py won't make up
for a lack of design sense, but it does help you avoid having to learn
2 different languages for doing 2 different things, which in my
opinion, would be 1 way too many. Bottom line, Anthony, go with
web2py. You won't regret it and you might even give yourself a hug and
a pat on the back for making such a smart decision.


[web2py] Re: Fullcalendar with JSON

2010-05-08 Thread Francisco Costa
Thank you for your answer Thadeus.
I was able to understand the issue of the problem.


On May 8, 5:27 pm, Thadeus Burgess  wrote:
> That is incorrect, and only if you want to run that example.. I use
> fullcalendar and I have it at /init/people/calendar.html and I have
> the json at /init/ajax_lib/events.json. You just need to make sure to
> return the correct JSON structure that fullcalendar understands. You
> will need a custom json template, because you need to return a list.
>
> --
> Thadeus
>
> On Sat, May 8, 2010 at 3:53 AM, Francisco Costa  
> wrote:
> > Hello,
> > I'm trying to use Fullcalendar in my app, and I would like to call
> > events from a JSON external file like this example:
> >http://arshaw.com/js/fullcalendar/examples/json.html
> > The problem is that I must have the JSOn file in the same directory as
> > the .html
> > How can I do this in web2py?


Re: [web2py] is row.update(name='someone') really works??

2010-05-08 Thread Thadeus Burgess
Looks like you are not running the latest version of web2py .

--
Thadeus





On Sat, May 8, 2010 at 4:34 PM, Eldr3D  wrote:
> Hello all
>
> i just back to web2py a few weeks ago and i am still learning all the
> new changes reading online official web2py book.
>
> currently i am using web2py DALs in a non web-application , so to
> parse and import data from text files into database (to update
> records).
>
>
> here is the example of what i am doing :
>
> from gluon.sql import DAL,SQLTable,SQLField,Field
> import os,time
> import glob
> db = DAL('mysql://r...@localhost/cds')
> i=0
> db.define_table('cdsdata',
>                Field('docID','string'),
>                Field('grpID','string'),
>                Field('author','string'),
>                Field('subject','string'),
>                Field('sentto','string'),
>                Field('cc','string'),
>                Field('bcc','string'),
>                Field('sentDate','string'),
>                Field('type','string'),
>                Field('extracted','text'),migrate=False)
>
>
> rows=db(db.cdsdata.id>0).select('extracted')
>
> for row in rows:
>    row.update(extracted=open("./exp/" + row.values()[0].values()[0]
> [-13:-1],'r').read())
>    i+=1
>    if i==1000:
>        time.sleep(0.5)
>        print "Updated Records : " + total
>        i=0
>        total+=1000
>
> db.commit()
> db.update()
>
>
> well it tries to update the rows but , they are not actually updated
> inside the database..
>
> also , is row.update_record() method is never existed? coz i cant call
> that function anymore..
>
> but what weird is when i try to do :
>
> db(db.cdsdata.id==1).update(extracted=" This is updated
> text!")
>
> it works flawlessly!
>
> So row.update is dosen't really work ?
> and row.update_record() never exist?
> :
>
>
> In [15]: row.update_record()
> ---
> KeyError                                  Traceback (most recent call
> last)
>
> /home/v3ss/db_importer/ in ()
>
> /home/v3ss/db_importer/gluon/sql.pyc in __getattr__(self, key)
>    662
>    663     def __getattr__(self, key):
> --> 664         return dict.__getitem__(self,key)
>    665
>    666     def __setattr__(self, key, value):
>
> KeyError: 'update_record'
>
>
>


Re: [web2py] migratin apps

2010-05-08 Thread Thadeus Burgess
Your tables already exist in the database. However you must have
deleted your /app/databases/*.table files, so as far as web2py is
concerned it is a blank database.

To remedy the solution, add this to each of your define table statements

db.define_table('.', fake_migrate=True)

Run your code once, this should create the needed
app/databases/*.table files, then remove th fake_migrate lines and you
should be all set.

--
Thadeus





On Sat, May 8, 2010 at 4:52 PM, Tomas Pelka  wrote:
> Hi all,
> is there any advice how to migrate my web2py application. I have shared
> postgress db. When I start up new instance (simple copied) of my app, I
> always get following traceback:
>
> Traceback (most recent call last):
>   File "/home/tom/web2py/gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/home/tom/web2py/applications/init/models/db.py", line 32, in
> 
>     auth.define_tables() # creates all needed tables
>   File "/home/tom/web2py/gluon/tools.py", line 829, in define_tables
>     format='%(first_name)s %(last_name)s (%(id)s)')
>   File "/home/tom/web2py/gluon/sql.py", line 1303, in define_table
>     t._create(migrate=migrate, fake_migrate=fake_migrate)
>   File "/home/tom/web2py/gluon/sql.py", line 1724, in _create
>     self._db._execute(query)
>   File "/home/tom/web2py/gluon/sql.py", line 958, in 
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> ProgrammingError: relation "auth_user" already exists
>
> Seems that web2py do not establish db connection properly. For example
> always when I want get something from bd:
>
> Traceback (most recent call last):
>   File "/home/tom/web2py/gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/home/tom/web2py/applications/NetSim/controllers/analyze.py", line
> 167, in 
>   File "/home/tom/web2py/gluon/globals.py", line 96, in 
>     self._caller = lambda f: f()
>   File "/home/tom/web2py/applications/NetSim/controllers/analyze.py", line
> 127, in index
>     ifaces = db().select(db.interfaces.ALL)
>   File "/home/tom/web2py/gluon/sql.py", line 1323, in __getattr__
>     return dict.__getitem__(self,key)
> KeyError: 'interfaces'
>
> But tabele "interfaces" is in bd.
>
> Thanks for comments
> Cheers Tom
>
> --
> Tomas Pelka


[web2py] migratin apps

2010-05-08 Thread Tomas Pelka

Hi all,
is there any advice how to migrate my web2py application. I have shared 
postgress db. When I start up new instance (simple copied) of my app, I 
always get following traceback:


Traceback (most recent call last):
  File "/home/tom/web2py/gluon/restricted.py", line 178, in restricted
exec ccode in environment
  File "/home/tom/web2py/applications/init/models/db.py", line 32, in 

auth.define_tables() # creates all needed 
tables

  File "/home/tom/web2py/gluon/tools.py", line 829, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)')
  File "/home/tom/web2py/gluon/sql.py", line 1303, in define_table
t._create(migrate=migrate, fake_migrate=fake_migrate)
  File "/home/tom/web2py/gluon/sql.py", line 1724, in _create
self._db._execute(query)
  File "/home/tom/web2py/gluon/sql.py", line 958, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: relation "auth_user" already exists

Seems that web2py do not establish db connection properly. For example 
always when I want get something from bd:


Traceback (most recent call last):
  File "/home/tom/web2py/gluon/restricted.py", line 178, in restricted
exec ccode in environment
  File "/home/tom/web2py/applications/NetSim/controllers/analyze.py", 
line 167, in 

  File "/home/tom/web2py/gluon/globals.py", line 96, in 
self._caller = lambda f: f()
  File "/home/tom/web2py/applications/NetSim/controllers/analyze.py", 
line 127, in index

ifaces = db().select(db.interfaces.ALL)
  File "/home/tom/web2py/gluon/sql.py", line 1323, in __getattr__
return dict.__getitem__(self,key)
KeyError: 'interfaces'

But tabele "interfaces" is in bd.

Thanks for comments
Cheers Tom

--
Tomas Pelka



[web2py] is row.update(name='someone') really works??

2010-05-08 Thread Eldr3D
Hello all

i just back to web2py a few weeks ago and i am still learning all the
new changes reading online official web2py book.

currently i am using web2py DALs in a non web-application , so to
parse and import data from text files into database (to update
records).


here is the example of what i am doing :

from gluon.sql import DAL,SQLTable,SQLField,Field
import os,time
import glob
db = DAL('mysql://r...@localhost/cds')
i=0
db.define_table('cdsdata',
Field('docID','string'),
Field('grpID','string'),
Field('author','string'),
Field('subject','string'),
Field('sentto','string'),
Field('cc','string'),
Field('bcc','string'),
Field('sentDate','string'),
Field('type','string'),
Field('extracted','text'),migrate=False)


rows=db(db.cdsdata.id>0).select('extracted')

for row in rows:
row.update(extracted=open("./exp/" + row.values()[0].values()[0]
[-13:-1],'r').read())
i+=1
if i==1000:
time.sleep(0.5)
print "Updated Records : " + total
i=0
total+=1000

db.commit()
db.update()


well it tries to update the rows but , they are not actually updated
inside the database..

also , is row.update_record() method is never existed? coz i cant call
that function anymore..

but what weird is when i try to do :

db(db.cdsdata.id==1).update(extracted=" This is updated
text!")

it works flawlessly!

So row.update is dosen't really work ?
and row.update_record() never exist?
:


In [15]: row.update_record()
---
KeyError  Traceback (most recent call
last)

/home/v3ss/db_importer/ in ()

/home/v3ss/db_importer/gluon/sql.pyc in __getattr__(self, key)
662
663 def __getattr__(self, key):
--> 664 return dict.__getitem__(self,key)
665
666 def __setattr__(self, key, value):

KeyError: 'update_record'




[web2py] Re: post via mail

2010-05-08 Thread Pepe
good!

anew: i will try :)

thanks Massimo!

On May 7, 5:17 pm, mdipierro  wrote:
> Yes but in a different way. Your VPS.net server probably can already
> receive emails (assuming there is account with the name of the
> receiver).
> You just need a script that uses pop to fetch emails from the inbox of
> that user account. It should actually be simpler. Somewhere I have
> that script for IMAP. I will look for it.
>
> On May 7, 11:32 am, Pepe  wrote:
>
>
>
> > Thanks Massimo,
> > I will try that.
>
> > only one question more: how can I implement (if is possible) 
> > this:http://code.google.com/appengine/docs/python/mail/receivingmail.html
> > in my server? (a vps.net account)
>
> > is that possible?
>
> > thinking in a CRM (other idea, not the original "post via mail") I
> > think that is more practical...
>
> > Pepe
>
> > On May 6, 1:50 pm, mdipierro  wrote:
>
> > > It is actually not difficult. Somewhere you create an email account
> > > that is the recipient of emails directed to the application. For
> > > example a gmail account.
>
> > > Then you write a web2py script that runs in background and that
> > > periodically connects to that account (using the python pop or imap
> > > modules), retrieves all new emails (one by one) and process them
> > > (parse the information you look for and store them in the database).
>
> > > You run the script with web2py.py -S app -M -R script.py
>
> > > On May 6, 12:41 pm, Pepe  wrote:
>
> > > > Hello!
>
> > > > I want to enable the possibility of post via email in one application.
>
> > > > so, i need info about how to do that, I never had did that before, so
> > > > any help is a good help for me.
>
> > > > Thanks a lot.
>
> > > > Pepe
> > > > _
>
> > > > Este mensaje también fue posteado en el grupo en 
> > > > Español:http://groups.google.com/group/web2py-usuarios/browse_thread/thread/8...


[web2py] Re: Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
I tried this. It works locally, but still having problems when
deployed. Now I'm getting a 500.

Here's the traceback:

: invalid syntax (, line 1)
Traceback (most recent call last):
  File "/base/data/home/apps/tthultimate/1.341813257625966505/
gaehandler.py", line 42, in 
import gluon.main
  File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
main.py", line 105, in 
rewrite.load()
  File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
rewrite.py", line 45, in load
raise e

On May 8, 5:05 pm, mdipierro  wrote:
> Can you try?
>
> routes_in = ((/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> On May 8, 11:58 am, Dane  wrote:
>
> > Hello,
>
> > In my routes.py file, I have this line:
>
> > routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > Working locally, if I go tohttp://localhost:8080/crossdomain.xml,
> > the file is there.
>
> > However, when I upload to google app 
> > engine,http://www.mydomain.appspot.com/crossdomain.xml
> > gives a 404. The rest of the deployed app is working fine.
>
> > Any ideas?
>
> > Thanks,
>
> > Dane


[web2py] Re: Routes.py not working when deployed to GAE

2010-05-08 Thread mdipierro
Can you try?

routes_in = ((/crossdomain.xml', '/init/static/crossdomain.xml'),)

On May 8, 11:58 am, Dane  wrote:
> Hello,
>
> In my routes.py file, I have this line:
>
> routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> Working locally, if I go tohttp://localhost:8080/crossdomain.xml,
> the file is there.
>
> However, when I upload to google app 
> engine,http://www.mydomain.appspot.com/crossdomain.xml
> gives a 404. The rest of the deployed app is working fine.
>
> Any ideas?
>
> Thanks,
>
> Dane


[web2py] Re: WebGrid for Web2py and Keyerror

2010-05-08 Thread mr.freeze
Did you delete the default DAL declaration at the top of db.py? Your
code works for me.

On May 8, 2:04 pm, winti  wrote:
> i changed it to myid and i get a error on:
> KeyError: 'myid'
>
> Stefan
>
> On May 8, 8:51 pm, "mr.freeze"  wrote:
>
> > 'identity' is probably a reserved word in sqlite. Try changing it to
> > something else.
>
> > On May 8, 1:36 pm, winti  wrote:
>
> > > Hello,
> > > in a controller i define a temp db and want to return the results with
> > > webgrid to a view.
> > > I get a Keyerror on 'identity'.
>
> > > Traceback (most recent call last):
> > >   File "/data/projects/frameworks/web2py/applications/gluon/
> > > restricted.py", line 178, in restricted
> > >     exec ccode in environment
> > >   File "/data/projects/frameworks/web2py/applications/applications/
> > > eDir/controllers/default.py", line 190, in 
> > >   File "/data/projects/frameworks/web2py/applications/gluon/
> > > globals.py", line 96, in 
> > >     self._caller = lambda f: f()
> > >   File "/data/projects/frameworks/web2py/applications/applications/
> > > eDir/controllers/default.py", line 187, in queryaddr
> > >     return dict(resi1=res,grid=grid())
> > >   File "/data/projects/frameworks/web2py/applications/applications/
> > > eDir/modules/webgrid.py", line 229, in __call__
> > >     field = db[t][f]
> > >   File "/data/projects/frameworks/web2py/applications/gluon/sql.py",
> > > line 1318, in __getitem__
> > >     return dict.__getitem__(self, str(key))
> > > KeyError: 'identity'
>
> > > def xyz():
>
> > > db=SQLDB('sqlite:memory:')
> > >         db.define_table("identity",
> > >                 db.Field("user","string",default=""),
> > >                 db.Field("ip","string",default=""),
> > >                 db.Field("type","string",default=""))
>
> > > ...
> > > ...
> > > 
> > > db.identity.insert(user=user,ip=ipreadeable,type=type)
> > > ...
> > > ...
>
> > > grid = webgrid.WebGrid(crud)
> > > grid.datasource = db(db.identity.id<0).select()
>
> > > Any idea
>
> > > Stefan


[web2py] Re: How to set multiple primary key?

2010-05-08 Thread Iceberg
I am not dealing with legacy tables, I am just starting a new db and
wondering whether I can set multiple primary key, in order to
eliminate the chance of duplicated data.

For example.

db = DAL('sqlite://storage.sqlite')
db.define_table('account',
  Field('given_name'),
  Field('surname'),
  Field('phone_number'),
  primarykey=['given_name','surname'])

On May9, 3:23am, DenesL  wrote:
> Multiple primary keys should work if you are defining legacy tables in
> one of the supported DB engines.
> Are you using MS SQL, DB2, Ingres or Informix?
> Can we see the model?
>
> On May 8, 5:57 am, Iceberg  wrote:
>
>
>
> > Hi there,
>
> > I am fiddling multiple primary keys. Somehow I managed to find
> > following example inside gluon/sql.py
>
> >         db.define_table('account',
> >           Field('accnum','integer'),
> >           Field('acctype'),
> >           Field('accdesc'),
> >           primarykey=['accnum','acctype'])
>
> > But running the example throws:
>
> > Traceback (most recent call last):
> >   ..
> >   File "C:\DOWNLOAD\google_appengine\web2py\gluon\sql.py", line 2112,
> > in __init__
> >     raise SyntaxError, 'invalid table "%s" attribute: %s' %
> > (tablename, k)
> > SyntaxError: invalid table "account" attribute: sequence_name
>
> > What did I do wrong?
>
> > Iceberg


[web2py] Re: How to set multiple primary key?

2010-05-08 Thread DenesL

Multiple primary keys should work if you are defining legacy tables in
one of the supported DB engines.
Are you using MS SQL, DB2, Ingres or Informix?
Can we see the model?


On May 8, 5:57 am, Iceberg  wrote:
> Hi there,
>
> I am fiddling multiple primary keys. Somehow I managed to find
> following example inside gluon/sql.py
>
>         db.define_table('account',
>           Field('accnum','integer'),
>           Field('acctype'),
>           Field('accdesc'),
>           primarykey=['accnum','acctype'])
>
> But running the example throws:
>
> Traceback (most recent call last):
>   ..
>   File "C:\DOWNLOAD\google_appengine\web2py\gluon\sql.py", line 2112,
> in __init__
>     raise SyntaxError, 'invalid table "%s" attribute: %s' %
> (tablename, k)
> SyntaxError: invalid table "account" attribute: sequence_name
>
> What did I do wrong?
>
> Iceberg


[web2py] Re: WebGrid for Web2py and Keyerror

2010-05-08 Thread winti
i changed it to myid and i get a error on:
KeyError: 'myid'

Stefan

On May 8, 8:51 pm, "mr.freeze"  wrote:
> 'identity' is probably a reserved word in sqlite. Try changing it to
> something else.
>
> On May 8, 1:36 pm, winti  wrote:
>
>
>
> > Hello,
> > in a controller i define a temp db and want to return the results with
> > webgrid to a view.
> > I get a Keyerror on 'identity'.
>
> > Traceback (most recent call last):
> >   File "/data/projects/frameworks/web2py/applications/gluon/
> > restricted.py", line 178, in restricted
> >     exec ccode in environment
> >   File "/data/projects/frameworks/web2py/applications/applications/
> > eDir/controllers/default.py", line 190, in 
> >   File "/data/projects/frameworks/web2py/applications/gluon/
> > globals.py", line 96, in 
> >     self._caller = lambda f: f()
> >   File "/data/projects/frameworks/web2py/applications/applications/
> > eDir/controllers/default.py", line 187, in queryaddr
> >     return dict(resi1=res,grid=grid())
> >   File "/data/projects/frameworks/web2py/applications/applications/
> > eDir/modules/webgrid.py", line 229, in __call__
> >     field = db[t][f]
> >   File "/data/projects/frameworks/web2py/applications/gluon/sql.py",
> > line 1318, in __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'identity'
>
> > def xyz():
>
> > db=SQLDB('sqlite:memory:')
> >         db.define_table("identity",
> >                 db.Field("user","string",default=""),
> >                 db.Field("ip","string",default=""),
> >                 db.Field("type","string",default=""))
>
> > ...
> > ...
> > 
> > db.identity.insert(user=user,ip=ipreadeable,type=type)
> > ...
> > ...
>
> > grid = webgrid.WebGrid(crud)
> > grid.datasource = db(db.identity.id<0).select()
>
> > Any idea
>
> > Stefan


[web2py] Re: WebGrid for Web2py and Keyerror

2010-05-08 Thread mr.freeze
'identity' is probably a reserved word in sqlite. Try changing it to
something else.


On May 8, 1:36 pm, winti  wrote:
> Hello,
> in a controller i define a temp db and want to return the results with
> webgrid to a view.
> I get a Keyerror on 'identity'.
>
> Traceback (most recent call last):
>   File "/data/projects/frameworks/web2py/applications/gluon/
> restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/data/projects/frameworks/web2py/applications/applications/
> eDir/controllers/default.py", line 190, in 
>   File "/data/projects/frameworks/web2py/applications/gluon/
> globals.py", line 96, in 
>     self._caller = lambda f: f()
>   File "/data/projects/frameworks/web2py/applications/applications/
> eDir/controllers/default.py", line 187, in queryaddr
>     return dict(resi1=res,grid=grid())
>   File "/data/projects/frameworks/web2py/applications/applications/
> eDir/modules/webgrid.py", line 229, in __call__
>     field = db[t][f]
>   File "/data/projects/frameworks/web2py/applications/gluon/sql.py",
> line 1318, in __getitem__
>     return dict.__getitem__(self, str(key))
> KeyError: 'identity'
>
> def xyz():
>
> db=SQLDB('sqlite:memory:')
>         db.define_table("identity",
>                 db.Field("user","string",default=""),
>                 db.Field("ip","string",default=""),
>                 db.Field("type","string",default=""))
>
> ...
> ...
> 
> db.identity.insert(user=user,ip=ipreadeable,type=type)
> ...
> ...
>
> grid = webgrid.WebGrid(crud)
> grid.datasource = db(db.identity.id<0).select()
>
> Any idea
>
> Stefan


[web2py] WebGrid for Web2py and Keyerror

2010-05-08 Thread winti
Hello,
in a controller i define a temp db and want to return the results with
webgrid to a view.
I get a Keyerror on 'identity'.

Traceback (most recent call last):
  File "/data/projects/frameworks/web2py/applications/gluon/
restricted.py", line 178, in restricted
exec ccode in environment
  File "/data/projects/frameworks/web2py/applications/applications/
eDir/controllers/default.py", line 190, in 
  File "/data/projects/frameworks/web2py/applications/gluon/
globals.py", line 96, in 
self._caller = lambda f: f()
  File "/data/projects/frameworks/web2py/applications/applications/
eDir/controllers/default.py", line 187, in queryaddr
return dict(resi1=res,grid=grid())
  File "/data/projects/frameworks/web2py/applications/applications/
eDir/modules/webgrid.py", line 229, in __call__
field = db[t][f]
  File "/data/projects/frameworks/web2py/applications/gluon/sql.py",
line 1318, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'identity'




def xyz():

db=SQLDB('sqlite:memory:')
db.define_table("identity",
db.Field("user","string",default=""),
db.Field("ip","string",default=""),
db.Field("type","string",default=""))

...
...

db.identity.insert(user=user,ip=ipreadeable,type=type)
...
...

grid = webgrid.WebGrid(crud)
grid.datasource = db(db.identity.id<0).select()



Any idea

Stefan




[web2py] Re: Is anyone using MongoDB with web2py?

2010-05-08 Thread David Marko
Yes, I know, but you should be able to use it without DAL using
pymongo as a primary MongoDB python driver. And thats where my
question goes.

David

On 8 kvě, 19:22, Pystar  wrote:
> For now, Web2py's DAL doesnt support NoSQL databases. I think Massimo
> can tell us more on the status of the DAL rewrite and when it would be
> possible.
>
> On May 8, 5:59 pm, David Marko  wrote:
>
>
>
> > Is anyone using MongoDB with web2py? How do you 'share' connection
> > object in your app when using pymongo?
>
> > If I put the code below into db.py, each request causes the new
> > connection opened to MongoDB what mean that after 500 requests to my
> > app, there are 500 separate connections I can see on MongoDB console.
>
> > >>> from pymongo import Connection
> > >>> connection = Connection()
>
> > Where to put the connection code to have some pooling mechanism so
> > connection is shared among requests?
>
> > David


[web2py] Re: Is anyone using MongoDB with web2py?

2010-05-08 Thread Pystar
For now, Web2py's DAL doesnt support NoSQL databases. I think Massimo
can tell us more on the status of the DAL rewrite and when it would be
possible.

On May 8, 5:59 pm, David Marko  wrote:
> Is anyone using MongoDB with web2py? How do you 'share' connection
> object in your app when using pymongo?
>
> If I put the code below into db.py, each request causes the new
> connection opened to MongoDB what mean that after 500 requests to my
> app, there are 500 separate connections I can see on MongoDB console.
>
> >>> from pymongo import Connection
> >>> connection = Connection()
>
> Where to put the connection code to have some pooling mechanism so
> connection is shared among requests?
>
> David


[web2py] Is anyone using MongoDB with web2py?

2010-05-08 Thread David Marko
Is anyone using MongoDB with web2py? How do you 'share' connection
object in your app when using pymongo?

If I put the code below into db.py, each request causes the new
connection opened to MongoDB what mean that after 500 requests to my
app, there are 500 separate connections I can see on MongoDB console.
>>> from pymongo import Connection
>>> connection = Connection()

Where to put the connection code to have some pooling mechanism so
connection is shared among requests?

David


[web2py] Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
Hello,

In my routes.py file, I have this line:

routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)

Working locally, if I go to http://localhost:8080/crossdomain.xml ,
the file is there.

However, when I upload to google app engine, 
http://www.mydomain.appspot.com/crossdomain.xml
gives a 404. The rest of the deployed app is working fine.

Any ideas?

Thanks,

Dane


Re: [web2py] New to web app development -- is web2py a good choice

2010-05-08 Thread Jason Brower
Yup... the software I create with web2py is stricty internal anyway.
They honestly would fire me if it looked too good.  I would be wasting
there money. :P
Best Regards,
Jason

On Sat, 2010-05-08 at 11:30 -0500, Thadeus Burgess wrote: 
> One thing I have noticed is django and RoR is for the most part, a
> designer oriented community. IE: Lots of designers, few real
> programmers/engineers, this is why you see design-oriented keywords
> floating around in those frameworks. Most of us here in the web2py
> community are programmers/engineers/physicists, etc... we don't have
> the best design skills, even if we are brilliant =)
> 
> --
> Thadeus
> 
> 
> 
> 
> 
> On Sat, May 8, 2010 at 9:07 AM, Alexei Vinidiktov
>  wrote:
> > On Thu, May 6, 2010 at 12:37 PM, Anthony  wrote:
> > [...]
> >
> >> From what I've read, web2py sounds like a great framework --
> >> comprehensive, well-integrated, easy to set up, learn, and deploy,
> >> etc. However, although it sounds good on paper, I haven't yet found a
> >> single site built with web2py that looks all that impressive (at least
> >> superficially). It's easy to find quite a number of sophisticated and
> >> impressive looking sites/apps built with Ruby on Rails and Django, but
> >> I haven't seen anything remotely comparable based on web2py. I'm
> >> wondering why the disparity.
> >
> > What you've seen on those sites is the façade. It's the work of
> > graphic designers and not a merit of the underlying frameworks. That's
> > what you see.
> >
> > I'm sure the same effect can be achieved with any web2py based
> > website. You just need to hire a great graphic designer and usability
> > expert.
> >
> > --
> > Alexei Vinidiktov
> >




Re: [web2py] New to web app development -- is web2py a good choice

2010-05-08 Thread Thadeus Burgess
One thing I have noticed is django and RoR is for the most part, a
designer oriented community. IE: Lots of designers, few real
programmers/engineers, this is why you see design-oriented keywords
floating around in those frameworks. Most of us here in the web2py
community are programmers/engineers/physicists, etc... we don't have
the best design skills, even if we are brilliant =)

--
Thadeus





On Sat, May 8, 2010 at 9:07 AM, Alexei Vinidiktov
 wrote:
> On Thu, May 6, 2010 at 12:37 PM, Anthony  wrote:
> [...]
>
>> From what I've read, web2py sounds like a great framework --
>> comprehensive, well-integrated, easy to set up, learn, and deploy,
>> etc. However, although it sounds good on paper, I haven't yet found a
>> single site built with web2py that looks all that impressive (at least
>> superficially). It's easy to find quite a number of sophisticated and
>> impressive looking sites/apps built with Ruby on Rails and Django, but
>> I haven't seen anything remotely comparable based on web2py. I'm
>> wondering why the disparity.
>
> What you've seen on those sites is the façade. It's the work of
> graphic designers and not a merit of the underlying frameworks. That's
> what you see.
>
> I'm sure the same effect can be achieved with any web2py based
> website. You just need to hire a great graphic designer and usability
> expert.
>
> --
> Alexei Vinidiktov
>


Re: [web2py] Fullcalendar with JSON

2010-05-08 Thread Thadeus Burgess
That is incorrect, and only if you want to run that example.. I use
fullcalendar and I have it at /init/people/calendar.html and I have
the json at /init/ajax_lib/events.json. You just need to make sure to
return the correct JSON structure that fullcalendar understands. You
will need a custom json template, because you need to return a list.

--
Thadeus





On Sat, May 8, 2010 at 3:53 AM, Francisco Costa  wrote:
> Hello,
> I'm trying to use Fullcalendar in my app, and I would like to call
> events from a JSON external file like this example:
> http://arshaw.com/js/fullcalendar/examples/json.html
> The problem is that I must have the JSOn file in the same directory as
> the .html
> How can I do this in web2py?
>


[web2py] Re: question about webfactional

2010-05-08 Thread Pai
that works!

Thanks annet!



On May 8, 1:52 am, annet  wrote:
> Pai,
>
> The solution to your problem is described in this thread:
>
> http://groups.google.com/group/web2py/browse_thread/thread/504dd2deff...
>
> Basically you have to log on to webfaction via terminal/ssh and
> manually create a directory in your remote web2py/applications
> directory. You can then upload and install a packed web2py app via the
> web interface.
>
> Kind regards,
>
> Annet.


Re: [web2py] Re: Bug and fix about IS_DATE_IN_RANGE()

2010-05-08 Thread Jonathan Lundell
On May 8, 2010, at 12:52 AM, Iceberg wrote:

> Thanks for the quick response and fix. But one more comment when
> talking about doctest. You current doctest cases does not qualified to
> catch the bug. You need to design cases for critical point. Besides,
> you need not use "print" in doctest.

Right. There are several examples elsewhere in the file that can be followed.

Ideally, one would create the failing test cases before fixing the bug.

> 
> For example, the current trunk:
> 
 v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1), \
> maximum=datetime.date(2009,12,31), \
> format="%m/%d/
> %Y",error_message="oops")
> 
 print v('03/03/2008')
>(datetime.date(2008, 3, 3), None)
> 
> I would suggest:
> 
 v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1), \
> maximum=datetime.date(2009,12,31), \
> format="%m/%d/
> %Y",error_message="oops")
> 
 v('1/01/2008')
>(datetime.date(2008, 1, 1), None)
> 
> Might not be considered as a big deal, although. Just my $0.02
> 
> Regards,
> Iceberg
> 
> On May8, 7:39am, mdipierro  wrote:
>> Done. I added one test each. we should have more tests in gluon/tests
>> we have none, only doctests for validators.
>> 
>> On May 7, 4:26 pm, Jonathan Lundell  wrote:
>> 
>> 
>> 
>>> On May 7, 2010, at 9:30 AM, Iceberg wrote:
>> 
 Right now, IS_DATE_IN_RANGE(minimum=foo, maximum=bar) does NOT accept
 the given minimum nor maximum value. That is not the design intention
 according to error message. Please get rid off the two equal marks in
 IS_DATE_IN_RANGE.__call__().
>> 
 Same applies to IS_DATETIME_IN_RANGE.
>> 
>>> Anybody who patches this: please add the relevant doctests.




Re: [web2py] New to web app development -- is web2py a good choice

2010-05-08 Thread Alexei Vinidiktov
On Thu, May 6, 2010 at 12:37 PM, Anthony  wrote:
[...]

> From what I've read, web2py sounds like a great framework --
> comprehensive, well-integrated, easy to set up, learn, and deploy,
> etc. However, although it sounds good on paper, I haven't yet found a
> single site built with web2py that looks all that impressive (at least
> superficially). It's easy to find quite a number of sophisticated and
> impressive looking sites/apps built with Ruby on Rails and Django, but
> I haven't seen anything remotely comparable based on web2py. I'm
> wondering why the disparity.

What you've seen on those sites is the façade. It's the work of
graphic designers and not a merit of the underlying frameworks. That's
what you see.

I'm sure the same effect can be achieved with any web2py based
website. You just need to hire a great graphic designer and usability
expert.

-- 
Alexei Vinidiktov


[web2py] Re: ToscaWidgets

2010-05-08 Thread lannick
Hi,

Nobody know Toscawidgets and have try it with web2py ?

Regards,
Lannick


On 26 avr, 13:14, lannick  wrote:
> Hi,
>
> Does anyone know and have used ToscaWidgets with web2py ? (http://
> toscawidgets.org/ )
>
> Regards,
> Lannick
>
> --
> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Reverse Search with .like

2010-05-08 Thread AsmanCom
Hey Guys, that helped a lot!
with a lil correction it works very nice.

Thanks for the Support.

On 8 Mai, 04:18, Russell  wrote:
> You might want to try something like this:.
>
>     from gluon.sql import Expression
>     db(table1.field1.like(Expression("('%' || table2.field2 ||
> '%')".select(db.table1.field1)
>
> Not very pretty, but it does work.
>
> On May 8, 9:13 am, mdipierro  wrote:
>
> > Can you try
>
> > from gluon.sql import Query
> > print db(Query(" '%' || NEW.field_1 || '%'  LIKE table_1.field_1
> > "))._select(db.table_1.field_1)
>
> > Do you get the query you want?
>
> > On May 7, 10:48 am, AsmanCom  wrote:
>
> > > It returns nothing... even if I write in the exact value and it should
> > > work like a fuzzy logic..
> > > like that:
>
> > > find_value= request.vars.value
>
> > > db('%' + table_1.field_1 +
> > > '%').lower().like(find_value).select(db.table_1.field_1)
>
> > > or
>
> > > db('%' + table_1.field_1 + '%').lower().like('%' + find_value +
> > > '%').select(db.table_1.field_1)
>
> > > Any Idea?
>
> > > On 7 Mai, 17:03, mdipierro  wrote:
>
> > > > This should work
>
> > > > db("'%' || NEW.field_1 || '%'  LIKE
> > > > table_1.field_1").select(db.table_1.field_1)
>
> > > > On May 7, 9:35 am, AsmanCom  wrote:
>
> > > > > Hi,
>
> > > > > here is the important Code from an Sqlite trigger i use very often, is
> > > > > this possible with web2py to?
>
> > > > > Sqlite:
> > > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%'
> > > > > LIKE table_1.field_1 )
>
> > > > > or i can even do:
>
> > > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%'
> > > > > LIKE  '%' || table_1.field_1  || '%'  )
>
> > > > > w2p:
> > > > > db.person.name.lower().like(‘m%’)


[web2py] How to set multiple primary key?

2010-05-08 Thread Iceberg
Hi there,

I am fiddling multiple primary keys. Somehow I managed to find
following example inside gluon/sql.py

db.define_table('account',
  Field('accnum','integer'),
  Field('acctype'),
  Field('accdesc'),
  primarykey=['accnum','acctype'])

But running the example throws:

Traceback (most recent call last):
  ..
  File "C:\DOWNLOAD\google_appengine\web2py\gluon\sql.py", line 2112,
in __init__
raise SyntaxError, 'invalid table "%s" attribute: %s' %
(tablename, k)
SyntaxError: invalid table "account" attribute: sequence_name

What did I do wrong?

Iceberg


[web2py] Re: jquery click function problem

2010-05-08 Thread salbefe
Thank you Massimo !!

Regards

On 7 mayo, 23:22, mdipierro  wrote:
> Because s are not executed in ajax loaded content. It is a
> browser thing. It is not in the specs. You can do
>
> 
Hello div> >
World
> > this will work because the code is executed onclick and not on ajax > load. > > Massimo > > On May 7, 12:22 pm, salbefe wrote: > > > Hello, > > > First of all, I think I should say sorry because probably this is not > > the correct place to post the following problem but I'm getting crazy. > > > My problem with jquery is as follows: > > > On a view I have a form that is submited via web2py ajax method. > > Something like this > > > [] > >
> > > . > >    
> >           > value="Buscar" class="btn" /> > >      
> >
> >
> > > This form is submited like this: > > >