[web2py] Re: Apache, Wsgi problem

2011-01-10 Thread Michael Toomim
Thanks, I just investigated this, but it looks like it did not fix the 
problem.

In 8.4.6 Postgres changed the default "wal_sync_method" to "fdatasync," 
because the old default "open_datasync" failed on ext4. I use ext3 (on 
ubuntu 9.10), but I tried changing this option in my postgres database 
anyway. I changed it, restarted postgres and apache, but still get the 
error.


[web2py] Re: Apache, Wsgi problem

2011-01-10 Thread ron_m
I don't know if it is worth mentioning but as a Ubuntu 10.04.1 user, I 
noticed the 8.4.6 update to PostgreSQL was pushed by Ubuntu near the end of 
December.

http://www.postgresql.org/docs/8.4/static/release-8-4-6.html

first item of the release notes mention the database can fail on some file 
systems notably ext4 with data=journal mount option. 

I mention it only because your problem appears with the use of postgres.


[web2py] Re: Apache, Wsgi problem

2011-01-10 Thread Michael Toomim
I'm still having this problem too (previous posts linked below).  I
would love to find a solution.  I'm not sure how to debug.

VP: Can you provide instructions for reproducing this bug using ab?  I
had trouble using ab in the past.  I am also on a VPS.

Since my last post (linked below), I have tried the following:
  1) setting migrate=False
  2) compiling the app

These did not fix the problem.

On Jan 9, 9:30 am, VP  wrote:
> It is indeed the case that there was a segmentation fault, reported in
> apache error log.
>
> Perhaps, it's not clear, but this problem occurs under posgres under
> debian lenny, not sqlite.  I am not running web2py as a CGIscript.  I
> am using the web2py deploymentscript(for setting up apache and
> web2py):
>
> 
>   WSGIDaemonProcess web2py user=myusername group=myusername \
>                            display-name=%{GROUP}
>   WSGIProcessGroup web2py
>   WSGIScriptAlias / /home/myusername/web2py/wsgihandler.py
>
> 
>
> On Jan 8, 9:59 pm, Graham Dumpleton 
> wrote:
>
>
>
> > You were possibly using a an old version of sqlite which isn't safe to use
> > in a multithreaded configuration.
>
> > The MPM settings are not going to help in this case as that error could only
> > come about because you are using mod_wsgi daemon mode and so application is
> > running in distinct process and not those affected by the MPM or its
> > settings.
>
> > The only other way you could get that error is that you are actually running
> > web2py as a CGIscript.
>
> > Overall, that specific error message means your daemon mode process that is
> > running web2py crashed. You would likely find that there is a segmentation
> > fault messages in main Apache error log as well at that time.
>
> > Crashing could be because of sqlite thread problems, but could also be
> > because you are forcing web2py to run in main interpreter of daemon
> > processes and at the same time are using a third party C extension module
> > for Python that is not safe for use in sub interpreters.
>
> > So, ensure sqlite is up to date. And ensure that you have:
>
> >   WSGIApplicationGroup %{GLOBAL}
>
> > in configuration to force use of main interpreter.
>
> > Graham
>
> > On Sunday, January 9, 2011 6:44:14 AM UTC+11, VP wrote:
>
> > > We occasionally got an Apache error so the page didn't get displayed.
> > > So I decided to stress test using Apache Bench (ab).  It seems the
> > > site suffered failure up to 50-100 concurrent connection.
>
> > > Apache error log showed this error:
>
> > > >>Prematureendofscriptheaders: wsgihandler.py
>
> > > After digging around, I found similar discussions and change
> > > apache2.conf like this:
>
> > > # prefork MPM
> > > StartServers 5
> > > MinSpareServers 5
> > > MaxSpareServers 10
> > > MaxClients 256
> > > MaxRequestsPerChild 500
> > > ServerLimit 256
>
> > > Didn't seem to help.
>
> > > 
>
> > > A few notes:
>
> > > + It appears when I switched to sqlite instead of posgres, I didn't
> > > have the problem.   (Sqlite had other problems, such as occasional
> > > database locking, which is more serious)
>
> > > + I am on a VPS with 768MB with 1GB burstable.   While I'm doing the
> > > stress test with Apache Bench (ab), using free on the server revealed
> > > memory usage was about 450MB.  (Which is a lot, but is still under
> > > limit).
>
> > > =
>
> > > In summary, memory was available.   But we got this wsgi error in
> > > Apache with multiple requests.
>
> > > Any idea please?
>
> > > Thanks.


Re: [web2py] jquery.tools.min.js

2011-01-10 Thread ron_m
Which version of jquery.tools.min.js did you include, what I mean is what 
feature set? There is a possible inclusion of a date picker looking at all 
the options on their web page for downloads as you build your custom version 
of jquery.tools.min.js. They all produce the same file name as output so it 
could be interesting to determine which one you actually have. Sorry haven't 
looked at the details of how they might document that if at all.

You would have to include after jquery itself for sure in terms of load 
order from web2py_ajax.html. 

I would look for a name collision since both the web2py included date picker 
and jquery.tools.min.js are enhancing the jquery name space. For tools, not 
sure if jslint could pick up a common name between them because minified js 
files can be a pain to look at.


[web2py] Re: Help with cron

2011-01-10 Thread pbreit
Ah, it's working! Sorry for false alarm.

[web2py] Re: Help with cron

2011-01-10 Thread pbreit
Fixed this (no .py) but still not working:

cron/crontab:
#run every 2 minutes
*/2 * * * * root *cron/release_pending_items

I've also tried:
cron/crontab:
#run every 2 minutes
*/2 * * * * root *applications/myapp/cron/release_pending_items.py

Is there any way to determine if cron is functioning? Do I need to restart 
the server if I make changes (side note: when I stop the server and then 
start it, it seems to stall and I have to quit out of web2py and re-run).


[web2py] Re: reference all fields of another table

2011-01-10 Thread mart
Never mind the help notice. restructured the models to abundantly use
(and possibly overuse) the "audit trail" model. The results are SWEET!
any new request form that I would need to add, requires just a small
table with its unique Fields. the rest of the data is provided by
combining a few of these:

'imei=db.Table(None,'imei',
   Field('manufacturer'),
   '


Then this to create a new request form: one New table + one new Field
= 3 page form (most of which is pre-populate by the controller :))

db.define_table('imeiRequest',
 common,
 imei,
 rm_request,
 Field('require_cert','boolean'))


the scripted parts in the controllers take care of all work.

Thanks,
Mart :)

On Jan 10, 11:22 am, mart  wrote:
> Hi,
>
> I could be looking in the wring place, but i don't see an example on
> referencing ALL the fields of another table without having to name
> them - I would like the combination of tables to be  more dynamic, so
> that "sub-tables (forms) could be created on the fly depending on user
> input... something like this (taken from the 'Tip of the day' thread):
>
> def newBuildRequest():    # formerly register()
>     form=SQLFORM.factory(db.rm_request,db.buildRequest)
>     if form.accepts(request.vars):
>         id =
> db.rm_request.insert(**db.rm_request._filter_fields(form.vars))
>         form.vars.rm_request=id
>         id = db.insert(**db.buildRequest._filter_fields(form.vars))
>         response.flash='Thanks for filling the form'
>     return dict(form=form)
>
> db.define_table('rm_request',     # main form - mandatory to al forms
>         Field('fied1'),
>         Field('fied2'),
>         Field('fied3'))
>
> db.define_table('customBuildRequest',      # sub-table/form - data
> comes from custom request (request not available in list)
>         Field('fied1'),
>         Field('fied2', requires=db(db, table1.ALLFIELDS))
>
> or
>
>         Field('fied2', requires=db(db, table1.fields()))
>
> or something...
>
> Thanks,
> Mart :)


[web2py] Re: Keys and GAE

2011-01-10 Thread Matt
Sorry that should have been:

 a = db(db.A.id == ['A:1', 'B:2', 'C:3', ''D:4')

Matt

On Jan 11, 4:39 pm, Matt  wrote:
> Thanks Christian,
>
> Your suggestion looks good.
>
> Could potentially specify the "tablename" like:
>
> db(db.address.id == ['user:21', 'address:96'])
>
> NB: this would need to support full recurvsive key generation so that
> you could specify:
>
> Assuming:
>
>                               C.parent = D.id = 4
>                    B.parent = C.id = 3
>         A.parent = B.id = 2
>         A.id = 1
>
> And have the key generated as:
>
>         key = Key.from_path('A', 1, parent=Key.from_path('B', 2,
> parent=Key.from_path('C', 3, parent=Key.from_path('D', 4
>
> Which would equate to:
>
>         a = db(db.A.id == ['D:4', 'C:3', 'B:2', 'A:1'])
>
> Matt
>
> On Jan 11, 3:48 pm, Christian Foster Howes  wrote:
>
>
>
>
>
>
>
> > Matt,
>
> > so now i understand completely.  thanks for the clarification.
>
> > this may be crazy talk, so hopefully those closer to the DAL will weigh
> > in here, but take a look at line select_raw of dal.py (i don't have a
> > line number since i have all modified versions, it's around 2670):
>
> >              elif filter.name=='__key__' and filter.op=='=':
> >                  if filter.value==0:
> >                      items = []
> >                  else:
> >                      item = tableobj.get_by_id(filter.value)
> >                      items = (item and [item]) or []
>
> > here is where the db(db.address.id == 42) gets put together.  I'm making
> > the assumption you would only do == queries, and that you might like
> > something this for your query:
> >     db(db.address.id == [, ]
>
> > which gets put into the dal code block like:
>
> >              elif filter.name=='__key__' and filter.op=='=':
> >                  if filter.value==0:
> >                      items = []
> >                  if isinstance(filter.value, list):
> >                      key = Key.from_path(filter.value[0].tablename, #get
> > table name here somehow
> >                                          filter.value[0].id,
> >                                          tablename, filter.value[1],
> >                  else:
> >                      item = tableobj.get_by_id(filter.value)
> >                      items = (item and [item]) or []
>
> > NOTE: i have not tested or even run this code.  just a suggestion on
> > what it might look like.
>
> > there is also this 
> > thread:https://groups.google.com/forum/#!topic/web2py/WNDXVNNUyQ8 but it 
> > does
> > not model parents quite like GAE would by default.
>
> > cfh
>
> > On 01/10/2011 06:21 PM, Matt wrote:
>
> > > Hi Christian,
>
> > > Thanks for your response.
>
> > > In order to save my entities (as part of an entity group) I've had to
> > > set the parent of the 'address' to be the 'user'. That way I can use a
> > > transaction to persist these multiple entities in one go.
>
> > > I.e. assuming:
>
> > >    db.define_table('user',
> > >            db.Field('name', 'string'))
>
> > >    db.define_table('address',
> > >            db.Field('street', 'string'))
>
> > > In my code (more or less):
>
> > >    from google.appengine.ext import db as gae
>
> > >    def txn(name, street):
> > >            user = db.user._tableobj(name=name)
> > >            address = db.address._tableobj(parent=user, street=street)
> > >            user.put()
> > >            address.put()
>
> > >    gae.run_in_transaction(txn, name='Barry', street='Whatever')
>
> > > Now since I've used a parent for the address I can't do queries using
> > > the DAL like:
>
> > >    address = db.address(addressId)
>
> > > or
>
> > >    address = db.address(db.address.id == addressId) etc.
>
> > > As it always returns None as the "key" for this entity is now composed
> > > of itself plus it's parent. Which I have no way to specify.
>
> > > So hence I have to step outside of web2py to retrieve records using
> > > raw GQL calls and means that I lose nice web2py features like:
>
> > > Inside my html:
>
> > >    {{= address.user.name }}
>
> > > Does that make sense?
>
> > > Ideally I'd like to be able to construct the key and compare it like
> > > any other field.
>
> > > Perhaps a custom GAE method to support this could be added to the
> > > core?
>
> > > Cheers,
> > > Matt
>
> > > On Jan 11, 12:55 pm, howesc  wrote:
> > >> I must admit i'm not following your example.  why do you need to query by
> > >> GAE __key__ rather than by ID?  (i have not used ancestors in GAE so 
> > >> maybe
> > >> that is why i'm mis-understanding).
>
> > >> but your reference to my previous exchange made me look at this in the 
> > >> new
> > >> DAL - and the !=,<,>,<=, and>= queries are broken again on GAE.  I'll
> > >> work on putting a patch together for that since i did it before.  if you
> > >> help me understand your problem better perhaps i can help get you the
> > >> solution that you need.
>
> > >> thanks,
>
> > >> christian


[web2py] Re: Keys and GAE

2011-01-10 Thread Matt
Thanks Christian,

Your suggestion looks good.

Could potentially specify the "tablename" like:

db(db.address.id == ['user:21', 'address:96'])

NB: this would need to support full recurvsive key generation so that
you could specify:

Assuming:

  C.parent = D.id = 4
   B.parent = C.id = 3
A.parent = B.id = 2
A.id = 1

And have the key generated as:

key = Key.from_path('A', 1, parent=Key.from_path('B', 2,
parent=Key.from_path('C', 3, parent=Key.from_path('D', 4

Which would equate to:

a = db(db.A.id == ['D:4', 'C:3', 'B:2', 'A:1'])

Matt

On Jan 11, 3:48 pm, Christian Foster Howes  wrote:
> Matt,
>
> so now i understand completely.  thanks for the clarification.
>
> this may be crazy talk, so hopefully those closer to the DAL will weigh
> in here, but take a look at line select_raw of dal.py (i don't have a
> line number since i have all modified versions, it's around 2670):
>
>              elif filter.name=='__key__' and filter.op=='=':
>                  if filter.value==0:
>                      items = []
>                  else:
>                      item = tableobj.get_by_id(filter.value)
>                      items = (item and [item]) or []
>
> here is where the db(db.address.id == 42) gets put together.  I'm making
> the assumption you would only do == queries, and that you might like
> something this for your query:
>     db(db.address.id == [, ]
>
> which gets put into the dal code block like:
>
>              elif filter.name=='__key__' and filter.op=='=':
>                  if filter.value==0:
>                      items = []
>                  if isinstance(filter.value, list):
>                      key = Key.from_path(filter.value[0].tablename, #get
> table name here somehow
>                                          filter.value[0].id,
>                                          tablename, filter.value[1],
>                  else:
>                      item = tableobj.get_by_id(filter.value)
>                      items = (item and [item]) or []
>
> NOTE: i have not tested or even run this code.  just a suggestion on
> what it might look like.
>
> there is also this 
> thread:https://groups.google.com/forum/#!topic/web2py/WNDXVNNUyQ8 but it does
> not model parents quite like GAE would by default.
>
> cfh
>
> On 01/10/2011 06:21 PM, Matt wrote:
>
>
>
>
>
>
>
> > Hi Christian,
>
> > Thanks for your response.
>
> > In order to save my entities (as part of an entity group) I've had to
> > set the parent of the 'address' to be the 'user'. That way I can use a
> > transaction to persist these multiple entities in one go.
>
> > I.e. assuming:
>
> >    db.define_table('user',
> >            db.Field('name', 'string'))
>
> >    db.define_table('address',
> >            db.Field('street', 'string'))
>
> > In my code (more or less):
>
> >    from google.appengine.ext import db as gae
>
> >    def txn(name, street):
> >            user = db.user._tableobj(name=name)
> >            address = db.address._tableobj(parent=user, street=street)
> >            user.put()
> >            address.put()
>
> >    gae.run_in_transaction(txn, name='Barry', street='Whatever')
>
> > Now since I've used a parent for the address I can't do queries using
> > the DAL like:
>
> >    address = db.address(addressId)
>
> > or
>
> >    address = db.address(db.address.id == addressId) etc.
>
> > As it always returns None as the "key" for this entity is now composed
> > of itself plus it's parent. Which I have no way to specify.
>
> > So hence I have to step outside of web2py to retrieve records using
> > raw GQL calls and means that I lose nice web2py features like:
>
> > Inside my html:
>
> >    {{= address.user.name }}
>
> > Does that make sense?
>
> > Ideally I'd like to be able to construct the key and compare it like
> > any other field.
>
> > Perhaps a custom GAE method to support this could be added to the
> > core?
>
> > Cheers,
> > Matt
>
> > On Jan 11, 12:55 pm, howesc  wrote:
> >> I must admit i'm not following your example.  why do you need to query by
> >> GAE __key__ rather than by ID?  (i have not used ancestors in GAE so maybe
> >> that is why i'm mis-understanding).
>
> >> but your reference to my previous exchange made me look at this in the new
> >> DAL - and the !=,<,>,<=, and>= queries are broken again on GAE.  I'll
> >> work on putting a patch together for that since i did it before.  if you
> >> help me understand your problem better perhaps i can help get you the
> >> solution that you need.
>
> >> thanks,
>
> >> christian


[web2py] Re: wrong documentation on ajax api sample?

2011-01-10 Thread DenesL

Yes, you can't upgrade... and the documentation is broken as per the
first post.


On Jan 10, 9:07 pm, Massimo Di Pierro 
wrote:
> No because the ajax part (web2py_ajax.html) stays with the app.It is
> not affected by upgrades unless you want to.
>
> On Jan 10, 5:17 pm, DenesL  wrote:
>
> > Does this cause any backward compatibility issues?.
>
> > On Jan 7, 10:25 am, DenesL  wrote:
>
> > > Hmmm... somewhere after 1.56.2 the ajax function was changed.
> > > It now uses serialize (which encodes a set of form elements as a
> > > string for submission) instead of the original getElementById.
>
>


Re: [web2py] Re: Keys and GAE

2011-01-10 Thread Christian Foster Howes

Matt,

so now i understand completely.  thanks for the clarification.

this may be crazy talk, so hopefully those closer to the DAL will weigh 
in here, but take a look at line select_raw of dal.py (i don't have a 
line number since i have all modified versions, it's around 2670):


elif filter.name=='__key__' and filter.op=='=':
if filter.value==0:
items = []
else:
item = tableobj.get_by_id(filter.value)
items = (item and [item]) or []

here is where the db(db.address.id == 42) gets put together.  I'm making 
the assumption you would only do == queries, and that you might like 
something this for your query:

   db(db.address.id == [, ]

which gets put into the dal code block like:

elif filter.name=='__key__' and filter.op=='=':
if filter.value==0:
items = []
if isinstance(filter.value, list):
key = Key.from_path(filter.value[0].tablename, #get 
table name here somehow

filter.value[0].id,
tablename, filter.value[1],
else:
item = tableobj.get_by_id(filter.value)
items = (item and [item]) or []

NOTE: i have not tested or even run this code.  just a suggestion on 
what it might look like.


there is also this thread: 
https://groups.google.com/forum/#!topic/web2py/WNDXVNNUyQ8  but it does 
not model parents quite like GAE would by default.


cfh


On 01/10/2011 06:21 PM, Matt wrote:

Hi Christian,

Thanks for your response.

In order to save my entities (as part of an entity group) I've had to
set the parent of the 'address' to be the 'user'. That way I can use a
transaction to persist these multiple entities in one go.

I.e. assuming:

db.define_table('user',
db.Field('name', 'string'))

db.define_table('address',
db.Field('street', 'string'))

In my code (more or less):

from google.appengine.ext import db as gae

def txn(name, street):
user = db.user._tableobj(name=name)
address = db.address._tableobj(parent=user, street=street)
user.put()
address.put()

gae.run_in_transaction(txn, name='Barry', street='Whatever')

Now since I've used a parent for the address I can't do queries using
the DAL like:

address = db.address(addressId)

or

address = db.address(db.address.id == addressId) etc.

As it always returns None as the "key" for this entity is now composed
of itself plus it's parent. Which I have no way to specify.

So hence I have to step outside of web2py to retrieve records using
raw GQL calls and means that I lose nice web2py features like:

Inside my html:

{{= address.user.name }}

Does that make sense?

Ideally I'd like to be able to construct the key and compare it like
any other field.

Perhaps a custom GAE method to support this could be added to the
core?

Cheers,
Matt


On Jan 11, 12:55 pm, howesc  wrote:

I must admit i'm not following your example.  why do you need to query by
GAE __key__ rather than by ID?  (i have not used ancestors in GAE so maybe
that is why i'm mis-understanding).

but your reference to my previous exchange made me look at this in the new
DAL - and the !=,<,>,<=, and>= queries are broken again on GAE.  I'll
work on putting a patch together for that since i did it before.  if you
help me understand your problem better perhaps i can help get you the
solution that you need.

thanks,

christian





[web2py] Help with cron

2011-01-10 Thread pbreit
I can't seem to get my cron working. Any tips?

Running 1.91.6 locally on a Mac.

cron/crontab:
#run every 2 minutes
*/2 * * * * root *cron/release_pending_items.py

controllers/cron.py:
def release_pending_items():
items = db(db.item.status=='pending').select()
for item in items:
item.update_record(status='active')
purchase = db(db.purchase.item==item.id).select().first()
purchase.update_record(status='abandoned')
db.commit()

Works fine when I call it in the browser:
http://127.0.0.1:8000/myapp/cron/release_pending_items


[web2py] Re: Keys and GAE

2011-01-10 Thread Matt
Hi Christian,

Thanks for your response.

In order to save my entities (as part of an entity group) I've had to
set the parent of the 'address' to be the 'user'. That way I can use a
transaction to persist these multiple entities in one go.

I.e. assuming:

db.define_table('user',
db.Field('name', 'string'))

db.define_table('address',
db.Field('street', 'string'))

In my code (more or less):

from google.appengine.ext import db as gae

def txn(name, street):
user = db.user._tableobj(name=name)
address = db.address._tableobj(parent=user, street=street)
user.put()
address.put()

gae.run_in_transaction(txn, name='Barry', street='Whatever')

Now since I've used a parent for the address I can't do queries using
the DAL like:

address = db.address(addressId)

or

address = db.address(db.address.id == addressId) etc.

As it always returns None as the "key" for this entity is now composed
of itself plus it's parent. Which I have no way to specify.

So hence I have to step outside of web2py to retrieve records using
raw GQL calls and means that I lose nice web2py features like:

Inside my html:

{{= address.user.name }}

Does that make sense?

Ideally I'd like to be able to construct the key and compare it like
any other field.

Perhaps a custom GAE method to support this could be added to the
core?

Cheers,
Matt


On Jan 11, 12:55 pm, howesc  wrote:
> I must admit i'm not following your example.  why do you need to query by
> GAE __key__ rather than by ID?  (i have not used ancestors in GAE so maybe
> that is why i'm mis-understanding).
>
> but your reference to my previous exchange made me look at this in the new
> DAL - and the !=, <, >, <=, and >= queries are broken again on GAE.  I'll
> work on putting a patch together for that since i did it before.  if you
> help me understand your problem better perhaps i can help get you the
> solution that you need.
>
> thanks,
>
> christian


[web2py] Re: SQLFORM and read-only references

2011-01-10 Thread Massimo Di Pierro
Is this in appadmin or your own forms?

On Jan 10, 5:44 pm, howesc  wrote:
> It seems that in the latest version of web2py (1.91.6 and today's trunk)
> that if you have a table (say auth_user), with a format string, and then you
> refer to it in another table as read-only like:
>   Field('updated_by', 'reference '+auth.settings.table_user_name,
>         default=auth.user_id,update=auth.user_id,writable=False),
>
> when the form is rendered we see 'None' rather than the format of the
> referenced table.  I can adjust the read-only field to have a represent
> like:
>   Field('created_by', 'reference '+auth.settings.table_user_name,
>         default=auth.user_id, writable=False,
>         represent=lambda x: auth_user_table[x].first_name + " " + \
>           auth_user_table[x].last_name+" ("+str(auth_user_table[x].id)+")" \
>           if x else None),
> (which matches my format string on my auth_user table).  Is this a
> regression, or was i making broken assumptions previously?
>
> thanks,
>
> christian


[web2py] Re: flush in web2py?

2011-01-10 Thread Massimo Di Pierro
Too complex and not worth it. I would just use ajax.

On Jan 10, 5:25 pm, Alexandre Andrade 
wrote:
> I can't imagine how to do this:
>
> "You would have to break a view into
> pieces, have an iterator process the pieces separately, return the
> iterator."
>
> Maybe using ajax I can achive this? Flush the content to a div?
>
> someone can post a example?
>
> 2011/1/10 Massimo Di Pierro 
>
>
>
>
>
>
>
>
>
> > Not possible in web2py without major refactoring. That is because the
> > view is a program that needs to run in order to produce an output.
>
> > One way to do would be to have an action return an iterator. Each term
> > in the iterator is flushed. You would have to break a view into
> > pieces, have an iterator process the pieces separately, return the
> > iterator.
>
> > Massimo
>
> > On Jan 10, 3:59 pm, Alexandre Andrade 
> > wrote:
> > > In php, you can flush the data with the flush() function.
>
> > > It allows to send the data to the browser without wait for the rest of
> > code.
>
> > > It's useful when you are doing a intensive computing task or a long time
> > > task and need send a answer to the user whie he waits.
>
> > > My question is:
>
> > > There is a way to do this with web2py?
>
> > > --
> > > Atenciosamente
>
> > > Alexandre Andrade
> > > Hipercenter.com Classificados Gratuitos e Inteligentes
>
> --
> Atenciosamente
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Re: wrong documentation on ajax api sample?

2011-01-10 Thread Massimo Di Pierro
No because the ajax part (web2py_ajax.html) stays with the app.It is
not affected by upgrades unless you want to.

On Jan 10, 5:17 pm, DenesL  wrote:
> Does this cause any backward compatibility issues?.
>
> On Jan 7, 10:25 am, DenesL  wrote:
>
>
>
>
>
>
>
> > Hmmm... somewhere after 1.56.2 the ajax function was changed.
> > It now uses serialize (which encodes a set of form elements as a
> > string for submission) instead of the original getElementById.


Re: [web2py] Email gateway

2011-01-10 Thread Kenneth Lundström

Thank You Bruno and Alexandre for your answers.

I think I have now downloaded the attachment but not written it anywhere 
yet. Would it be possible to use the uploads function i web2py to save 
the file in uploads and update a table with info about the new file?



Kenneth



You should look to the built in modules:

from poplib import *

or

from imaplib import *

I used poplib to get raw text messages, but I never get attached 
files, but I guess it can do it.



2011/1/10 Kenneth Lundström >


A gateway that works the other way. Instead of sending emails from
web2py I悲 like to receive emails.

I惴 working on a app where you upload PDF:s containing receipts.
Those PDF:s are usually scanned in a photocopier that emails the
PDF to your email. Then you have to login in to my app and upload
it. So my idea was to give the photocopier another email adress
which my app reads and extracts the PDF from it

Has anybody made anything like this? Where should I start? I guess
it should be some kind of pop/imap client polling the postbox and
reading and extrating everything from it.


Kenneth




--

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




Re: [web2py] Re: Inserting additional fields in crud

2011-01-10 Thread Martin H
Thanks. That thread did it.

orm=SQLFORM 
.factory(db.client,Field('extra_field'))



[web2py] Re: Keys and GAE

2011-01-10 Thread howesc
I must admit i'm not following your example.  why do you need to query by 
GAE __key__ rather than by ID?  (i have not used ancestors in GAE so maybe 
that is why i'm mis-understanding).

but your reference to my previous exchange made me look at this in the new 
DAL - and the !=, <, >, <=, and >= queries are broken again on GAE.  I'll 
work on putting a patch together for that since i did it before.  if you 
help me understand your problem better perhaps i can help get you the 
solution that you need.

thanks,

christian


[web2py] SQLFORM and read-only references

2011-01-10 Thread howesc
It seems that in the latest version of web2py (1.91.6 and today's trunk) 
that if you have a table (say auth_user), with a format string, and then you 
refer to it in another table as read-only like:
  Field('updated_by', 'reference '+auth.settings.table_user_name,
default=auth.user_id,update=auth.user_id,writable=False),

when the form is rendered we see 'None' rather than the format of the 
referenced table.  I can adjust the read-only field to have a represent 
like:
  Field('created_by', 'reference '+auth.settings.table_user_name,
default=auth.user_id, writable=False,
represent=lambda x: auth_user_table[x].first_name + " " + \
  auth_user_table[x].last_name+" ("+str(auth_user_table[x].id)+")" \
  if x else None),
(which matches my format string on my auth_user table).  Is this a 
regression, or was i making broken assumptions previously?

thanks,

christian


Re: [web2py] Re: flush in web2py?

2011-01-10 Thread Alexandre Andrade
I can't imagine how to do this:

"You would have to break a view into
pieces, have an iterator process the pieces separately, return the
iterator."

Maybe using ajax I can achive this? Flush the content to a div?

someone can post a example?



2011/1/10 Massimo Di Pierro 

> Not possible in web2py without major refactoring. That is because the
> view is a program that needs to run in order to produce an output.
>
> One way to do would be to have an action return an iterator. Each term
> in the iterator is flushed. You would have to break a view into
> pieces, have an iterator process the pieces separately, return the
> iterator.
>
>
> Massimo
>
>
> On Jan 10, 3:59 pm, Alexandre Andrade 
> wrote:
> > In php, you can flush the data with the flush() function.
> >
> > It allows to send the data to the browser without wait for the rest of
> code.
> >
> > It's useful when you are doing a intensive computing task or a long time
> > task and need send a answer to the user whie he waits.
> >
> > My question is:
> >
> > There is a way to do this with web2py?
> >
> > --
> > Atenciosamente
> >
> > Alexandre Andrade
> > Hipercenter.com Classificados Gratuitos e Inteligentes
>



-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Re: wrong documentation on ajax api sample?

2011-01-10 Thread DenesL

Does this cause any backward compatibility issues?.

On Jan 7, 10:25 am, DenesL  wrote:
> Hmmm... somewhere after 1.56.2 the ajax function was changed.
> It now uses serialize (which encodes a set of form elements as a
> string for submission) instead of the original getElementById.


Re: [web2py] jquery.tools.min.js

2011-01-10 Thread Kenneth Lundström
Yes, I tried to load it as number 1 first, but I´ll try again some other 
places.


Thank you for your answer.


Kenneth


Sometimes it is just the order of loading: did you try to change the
order i.e. the "3" to something else?

hope it works!
mic

2011/1/10 Kenneth Lundström:

A while ago I got an app from Bruno with an example app showing how to open
a modal window.

It works great in the example but when I copied it to my own app I couldn´t
get it working. After some debugging I found out that I need to include the
jquery.tools.min.js file.

The only way I could get it working was by adding it to web2py_ajax.html. I
added it to the file with:
response.files.insert(3,URL('static','jquery.tools.min.js'))

Everything was cool until I noticed that the small date picker calender is
not working anymore. Only way to get it to work is by commenting out that
jquery.tools.min.js file.

How do I include that tools file without disabling the date picker?


Kenneth






Re: [web2py] jquery.tools.min.js

2011-01-10 Thread Michele Comitini
Sometimes it is just the order of loading: did you try to change the
order i.e. the "3" to something else?

hope it works!
mic

2011/1/10 Kenneth Lundström :
> A while ago I got an app from Bruno with an example app showing how to open
> a modal window.
>
> It works great in the example but when I copied it to my own app I couldn´t
> get it working. After some debugging I found out that I need to include the
> jquery.tools.min.js file.
>
> The only way I could get it working was by adding it to web2py_ajax.html. I
> added it to the file with:
> response.files.insert(3,URL('static','jquery.tools.min.js'))
>
> Everything was cool until I noticed that the small date picker calender is
> not working anymore. Only way to get it to work is by commenting out that
> jquery.tools.min.js file.
>
> How do I include that tools file without disabling the date picker?
>
>
> Kenneth
>
>


Re: [web2py] Problems with ssh tunnel to run cherokee-admin and configure web2py

2011-01-10 Thread Offray Vladimir Luna Cárdenas
Hi,

El 10/01/11 14:38, pbreit escribió:
> I'm not sure why '-N' would be necessary. I don't seem to need it on 
> RackSpace Cloud Ubuntu 10.04.
> 
> The '-b' flag defeats the purpose. '-b' enables you to connect to Cherokee 
> admin over any port (ie, http://173.230.137.80/admin). Omitting '-b' is what 
> requires tunneling through localhost which is a security precaution.
> 

After restarting the graphical mode I can use ssh tunneling for login
into cherokee-admin without any problem or additional flags. I don't
know what was happening in first place, but now all is working as in the
slice.

Thanks,

Offray


[web2py] Re: [Tips] Change style of sqlform

2011-01-10 Thread Anthony
This is great. Thanks. If you have time, maybe you could add it as a slice: 
http://web2pyslices.com

Re: [web2py] Gzip compression of javascript to speed up website

2011-01-10 Thread Michele Comitini
If you use apache proxy rewrite in front of your web2py you can
compress everything even html.
I do not know if it is possible with apache+fcgi or apache+wsgi, does anyone?

mic

2011/1/10 pbreit :
> Also, for Jquery:
> http://code.google.com/apis/libraries/devguide.html#jquery
>


Re: [web2py] Re: Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Richard Vézina
Hello Massimo it is related to this thread I think :
http://groups.google.com/group/web2py/browse_thread/thread/561ee826ac9c1ff2?pli=1

So
you will close more then one issue ;-)

Richard

On Mon, Jan 10, 2011 at 4:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> It took me a while to debug this.
> The problem is that the ajax service that fills the table requires
> login.
> You probably have not created an account or have not logged in.
> The page that displays the jqgrid does not require login so it shows,
> but the service responds with a login page instead of sending the
> data.
>
> There should be a clearly displayed error in this case and I will
> modify plugin_wiki to take care of this case more gracefully.
>
> On Jan 10, 2:00 pm, Lisandro  wrote:
> > I downloaded web2py (1.91.6) and executed the development server.
> > I edited the "welcome" app:
> >
> > First, I installed the plugin "plugin_wiki" in the "welcome" app.
> >
> > Second, I edited the db.py, adding the following line (every other
> > thing stays as default):
> >
> ---
> 
> > db.define_table('ciudadanos', Field('nro_documento'))
> >
> ---
> 
> > I added some sample records.
> >
> > Third, I edited the "default/index.html" view, adding the following
> > line:
> >
> ---
> 
> > {{=plugin_wiki.widget('jqgrid', 'ciudadanos')}}
> >
> ---
> 
> >
> > When I acceshttp://.../welcome/default/index, I can see the jqgrid,
> > but it contains nothing.
> > I tried with:
> >  * {{=plugin_wiki.widget('jqgrid',  table='ciudadanos')}}
> >  * {{=plugin_wiki.widget('jqgrid', table=db.ciudadanos)}}
> > But nothing happens.
> >
> > ¿What am I doing wrong? Thanks in advance.
>


Re: [web2py] Gzip compression of javascript to speed up website

2011-01-10 Thread pbreit
Also, for Jquery:
http://code.google.com/apis/libraries/devguide.html#jquery


[web2py] Keys and GAE

2011-01-10 Thread Matt
Hi there,

How can I construct a GAE query using the DAL which allows me to
specify the __key__?

I can see several references to this in the dal.py file. Also in the
following post:

http://groups.google.com/group/web2py/browse_thread/thread/2ed53b5dc9069bef/785854e3ff3aa40b?lnk=gst&q=ANCESTOR#785854e3ff3aa40b

I need to do something like:

key = Key.from_path('address', addressId,
parent=Key.from_path('user', userId))   <--- need to be able to set
the parent

address = db.address(db.address.key == str(key)) or something to
this effect.

I know I can access the internal GAE model like

   address = db.address._tableobj.get_by_id(id,
parent=Key.from_path('user', userId))

   or

   address = gae,get(key)

But then I've stepped _outside_ of web2py and alot of the useful
functionality provided by web2py is unusable.

Thanks in advance,
Matt

PS: Alternatively is there a way of re-wrapping these GAE models back
up into a Row?


[web2py] Re: [w2py-dev] Re: ajax upload for components

2011-01-10 Thread Michele Comitini
I made a slice:

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

mic

2011/1/10 K.R.Arun :
> Can you show me an example with file upload using jQuery form plugin?

> Michele Comitini wrote:
>> sorry i have to repeat myself, use the following, it is working and it
>> is simple:
>> http://jquery.malsup.com/form/
>>
>> it does everything for you, and gives more control than LOAD(...,ajax=True).
>>
>> mic
>> 2011/1/9 Massimo Di Pierro :
>> >
>> > On Jan 9, 2011, at 11:31 AM, Arun K.Rajeevan wrote:
>> >
>> > iframe works its own. I'm not a pro on javascript.
>> > May be there is a way in js to access parent document from within iframe.
>> > If there's so, you can write your own js code to update main page (which
>> > embeds iframe).
>> >
>> > yes there is. windows. parent
>> > http://developer.apple.com/internet/webcontent/iframe.html
>> >
>> > I can tell you one more suggestion.
>> > If the parts in the page to be uploaded after each upload is represented
>> > together in the document,
>> > you can redesign the page so that, upload form and parts to be updated
>> > are separated out to a component and load it into iframe.
>> > Since everything is within same scope (iframe) it'll work.
>> > Sorry, I'm not an expert to suggest a way (if part to be uploaded are
>> > scattered in the main document)
>> > (I'm pretty sure JS can do that.)  also you are not limited to use only
>> > uploadify there are others too.
>> > --
>> > mail from:GoogleGroups "web2py-developers" mailing list
>> > make speech: web2py-develop...@googlegroups.com
>> > unsubscribe: web2py-developers+unsubscr...@googlegroups.com
>> > details : http://groups.google.com/group/web2py-developers
>> > the project: http://code.google.com/p/web2py/
>> > official : http://www.web2py.com/
>> >
>> > --
>> > mail from:GoogleGroups "web2py-developers" mailing list
>> > make speech: web2py-develop...@googlegroups.com
>> > unsubscribe: web2py-developers+unsubscr...@googlegroups.com
>> > details : http://groups.google.com/group/web2py-developers
>> > the project: http://code.google.com/p/web2py/
>> > official : http://www.web2py.com/
>> >


[web2py] Re: flush in web2py?

2011-01-10 Thread Massimo Di Pierro
Not possible in web2py without major refactoring. That is because the
view is a program that needs to run in order to produce an output.

One way to do would be to have an action return an iterator. Each term
in the iterator is flushed. You would have to break a view into
pieces, have an iterator process the pieces separately, return the
iterator.


Massimo


On Jan 10, 3:59 pm, Alexandre Andrade 
wrote:
> In php, you can flush the data with the flush() function.
>
> It allows to send the data to the browser without wait for the rest of code.
>
> It's useful when you are doing a intensive computing task or a long time
> task and need send a answer to the user whie he waits.
>
> My question is:
>
> There is a way to do this with web2py?
>
> --
> Atenciosamente
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos e Inteligentes


Re: [web2py] Gzip compression of javascript to speed up website

2011-01-10 Thread Bruno Rocha
Not gzip, but works well -> http://pypi.python.org/pypi/WebDepCompress/0.2

2011/1/10 DJ 

> Hi there,
>
> I was using Chrome's audit tool to see how I can increase my application
> speed. One of recommendations Chrome suggests is that I gzip javascript
> files (jquery, others) to decrease loading time.
>
> Can the web2py server be set to serve zipped content based on the incoming
> browser? Also, can we set the browser to cache certain reusable aspects like
> CSS, images, etc?
>
> -Sebastian
>



-- 

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


[web2py] Re: Is it a bug in "with_alias"?

2011-01-10 Thread Massimo Di Pierro
Actually I am not sure why the SQL is wrong. The SQL looks correct
although with_alias for a field is undocumented, except for tables,
and I am not sure how well it works.

On Jan 10, 3:42 pm, LightOfMooN  wrote:
> rolics = db(db.rolic.id>0).select(db.rolic.id.with_alias('myid'))
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/contrib/shell.py", line 225, in
> run
>     exec compiled in statement_module.__dict__
>   File "", line 1, in 
>   File "/home/www-data/web2py/gluon/dal.py", line 4507, in select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "/home/www-data/web2py/gluon/dal.py", line 1003, in select
>     rows = response(sql)
>   File "/home/www-data/web2py/gluon/dal.py", line 994, in response
>     self.execute(sql)
>   File "/home/www-data/web2py/gluon/dal.py", line 1067, in execute
>     return self.log_execute(*a, **b)
>   File "/home/www-data/web2py/gluon/dal.py", line 1064, in log_execute
>     return self.cursor.execute(*a,**b)
> ProgrammingError: syntax error at or near "AS"
> LINE 1: SELECT  (rolic.id AS myid) FROM rolic WHERE (rolic.id > 0);
>                                       ^
>
> What's wrong? Help, please.


Re: [web2py] Re: Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Bruno Rocha
>
> Ok, thanks very much! That was the problem, I had to login :)
>
> I've heard of PowerTable, and even I visited the webpage, saw the
> demos. PowerTable is really cool, but (I'm quoting the author in this)
> it's not appropriate for tables with lot of records, because it uses
> "datatable", and datatable isn't server side processing;


Not yet,

Datatables has serverside processing
http://datatables.net/examples/server_side/server_side.html

But, It is not
in plugin_powerTable yet, I have a list of wishes and issues, I am working
on my free time to fix bugs and implement new features.

There are some people helping with tests, and I hope to implement ServerSide
processing very soon ( I actually have it working on my machine, but it is
not very well included in the plugin)

I hope to be able to do something like:

plugins.powerTable.datasource = URL('a_funtion_which_returns_xml_or_json')

I am looking throught webgrid and Jqgrid code to take some ideas and it is
on the way.

For now, you have to go with webgrid or jqgrid if you need server side
processing.

-- 

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


[web2py] Gzip compression of javascript to speed up website

2011-01-10 Thread DJ
Hi there,

I was using Chrome's audit tool to see how I can increase my application 
speed. One of recommendations Chrome suggests is that I gzip javascript 
files (jquery, others) to decrease loading time.

Can the web2py server be set to serve zipped content based on the incoming 
browser? Also, can we set the browser to cache certain reusable aspects like 
CSS, images, etc?

-Sebastian


[web2py] flush in web2py?

2011-01-10 Thread Alexandre Andrade
In php, you can flush the data with the flush() function.

It allows to send the data to the browser without wait for the rest of code.

It's useful when you are doing a intensive computing task or a long time
task and need send a answer to the user whie he waits.


My question is:

There is a way to do this with web2py?



-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Re: Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Lisandro
Ok, thanks very much! That was the problem, I had to login :)

I've heard of PowerTable, and even I visited the webpage, saw the
demos. PowerTable is really cool, but (I'm quoting the author in this)
it's not appropriate for tables with lot of records, because it uses
"datatable", and datatable isn't server side processing; that's the
cool stuff of jqgrid.

Thanks Richard and Massimo


On 10 ene, 18:13, Massimo Di Pierro 
wrote:
> It took me a while to debug this.
> The problem is that the ajax service that fills the table requires
> login.
> You probably have not created an account or have not logged in.
> The page that displays the jqgrid does not require login so it shows,
> but the service responds with a login page instead of sending the
> data.
>
> There should be a clearly displayed error in this case and I will
> modify plugin_wiki to take care of this case more gracefully.
>
> On Jan 10, 2:00 pm, Lisandro  wrote:
>
> > I downloaded web2py (1.91.6) and executed the development server.
> > I edited the "welcome" app:
>
> > First, I installed the plugin "plugin_wiki" in the "welcome" app.
>
> > Second, I edited the db.py, adding the following line (every other
> > thing stays as default):
> > --- 
> > 
> > db.define_table('ciudadanos', Field('nro_documento'))
> > --- 
> > 
> > I added some sample records.
>
> > Third, I edited the "default/index.html" view, adding the following
> > line:
> > --- 
> > 
> > {{=plugin_wiki.widget('jqgrid', 'ciudadanos')}}
> > --- 
> > 
>
> > When I acceshttp://.../welcome/default/index, I can see the jqgrid,
> > but it contains nothing.
> > I tried with:
> >  * {{=plugin_wiki.widget('jqgrid',  table='ciudadanos')}}
> >  * {{=plugin_wiki.widget('jqgrid', table=db.ciudadanos)}}
> > But nothing happens.
>
> > ¿What am I doing wrong? Thanks in advance.
>
>


Re: [web2py] Email gateway

2011-01-10 Thread Alexandre Andrade
You can start from

http://docs.python.org/library/poplib.html
http://docs.python.org/library/imaplib.html

http://docs.python.org/library/email.parser.html


Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes



2011/1/10 Kenneth Lundström 

> A gateway that works the other way. Instead of sending emails from web2py
> I悲 like to receive emails.
>
> I惴 working on a app where you upload PDF:s containing receipts. Those PDF:s
> are usually scanned in a photocopier that emails the PDF to your email. Then
> you have to login in to my app and upload it. So my idea was to give the
> photocopier another email adress which my app reads and extracts the PDF
> from it.
>
> Has anybody made anything like this? Where should I start? I guess it
> should be some kind of pop/imap client polling the postbox and reading and
> extrating everything from it.
>
>
> Kenneth
>
>


--


[web2py] jquery.tools.min.js

2011-01-10 Thread Kenneth Lundström
A while ago I got an app from Bruno with an example app showing how to 
open a modal window.


It works great in the example but when I copied it to my own app I 
couldn´t get it working. After some debugging I found out that I need to 
include the jquery.tools.min.js file.


The only way I could get it working was by adding it to 
web2py_ajax.html. I added it to the file with:

response.files.insert(3,URL('static','jquery.tools.min.js'))

Everything was cool until I noticed that the small date picker calender 
is not working anymore. Only way to get it to work is by commenting out 
that jquery.tools.min.js file.


How do I include that tools file without disabling the date picker?


Kenneth



[web2py] Re: Is it a bug in "with_alias"?

2011-01-10 Thread LightOfMooN
oops, sorry, failed with spaces
"^" is under "AS", not under "FROM"


Re: [web2py] Email gateway

2011-01-10 Thread Bruno Rocha
You should look to the built in modules:

from poplib import *

or

from imaplib import *

I used poplib to get raw text messages, but I never get attached files, but
I guess it can do it.


2011/1/10 Kenneth Lundström 

> A gateway that works the other way. Instead of sending emails from web2py
> I悲 like to receive emails.
>
> I惴 working on a app where you upload PDF:s containing receipts. Those PDF:s
> are usually scanned in a photocopier that emails the PDF to your email. Then
> you have to login in to my app and upload it. So my idea was to give the
> photocopier another email adress which my app reads and extracts the PDF
> from it
>
> Has anybody made anything like this? Where should I start? I guess it
> should be some kind of pop/imap client polling the postbox and reading and
> extrating everything from it.
>
>
> Kenneth
>
>


-- 

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


[web2py] Is it a bug in "with_alias"?

2011-01-10 Thread LightOfMooN
rolics = db(db.rolic.id>0).select(db.rolic.id.with_alias('myid'))

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/contrib/shell.py", line 225, in
run
exec compiled in statement_module.__dict__
  File "", line 1, in 
  File "/home/www-data/web2py/gluon/dal.py", line 4507, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "/home/www-data/web2py/gluon/dal.py", line 1003, in select
rows = response(sql)
  File "/home/www-data/web2py/gluon/dal.py", line 994, in response
self.execute(sql)
  File "/home/www-data/web2py/gluon/dal.py", line 1067, in execute
return self.log_execute(*a, **b)
  File "/home/www-data/web2py/gluon/dal.py", line 1064, in log_execute
return self.cursor.execute(*a,**b)
ProgrammingError: syntax error at or near "AS"
LINE 1: SELECT  (rolic.id AS myid) FROM rolic WHERE (rolic.id > 0);
  ^

What's wrong? Help, please.


Re: [web2py] Re: The first code example of the CRUD Methods section of the online web2py book

2011-01-10 Thread Alexandre Andrade
Please forgot my last message.



2011/1/10 Alexandre Andrade 

> > The problem is supposed to be in this line:
> > persons = crud.select(db.person, fields=['name'],
> > headers={'person.name': 'Name'})
>
> There is a typo, the last line shoul be:
>
> headers={{'person.name': 'Name'})
>
>
>
> 2011/1/10 Massimo Di Pierro 
>
> Nothing. Can we see more of the code?
>>
>> On Jan 10, 1:47 pm, AW  wrote:
>> > I tried to run the .../default/people request after I put a simple
>> > view in place:
>> >
>> > {{extend 'layout.html'}}
>> >
>> > {{=form}}
>> >
>> > And I just got this error message:
>> > "
>> > Error snapshot
>> > Detailed traceback description
>> > Exception: ('person')
>> > "
>> >
>> > The problem is supposed to be in this line:
>> > persons = crud.select(db.person, fields=['name'],
>> > headers={'person.name': 'Name'})
>> >
>> > What's wrong with that? Thanks.
>>
>
>
>
> --
> Atenciosamente
>
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos e Inteligentes
>



-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Email gateway

2011-01-10 Thread Kenneth Lundström
A gateway that works the other way. Instead of sending emails from 
web2py I´d like to receive emails.


I´m working on a app where you upload PDF:s containing receipts. Those 
PDF:s are usually scanned in a photocopier that emails the PDF to your 
email. Then you have to login in to my app and upload it. So my idea was 
to give the photocopier another email adress which my app reads and 
extracts the PDF from it.


Has anybody made anything like this? Where should I start? I guess it 
should be some kind of pop/imap client polling the postbox and reading 
and extrating everything from it.



Kenneth



Re: [web2py] Re: The first code example of the CRUD Methods section of the online web2py book

2011-01-10 Thread Alexandre Andrade
> The problem is supposed to be in this line:
> persons = crud.select(db.person, fields=['name'],
> headers={'person.name': 'Name'})

There is a typo, the last line shoul be:

headers={{'person.name': 'Name'})



2011/1/10 Massimo Di Pierro 

> Nothing. Can we see more of the code?
>
> On Jan 10, 1:47 pm, AW  wrote:
> > I tried to run the .../default/people request after I put a simple
> > view in place:
> >
> > {{extend 'layout.html'}}
> >
> > {{=form}}
> >
> > And I just got this error message:
> > "
> > Error snapshot
> > Detailed traceback description
> > Exception: ('person')
> > "
> >
> > The problem is supposed to be in this line:
> > persons = crud.select(db.person, fields=['name'],
> > headers={'person.name': 'Name'})
> >
> > What's wrong with that? Thanks.
>



-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Re: The first code example of the CRUD Methods section of the online web2py book

2011-01-10 Thread Massimo Di Pierro
Nothing. Can we see more of the code?

On Jan 10, 1:47 pm, AW  wrote:
> I tried to run the .../default/people request after I put a simple
> view in place:
>
> {{extend 'layout.html'}}
>
> {{=form}}
>
> And I just got this error message:
> "
> Error snapshot
> Detailed traceback description
> Exception: ('person')
> "
>
> The problem is supposed to be in this line:
> persons = crud.select(db.person, fields=['name'],
> headers={'person.name': 'Name'})
>
> What's wrong with that? Thanks.


[web2py] Re: Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Massimo Di Pierro
It took me a while to debug this.
The problem is that the ajax service that fills the table requires
login.
You probably have not created an account or have not logged in.
The page that displays the jqgrid does not require login so it shows,
but the service responds with a login page instead of sending the
data.

There should be a clearly displayed error in this case and I will
modify plugin_wiki to take care of this case more gracefully.

On Jan 10, 2:00 pm, Lisandro  wrote:
> I downloaded web2py (1.91.6) and executed the development server.
> I edited the "welcome" app:
>
> First, I installed the plugin "plugin_wiki" in the "welcome" app.
>
> Second, I edited the db.py, adding the following line (every other
> thing stays as default):
> --- 
> 
> db.define_table('ciudadanos', Field('nro_documento'))
> --- 
> 
> I added some sample records.
>
> Third, I edited the "default/index.html" view, adding the following
> line:
> --- 
> 
> {{=plugin_wiki.widget('jqgrid', 'ciudadanos')}}
> --- 
> 
>
> When I acceshttp://.../welcome/default/index, I can see the jqgrid,
> but it contains nothing.
> I tried with:
>  * {{=plugin_wiki.widget('jqgrid',  table='ciudadanos')}}
>  * {{=plugin_wiki.widget('jqgrid', table=db.ciudadanos)}}
> But nothing happens.
>
> ¿What am I doing wrong? Thanks in advance.


[web2py] Re: The first code example of the CRUD Methods section of the online web2py book

2011-01-10 Thread AW
I tried to run the .../default/people request after I put a simple
view in place:

{{extend 'layout.html'}}

{{=form}}


And I just got this error message:
"
Error snapshot
Detailed traceback description
Exception: ('person')
"

The problem is supposed to be in this line:
persons = crud.select(db.person, fields=['name'],
headers={'person.name': 'Name'})

What's wrong with that? Thanks.


[web2py] [Offtopic] Generate a mockup from existing web page

2011-01-10 Thread mikech
Interesting blog entry on the Foreui mockup tool blog about a service that 
is free for now which generated either Balsamiq or Foreui meta file from an 
existing web page.  The author tried it on the front page of Linkedin with 
some success.  I tried it on the front page of Dzone with quite a bit less 
luck. 
http://www.foreui.com/blog/?p=1065

Here is a direct link to the tools homepage:
http://www.looksie.me/




Re: [web2py] Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Richard Vézina
Why not try powerTable?

On Mon, Jan 10, 2011 at 3:00 PM, Lisandro wrote:

> I downloaded web2py (1.91.6) and executed the development server.
> I edited the "welcome" app:
>
> First, I installed the plugin "plugin_wiki" in the "welcome" app.
>
> Second, I edited the db.py, adding the following line (every other
> thing stays as default):
>
> ---
> db.define_table('ciudadanos', Field('nro_documento'))
>
> ---
> I added some sample records.
>
>
> Third, I edited the "default/index.html" view, adding the following
> line:
>
> ---
> {{=plugin_wiki.widget('jqgrid', 'ciudadanos')}}
>
> ---
>
> When I acces http://.../welcome/default/index, I can see the jqgrid,
> but it contains nothing.
> I tried with:
>  * {{=plugin_wiki.widget('jqgrid',  table='ciudadanos')}}
>  * {{=plugin_wiki.widget('jqgrid', table=db.ciudadanos)}}
> But nothing happens.
>
> ¿What am I doing wrong? Thanks in advance.


[web2py] Problems trying to use jqgrid from plugin_wiki

2011-01-10 Thread Lisandro
I downloaded web2py (1.91.6) and executed the development server.
I edited the "welcome" app:

First, I installed the plugin "plugin_wiki" in the "welcome" app.

Second, I edited the db.py, adding the following line (every other
thing stays as default):
---
db.define_table('ciudadanos', Field('nro_documento'))
---
I added some sample records.


Third, I edited the "default/index.html" view, adding the following
line:
---
{{=plugin_wiki.widget('jqgrid', 'ciudadanos')}}
---

When I acces http://.../welcome/default/index, I can see the jqgrid,
but it contains nothing.
I tried with:
 * {{=plugin_wiki.widget('jqgrid',  table='ciudadanos')}}
 * {{=plugin_wiki.widget('jqgrid', table=db.ciudadanos)}}
But nothing happens.

¿What am I doing wrong? Thanks in advance.


Re: [web2py] Re: BETA: new URL routing facility

2011-01-10 Thread Jonathan Lundell
On Jan 10, 2011, at 11:31 AM, pbreit wrote:
> As usual, there's more to it than I first imagined!
> 
> To overcome the issue of routes being overwritten with an update, could there 
> be a routes_default.py that ships with Web2py and can be overridden by 
> routes.py in the same directory? Not super important.

That's possible. The problem I see with it is that it changes the behavior 
(including URLs) of web2py for those users who are not using routes.py unless 
routes_default.py specifies exactly the same routing as not having a routes 
file at all. In which case, what's the point?

> 
> I envision something like (pseudocode):
> 
> In /web2py/routes.py:
> 
> default_app = 'init', 'welcome'  # try init first, then welcome
> default_controller = 'default'
> default_function = 'index'
> if exists(applications/*/routes.py)
> use(applications/*/routes.py) # would override default 
> controller/function

That's basically the way it works.

> 
> But I guess hard-coding default routing in core can protect against accidents.
> 
> Domain-based routing does sound like it would be a good feature.
> 
> Do I understand correctly that regex and non-regex routing cannot be used at 
> same time? I'm guessing that's going to be a requested feature.
> 

That's true for now, anyway. Mixing them doesn't work because there ends up 
being redundant code in the base routes.py, and we have to know which one to 
use.

If there's a demand for it, I could probably add a regex capability to the new 
router. I'd need to think about that some.

Re: [web2py] Problems with ssh tunnel to run cherokee-admin and configure web2py

2011-01-10 Thread pbreit
I'm not sure why '-N' would be necessary. I don't seem to need it on 
RackSpace Cloud Ubuntu 10.04.

The '-b' flag defeats the purpose. '-b' enables you to connect to Cherokee 
admin over any port (ie, http://173.230.137.80/admin). Omitting '-b' is what 
requires tunneling through localhost which is a security precaution.


Re: [web2py] Re: BETA: new URL routing facility

2011-01-10 Thread pbreit
As usual, there's more to it than I first imagined!

To overcome the issue of routes being overwritten with an update, could 
there be a routes_default.py that ships with Web2py and can be overridden by 
routes.py in the same directory? Not super important.

I envision something like (pseudocode):

In /web2py/routes.py:

default_app = 'init', 'welcome'  # try init first, then welcome
default_controller = 'default'
default_function = 'index'
if exists(applications/*/routes.py)
use(applications/*/routes.py) # would override default 
controller/function

But I guess hard-coding default routing in core can protect against 
accidents.

Domain-based routing does sound like it would be a good feature.

Do I understand correctly that regex and non-regex routing cannot be used at 
same time? I'm guessing that's going to be a requested feature.




Re: [web2py] Problems with ssh tunnel to run cherokee-admin and configure web2py

2011-01-10 Thread Offray Vladimir Luna Cárdenas
Hi again,

El 10/01/11 13:13, Offray Vladimir Luna Cárdenas escribió:
> Hi all,
> 
> 
> I have being testing cherokee + uWSGI for serving web2py. Locally they
> work fine, so I decided to put it under my virtual host (a linode VPS).
> I was following the intructions on [1] and so I imagine that I need to do:
> 
> ssh -L 9090:localhost:9090 r...@173.230.137.80
> 
> and:
> 
> ssh -L 9090:127.0.0.1:9090 r...@173.230.137.80
> 
> but in both cases, after putting my root's password I get:
> 
> channel 3: open failed: connect failed: Connection refused
> 
> At this moment I'm looking how to get this working on archlinux, seeing
> if may be is something in the configuration at the VPS, but any help or
> pointer to a solution will be appreciated.
> 
> Cheers,
> 


I solved the problem. It was just a minor flags needed in the command.
If I launch "cherokee-admin -b" and do:

ssh -L 9090:localhost:9090 r...@173.230.137.80 -N


it works without any problem. (notice the "-b" and "-N" flags
respectively) as reported in [1]

[1]
http://library.linode.com/web-servers/cherokee/installing-cherokee-debian-5-lenny

Cheers,

Offray



Re: [web2py] Problems with ssh tunnel to run cherokee-admin and configure web2py

2011-01-10 Thread Marin Pranjic
Slice is ok and your problem is not web2py related.
Try restarting ssh demon (i googled, not sure if it'll work).

On Mon, Jan 10, 2011 at 7:13 PM, Offray Vladimir Luna Cárdenas <
off...@riseup.net> wrote:

> Hi all,
>
>
> I have being testing cherokee + uWSGI for serving web2py. Locally they
> work fine, so I decided to put it under my virtual host (a linode VPS).
> I was following the intructions on [1] and so I imagine that I need to do:
>
> ssh -L 9090:localhost:9090 r...@173.230.137.80
>
> and:
>
> ssh -L 9090:127.0.0.1:9090 r...@173.230.137.80
>
> but in both cases, after putting my root's password I get:
>
> channel 3: open failed: connect failed: Connection refused
>
> At this moment I'm looking how to get this working on archlinux, seeing
> if may be is something in the configuration at the VPS, but any help or
> pointer to a solution will be appreciated.
>
> Cheers,
>
> Offray
>
>
> References:
> ==
>
> [1] http://web2pyslices.com/main/slices/take_slice/110
>


Re: [web2py] Re: BETA: new URL routing facility

2011-01-10 Thread Jonathan Lundell
On Jan 10, 2011, at 9:33 AM, Wikus van de Merwe wrote:
> I'm not using these routes. These were just made up examples to challenge the 
> proposed new routes. Now I understand that new routes are not intend to be 
> replacement for the old one, but rather a simplified alternative to handle 
> the most common needs.

Though by "most common" I mean "nearly all". If there's a real-world case that 
the new scheme doesn't handle, I'd like to know about it so that case can go on 
the list.

> 
> However, it looks still quite complicated for me. I never liked the fact that 
> application specific routes are global. I think it would be much more clear 
> if global routes would be used to map to applications only (both based on url 
> paths and domains) and the app-specific local routes would be used to map 
> paths to controllers/functions.

That's entirely up to the user. The reason I allow (not require) app-specific 
route to be defined in the base routes.py is that the router for applications 
like the stock welcome/admin/examples is exactly:

routers=dict(
BASE = dict(),
admin = dict(),
examples = dict(),
welcome = dict(),
)

or, more compactly:

routers = {}

...and it seemed like an undue burden to oblige the user to create three more 
routes.py files for that. Nonetheless, you're free to do it if you want.


> I also support pbreit here saying it should be the default, that is web2py on 
> installation should have welcome and example apps with local routes. This 
> separation makes things easier to understand and manage.

I agree, except that I think it needs to be something like routes.standard.py, 
with the user copying it to routes.py. Otherwise, if the user customizes 
routes.py, it'll get overwritten at the next web2py update.

> 
> And answering your questions, I'm deploying my apps on GAE and I'm not using 
> domains. I'm using routes.py to simplify urls so that it is easier to 
> remember them or use in printed materials. For the rest I'm happy with the 
> default /controller/function dispatching.

In that case, with the new facility, all you need in routes.py is:

routers = {}

...if your default application is 'init'. Otherwise:

routers = dict(
BASE = dict( default_application='myapp' )
)

...and you should get maximal URL simplification. (You can also specify 
default_controller and default_function if they're not default/index.)



[web2py] Re: BETA: new URL routing facility

2011-01-10 Thread Massimo Di Pierro
What do you mean by "I never liked the fact that application specific
routes are global"?
You can have per/app routing files. Jonathan implemented this and it
has been available for a while, although not documented in the printed
book.
Massimo

On Jan 10, 11:33 am, Wikus van de Merwe 
wrote:
> I'm not using these routes. These were just made up examples to challenge
> the proposed new routes. Now I understand that new routes are not intend to
> be replacement for the old one, but rather a simplified alternative to
> handle the most common needs.
>
> However, it looks still quite complicated for me. I never liked the fact
> that application specific routes are global. I think it would be much more
> clear if global routes would be used to map to applications only (both based
> on url paths and domains) and the app-specific local routes would be used to
> map paths to controllers/functions. I also support pbreit here saying it
> should be the default, that is web2py on installation should have welcome
> and example apps with local routes. This separation makes things easier to
> understand and manage.
>
> And answering your questions, I'm deploying my apps on GAE and I'm not using
> domains. I'm using routes.py to simplify urls so that it is easier to
> remember them or use in printed materials. For the rest I'm happy with the
> default /controller/function dispatching.


[web2py] Problems with ssh tunnel to run cherokee-admin and configure web2py

2011-01-10 Thread Offray Vladimir Luna Cárdenas
Hi all,


I have being testing cherokee + uWSGI for serving web2py. Locally they
work fine, so I decided to put it under my virtual host (a linode VPS).
I was following the intructions on [1] and so I imagine that I need to do:

ssh -L 9090:localhost:9090 r...@173.230.137.80

and:

ssh -L 9090:127.0.0.1:9090 r...@173.230.137.80

but in both cases, after putting my root's password I get:

channel 3: open failed: connect failed: Connection refused

At this moment I'm looking how to get this working on archlinux, seeing
if may be is something in the configuration at the VPS, but any help or
pointer to a solution will be appreciated.

Cheers,

Offray


References:
==

[1] http://web2pyslices.com/main/slices/take_slice/110


[web2py] [Tips] Change style of sqlform

2011-01-10 Thread Martin.Mulone
http://martin.tecnodoc.com.ar/myblog/2011/01/10/hacking-web2py-sqlform-part-1


[web2py] Re: SOAP service - repeating elements/sets of elements

2011-01-10 Thread Dragonfyre13
Opened two defects, one for web2py, one for pysimplesoap. Attached
patch files to both:
http://code.google.com/p/web2py/issues/detail?id=153
http://code.google.com/p/pysimplesoap/issues/detail?id=21

The patch files fix the problem nicely, I've been using this code
since previous to my last email, and there's no instability I can
find. I did a code review with 2 internal resources here on the
modifications (however small) and tested as completely as possible
(I'm a Software Test Engineer, testing comes naturally).

On Jan 6, 7:34 pm, Dragonfyre13  wrote:
> What you say below makes sense. The bad code part of it was just my
> design sense screaming since it's required that there be specific
> keys, and the values be specific types. Would have been better suited
> to their own key/value pairs, rather than generic ones.
>
> I'll check more into raising my ownsoapfaults as well.
>
> I did find a bug (in web2py, and hopefully it can get a change made to
> pysimplesoap to support the clean version of the fix I put in)
>
> Basically, persoapspec, asoapfault MUST return a 500 HTTP response
> code. Web2py doesn't. It's an easy modification to make, I threw it
> into my local copy of web2py (How do I submit a patch, by the way?
> Just post one on this mailing list? Or maybe I'm missing a really nice
> bugtracker for web2py that I should know about...). Fixing it required
> implementing an extension to the dispatcher.dispatcher code, handing
> in a param (return_status) that defaults to False, but if True the
> method will return a tuple of (fault, response) with fault being True
> if the response is a fault, or False if the response is not a fault.
> That allows web2py to trigger response.status to be 500, rather than
> the default 200.
>
> Where should I submit a patch for pysimplesoap (if this is something
> you'd be interested in throwing in there)? And how do I make sure that
> version gets in web2py, as well as a patch gets into web2py to address
> not returning a 500 response code onsoapfault? (Guessing some sort
> of bug tracking system!)
>
> On Jan 4, 8:44 am, Mariano Reingart  wrote:
>
> > On Mon, Jan 3, 2011 at 8:49 PM, Dragonfyre13  wrote:
> > > Thought this might be interesting to someone, as it took me digging
> > > through the  pysimplesoap code to figure out. So I'll record it here
> > > for posterity.
>
> > > In web2py, I needed asoapservice that can have one to many sets of a
> > > a particular element. This caused some issues, as there's not really a
> > > convention documented for supporting multiple elements posted in,
> > > without explicitly defining all of them.
>
> > See:http://code.google.com/p/pysimplesoap/wiki/ComplexTypeshttp://code.go...
>
> > But you are right, that is not documented in deep, I'll make a recipe
> > with further explanations.
>
> > > what I found, was putting a dict in a list, you could get this (taken
> > > from the "unmarshall" section of the simplexml code, since the
> > > pysimplesoap does this:
> > > args = method.children().unmarshall(args_types)
>
> > > # types is a dict of {tag name: convertion function}
> > > # example: types={'p': {'a': int,'b': int}, 'c': [{'d':str}]}
> > > #   expected xml: 12holachau
> > > #   returned value: {'p': {'a':1,'b':2}, `'c':[{'d':'hola'},
> > > {'d':'chau'}]}
>
> > > Notice in there, that by putting the {'d':str} object in a list, even
> > > a single element list, it makes it able to be repeated, over and over
> > > again. No idea how to set a limit on repetitions, or how this would
> > > react to simply not including a value (is a zero to many, or one to
> > > many?) but I'm trying it out now. Here's the completed decorator and
> > > func definition:
>
> > > @service.soap('methodName',returns={'result':bool},
> > >              args={'data':[{'elemName':str, 'elemValue':str}]})
> > > def mymethod(data):
> > >    """
> > >    Does nothing right now.
> > >    """
> > >    # the var data is filled with a list of dicts. Each dict has two
> > > elements,
> > >    # "elemName" and "elemValue", both strings. Can iterate over this,
> > > and pull
> > >    # out any data required.
> > >    return True
>
> > > So it currently doesn't do anything yet, and the design is bad since I
> > > was handed a wsdl and told "make that work", but here's outstanding
> > > questions I have on pysimplesoap/web2pysoapstuff:
>
> > The code seems fine, why you say that it is a bad design?
> > It does what you need?
>
> > > 1) It doesn't look like there's currently any way to say "int between
> > > x and y", just that it's an int. Since it's auto generating the wsdl,
> > > that seems important...
>
> > This cannot be done now, it would require changing the simple type
> > declaration, using custom types instead of python types (int, float,
> > etc.).
> > See reply 4
>
> > > 2) Same as above goes for data from a particular set. I can validate
> > > this in the code of the service, but I really have no clue how to get
> > > that into the wsdl.
>
> > What do you

Re: [web2py] Re: BETA: new URL routing facility

2011-01-10 Thread Wikus van de Merwe
I'm not using these routes. These were just made up examples to challenge 
the proposed new routes. Now I understand that new routes are not intend to 
be replacement for the old one, but rather a simplified alternative to 
handle the most common needs.

However, it looks still quite complicated for me. I never liked the fact 
that application specific routes are global. I think it would be much more 
clear if global routes would be used to map to applications only (both based 
on url paths and domains) and the app-specific local routes would be used to 
map paths to controllers/functions. I also support pbreit here saying it 
should be the default, that is web2py on installation should have welcome 
and example apps with local routes. This separation makes things easier to 
understand and manage.

And answering your questions, I'm deploying my apps on GAE and I'm not using 
domains. I'm using routes.py to simplify urls so that it is easier to 
remember them or use in printed materials. For the rest I'm happy with the 
default /controller/function dispatching.


[web2py] Re: Tip of the day

2011-01-10 Thread mart
Yes, I saw the slice and was all sounds great, I just dont have the
big picture on how they stay linked (at least i don't see it)..other
thing that may do the trick is a variation on the "audit slice"...
looking into that one

Do we know if this 'Tip of the day' works well with the audit (saw
that also on web2pyslice)... by putting it in one the tables, will
that be linked to the second table as well?

Thanks,
Mart :)

On Jan 10, 7:45 am, "Arun K.Rajeevan"  wrote:
> This one was there at web2pyslice's
>
> But It doesn't worked for me when I had a field of type file in one of the
> forms.
> Yes, it worked fine on rocket server comes with web2py.
> But I had to make that work on GAE (but it doesn't worked)
>
> I had a long thread here. And waiting Massimo to figure out what went
> wrong.


[web2py] Re: Combining left outer join how to?

2011-01-10 Thread Uolter
Hi DenesL,

thank you very much for your feedback.

I gave it a go, but I'm still getting doubled records.

User John appears twice even if in the auth_user table he is alone.

Uolter


On Jan 6, 3:30 pm, DenesL  wrote:
> Just make a list of theleftjoins:
>
> users=db().select(db.auth_user.ALL,
> db.auth_group.ALL,
>  left=[db.auth_membership.on(db.auth_user.id ==
> db.auth_membership.user_id),
>         db.auth_group.on(db.auth_user.id ==
> db.auth_membership.user_id) ] )
>
> On Jan 6, 5:25 am, Uolter  wrote:
>
> > Hi all,
>
> > I have this sql query that combine twoleftouterjoin.
>
> > select * from auth_user
> >    LEFTOUTERJOINauth_membership on
> > auth_membership.user_id=auth_user.id
> >    LEFTOUTERJOINauth_group on auth_membership.user_id=auth_user.id
>
> > basically, it returns all users with their role when they have a role
> > or not.
>
> > It works fine in sqlite and I wonder how run it in Web2py?
>
> > I'm trying something like this, but it doesn't work as expected:
>
> > users=db().select(db.auth_user.ALL, db.auth_group.ALL,
> >left=db.auth_membership.on(db.auth_user.id ==
> > db.auth_membership.user_id & db.auth_group.id ==
> > db.auth_membership.group_id))
>
> > Need some help!!!
>
> > Thanks in advance
>
> > Uolter
>
> > twitter:@uollter
>
> > linkedin:http://it.linkedin.com/in/wtraspad
>
>


[web2py] Re: computed fields and SQLFORM

2011-01-10 Thread howesc
yes it kinda would.  i would love to be able to see the values of the fields 
and have them update via javascript as the fields they depend on are 
modified, but that is beyond the functionality of SQLFORM.  But i do want to 
see the current values when i am editing the form

given the potential confusing-ness of it, i'm happy to keep my method of 
creating the field list, just thought i would ask to see what others thought 
about it.

christian


Re: [web2py] Re: customize json output

2011-01-10 Thread Michele Comitini
I would rely on repr too much, Wikus is correct,
and all escape sequences are safe?

http://json.org/

simplejson slow vs repr? on GAE it should be even slower...



2011/1/10 Wikus van de Merwe :
> Unfortunately there is a subtle difference between the output of repr/str
> and JSON. Python by default uses single quotes while JSON needs the double
> ones. If there are no strings in the dict though, str/repr would work all
> fine.
>


Re: [web2py] Re: BETA: new URL routing facility

2011-01-10 Thread Jonathan Lundell
On Jan 9, 2011, at 11:41 PM, pbreit wrote:
> I'm a bit confused as well. Perhaps some more example would help.

What's your current routes.py?

A general question for the list: how many of you are using domain routing? That 
is, where you route a particular incoming domain to a particular route? And if 
you are, are you using autoroutes, or your own regexes?

How many of you are using routes.py for something else?

> 
> Also, I would agree that per-application routing should be the default.

I'm not sure what you mean by this. You get per-app routing if you specify an 
app-specific route, either in the base router or the app-specific routes.py.

> And further, the global routes file should be enabled by default and should 
> provide the same routes as you currently get with a fresh install of Web2py 
> (with any app-routes overriding).




[web2py] reference all fields of another table

2011-01-10 Thread mart
Hi,

I could be looking in the wring place, but i don't see an example on
referencing ALL the fields of another table without having to name
them - I would like the combination of tables to be  more dynamic, so
that "sub-tables (forms) could be created on the fly depending on user
input... something like this (taken from the 'Tip of the day' thread):

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


db.define_table('rm_request', # main form - mandatory to al forms
Field('fied1'),
Field('fied2'),
Field('fied3'))

db.define_table('customBuildRequest',  # sub-table/form - data
comes from custom request (request not available in list)
Field('fied1'),
Field('fied2', requires=db(db, table1.ALLFIELDS))

or

Field('fied2', requires=db(db, table1.fields()))

or something...


Thanks,
Mart :)



[web2py] Re: customize json output

2011-01-10 Thread Wikus van de Merwe
Unfortunately there is a subtle difference between the output of repr/str 
and JSON. Python by default uses single quotes while JSON needs the double 
ones. If there are no strings in the dict though, str/repr would work all 
fine.


[web2py] Re: Key error with new DAL and _extra

2011-01-10 Thread Massimo Di Pierro
Thanks for reporting this.

The proper new way is:

m = db.foo.bar.max()
for row in db(...).select(m):
print row[m]

The old way and still backward compatible is:

m = db.foo.bar.max()
for row in db(...).select(m):
print row._extra[m]

A hack that worked with the old way but broke with the new dal is:

m = db.foo.bar.max()
for row in db(...).select(m):
print row._extra['MAX(foo.bar)']

I just changed trunk to make sure that the hack worked as you
originally had it but I do not think it was ever documented in the
book.

Massimo

On Jan 10, 6:59 am, Stefan Scholl  wrote:
> Hi!
>
> Just updated a project from 1.89.5 to 1.91.6. Got a key error.
>
> row._extra['MAX(foo.bar)'] had a problem with the key. The query has a
> "db.foo.bar.max()," in the select().
> (Funny: Can't find anything about _extra and max() again in the book
> now?)
>
> Changed the key to 'max(foo.bar)' and now everything is OK. But it's
> dent in the backward compatibility promise.
>
> Regards,
> Stefan


[web2py] Re: Finding out if login has failed

2011-01-10 Thread Massimo Di Pierro
You can set your message with

auth.messages.invalid_login = ""

On Jan 10, 6:58 am, Ruiwen Chua  wrote:
> Hi,
>
> Currently, I'm using the default auth() (eg. return dict(form=auth())
> method for generating the form for my user login view.
>
> I'd like to know if there's any way by which I can tell if a login has
> failed from within the controller action? I've just asked on the IRC
> channel, and the answer I got was to check response.flash in the view.
> However, I'm using a custom layout and do not have the flash
> displaying anywhere near my login form.
>
> Is there a way that I can tell if the login has failed, and display my
> own error message if need be, without having to rely on response.flash
> in the view?
>
> Cheers
> Ruiwen


[web2py] Key error with new DAL and _extra

2011-01-10 Thread Stefan Scholl
Hi!

Just updated a project from 1.89.5 to 1.91.6. Got a key error.

row._extra['MAX(foo.bar)'] had a problem with the key. The query has a
"db.foo.bar.max()," in the select().
(Funny: Can't find anything about _extra and max() again in the book
now?)


Changed the key to 'max(foo.bar)' and now everything is OK. But it's
dent in the backward compatibility promise.


Regards,
Stefan


[web2py] Finding out if login has failed

2011-01-10 Thread Ruiwen Chua
Hi,

Currently, I'm using the default auth() (eg. return dict(form=auth())
method for generating the form for my user login view.

I'd like to know if there's any way by which I can tell if a login has
failed from within the controller action? I've just asked on the IRC
channel, and the answer I got was to check response.flash in the view.
However, I'm using a custom layout and do not have the flash
displaying anywhere near my login form.

Is there a way that I can tell if the login has failed, and display my
own error message if need be, without having to rely on response.flash
in the view?


Cheers
Ruiwen


[web2py] Re: Tip of the day

2011-01-10 Thread Arun K.Rajeevan
This one was there at web2pyslice's

But It doesn't worked for me when I had a field of type file in one of the 
forms.
Yes, it worked fine on rocket server comes with web2py.
But I had to make that work on GAE (but it doesn't worked)

I had a long thread here. And waiting Massimo to figure out what went 
wrong. 


[web2py] Re: on a possible web2py memory leak

2011-01-10 Thread Massimo Di Pierro
Yes. For the record, having this class:

class A:
def __init__(self): self.x=x
def __del__(self): pass

and doing this in an action

a=A()

would cause the same leak on ANY web framework running on CPython (not
on Jython).
Using __del__ in python is dangerous.



On Jan 10, 3:15 am, Michele Comitini 
wrote:
> good article, esp. the "The trouble with Finalizers" part
>
> 2011/1/10 ron_m :
>
>
>
>
>
>
>
> > In the sample code if one comments out the __del__ method in the class the
> > leak does not occur. That is not to say it can't happen I suppose in a more
> > complicated code example but I believe the __del__ is a required piece. This
> > test was performed without the gc.collect() being present. I ran System
> > Monitor on Ubuntu and watched the python process after each edit and
> > monitored memory size to verify. So the only way I got the leak was to have
> > the __del__method present on the class in the exec example and not have the
> > gc.collect() call.
>
> > I left the process running with the leak (__del__ present in class and
> > gc.collect() commented out) and it got to 3 GB of process space so the
> > collector never ran. The system was showing all the signs of a machine in
> > trouble from memory pressure, I have 4 GB of physical memory. The size
> > builds quite rapidly.
>
> > This is an old article published as the gc module was added to Python that
> > explains a bit about gc in Python.
>
> >http://arctrix.com/nas/python/gc/
>
> > Because it is old it may not be 100% accurate today but does go into the
> > problem some better than the reference documentation.
>
> > This article was decent as well
>
> >http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__...
>
> > Ron


Re: [web2py] Re: ADVOCACY: "every single other Python program ever written uses imports"?

2011-01-10 Thread Michele Comitini
>From my perspective, web2py style is very much influenced by its
functional approach and the usage of functors.  This gives a great
amount
of tools to new comers, but can be problmematic with experienced
programmers that have been working with a COO (class object oriented:
read java)
language.

 I have a bit of experience with OO (truly object oriented) languages
besides python, such as lisp or scheme so I feel web2py confortable.
But with java experience and being used to the define Interface,
define Class, define Subclass of Class,  instanciate Object and so on,
I understand that it is not
clear how and where you can do that.  Maybe it is just a matter of
documentation, a "Library Reference" distinct from a "Tutorial" ?

Other python frameworks stick to COO so maybe more people feel
confortable, and have a API or Library Reference?

mic

2011/1/10 Anthony :
> On Sunday, January 9, 2011 4:49:45 PM UTC-5, pbreit wrote:
>>
>> For one, I don't think businesses care much about backwards compatibility.
>> My experience in the enterprise was that vendors were constantly churning
>> out non-backwards-compatibile updates and customers were routinely several
>> versions behind.
>
>
> Maybe they remain several versions behind because they don't want to keep
> dealing with backwards-incompatible upgrades (i.e., skip a few versions and
> just deal with an occasional big incompatible change). The cool thing about
> web2py is you can take advantage of every new feature that comes out (every
> couple weeks) without breaking your programs.


[web2py] Re: "undefined record" error in appadmin on GAE

2011-01-10 Thread Massimo Di Pierro
I believe we added some checks in 1.91.5 that fix this problem. Not
completely but may work in your case. Give that a try first and your
case is not covered we'll improve it.

On Jan 10, 1:39 am, johntynan  wrote:
> I am running a web2py application on GAE.  I would like to export
> different tables as CSV files from my application by way of the
> appadmin.  (My goal is to create both a backup of the data and a test
> suite with actual data).
>
> However, I am receiving the following "undefined record" error when
> viewing different tables using the appadmin:
>
> http://pastie.textmate.org/1444589
>
> I am using web2py Version 1.83.2 and GAE release "1.4.0"
>
> Awhile back, Massimo had helped me to understand what appears to be a
> similar issue
>
> "It is trying to represent a reference field with an invalid
> reference"
>
> as described in this thread (although this earlier error was occuring
> in my application and not in the appadmin):
>
> http://groups.google.com/group/web2py/browse_thread/thread/4fbc46b845...
>
> When displaying tables by way of the appadmin is there any
> "represention of a reference field" which could be causing this issue?
>
> I believe I know what could have led to this issue, my client deleted
> a row from a table.  This row is referenced by data in other tables.
>
> In thinking about a solution, I could try to re-create the entry in
> the table by way of the appadmin (I am pretty sure I have the
> information for this single row in the table from a previous backup).
> I could also use the Datastore Viewer in GAE's admin console to create
> or edit the entry.  I also wonder if Google's bulk loader tool would
> be helpful in backing up, editing and restoring the data.
>
> Have other people run into this issue and if so, what steps have you
> taken to arrive at a solution?
>
> Also, do you have any recommendations for ways where I could
> periodically test for this kind of inconsistency?  Do you have any
> suggestions for how I might prevent this issue from happening in the
> future?


[web2py] Re: Tip of the day

2011-01-10 Thread mart
Hi, Just tried this and does the trick! :) I''m just a little unclear
on how these two (or more?) tables are linked once submitted?

Example: request forms.
There can be many types of requests and let's say that they all have a
set fields that all request forms have (like: name, email, priority,
created_on, etc...), then maybe the specifics can be unique to the
request (I.e. a new_build_request vs buildSystem_feature_request) -

In this case, I would combine the common 'rm_request' table & the
'new_build_request' table, then similarly, 'rm_request' table & the
'buildSystem_feature_request'

So when the form gets submitted, how does the select() work? How do we
correlate the data from rm_request to the new_build_request data?


And ditto on Carlos' question about updates :) How would that work?

Thanks,
Mart :)



On Dec 12 2010, 4:33 pm, Carlos  wrote:
> Hi,
>
> I am wondering how this solution (singleformwithlinkedtables) can
> be used for updates (in addition to creates)?.
>
> Thanks,
>
>    Carlos
>
> On Dec 6, 4:32 am, DenesL  wrote:
>
>
>
>
>
>
>
> > True, only restriction is no common field names.
> > I have added this to the book.
>
> > On Dec 5, 11:05 pm, mdipierro  wrote:
>
> > > No field names in comment yes. References between them is not a
> > > problem as long the reference fields are not writable and readable
> > > when generating theform.
>
> > > On Dec 5, 9:41 pm, DenesL  wrote:
>
> > > > This only works fortablesthat do not have field names in common
> > > > and have no references between them.
>
> > > > On Oct 16, 9:57 am, mdipierro  wrote:
>
> > > > > It often happens that you have twotables(for example 'client' and
> > > > > 'address' which arelinkedtogether by a reference and you want to
> > > > > create asingleformthat allows to insert info about one client and
> > > > > its default address. Here is how:
>
> > > > > model:
>
> > > > > db.define_table('client',
> > > > >      Field('name'))
> > > > > db.define_table('address',
> > > > >     Field('client',db.client,writable=False,readable=False),
> > > > >     Field('street'),Field('city'))
>
> > > > > controller:
>
> > > > > def register():
> > > > >    form=SQLFORM.factory(db.client,db.address)
> > > > >     ifform.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 theform'
> > > > >     return dict(form=form)
>
> > > > > Notice the SQLFORM.factory (it makes ONEformusing public fields from
> > > > > bothtablesand inherits their validators too).
> > > > > Onformaccepts this does two inserts (some data in one table and some
> > > > > data in the other).
>
> > > > > Massimo


Re: [web2py] Re: on a possible web2py memory leak

2011-01-10 Thread Michele Comitini
good article, esp. the "The trouble with Finalizers" part


2011/1/10 ron_m :
> In the sample code if one comments out the __del__ method in the class the
> leak does not occur. That is not to say it can't happen I suppose in a more
> complicated code example but I believe the __del__ is a required piece. This
> test was performed without the gc.collect() being present. I ran System
> Monitor on Ubuntu and watched the python process after each edit and
> monitored memory size to verify. So the only way I got the leak was to have
> the __del__method present on the class in the exec example and not have the
> gc.collect() call.
>
> I left the process running with the leak (__del__ present in class and
> gc.collect() commented out) and it got to 3 GB of process space so the
> collector never ran. The system was showing all the signs of a machine in
> trouble from memory pressure, I have 4 GB of physical memory. The size
> builds quite rapidly.
>
> This is an old article published as the gc module was added to Python that
> explains a bit about gc in Python.
>
> http://arctrix.com/nas/python/gc/
>
> Because it is old it may not be 100% accurate today but does go into the
> problem some better than the reference documentation.
>
> This article was decent as well
>
> http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/
>
> Ron
>
>
>
>


Re: [web2py] Re: Inserting additional fields in crud

2011-01-10 Thread Kenneth Lundström

Is this what your looking for:
http://groups.google.com/group/web2py/browse_thread/thread/a0566bf740023b1/41eadc3ba1b53176?lnk=gst&q=form+append#41eadc3ba1b53176


Kenneth

I've tried using SQLFORM and adding additional fields by simply adding 
html inputs. The fields are not accessible via form.vars.name. Is it 
possible to have additional fields in SQLFORM or crud that are not in 
the model? 




[web2py] Re: Inserting additional fields in crud

2011-01-10 Thread pbreit
Did you check out SQLFORM.factory?
http://web2py.com/book/default/chapter/07#SQLFORM.factory

I'd highly recommend using Web2py's built-in user functions, at least 
initially. It includes all the basic user functions. Then you can focus on 
your application and come back to user auth later if you really don't like 
what you get with the built-in functionality.