[web2py] Re: concurrency problem

2010-04-05 Thread Iceberg
Good to hear that is on your todo list, Massimo. When you do that,
please also figure out a way to chain multi onvalidate functions,
because I expect the crud.unmodified() would be used quite popular, if
not everytime.

Iceberg


On Apr5, 1:42pm, mdipierro mdipie...@cs.depaul.edu wrote:
 This is a good point. I do not think this should be dealt with at the
 DB level because, if I understand it is an app workflow problem.
 If I understand

 For every user there are two HTTP requests (one to generate the update
 form, one to submit the form) and each is executed in its own
 transaction. So the only problem is when the data changes in DB for
 the record in question in between the two requests. This cannot be
 solved at the DB level because you do not want to lock the record in
 one request and unlock in the second request since the second may
 never arrive (user reload page, click back button, connection is
 dropped, etc.). This much be resolved by an explicit check that the
 record content in between requests has not changed. I have once posted
 an example of how to do it with web2py but now I cannot find it.

 Anyway, this can be done easily at the app level by adding a timestamp
 to the record and checking onvalidation that the record timestamp did
 not change in between the two requests. This should not be default
 web2py behaviors since the check depends on the model and, moreover,
 it may be slow and un-necessary in the general case.

 Like we have onaccept=crud.archive, we could have a
 onvalidate=curd.unmodified to provide a standard API to perform this
 check. I will put it in my todo list.

 Massimo

 On Apr 4, 11:59 pm, Iceberg iceb...@21cn.com wrote:



  Yarko, you suggest using a full-featured db instead of sqlite. But
  sqlite's internal reader/writer lock is one thing, the overwrite
  problem is another. No matter what kind of db we are using, we still
  need to deal with the overwrite problem.

  Scenario:
  9:00am clerk Adam read the balance of a client's account, it is $100
  9:01am clerk Bob read the balance of same client, it is $100
  9:02am clerk Adam plans to deduct $10 from the account, and updating
  the new balance as $90
  9:03am NOT knowing what Adam had done, Bob plans to deduct $20 from
  the account, and updating the new balance as $80

  There is no physical concurrency here. But we need some measure to
  refuse Bob's last attempt. There is this kind of measures, such as
  optimistic lock mechanism in the app level. What I want to discuss is
  that, do we need implement optimistic lock in our every web2py app, or
  can/need we do something in DAL level, such as PyDbLite did by the
  __version field, to benefit all web2py app?

  Ideas? Thanks.
  iceberg

  On Apr3, 8:18pm, Iceberg iceb...@21cn.com wrote:

   Yarko, you also raise a very good point. And this makes me feel
   nervous, because all my previous web app are vulnerable to this
   overwrite issue. :-/

   Besides the locking plugin, which is optional and not aware by
   everyone, do you think we can add some built-in, anti-overwrite
   protection inside DAL? For example, if the table contains a field
   named __version__, then DAL is responsible for automatically perform
   version check before every update(). The idea is borrowed from
   PyDbLite (http://pypi.python.org/pypi/PyDbLite/2.3). And perhaps DAL
   can do more, by raise exception when concurrent modification is
   detected during crud.update().

   Quoted fromhttp://www.pydblite.net/en/PyDbLite.html

   - another internal field called __version__ is also managed by the
   database engine. It is a integer which is set to 0 when the record is
   created, then incremented by 1 each time the record is updated. This
   is used to detect concurrency control, for instance in a web
   application where 2 users select the same record and want to update it
   at the same time

   Regards,
   Iceberg

   On Apr2, 10:44pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote:

The first thing I thought of when I read your post was 
this:http://web2py.com/plugins/default/locking

and I wondered how you implemented your solution.

I could imagine, if two users open a form, and both submit form.id 2,
one will overwrite the other's.

(hope this is helpful)
Regards,
- Yarko

On Apr 2, 5:00 am, Sven svenstrin...@gmail.com wrote:

 Hi,

 I programmed a psychological experiment in flash and store answers/
 results in a sqlite database using web2py (behind  nginx server +
 fastcgi)  and pyamf. Everything seems to be all right when I test it,
 but with as few as 2 simultaneous users I (sometimes) run into
 trouble. A try with seven simultaneous users resulted in only 2
 succesfully stored experimental data.sets
 I find it very hard to debug, since there are no tickets in web2py.
 Flash does sometimes produce a remoting error in that situation, but
 without too much information.

 I seems to me 

[web2py] web2py on github

2010-04-05 Thread elffikk
hi,

I use a few project stored on github, and I find it easier to navigate
source code or to get a trunk version.
What about moving web2py on github?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: concurrency problem

2010-04-05 Thread Sven
First of all I agree. I can just as well use a full-feature db and I
have migrated to postgresql.
I was just curious if it was possible/sensible to solve the problem
without changing database or my application code; in other words let
web2py do it for me. I guess the answer is no ;)

Sven

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Unicode characters problem (Dreamhost installation)

2010-04-05 Thread Alexei Vinidiktov
I just tried copying a working copy of web2py 1.76.5 from my Windows
machine to my Dreamhost VPS account, but it didn't solve the problem.
I'm still getting the same ticket about DAL not being defined.

Is there anything else I can do?

2010/4/5 mdipierro mdipie...@cs.depaul.edu:
 this is a very strange error, as if one of the system files were
 corrupted.
 I would remover everything web2py re-unzip it and copy your
 applications back in applications.

 Massimo

 On Apr 4, 7:28 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:
 I got it from web2py.com. I'm sure that I've now installed web2py 1.76.5.

 The strange thing is an older version that used to work fine before I
 installed 1.76.5 is now giving me the same error message as the 1.76.5
 one.

 The oldest of all three though seems to work but not entirely  (see my
 second message).

 I guess something went wrong on Dreamhost's end (or rather I did
 something wrong), but I can't think of what it may be. I wonder where
 I should look.

 2010/4/5 mdipierro mdipie...@cs.depaul.edu:



  where d you get it. I do not think this is a new version.

  On Apr 4, 10:02 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  I seem to have used the wrong old version of web2py, but even now that
  I've installed the new version, I'm getting a different error:

  Traceback (most recent call last):
    File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
  restricted
    File /home/alvinru/phonetizer.com/applications/welcome/models/db.py,
  line 15, in module
      db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or 
  other DB
  NameError: name 'DAL' is not defined

  In file: /home/alvinru/phonetizer.com/applications/welcome/models/db.py

  2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:

   I don't know what I have done, but my test apps have stopped working
   at all on Dreamhost.

   The default apps still work fine.

   Here's the ticket I'm getting when trying to load any app in the 
   browser:

   Error traceback Traceback (most recent call last):
    File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
   restricted
      exec ccode in environment
    File /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py,
   line 12, in module
      db.define_table('todo', db.Field('task'))
    File /home/alvinru/phonetizer.com/gluon/sql.py, line 239, in 
   __getattr__
      def __getattr__(self, key): return self[key]
   KeyError: 'Field'

   In file: /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py 
   #!/usr/bin/python
   # -*- coding: utf-8 -*-

   try:
      from gluon.contrib.gql import *  # if running on Google App Engine
   except:
      db = SQLDB('sqlite://storage.db')  # if not, use SQLite or other DB
   else:
      db = GQLDB()  # connect to Google BigTable
      session.connect(request, response, db=db)  # and store sessions there

   db.define_table('todo', db.Field('task'))

   from gluon.tools import Service     # new in web2py 1.56
   service = Service(globals())

   2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:
   Hello,

   I've deployed the latest version of web2py on Dreamhost using wsgi.
   I'm using a custom installation of Python 2.5.

   The web2py installation seems to work fine, but there's one problem.

   I've created a test program using the qooxdoo web application
   framework for the GUI part which mimics the functionality in the
   pyjamas example program: displaying a list of todo items, adding and
   deleting items.

   It works fine on my local development machine, it works fine on GAE,
   but on my Dreamhost installation I'm getting an error when trying to
   add a task that contains non ascii symbols, for example Russian
   characters as in задание номер один (task number one).

   I also have a pyjamas version of the same todo app and it exhibits the
   same behavior (works fine on GAE, not so on Dreamhost).

   Here is the message that I get back from the xmlrpc method call to 
   addTask:

   Exception during async call: UNEXPECTED origin undefined error 100:
   UnicodeEncodeError: 'ascii' codec can't encode characters in position
   0-5: ordinal not in range(128)

   You can see it live here:
  http://www.phonetizer.com/qooxdoo

   The pyjamas version is here:
  http://www.phonetizer.com/pyjamas

   It is also deployed on GAE and works fine here:
  http://web2pyapp.appspot.com/qooxdoo

   I also have a much older version of web2py deployed on Dreamhost.
   Unlike the new version it uses fastcgi and works as expected.

   Do you have any ideas as to why the newer version is misbehaving?

   Thanks.

   --
   Alexei Vinidiktov

   --
   Alexei Vinidiktov

  --
  Alexei Vinidiktov

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
 

Re: [web2py] Re: concurrency problem

2010-04-05 Thread Vasile Ermicioi
that is an idea!
it will be great if web2py will do what sqlalchemy does
http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/pooling.html#sqlalchemy.pool.SingletonThreadPool

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: How to use virtualfields?

2010-04-05 Thread Iceberg
Old problem solved, new problem arises.

There is a somewhat obvious difference which I did not notice before.

  (1) db.table.virtualfields.append(ComputedFields())
  This need to be executed BEFORE db().select(), otherwise it will NOT
affect the select result rows.

  (2) rows.setvirtualfields(table=ComputedFields())
  This of course can only be used AFTER you've got the rows (and you
can't possibly go to the wrong way.)

However, there must be some more subtle difference I don't know yet.
Even I use (1) BEFORE my db().select(), I found that is much slower
(perhaps due to some lazy function call). And worse, (1) can't support
virtual field has SAME name as real field, while (2) can. My code
looks like:

  class VirtualFields:
  distributors=db().select(db.Distributor.id,db.Distributor.name,
  cache=(cache.ram,3600*24)).as_dict()
  def income(self):
  # round the real field income into per thousand unit
  return self.mytable.income / 1000.0
  def distributor(self):
  # tend to change real field distributor from id to its
name
  return self.distributors.get(
  self.Orders.distributor,{}).get('name')

So I think I have to stick to usage (2), do I?

BTW, I am using the latest web2py trunk on Windows XP.

Regards,
Iceberg

On Apr5, 12:18pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I just did this as a test and it worked:

  db=DAL('sqlite:memory:')
  db.define_table('test',Field('quantity','integer'))
  class VirtualFields():

 ...     def profit(self): return self.test.quantity*100 
 db.test.virtualfields.append(VirtualFields())
  db.test.insert(quantity=5)
 1
  rows=db(db.test.id0).select()
  for row in rows: print row

 ...
 Row {'update_record': function lambda at 0x1b8dbb0, 'profit':
 500, 'id': 1, 'delete_record': function lambda at 0x1b8dab0,
 'quantity': 5}

 Sure you are running an updated version of web2py? Which os? which
 version?


   On Sun, Apr 4, 2010 at 10:51 PM, Iceberg iceb...@21cn.com wrote:
Hi there,

I search virtualfields inhttp://www.web2py.com/bookbutfound
nothing.

So I read this post instead:  
https://groups.google.com/group/web2py/browse_frm/thread/d59ee3d6c2e6...

But I found that
 db.table.virtualfields.append(ComputedFields())
doesn't work.

Only this work:
 rows.setvirtualfields(table=ComputedFields())

Does the former syntax really supposed to exist?

I am using web2py 1.75.4

Regards,
Iceberg


-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Unicode characters problem (Dreamhost installation)

2010-04-05 Thread Alexei Vinidiktov
I think I got it to work! I deleted the domain from the control panel
altogether and then readded it, and web2py 1.76.5 started working.
Problem solved for the time being. I don't know what what the exact
cause though.

And the problem with Unicode characters is also gone, because it only
existed in a much older version of web2py 1.39.

2010/4/5 Alexei Vinidiktov alexei.vinidik...@gmail.com:
 I just tried copying a working copy of web2py 1.76.5 from my Windows
 machine to my Dreamhost VPS account, but it didn't solve the problem.
 I'm still getting the same ticket about DAL not being defined.

 Is there anything else I can do?

 2010/4/5 mdipierro mdipie...@cs.depaul.edu:
 this is a very strange error, as if one of the system files were
 corrupted.
 I would remover everything web2py re-unzip it and copy your
 applications back in applications.

 Massimo

 On Apr 4, 7:28 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:
 I got it from web2py.com. I'm sure that I've now installed web2py 1.76.5.

 The strange thing is an older version that used to work fine before I
 installed 1.76.5 is now giving me the same error message as the 1.76.5
 one.

 The oldest of all three though seems to work but not entirely  (see my
 second message).

 I guess something went wrong on Dreamhost's end (or rather I did
 something wrong), but I can't think of what it may be. I wonder where
 I should look.

 2010/4/5 mdipierro mdipie...@cs.depaul.edu:



  where d you get it. I do not think this is a new version.

  On Apr 4, 10:02 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  I seem to have used the wrong old version of web2py, but even now that
  I've installed the new version, I'm getting a different error:

  Traceback (most recent call last):
    File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
  restricted
    File /home/alvinru/phonetizer.com/applications/welcome/models/db.py,
  line 15, in module
      db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or 
  other DB
  NameError: name 'DAL' is not defined

  In file: /home/alvinru/phonetizer.com/applications/welcome/models/db.py

  2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:

   I don't know what I have done, but my test apps have stopped working
   at all on Dreamhost.

   The default apps still work fine.

   Here's the ticket I'm getting when trying to load any app in the 
   browser:

   Error traceback Traceback (most recent call last):
    File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
   restricted
      exec ccode in environment
    File /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py,
   line 12, in module
      db.define_table('todo', db.Field('task'))
    File /home/alvinru/phonetizer.com/gluon/sql.py, line 239, in 
   __getattr__
      def __getattr__(self, key): return self[key]
   KeyError: 'Field'

   In file: 
   /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py 
   #!/usr/bin/python
   # -*- coding: utf-8 -*-

   try:
      from gluon.contrib.gql import *  # if running on Google App Engine
   except:
      db = SQLDB('sqlite://storage.db')  # if not, use SQLite or other DB
   else:
      db = GQLDB()  # connect to Google BigTable
      session.connect(request, response, db=db)  # and store sessions 
   there

   db.define_table('todo', db.Field('task'))

   from gluon.tools import Service     # new in web2py 1.56
   service = Service(globals())

   2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:
   Hello,

   I've deployed the latest version of web2py on Dreamhost using wsgi.
   I'm using a custom installation of Python 2.5.

   The web2py installation seems to work fine, but there's one problem.

   I've created a test program using the qooxdoo web application
   framework for the GUI part which mimics the functionality in the
   pyjamas example program: displaying a list of todo items, adding and
   deleting items.

   It works fine on my local development machine, it works fine on GAE,
   but on my Dreamhost installation I'm getting an error when trying to
   add a task that contains non ascii symbols, for example Russian
   characters as in задание номер один (task number one).

   I also have a pyjamas version of the same todo app and it exhibits the
   same behavior (works fine on GAE, not so on Dreamhost).

   Here is the message that I get back from the xmlrpc method call to 
   addTask:

   Exception during async call: UNEXPECTED origin undefined error 100:
   UnicodeEncodeError: 'ascii' codec can't encode characters in position
   0-5: ordinal not in range(128)

   You can see it live here:
  http://www.phonetizer.com/qooxdoo

   The pyjamas version is here:
  http://www.phonetizer.com/pyjamas

   It is also deployed on GAE and works fine here:
  http://web2pyapp.appspot.com/qooxdoo

   I also have a much older version of web2py deployed on Dreamhost.
   Unlike the new version it uses fastcgi and works as expected.

   Do you 

[web2py] Re: Errors with the new version

2010-04-05 Thread hamdy.a.farag
Massimo, I sent you the patch
There's also another problem that I got confused about
when using crud.update in case of deleting a record
crud.settings.keepvalues = False  is not working.
after deleting the record , form is not cleared

in fact it is not working either in case of updating record or
deleting it using crud.update()

On Apr 4, 6:37 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Can you please email me a patch or the updated tools.py? Thanks

 Massimo

 On Apr 4, 5:07 am, hamdy.a.farag hamdy.a.fa...@inbox.com wrote:

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] More problems with new version

2010-04-05 Thread Kenneth
As I continue to develop my old application from last summer I get
more and more problems that I think is related to the upgrading I did.
Now that i try to add a record to att table I get:


Traceback (most recent call last):
  File gluon/restricted.py, line 173, in restricted
exec ccode in environment
  File /data/domains/exp-kal.nudata.fi/applications/init/controllers/
campaign.py, line 57, in module
  File gluon/globals.py, line 96, in lambda
self._caller = lambda f: f()
  File gluon/tools.py, line 1864, in f
return action(*a, **b)
  File /data/domains/exp-kal.nudata.fi/applications/init/controllers/
campaign.py, line 47, in edit
if form.accepts(request.vars, session):
  File gluon/sqlhtml.py, line 975, in accepts
self.vars.id = self.table.insert(**fields)
  File gluon/sql.py, line 1891, in insert
self._db._execute(query)
  File gluon/sql.py, line 928, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  File build/bdist.linux-x86_64/egg/MySQLdb/cursors.py, line 173, in
execute
self.errorhandler(self, exc, value)
  File build/bdist.linux-x86_64/egg/MySQLdb/connections.py, line 36,
in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: (1452, 'Cannot add or update a child row: a foreign
key constraint fails (`copy_kalenterit/campaign`, CONSTRAINT
`campaign_ibfk_3` FOREIGN KEY (`district`) REFERENCES `

To make sure the problem is with the upgrade I took the old
application and upgraded web2py. I get the same foreign key contraint
fails error.

Could the this error maybe related to this error:
http://groups.google.com/group/web2py/browse_thread/thread/b513b6cc917a026f
Both are database related. Old version is 1.65.4 which is working and
new is 1.76.5.

Any idea where to start looking for the problem or has something
changed in web2py which should be changed in my application too.


Kenneth

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: args problem in 1.76.5

2010-04-05 Thread DenesL

Thank you Jonathan and sorry that I have not been able to contribute
more.
Until we find a way to fix the missing part it is not really usable.

At the risk of repeating myself, this is not only about blanks being
converted to underscores which is not the only sanitizing of args done
by web2py, this will allow any character to be processed, for example
characters with different types of accents so common in Dutch,
French, Spanish, and many other languages.
For those interested it should be stressed that by turning on this
feature the developer has to take responsibility of sanitizing the
args.


On Apr 4, 6:55 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Apr 4, 2010, at 4:37 PM, DenesL wrote:

  It should be noted that there was some work done towards enabling an
  alternate setting that would allow the developer access to the
  unchanged (raw) args but it has not been finished yet.

  This would allow any character set in args which I believe mainly
  concerns non-English speaking developers/users.

  If any of you feel, as I do, that this is important please voice your
  concern.

 The raw args feature is available in the current release. Specify it for a 
 particular app in routes.py, and request.raw_args will have the unprocessed 
 args. %20 will be converted to space.

 URL rewriting is still somewhat broken, especially when a ? is involved. I've 
 got a plan to address that too, but I haven't had a lot of time to put in on 
 it.



  Denes.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cx_Oracle segfaults

2010-04-05 Thread Gabriele Alberti
Hello,
yes I am running 1.76.1 (2010-03-01 19:56:55); I'll try the latest and
I'll let you know ASAP.

Thank you very much,

G.

On Apr 5, 5:43 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Thank you Gabriele,

 is should definitively be threaded=False and not True since web2py
 does not share connection between threads. Yet, this is already the
 default. You must be running an older version of web2py.You should
 upgrade.

 Massimo

 On Apr 4, 11:33 am, Gabriele  Alberti gabriele.albe...@gmail.com
 wrote:



  Hello,
  I have been using web2py with oracle since few months now. With small
  loads everything works fine, but when the load grows, often the python
  process gets killed with a segfault; after few headaches to understand
  what was going on, I think I spotted the problem and tried a solution
  that works for me.
  It seems the cx_Oracle libs when used in threaded programs (such as
  the web2py server) needs to handle some locking, as suggested in the
  cx_Oracle documentation found at

 http://cx-oracle.sourceforge.net/html/module.html

  [...]
  The threaded argument is expected to be a boolean expression which
  indicates whether or not Oracle should use the mode OCI_THREADED to
  wrap accesses to connections with a mutex. Doing so in single threaded
  applications imposes a performance penalty of about 10-15% which is
  why the default is False.
  [...]

  I am not 100% sure this was the problem as I couldnt find a reasonable
  way to prove it; however, since when I applied the following patch
  (thats the only change I've made) I havent had crashes anymore.
  So this is the simple patch I used and I propose

  --- sql.py      2010-04-04 18:18:26.0 +0200
  +++ sql_orig.py 2010-04-04 18:17:38.0 +0200
  @@ -964,7 +964,7 @@
           elif self._uri[:9] == 'oracle://':
               self._dbname = 'oracle'
               self._pool_connection(lambda : \
  -
  cx_Oracle.connect(self._uri[9:],threaded=True))
  +                                  cx_Oracle.connect(self._uri[9:]))
               self._cursor = self._connection.cursor()
               self._execute = lambda a: \
                   oracle_fix_execute(a,self._cursor.execute)

  I'd like someone else to confirm this, and I really hope this can
  help.

  Kind regards,

  G.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cx_Oracle segfaults

2010-04-05 Thread Gabriele Alberti
Hello,
I am sorry but I have to disagree. I dont know exactly what happens as
I am not into the DAL so much, but as I installed the latest version
(running 1.76.5 now) with no threaded argument in the cx_Oracle
connection I started getting back segfaults. They disappeared
immediately after I put the threaded=True argument..

If there's anything I can do to help, I'll be glad to.

Regards,

G.

On Apr 5, 12:59 pm, Gabriele  Alberti gabriele.albe...@gmail.com
wrote:
 Hello,
 yes I am running 1.76.1 (2010-03-01 19:56:55); I'll try the latest and
 I'll let you know ASAP.

 Thank you very much,

 G.

 On Apr 5, 5:43 am, mdipierro mdipie...@cs.depaul.edu wrote:



  Thank you Gabriele,

  is should definitively be threaded=False and not True since web2py
  does not share connection between threads. Yet, this is already the
  default. You must be running an older version of web2py.You should
  upgrade.

  Massimo

  On Apr 4, 11:33 am, Gabriele  Alberti gabriele.albe...@gmail.com
  wrote:

   Hello,
   I have been using web2py with oracle since few months now. With small
   loads everything works fine, but when the load grows, often the python
   process gets killed with a segfault; after few headaches to understand
   what was going on, I think I spotted the problem and tried a solution
   that works for me.
   It seems the cx_Oracle libs when used in threaded programs (such as
   the web2py server) needs to handle some locking, as suggested in the
   cx_Oracle documentation found at

  http://cx-oracle.sourceforge.net/html/module.html

   [...]
   The threaded argument is expected to be a boolean expression which
   indicates whether or not Oracle should use the mode OCI_THREADED to
   wrap accesses to connections with a mutex. Doing so in single threaded
   applications imposes a performance penalty of about 10-15% which is
   why the default is False.
   [...]

   I am not 100% sure this was the problem as I couldnt find a reasonable
   way to prove it; however, since when I applied the following patch
   (thats the only change I've made) I havent had crashes anymore.
   So this is the simple patch I used and I propose

   --- sql.py      2010-04-04 18:18:26.0 +0200
   +++ sql_orig.py 2010-04-04 18:17:38.0 +0200
   @@ -964,7 +964,7 @@
            elif self._uri[:9] == 'oracle://':
                self._dbname = 'oracle'
                self._pool_connection(lambda : \
   -
   cx_Oracle.connect(self._uri[9:],threaded=True))
   +                                  cx_Oracle.connect(self._uri[9:]))
                self._cursor = self._connection.cursor()
                self._execute = lambda a: \
                    oracle_fix_execute(a,self._cursor.execute)

   I'd like someone else to confirm this, and I really hope this can
   help.

   Kind regards,

   G.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: args problem in 1.76.5

2010-04-05 Thread annet
Massimo,

The problem is that web2py did replace spaces with underscores, but in
version 1.76.x it no longer does. The function described above worked,
until I upgraded to version 1.76.5.

That's why I have this line of code in my view:

h3Nieuws {{=month.replace('_',' ')}}/h3

to have the month display like without the underscore: April 2009
instead of April_2009


Kind regards,

Annet.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: web2py production deployment on vps.net (VIDEO)

2010-04-05 Thread ciastek
Christopher, just run web2py.py once after running setup-web2py-
ubuntu.sh
Details: 
http://groups.google.com/group/web2py/browse_thread/thread/20e724c51c4dca55/7a6bc911316dd23a


On Apr 3, 11:28 am, Christopher Steel chris.st...@gmail.com wrote:
 With 8.04 64 I am unable to create new applications via the web2py
 interface, get the message unable to create application

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: webserver slow, misreported

2010-04-05 Thread Timothy Farrell
You are right, I was going to add that feature and then forgot about 
it.  Someone reported a PyPI bug over the weekend (it would not affect 
web2py).  I'll see if I can make the logging a bit more flexible and 
release a 1.1 in the next few days.


In the meantime, look into the cron thing.

-tim

On 4/4/2010 6:44 PM, Michael Toomim wrote:

I see, thank you.  I want to measure the web server's response time
when I deploy this on turk... Unfortunately the rocket log does not
report time to serve a request.  Do you think it is easy to get that
information from rocket?  Do you store the start and stop times for
each request?  I see start times stored in connections, but I'm not
sure that's the right object.

On Mar 30, 6:09 am, Timothy Farrelltfarr...@swgen.com  wrote:
   
I don't think upgrading will help much since Cherrypy was also slow.  
However, doing so would help cover all your bases.


If you want to use the http log from Rocket you can do this.  I'm
assuming you invoke web2py.py from a bash script or just run it
manually.  Paste the following code into the top of web2py.py

import  logging
import  logging.handlers
log  =  logging.getLogger('Rocket.Requests')
log.setLevel(logging.INFO)
log.addHandler(logging.handlers.FileHandler('rocket.log')

I, like Yarko, do think this has more to do with something else.  At one
point web2py had a profiler built-in.  That could be a good tool for
finding slow spots.

-tim

On 3/29/2010 7:59 PM, MichaelToomimwrote:



 

Yes, this is on linux!  Do you recommend upgrading and trying again?
   
 

mturk doesn't affect anything, I am just serving webpages that appear
in iframes on the mturk website.  From our perspective, I'm serving
webpages.
   
 

Do you have a method of logging how much time it takes to serve a page
with rocket?  Something that I can use instead of httpserver.log?  It
seems important for me to measure real-world performance, which ab
does not do.
   
 

My server has 768MB ram, and the only thing it does is run this web2py
server.  I assumed ram was not full, but did not check.  I will check
next time.
   
 

On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.comwrote:
   

snip/
 
   


--
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] left join problem

2010-04-05 Thread Jose
I see that the last change you made was:

changeset:   362:49d44e1bc17d
tag: tip
user:mdipie...@massimo-di-pierros-macbook.local
date:Fri Apr 02 23:51:07 2010 -0500
summary: possible join problem fix, thanks Brian Harrison

After that left =(...) makes an error occurs.

File /usr/home/jose/w2p/gluon/sql.py, line 1067, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
ProgrammingError: (-104, 'isc_dsql_prepare: \n  Dynamic SQL Error\n
SQL error code = -104\n  Token unknown - line 1, column 258\n  )')

Before the upgrade, worked fine.

Jose

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] XML with custom TAG

2010-04-05 Thread Jason Lotz
I'm trying to pass an XML string with custom TAG to a view, but I'm
having trouble with syntax.

Required XML Syntax:
rows
row id=unique_rowid
cellcell content/cell
cellcell content/cell
/row
/rows

The code string in the controller:
rowxml=TAG.rows(*[TAG.row(*[TAG.cell(r[f]) for f in rowflds]) for r in
rows])

The above code string creates the XML structure I need but I'm missing
the unique_rowid. I have tried several ways to included _id=r but I
get syntax errors.

Can someone help me with the syntax to add id= in the row?


--Jay

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Problem with MANY-MANY relationship

2010-04-05 Thread Ishbir
I've got some problem with the MANY-MANY relation in Web2Py. This is
my code-

http://pastie.textmate.org/903738

Now, the problem is that the query returns only those records which
have tags, not the ones without them. However, if I specify query|
db.snippets.id0 or anything, it gives me garbled results with all the
tables mixed up and nothing right..

Is there any way around this? I thought about using the tagging plugin
but the issue is that I don't think it would be very efficient since I
need to also display the tags on the index page and that would result
in n+1 queries where n is the no. of snippets. Or I am just getting
apprehensive and it will just take 2-3 queries to get the tags of
snippet?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: XML with custom TAG

2010-04-05 Thread DenesL


On Apr 5, 9:14 am, Jason Lotz jayl...@gmail.com wrote:
 I'm trying to pass an XML string with custom TAG to a view, but I'm
 having trouble with syntax.

 Required XML Syntax:
 rows
 row id=unique_rowid
 cellcell content/cell
 cellcell content/cell
 /row
 /rows

 The code string in the controller:
 rowxml=TAG.rows(*[TAG.row(*[TAG.cell(r[f]) for f in rowflds]) for r in
 rows])

rowxml=TAG.rows(*[TAG.row(_id='abc', *[TAG.cell(r[f]) for f in
rowflds]) for r in rows])

 The above code string creates the XML structure I need but I'm missing
 the unique_rowid. I have tried several ways to included _id=r but I
 get syntax errors.

 Can someone help me with the syntax to add id= in the row?

 --Jay

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Validator on upload field

2010-04-05 Thread Chris
Thanks, I tried it with trunk and it works.

Is trunk considered stable enough to run from it all the time or is it
better to stick with the releases and upgrade with each new release?

On Apr 2, 8:17 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I think this was fixed in trunk a couple of weeks ago.

 Massimo

 On Apr 2, 3:35 pm, Chris crflei...@gmail.com wrote:

  I can't seem to get acustomvalidatorto be called on a Field of type
  'upload' when editing a record in appadmin. It works on the other text
  fields or when inserting a new record.

  Thevalidatordoesn't do anything yet, but here's the what I was
  starting with to make sure it worked:

  class IS_FILE_TYPE(Validator):

      def __call__(self, value):
          return (value, 'message')

  This is using python 2.6 on linux.

  Using python 2.5 on OS X I get an error when editing a record and
  using thevalidatorI wrote. Here's the traceback:

  Traceback (most recent call last):
    File /Users/chris/workspace/project/gluon/restricted.py, line 173,
  in restricted
      exec ccode in environment
    File /Users/chris/workspace/project/applications/init/controllers/
  appadmin.py, line 410, in module
    File /Users/chris/workspace/project/gluon/globals.py, line 96, in
  lambda
      self._caller = lambda f: f()
    File /Users/chris/workspace/project/applications/init/controllers/
  appadmin.py, line 275, in update
      if form.accepts(request.vars, session):
    File /Users/chris/workspace/project/gluon/sqlhtml.py, line 844, in
  accepts
      if not request_vars.get(key, None) \
    File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
  python2.5/cgi.py, line 624, in __len__
      return len(self.keys())
    File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
  python2.5/cgi.py, line 600, in keys
      raise TypeError, not indexable
  TypeError: not indexable

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: args problem in 1.76.5

2010-04-05 Thread Jonathan Lundell
On Apr 5, 2010, at 3:15 AM, DenesL wrote:

 
 Thank you Jonathan and sorry that I have not been able to contribute
 more.
 Until we find a way to fix the missing part it is not really usable.
 
 At the risk of repeating myself, this is not only about blanks being
 converted to underscores which is not the only sanitizing of args done
 by web2py, this will allow any character to be processed, for example
 characters with different types of accents so common in Dutch,
 French, Spanish, and many other languages.
 For those interested it should be stressed that by turning on this
 feature the developer has to take responsibility of sanitizing the
 args.

The basic problem here (or at least one of the basic problems) is the way the 
routes.py logic handles '?' in separating vars from the rest of the URL, and 
then reassembling the URL after processing. It's definitely broken for anything 
that encodes a question mark in args.

All I was saying above is that the new logic solves a subset of problems, 
including spaces in args. It's definitely not a complete solution.

 
 
 On Apr 4, 6:55 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Apr 4, 2010, at 4:37 PM, DenesL wrote:
 
 It should be noted that there was some work done towards enabling an
 alternate setting that would allow the developer access to the
 unchanged (raw) args but it has not been finished yet.
 
 This would allow any character set in args which I believe mainly
 concerns non-English speaking developers/users.
 
 If any of you feel, as I do, that this is important please voice your
 concern.
 
 The raw args feature is available in the current release. Specify it for a 
 particular app in routes.py, and request.raw_args will have the unprocessed 
 args. %20 will be converted to space.
 
 URL rewriting is still somewhat broken, especially when a ? is involved. 
 I've got a plan to address that too, but I haven't had a lot of time to put 
 in on it.
 
 
 
 Denes.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.
 


-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Rows don't serialize well if unicode in _extra

2010-04-05 Thread fgpy
Hi,

I have an issue with version 1.76.1, when I use a select statement
with several tables storing data in unicode.

It seems that when the fields are not fully qualified (like col1
instead of dbname.col1), results are stored in an _extra dictionary.

The issue is that when _extra contains unicode data (like
u'\u65e5\u672c'), the data is not send to the UTF8 converter in the
csv_export method and an error appears.

The problem seems to be in gluon.sql.Rows. I did a quick fix on my
local install by adding utf8 encoding on the _extra part, but could
you make it more generic as a fix?

Thank you,
fg

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: XML with custom TAG

2010-04-05 Thread Jason Lotz
Brilliant, Thanks!!


Jay

On Apr 5, 10:56 pm, DenesL denes1...@yahoo.ca wrote:
 On Apr 5, 9:14 am, Jason Lotz jayl...@gmail.com wrote:

  I'm trying to pass an XML string with custom TAG to a view, but I'm
  having trouble with syntax.

  Required XML Syntax:
  rows
          row id=unique_rowid
              cellcell content/cell
              cellcell content/cell
          /row
  /rows

  The code string in the controller:
  rowxml=TAG.rows(*[TAG.row(*[TAG.cell(r[f]) for f in rowflds]) for r in
  rows])

 rowxml=TAG.rows(*[TAG.row(_id='abc', *[TAG.cell(r[f]) for f in
 rowflds]) for r in rows])



  The above code string creates the XML structure I need but I'm missing
  the unique_rowid. I have tried several ways to included _id=r but I
  get syntax errors.

  Can someone help me with the syntax to add id= in the row?

  --Jay

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Problem with MANY-MANY relationship

2010-04-05 Thread Ishbir
Thinking of ditching MANY-MANY altogether, I have come up with this
approach which uses multiple=True-

http://web2py.pastebin.com/813ZELF5

However, the problem is that whenever I do something like
snippet.tags, it just gives me a string list with the IDs. How do I
make it give me a list of the tags associated with the record so that
I can access the name field with something like-

for tag in snippet.tags:
print tag.name

??

On Apr 5, 6:46 pm, Ishbir ishbi...@gmail.com wrote:
 I've got some problem with the MANY-MANY relation in Web2Py. This is
 my code-

 http://pastie.textmate.org/903738

 Now, the problem is that the query returns only those records which
 have tags, not the ones without them. However, if I specify query|
 db.snippets.id0 or anything, it gives me garbled results with all the
 tables mixed up and nothing right..

 Is there any way around this? I thought about using the tagging plugin
 but the issue is that I don't think it would be very efficient since I
 need to also display the tags on the index page and that would result
 in n+1 queries where n is the no. of snippets. Or I am just getting
 apprehensive and it will just take 2-3 queries to get the tags of
 snippet?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: web2py on github

2010-04-05 Thread mdipierro
I somebody wants to keep an official mirror there I have no
objection. I prefer to stick with mercurial on Google because
mercurial is 100% python.

On Apr 5, 1:53 am, elffikk elff...@gmail.com wrote:
 hi,

 I use a few project stored on github, and I find it easier to navigate
 source code or to get a trunk version.
 What about moving web2py on github?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: concurrency problem

2010-04-05 Thread mdipierro
You can already chain them

onvalidate=lambda form: (f1(form),f2(form),f3(form))

On Apr 5, 1:14 am, Iceberg iceb...@21cn.com wrote:
 Good to hear that is on your todo list, Massimo. When you do that,
 please also figure out a way to chain multi onvalidate functions,
 because I expect the crud.unmodified() would be used quite popular, if
 not everytime.

 Iceberg

 On Apr5, 1:42pm, mdipierro mdipie...@cs.depaul.edu wrote:

  This is a good point. I do not think this should be dealt with at the
  DB level because, if I understand it is an app workflow problem.
  If I understand

  For every user there are two HTTP requests (one to generate the update
  form, one to submit the form) and each is executed in its own
  transaction. So the only problem is when the data changes in DB for
  the record in question in between the two requests. This cannot be
  solved at the DB level because you do not want to lock the record in
  one request and unlock in the second request since the second may
  never arrive (user reload page, click back button, connection is
  dropped, etc.). This much be resolved by an explicit check that the
  record content in between requests has not changed. I have once posted
  an example of how to do it with web2py but now I cannot find it.

  Anyway, this can be done easily at the app level by adding a timestamp
  to the record and checking onvalidation that the record timestamp did
  not change in between the two requests. This should not be default
  web2py behaviors since the check depends on the model and, moreover,
  it may be slow and un-necessary in the general case.

  Like we have onaccept=crud.archive, we could have a
  onvalidate=curd.unmodified to provide a standard API to perform this
  check. I will put it in my todo list.

  Massimo

  On Apr 4, 11:59 pm, Iceberg iceb...@21cn.com wrote:

   Yarko, you suggest using a full-featured db instead of sqlite. But
   sqlite's internal reader/writer lock is one thing, the overwrite
   problem is another. No matter what kind of db we are using, we still
   need to deal with the overwrite problem.

   Scenario:
   9:00am clerk Adam read the balance of a client's account, it is $100
   9:01am clerk Bob read the balance of same client, it is $100
   9:02am clerk Adam plans to deduct $10 from the account, and updating
   the new balance as $90
   9:03am NOT knowing what Adam had done, Bob plans to deduct $20 from
   the account, and updating the new balance as $80

   There is no physical concurrency here. But we need some measure to
   refuse Bob's last attempt. There is this kind of measures, such as
   optimistic lock mechanism in the app level. What I want to discuss is
   that, do we need implement optimistic lock in our every web2py app, or
   can/need we do something in DAL level, such as PyDbLite did by the
   __version field, to benefit all web2py app?

   Ideas? Thanks.
   iceberg

   On Apr3, 8:18pm, Iceberg iceb...@21cn.com wrote:

Yarko, you also raise a very good point. And this makes me feel
nervous, because all my previous web app are vulnerable to this
overwrite issue. :-/

Besides the locking plugin, which is optional and not aware by
everyone, do you think we can add some built-in, anti-overwrite
protection inside DAL? For example, if the table contains a field
named __version__, then DAL is responsible for automatically perform
version check before every update(). The idea is borrowed from
PyDbLite (http://pypi.python.org/pypi/PyDbLite/2.3). And perhaps DAL
can do more, by raise exception when concurrent modification is
detected during crud.update().

Quoted fromhttp://www.pydblite.net/en/PyDbLite.html

- another internal field called __version__ is also managed by the
database engine. It is a integer which is set to 0 when the record is
created, then incremented by 1 each time the record is updated. This
is used to detect concurrency control, for instance in a web
application where 2 users select the same record and want to update it
at the same time

Regards,
Iceberg

On Apr2, 10:44pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote:

 The first thing I thought of when I read your post was 
 this:http://web2py.com/plugins/default/locking

 and I wondered how you implemented your solution.

 I could imagine, if two users open a form, and both submit form.id 2,
 one will overwrite the other's.

 (hope this is helpful)
 Regards,
 - Yarko

 On Apr 2, 5:00 am, Sven svenstrin...@gmail.com wrote:

  Hi,

  I programmed a psychological experiment in flash and store answers/
  results in a sqlite database using web2py (behind  nginx server +
  fastcgi)  and pyamf. Everything seems to be all right when I test 
  it,
  but with as few as 2 simultaneous users I (sometimes) run into
  trouble. A try with seven simultaneous users resulted in only 2
  succesfully stored 

[web2py] Re: concurrency problem

2010-04-05 Thread mdipierro
ERRATA:

You can already chain them

onvalidation=lambda form: (f1(form),f2(form),f3(form))

On Apr 5, 10:34 am, mdipierro mdipie...@cs.depaul.edu wrote:
 You can already chain them

 onvalidate=lambda form: (f1(form),f2(form),f3(form))

 On Apr 5, 1:14 am, Iceberg iceb...@21cn.com wrote:

  Good to hear that is on your todo list, Massimo. When you do that,
  please also figure out a way to chain multi onvalidate functions,
  because I expect the crud.unmodified() would be used quite popular, if
  not everytime.

  Iceberg

  On Apr5, 1:42pm, mdipierro mdipie...@cs.depaul.edu wrote:

   This is a good point. I do not think this should be dealt with at the
   DB level because, if I understand it is an app workflow problem.
   If I understand

   For every user there are two HTTP requests (one to generate the update
   form, one to submit the form) and each is executed in its own
   transaction. So the only problem is when the data changes in DB for
   the record in question in between the two requests. This cannot be
   solved at the DB level because you do not want to lock the record in
   one request and unlock in the second request since the second may
   never arrive (user reload page, click back button, connection is
   dropped, etc.). This much be resolved by an explicit check that the
   record content in between requests has not changed. I have once posted
   an example of how to do it with web2py but now I cannot find it.

   Anyway, this can be done easily at the app level by adding a timestamp
   to the record and checking onvalidation that the record timestamp did
   not change in between the two requests. This should not be default
   web2py behaviors since the check depends on the model and, moreover,
   it may be slow and un-necessary in the general case.

   Like we have onaccept=crud.archive, we could have a
   onvalidate=curd.unmodified to provide a standard API to perform this
   check. I will put it in my todo list.

   Massimo

   On Apr 4, 11:59 pm, Iceberg iceb...@21cn.com wrote:

Yarko, you suggest using a full-featured db instead of sqlite. But
sqlite's internal reader/writer lock is one thing, the overwrite
problem is another. No matter what kind of db we are using, we still
need to deal with the overwrite problem.

Scenario:
9:00am clerk Adam read the balance of a client's account, it is $100
9:01am clerk Bob read the balance of same client, it is $100
9:02am clerk Adam plans to deduct $10 from the account, and updating
the new balance as $90
9:03am NOT knowing what Adam had done, Bob plans to deduct $20 from
the account, and updating the new balance as $80

There is no physical concurrency here. But we need some measure to
refuse Bob's last attempt. There is this kind of measures, such as
optimistic lock mechanism in the app level. What I want to discuss is
that, do we need implement optimistic lock in our every web2py app, or
can/need we do something in DAL level, such as PyDbLite did by the
__version field, to benefit all web2py app?

Ideas? Thanks.
iceberg

On Apr3, 8:18pm, Iceberg iceb...@21cn.com wrote:

 Yarko, you also raise a very good point. And this makes me feel
 nervous, because all my previous web app are vulnerable to this
 overwrite issue. :-/

 Besides the locking plugin, which is optional and not aware by
 everyone, do you think we can add some built-in, anti-overwrite
 protection inside DAL? For example, if the table contains a field
 named __version__, then DAL is responsible for automatically perform
 version check before every update(). The idea is borrowed from
 PyDbLite (http://pypi.python.org/pypi/PyDbLite/2.3). And perhaps DAL
 can do more, by raise exception when concurrent modification is
 detected during crud.update().

 Quoted fromhttp://www.pydblite.net/en/PyDbLite.html

 - another internal field called __version__ is also managed by the
 database engine. It is a integer which is set to 0 when the record is
 created, then incremented by 1 each time the record is updated. This
 is used to detect concurrency control, for instance in a web
 application where 2 users select the same record and want to update it
 at the same time

 Regards,
 Iceberg

 On Apr2, 10:44pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote:

  The first thing I thought of when I read your post was 
  this:http://web2py.com/plugins/default/locking

  and I wondered how you implemented your solution.

  I could imagine, if two users open a form, and both submit form.id 
  2,
  one will overwrite the other's.

  (hope this is helpful)
  Regards,
  - Yarko

  On Apr 2, 5:00 am, Sven svenstrin...@gmail.com wrote:

   Hi,

   I programmed a psychological experiment in flash and store 
   answers/
   results in a sqlite database using web2py (behind  nginx server 

Re: [web2py] Problem with MANY-MANY relationship

2010-04-05 Thread Thadeus Burgess
Your join is performing a union, your queries could (and will) get
quite huge, since your getting a record for every tag. (so for two
tags you actually get two rows for that snippet). A left join will
provide you with everything, but you still get a row for every tag.

Even with a left join you will still have to query for the title of the tag

 rows = db().select(db.snippets.ALL, db.snippet_tags_link.ALL, 
 left=db.snippet_tags_link.on(db.snippets.id == 
 db.snippet_tags_link.snippet_id))
 print rows
snippets.id,snippets.title,snippets.content,snippets.created,snippet_tags_link.id,snippet_tags_link.snippet_id,snippet_tags_link.tag_id
1,hi,hello world,2010-04-05 09:21:20,1,1,1
1,hi,hello world,2010-04-05 09:21:20,2,1,1
2,woot,erifica,2010-04-05 09:21:20,NULL,NULL,NULL


Or you can do a secondary query to get the tags.

snippets = db().select()
for snip in snippets:
   print snippet.title
   for tag in snip.snippet_tags_link.select():
  print tag.snippet_tags.name

-Thadeus





On Mon, Apr 5, 2010 at 8:46 AM, Ishbir ishbi...@gmail.com wrote:
 I've got some problem with the MANY-MANY relation in Web2Py. This is
 my code-

 http://pastie.textmate.org/903738

 Now, the problem is that the query returns only those records which
 have tags, not the ones without them. However, if I specify query|
 db.snippets.id0 or anything, it gives me garbled results with all the
 tables mixed up and nothing right..

 Is there any way around this? I thought about using the tagging plugin
 but the issue is that I don't think it would be very efficient since I
 need to also display the tags on the index page and that would result
 in n+1 queries where n is the no. of snippets. Or I am just getting
 apprehensive and it will just take 2-3 queries to get the tags of
 snippet?

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: How to use virtualfields?

2010-04-05 Thread mdipierro
You know web2y better than me. I had forgotten about Rows.as_dict()

If option 2 works with you, use 2.

On Apr 5, 3:13 am, Iceberg iceb...@21cn.com wrote:
 Old problem solved, new problem arises.

 There is a somewhat obvious difference which I did not notice before.

   (1) db.table.virtualfields.append(ComputedFields())
   This need to be executed BEFORE db().select(), otherwise it will NOT
 affect the select result rows.

   (2) rows.setvirtualfields(table=ComputedFields())
   This of course can only be used AFTER you've got the rows (and you
 can't possibly go to the wrong way.)

 However, there must be some more subtle difference I don't know yet.
 Even I use (1) BEFORE my db().select(), I found that is much slower
 (perhaps due to some lazy function call). And worse, (1) can't support
 virtual field has SAME name as real field, while (2) can. My code
 looks like:

   class VirtualFields:
       distributors=db().select(db.Distributor.id,db.Distributor.name,
           cache=(cache.ram,3600*24)).as_dict()
       def income(self):
           # round the real field income into per thousand unit
           return self.mytable.income / 1000.0
       def distributor(self):
           # tend to change real field distributor from id to its
 name
           return self.distributors.get(
               self.Orders.distributor,{}).get('name')

 So I think I have to stick to usage (2), do I?

 BTW, I am using the latest web2py trunk on Windows XP.

 Regards,
 Iceberg

 On Apr5, 12:18pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I just did this as a test and it worked:

   db=DAL('sqlite:memory:')
   db.define_table('test',Field('quantity','integer'))
   class VirtualFields():

  ...     def profit(self): return self.test.quantity*100 
  db.test.virtualfields.append(VirtualFields())
   db.test.insert(quantity=5)
  1
   rows=db(db.test.id0).select()
   for row in rows: print row

  ...
  Row {'update_record': function lambda at 0x1b8dbb0, 'profit':
  500, 'id': 1, 'delete_record': function lambda at 0x1b8dab0,
  'quantity': 5}

  Sure you are running an updated version of web2py? Which os? which
  version?

On Sun, Apr 4, 2010 at 10:51 PM, Iceberg iceb...@21cn.com wrote:
 Hi there,

 I search virtualfields inhttp://www.web2py.com/bookbutfound
 nothing.

 So I read this post instead:  
 https://groups.google.com/group/web2py/browse_frm/thread/d59ee3d6c2e6...

 But I found that
  db.table.virtualfields.append(ComputedFields())
 doesn't work.

 Only this work:
  rows.setvirtualfields(table=ComputedFields())

 Does the former syntax really supposed to exist?

 I am using web2py 1.75.4

 Regards,
 Iceberg

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Errors with the new version

2010-04-05 Thread mdipierro
another patch?

On Apr 5, 4:14 am, hamdy.a.farag hamdy.a.fa...@inbox.com wrote:
 Massimo, I sent you the patch
 There's also another problem that I got confused about
 when using crud.update in case of deleting a record
 crud.settings.keepvalues = False  is not working.
 after deleting the record , form is not cleared

 in fact it is not working either in case of updating record or
 deleting it using crud.update()

 On Apr 4, 6:37 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Can you please email me a patch or the updated tools.py? Thanks

  Massimo

  On Apr 4, 5:07 am, hamdy.a.farag hamdy.a.fa...@inbox.com wrote:

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: How to use virtualfields?

2010-04-05 Thread Thadeus Burgess
Its slower because each function is executed with the query. So what
happens is when you get your rows object, it is the value of the
function, not the function.

If you wrap all of your functions in a lambda as a lazy function,
then it will increase the speed

please look at 
http://thadeusb.com/weblog/view/web2py_virtualfields_as_an_orm_an_sqlalchemy_approach
for more information

-Thadeus





On Mon, Apr 5, 2010 at 3:13 AM, Iceberg iceb...@21cn.com wrote:
 Old problem solved, new problem arises.

 There is a somewhat obvious difference which I did not notice before.

  (1) db.table.virtualfields.append(ComputedFields())
  This need to be executed BEFORE db().select(), otherwise it will NOT
 affect the select result rows.

  (2) rows.setvirtualfields(table=ComputedFields())
  This of course can only be used AFTER you've got the rows (and you
 can't possibly go to the wrong way.)

 However, there must be some more subtle difference I don't know yet.
 Even I use (1) BEFORE my db().select(), I found that is much slower
 (perhaps due to some lazy function call). And worse, (1) can't support
 virtual field has SAME name as real field, while (2) can. My code
 looks like:

  class VirtualFields:
      distributors=db().select(db.Distributor.id,db.Distributor.name,
          cache=(cache.ram,3600*24)).as_dict()
      def income(self):
          # round the real field income into per thousand unit
          return self.mytable.income / 1000.0
      def distributor(self):
          # tend to change real field distributor from id to its
 name
          return self.distributors.get(
              self.Orders.distributor,{}).get('name')

 So I think I have to stick to usage (2), do I?

 BTW, I am using the latest web2py trunk on Windows XP.

 Regards,
 Iceberg

 On Apr5, 12:18pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I just did this as a test and it worked:

  db=DAL('sqlite:memory:')
  db.define_table('test',Field('quantity','integer'))
  class VirtualFields():

 ...     def profit(self): return self.test.quantity*100 
 db.test.virtualfields.append(VirtualFields())
  db.test.insert(quantity=5)
 1
  rows=db(db.test.id0).select()
  for row in rows: print row

 ...
 Row {'update_record': function lambda at 0x1b8dbb0, 'profit':
 500, 'id': 1, 'delete_record': function lambda at 0x1b8dab0,
 'quantity': 5}

 Sure you are running an updated version of web2py? Which os? which
 version?


   On Sun, Apr 4, 2010 at 10:51 PM, Iceberg iceb...@21cn.com wrote:
Hi there,

I search virtualfields inhttp://www.web2py.com/bookbutfound
nothing.

So I read this post instead:  
https://groups.google.com/group/web2py/browse_frm/thread/d59ee3d6c2e6...

But I found that
 db.table.virtualfields.append(ComputedFields())
doesn't work.

Only this work:
 rows.setvirtualfields(table=ComputedFields())

Does the former syntax really supposed to exist?

I am using web2py 1.75.4

Regards,
Iceberg


 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cx_Oracle segfaults

2010-04-05 Thread mdipierro
perhaps I misread your original post. Your patch suggested REMOVING
threaded=True and all I am saying is that it is not there. Are you
saying I misread your patch and you think threaded=True SHOULD be
there?

Are you using connection pooling? That may be why it is needed.

Massimo

On Apr 5, 6:23 am, Gabriele  Alberti gabriele.albe...@gmail.com
wrote:
 Hello,
 I am sorry but I have to disagree. I dont know exactly what happens as
 I am not into the DAL so much, but as I installed the latest version
 (running 1.76.5 now) with no threaded argument in the cx_Oracle
 connection I started getting back segfaults. They disappeared
 immediately after I put the threaded=True argument..

 If there's anything I can do to help, I'll be glad to.

 Regards,

 G.

 On Apr 5, 12:59 pm, Gabriele  Alberti gabriele.albe...@gmail.com
 wrote:

  Hello,
  yes I am running 1.76.1 (2010-03-01 19:56:55); I'll try the latest and
  I'll let you know ASAP.

  Thank you very much,

  G.

  On Apr 5, 5:43 am, mdipierro mdipie...@cs.depaul.edu wrote:

   Thank you Gabriele,

   is should definitively be threaded=False and not True since web2py
   does not share connection between threads. Yet, this is already the
   default. You must be running an older version of web2py.You should
   upgrade.

   Massimo

   On Apr 4, 11:33 am, Gabriele  Alberti gabriele.albe...@gmail.com
   wrote:

Hello,
I have been using web2py with oracle since few months now. With small
loads everything works fine, but when the load grows, often the python
process gets killed with a segfault; after few headaches to understand
what was going on, I think I spotted the problem and tried a solution
that works for me.
It seems the cx_Oracle libs when used in threaded programs (such as
the web2py server) needs to handle some locking, as suggested in the
cx_Oracle documentation found at

   http://cx-oracle.sourceforge.net/html/module.html

[...]
The threaded argument is expected to be a boolean expression which
indicates whether or not Oracle should use the mode OCI_THREADED to
wrap accesses to connections with a mutex. Doing so in single threaded
applications imposes a performance penalty of about 10-15% which is
why the default is False.
[...]

I am not 100% sure this was the problem as I couldnt find a reasonable
way to prove it; however, since when I applied the following patch
(thats the only change I've made) I havent had crashes anymore.
So this is the simple patch I used and I propose

--- sql.py      2010-04-04 18:18:26.0 +0200
+++ sql_orig.py 2010-04-04 18:17:38.0 +0200
@@ -964,7 +964,7 @@
         elif self._uri[:9] == 'oracle://':
             self._dbname = 'oracle'
             self._pool_connection(lambda : \
-
cx_Oracle.connect(self._uri[9:],threaded=True))
+                                  cx_Oracle.connect(self._uri[9:]))
             self._cursor = self._connection.cursor()
             self._execute = lambda a: \
                 oracle_fix_execute(a,self._cursor.execute)

I'd like someone else to confirm this, and I really hope this can
help.

Kind regards,

G.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Validator on upload field

2010-04-05 Thread mdipierro
I will release a stable one soon.



On Apr 5, 10:05 am, Chris crflei...@gmail.com wrote:
 Thanks, I tried it with trunk and it works.

 Is trunk considered stable enough to run from it all the time or is it
 better to stick with the releases and upgrade with each new release?

 On Apr 2, 8:17 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I think this was fixed in trunk a couple of weeks ago.

  Massimo

  On Apr 2, 3:35 pm, Chris crflei...@gmail.com wrote:

   I can't seem to get acustomvalidatorto be called on a Field of type
   'upload' when editing a record in appadmin. It works on the other text
   fields or when inserting a new record.

   Thevalidatordoesn't do anything yet, but here's the what I was
   starting with to make sure it worked:

   class IS_FILE_TYPE(Validator):

       def __call__(self, value):
           return (value, 'message')

   This is using python 2.6 on linux.

   Using python 2.5 on OS X I get an error when editing a record and
   using thevalidatorI wrote. Here's the traceback:

   Traceback (most recent call last):
     File /Users/chris/workspace/project/gluon/restricted.py, line 173,
   in restricted
       exec ccode in environment
     File /Users/chris/workspace/project/applications/init/controllers/
   appadmin.py, line 410, in module
     File /Users/chris/workspace/project/gluon/globals.py, line 96, in
   lambda
       self._caller = lambda f: f()
     File /Users/chris/workspace/project/applications/init/controllers/
   appadmin.py, line 275, in update
       if form.accepts(request.vars, session):
     File /Users/chris/workspace/project/gluon/sqlhtml.py, line 844, in
   accepts
       if not request_vars.get(key, None) \
     File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
   python2.5/cgi.py, line 624, in __len__
       return len(self.keys())
     File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
   python2.5/cgi.py, line 600, in keys
       raise TypeError, not indexable
   TypeError: not indexable

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Rows don't serialize well if unicode in _extra

2010-04-05 Thread mdipierro
What do you mean by

when the fields are not fully qualified (like col1 instead of dbname.col1)

?

On Apr 5, 10:19 am, fgpy franck...@gmail.com wrote:
 Hi,

 I have an issue with version 1.76.1, when I use a select statement
 with several tables storing data in unicode.

 It seems that when the fields are not fully qualified (like col1
 instead of dbname.col1), results are stored in an _extra dictionary.

 The issue is that when _extra contains unicode data (like
 u'\u65e5\u672c'), the data is not send to the UTF8 converter in the
 csv_export method and an error appears.

 The problem seems to be in gluon.sql.Rows. I did a quick fix on my
 local install by adding utf8 encoding on the _extra part, but could
 you make it more generic as a fix?

 Thank you,
 fg

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Using the Google Data APIs in my GAE web2py project

2010-04-05 Thread Leandro - ProfessionalIT
Hi Friends,
   In the documentation of gdata-python-client library I have this:

Using the gdata-python-client library
Google offers a Google Data Python client library that simplifies
token management and requesting data from specific Google Data APIs.
We recently released a version of this library that supports making
requests from Google App Engine applications. In this article we'll
use this library, but of course you're welcome to use whatever works
best for your application. Download the gdata-python-client library.
To use this library with your Google App Engine application, simply
place the library source files in your application's directory, and
import them as you usually would. The source directories you need to
upload with your application code are src/gdata and src/atom. Then, be
sure to call the gdata.alt.appengine.run_on_appengine function on each
instance of a gdata.service.GDataService object. There's nothing more
to it than that!

Well, I'm trying paste the 'src' folder in two places and don't have
succes, my tests is start the shell with web2py -shell=myapp and
trying import a class of src folder:
   1 - In the root of my GAE application folder
   2 - In the directory 'modules' of my app

Where i have that put this src folder ?

best regards,
Leandro.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cx_Oracle segfaults

2010-04-05 Thread Gabriele Alberti
Hello,
I am not using connection pooling, and threaded=True is needed to
avoid segfaults.

I dont know why this happens, my wild guess is that cx_Oracle (or its
underlying libs), when used in the same process, also if different
threads, share something between different connections, needing
locking..

G.

On Apr 5, 5:45 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 perhaps I misread your original post. Your patch suggested REMOVING
 threaded=True and all I am saying is that it is not there. Are you
 saying I misread your patch and you think threaded=True SHOULD be
 there?

 Are you using connection pooling? That may be why it is needed.

 Massimo

 On Apr 5, 6:23 am, Gabriele  Alberti gabriele.albe...@gmail.com
 wrote:



  Hello,
  I am sorry but I have to disagree. I dont know exactly what happens as
  I am not into the DAL so much, but as I installed the latest version
  (running 1.76.5 now) with no threaded argument in the cx_Oracle
  connection I started getting back segfaults. They disappeared
  immediately after I put the threaded=True argument..

  If there's anything I can do to help, I'll be glad to.

  Regards,

  G.

  On Apr 5, 12:59 pm, Gabriele  Alberti gabriele.albe...@gmail.com
  wrote:

   Hello,
   yes I am running 1.76.1 (2010-03-01 19:56:55); I'll try the latest and
   I'll let you know ASAP.

   Thank you very much,

   G.

   On Apr 5, 5:43 am, mdipierro mdipie...@cs.depaul.edu wrote:

Thank you Gabriele,

is should definitively be threaded=False and not True since web2py
does not share connection between threads. Yet, this is already the
default. You must be running an older version of web2py.You should
upgrade.

Massimo

On Apr 4, 11:33 am, Gabriele  Alberti gabriele.albe...@gmail.com
wrote:

 Hello,
 I have been using web2py with oracle since few months now. With small
 loads everything works fine, but when the load grows, often the python
 process gets killed with a segfault; after few headaches to understand
 what was going on, I think I spotted the problem and tried a solution
 that works for me.
 It seems the cx_Oracle libs when used in threaded programs (such as
 the web2py server) needs to handle some locking, as suggested in the
 cx_Oracle documentation found at

http://cx-oracle.sourceforge.net/html/module.html

 [...]
 The threaded argument is expected to be a boolean expression which
 indicates whether or not Oracle should use the mode OCI_THREADED to
 wrap accesses to connections with a mutex. Doing so in single threaded
 applications imposes a performance penalty of about 10-15% which is
 why the default is False.
 [...]

 I am not 100% sure this was the problem as I couldnt find a reasonable
 way to prove it; however, since when I applied the following patch
 (thats the only change I've made) I havent had crashes anymore.
 So this is the simple patch I used and I propose

 --- sql.py      2010-04-04 18:18:26.0 +0200
 +++ sql_orig.py 2010-04-04 18:17:38.0 +0200
 @@ -964,7 +964,7 @@
          elif self._uri[:9] == 'oracle://':
              self._dbname = 'oracle'
              self._pool_connection(lambda : \
 -
 cx_Oracle.connect(self._uri[9:],threaded=True))
 +                                  cx_Oracle.connect(self._uri[9:]))
              self._cursor = self._connection.cursor()
              self._execute = lambda a: \
                  oracle_fix_execute(a,self._cursor.execute)

 I'd like someone else to confirm this, and I really hope this can
 help.

 Kind regards,

 G.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Unicode characters problem (Dreamhost installation)

2010-04-05 Thread Yarko Tymciurak
On Apr 5, 3:23 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
wrote:
 I think I got it to work! I deleted the domain from the control panel
 altogether and then readded it, and web2py 1.76.5 started working.
 Problem solved for the time being. I don't know what what the exact
 cause though.

I'm guessing here, as you did not explicitly say - maybe you did not
stop / restart the server (i.e. Apache...).  Not sure how Dreamhost
has it configured, but removing the app and re-installing it would
have that effect also.

Hope this is helpful in getting to understanding what was going on.

Regards,
Yarko


 And the problem with Unicode characters is also gone, because it only
 existed in a much older version of web2py 1.39.

 2010/4/5 Alexei Vinidiktov alexei.vinidik...@gmail.com:



  I just tried copying a working copy of web2py 1.76.5 from my Windows
  machine to my Dreamhost VPS account, but it didn't solve the problem.
  I'm still getting the same ticket about DAL not being defined.

  Is there anything else I can do?

  2010/4/5 mdipierro mdipie...@cs.depaul.edu:
  this is a very strange error, as if one of the system files were
  corrupted.
  I would remover everything web2py re-unzip it and copy your
  applications back in applications.

  Massimo

  On Apr 4, 7:28 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  I got it from web2py.com. I'm sure that I've now installed web2py 1.76.5.

  The strange thing is an older version that used to work fine before I
  installed 1.76.5 is now giving me the same error message as the 1.76.5
  one.

  The oldest of all three though seems to work but not entirely  (see my
  second message).

  I guess something went wrong on Dreamhost's end (or rather I did
  something wrong), but I can't think of what it may be. I wonder where
  I should look.

  2010/4/5 mdipierro mdipie...@cs.depaul.edu:

   where d you get it. I do not think this is a new version.

   On Apr 4, 10:02 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
   wrote:
   I seem to have used the wrong old version of web2py, but even now that
   I've installed the new version, I'm getting a different error:

   Traceback (most recent call last):
     File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
   restricted
     File 
   /home/alvinru/phonetizer.com/applications/welcome/models/db.py,
   line 15, in module
       db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or 
   other DB
   NameError: name 'DAL' is not defined

   In file: /home/alvinru/phonetizer.com/applications/welcome/models/db.py

   2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:

I don't know what I have done, but my test apps have stopped working
at all on Dreamhost.

The default apps still work fine.

Here's the ticket I'm getting when trying to load any app in the 
browser:

Error traceback Traceback (most recent call last):
 File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, in
restricted
   exec ccode in environment
 File 
/home/alvinru/phonetizer.com/applications/pyjamas/models/db.py,
line 12, in module
   db.define_table('todo', db.Field('task'))
 File /home/alvinru/phonetizer.com/gluon/sql.py, line 239, in 
__getattr__
   def __getattr__(self, key): return self[key]
KeyError: 'Field'

In file: 
/home/alvinru/phonetizer.com/applications/pyjamas/models/db.py 
#!/usr/bin/python
# -*- coding: utf-8 -*-

try:
   from gluon.contrib.gql import *  # if running on Google App Engine
except:
   db = SQLDB('sqlite://storage.db')  # if not, use SQLite or other 
DB
else:
   db = GQLDB()  # connect to Google BigTable
   session.connect(request, response, db=db)  # and store sessions 
there

db.define_table('todo', db.Field('task'))

from gluon.tools import Service     # new in web2py 1.56
service = Service(globals())

2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:
Hello,

I've deployed the latest version of web2py on Dreamhost using wsgi.
I'm using a custom installation of Python 2.5.

The web2py installation seems to work fine, but there's one problem.

I've created a test program using the qooxdoo web application
framework for the GUI part which mimics the functionality in the
pyjamas example program: displaying a list of todo items, adding and
deleting items.

It works fine on my local development machine, it works fine on GAE,
but on my Dreamhost installation I'm getting an error when trying to
add a task that contains non ascii symbols, for example Russian
characters as in задание номер один (task number one).

I also have a pyjamas version of the same todo app and it exhibits 
the
same behavior (works fine on GAE, not so on Dreamhost).

Here is the message that I get back from the xmlrpc method call to 
addTask:

Exception during async call: UNEXPECTED origin 

[web2py] Re: left join problem

2010-04-05 Thread mdipierro
Please check now. Is it fixed?

On Apr 5, 7:56 am, Jose jjac...@gmail.com wrote:
 I see that the last change you made was:

 changeset:   362:49d44e1bc17d
 tag:         tip
 user:        mdipie...@massimo-di-pierros-macbook.local
 date:        Fri Apr 02 23:51:07 2010 -0500
 summary:     possible join problem fix, thanks Brian Harrison

 After that left =(...) makes an error occurs.

 File /usr/home/jose/w2p/gluon/sql.py, line 1067, in lambda
     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
 ProgrammingError: (-104, 'isc_dsql_prepare: \n  Dynamic SQL Error\n
 SQL error code = -104\n  Token unknown - line 1, column 258\n  )')

 Before the upgrade, worked fine.

 Jose

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cx_Oracle segfaults

2010-04-05 Thread mdipierro
in trunk

On Apr 5, 11:52 am, Gabriele  Alberti gabriele.albe...@gmail.com
wrote:
 Hello,
 I am not using connection pooling, and threaded=True is needed to
 avoid segfaults.

 I dont know why this happens, my wild guess is that cx_Oracle (or its
 underlying libs), when used in the same process, also if different
 threads, share something between different connections, needing
 locking..

 G.

 On Apr 5, 5:45 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  perhaps I misread your original post. Your patch suggested REMOVING
  threaded=True and all I am saying is that it is not there. Are you
  saying I misread your patch and you think threaded=True SHOULD be
  there?

  Are you using connection pooling? That may be why it is needed.

  Massimo

  On Apr 5, 6:23 am, Gabriele  Alberti gabriele.albe...@gmail.com
  wrote:

   Hello,
   I am sorry but I have to disagree. I dont know exactly what happens as
   I am not into the DAL so much, but as I installed the latest version
   (running 1.76.5 now) with no threaded argument in the cx_Oracle
   connection I started getting back segfaults. They disappeared
   immediately after I put the threaded=True argument..

   If there's anything I can do to help, I'll be glad to.

   Regards,

   G.

   On Apr 5, 12:59 pm, Gabriele  Alberti gabriele.albe...@gmail.com
   wrote:

Hello,
yes I am running 1.76.1 (2010-03-01 19:56:55); I'll try the latest and
I'll let you know ASAP.

Thank you very much,

G.

On Apr 5, 5:43 am, mdipierro mdipie...@cs.depaul.edu wrote:

 Thank you Gabriele,

 is should definitively be threaded=False and not True since web2py
 does not share connection between threads. Yet, this is already the
 default. You must be running an older version of web2py.You should
 upgrade.

 Massimo

 On Apr 4, 11:33 am, Gabriele  Alberti gabriele.albe...@gmail.com
 wrote:

  Hello,
  I have been using web2py with oracle since few months now. With 
  small
  loads everything works fine, but when the load grows, often the 
  python
  process gets killed with a segfault; after few headaches to 
  understand
  what was going on, I think I spotted the problem and tried a 
  solution
  that works for me.
  It seems the cx_Oracle libs when used in threaded programs (such as
  the web2py server) needs to handle some locking, as suggested in the
  cx_Oracle documentation found at

 http://cx-oracle.sourceforge.net/html/module.html

  [...]
  The threaded argument is expected to be a boolean expression which
  indicates whether or not Oracle should use the mode OCI_THREADED to
  wrap accesses to connections with a mutex. Doing so in single 
  threaded
  applications imposes a performance penalty of about 10-15% which is
  why the default is False.
  [...]

  I am not 100% sure this was the problem as I couldnt find a 
  reasonable
  way to prove it; however, since when I applied the following patch
  (thats the only change I've made) I havent had crashes anymore.
  So this is the simple patch I used and I propose

  --- sql.py      2010-04-04 18:18:26.0 +0200
  +++ sql_orig.py 2010-04-04 18:17:38.0 +0200
  @@ -964,7 +964,7 @@
           elif self._uri[:9] == 'oracle://':
               self._dbname = 'oracle'
               self._pool_connection(lambda : \
  -
  cx_Oracle.connect(self._uri[9:],threaded=True))
  +                                  cx_Oracle.connect(self._uri[9:]))
               self._cursor = self._connection.cursor()
               self._execute = lambda a: \
                   oracle_fix_execute(a,self._cursor.execute)

  I'd like someone else to confirm this, and I really hope this can
  help.

  Kind regards,

  G.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Unicode characters problem (Dreamhost installation)

2010-04-05 Thread Yarko Tymciurak
On Apr 5, 11:55 am, Yarko Tymciurak resultsinsoftw...@gmail.com
wrote:
 On Apr 5, 3:23 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:

  I think I got it to work! I deleted the domain from the control panel
  altogether and then readded it, and web2py 1.76.5 started working.
  Problem solved for the time being. I don't know what what the exact
  cause though.

 I'm guessing here, as you did not explicitly say - maybe you did not
 stop / restart the server (i.e. Apache...).  Not sure how Dreamhost
 has it configured, but removing the app and re-installing it would
 have that effect also.

The general thing to remember:

Your app is read on a per-request basis:   first models, then the
controller, and the function call;
If you change any core modules, you need to restart the server
(otherwise, just reload the page!).
Getting used to developing by just updating the code, I sometimes
forget when a restart needs to happen.
I'm not sure, but in the past I think adding a module (?) also needed
a server restart (not sure exactly why; correct me if I'm wrong).

- Yarko

 Hope this is helpful in getting to understanding what was going on.

 Regards,
 Yarko



  And the problem with Unicode characters is also gone, because it only
  existed in a much older version of web2py 1.39.

  2010/4/5 Alexei Vinidiktov alexei.vinidik...@gmail.com:

   I just tried copying a working copy of web2py 1.76.5 from my Windows
   machine to my Dreamhost VPS account, but it didn't solve the problem.
   I'm still getting the same ticket about DAL not being defined.

   Is there anything else I can do?

   2010/4/5 mdipierro mdipie...@cs.depaul.edu:
   this is a very strange error, as if one of the system files were
   corrupted.
   I would remover everything web2py re-unzip it and copy your
   applications back in applications.

   Massimo

   On Apr 4, 7:28 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
   wrote:
   I got it from web2py.com. I'm sure that I've now installed web2py 
   1.76.5.

   The strange thing is an older version that used to work fine before I
   installed 1.76.5 is now giving me the same error message as the 1.76.5
   one.

   The oldest of all three though seems to work but not entirely  (see my
   second message).

   I guess something went wrong on Dreamhost's end (or rather I did
   something wrong), but I can't think of what it may be. I wonder where
   I should look.

   2010/4/5 mdipierro mdipie...@cs.depaul.edu:

where d you get it. I do not think this is a new version.

On Apr 4, 10:02 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
wrote:
I seem to have used the wrong old version of web2py, but even now 
that
I've installed the new version, I'm getting a different error:

Traceback (most recent call last):
  File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, 
in
restricted
  File 
/home/alvinru/phonetizer.com/applications/welcome/models/db.py,
line 15, in module
    db = DAL('sqlite://storage.sqlite')       # if not, use SQLite 
or other DB
NameError: name 'DAL' is not defined

In file: 
/home/alvinru/phonetizer.com/applications/welcome/models/db.py

2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:

 I don't know what I have done, but my test apps have stopped 
 working
 at all on Dreamhost.

 The default apps still work fine.

 Here's the ticket I'm getting when trying to load any app in the 
 browser:

 Error traceback Traceback (most recent call last):
  File /home/alvinru/phonetizer.com/gluon/restricted.py, line 62, 
 in
 restricted
    exec ccode in environment
  File 
 /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py,
 line 12, in module
    db.define_table('todo', db.Field('task'))
  File /home/alvinru/phonetizer.com/gluon/sql.py, line 239, in 
 __getattr__
    def __getattr__(self, key): return self[key]
 KeyError: 'Field'

 In file: 
 /home/alvinru/phonetizer.com/applications/pyjamas/models/db.py 
 #!/usr/bin/python
 # -*- coding: utf-8 -*-

 try:
    from gluon.contrib.gql import *  # if running on Google App 
 Engine
 except:
    db = SQLDB('sqlite://storage.db')  # if not, use SQLite or 
 other DB
 else:
    db = GQLDB()  # connect to Google BigTable
    session.connect(request, response, db=db)  # and store sessions 
 there

 db.define_table('todo', db.Field('task'))

 from gluon.tools import Service     # new in web2py 1.56
 service = Service(globals())

 2010/4/4 Alexei Vinidiktov alexei.vinidik...@gmail.com:
 Hello,

 I've deployed the latest version of web2py on Dreamhost using 
 wsgi.
 I'm using a custom installation of Python 2.5.

 The web2py installation seems to work fine, but there's one 
 problem.

 I've created a test program using the qooxdoo web application
 framework for the 

[web2py] Re: left join problem

2010-04-05 Thread Jose


On 5 abr, 16:58, mdipierro mdipie...@cs.depaul.edu wrote:
 Please check now. Is it fixed?

still gives the same error. There is also a syntax error in tools.py
in lina 2024, missing the colon.

if form.accepts(request.post_vars, _session, formname=_formname,
onvalidation=onvalidation, keepvalues=keepvalues):

Jose

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: left join problem

2010-04-05 Thread mdipierro
One more try please.

On Apr 5, 12:49 pm, Jose jjac...@gmail.com wrote:
 On 5 abr, 16:58, mdipierro mdipie...@cs.depaul.edu wrote:

  Please check now. Is it fixed?

 still gives the same error. There is also a syntax error in tools.py
 in lina 2024, missing the colon.

 if form.accepts(request.post_vars, _session, formname=_formname,
                     onvalidation=onvalidation, keepvalues=keepvalues):

 Jose

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: left join problem

2010-04-05 Thread Jose


On 5 abr, 17:59, mdipierro mdipie...@cs.depaul.edu wrote:
 One more try please.

Now, it works well!

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Building a query from a form

2010-04-05 Thread Johann Spies
Using this form:

  veld = ['affiliation', 'country','year','journal','author']

   form = SQLFORM.factory(
Field('k', label='Type in up to 5 keywords separated by '
'(spaces).',requires=IS_NOT_EMPTY()),
Field('how', label='Search all or any of the
keywords',default='all', requires = IS_IN_SET(['any','all'])),
Field('refine', label='Refine by search in another
field',default=None, requires= IS_IN_SET(veld)),
Field('value', label='What to search for',default=None))

And the following function to build the keyword query (thanks to help
from this Massimo):

h = request.vars.how
if h == 'any':
query = reduce(lambda
a,b:a|b,[db.sarua.keywords.lower().like('%'+ k
+'%')|db.sarua.title.lower().like('%'+k
+'%')|db.sarua.journal.lower().like('%'+k +'%') for k in
request.vars.k.lower().split()])
else:
query = reduce(lambda
a,b:ab,[db.sarua.keywords.lower().like('%'+ k
+'%')|db.sarua.title.lower().like('%'+k
+'%')|db.sarua.journal.lower().like('%'+k +'%') for k in
request.vars.k.lower().split()])

I want to add the rest of the form to the query.  I have tried:

r = request.vars.refine

if not r :
query = query
else:
query = query + '' +
db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower
+ '%')

but this is not working because the query is not of the type str:

query = query + '' +
db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower
+ '%')
TypeError: unsupported operand type(s) for +: 'Query' and 'str'

How do I extend query built by lambda?

Regards
Johann
-- 
   Every good gift and every perfect gift is from above,
  and cometh down from the Father of lights, with whom
  is no variableness, neither shadow of turning.
 James 1:17

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Building a query from a form

2010-04-05 Thread mdipierro
query =
query(db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower
+ '%'))

On Apr 5, 1:34 pm, Johann Spies johann.sp...@gmail.com wrote:
 Using this form:

   veld = ['affiliation', 'country','year','journal','author']

    form = SQLFORM.factory(
         Field('k', label='Type in up to 5 keywords separated by '
 '(spaces).',requires=IS_NOT_EMPTY()),
         Field('how', label='Search all or any of the
 keywords',default='all', requires = IS_IN_SET(['any','all'])),
         Field('refine', label='Refine by search in another
 field',default=None, requires= IS_IN_SET(veld)),
         Field('value', label='What to search for',default=None))

 And the following function to build the keyword query (thanks to help
 from this Massimo):

         h = request.vars.how
         if h == 'any':
             query = reduce(lambda
 a,b:a|b,[db.sarua.keywords.lower().like('%'+ k
 +'%')|db.sarua.title.lower().like('%'+k
 +'%')|db.sarua.journal.lower().like('%'+k +'%') for k in
 request.vars.k.lower().split()])
         else:
             query = reduce(lambda
 a,b:ab,[db.sarua.keywords.lower().like('%'+ k
 +'%')|db.sarua.title.lower().like('%'+k
 +'%')|db.sarua.journal.lower().like('%'+k +'%') for k in
 request.vars.k.lower().split()])

 I want to add the rest of the form to the query.  I have tried:

         r = request.vars.refine

         if not r :
             query = query
         else:
             query = query + '' +
 db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower
 + '%')

 but this is not working because the query is not of the type str:

     query = query + '' +
 db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower
 + '%')
 TypeError: unsupported operand type(s) for +: 'Query' and 'str'

 How do I extend query built by lambda?

 Regards
 Johann
 --
        Every good gift and every perfect gift is from above,
       and cometh down from the Father of lights, with whom
       is no variableness, neither shadow of turning.
                              James 1:17

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread Thadeus Burgess
I get this traceback when attempting to access a reference field.

rows = db().select(db.table.ALL)
for r in rows:
  r.id
  r.title
  r.reference_field.name
  r.reference_field.description

Traceback (most recent call last):
  File /home/tburgess/Applications/web2py/gluon/restricted.py, line
173, in restricted
exec ccode in environment
  File 
/home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
line 84, in module
{{=db.field[column].represent(d.B[column])}}
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
in __getattr__
self.__allocate()
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
in __allocate
self._record = self._table[int(self)]
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
in __getitem__
return self._db(self.id == key).select()._first()
AttributeError: 'Rows' object has no attribute '_first'


I get this traceback from form = SQLFORM(db.mytable)

Traceback (most recent call last):
  File /home/tburgess/Applications/web2py/gluon/restricted.py, line
173, in restricted
exec ccode in environment
  File 
/home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
line 278, in module
  File 
/home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
line 28, in compress_response
d = d()
  File 
/home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
line 15, in index
return dict(hi='hi', form=SQLFORM(db.mytable))
  File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
688, in __init__
inp = self.widgets.multiple.widget(field, default)
  File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
211, in widget
return OptionsWidget.widget(field, value, **attributes)
  File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
187, in widget
options = requires[0].options()
  File /home/tburgess/Applications/web2py/gluon/validators.py, line
2227, in _options
options = self.other.options()
  File /home/tburgess/Applications/web2py/gluon/validators.py, line
385, in options
self.build_set()
  File /home/tburgess/Applications/web2py/gluon/validators.py, line
369, in build_set
records = self.dbset.select(*self.fields, **dd)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
return self._db._adapter.select(self._query,*fields,**attributes)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 501, in select
query = self.SELECT(query,*fields, **attributes)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 432, in SELECT
tablenames.append(f._tablename)
AttributeError: 'str' object has no attribute '_tablename'


-Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread mdipierro
I fixed the former. I did not fix the latter. It is a known problem
with the new dal and one of the few things that needs to be ironed
out: it does not like select('fieldname') only
select(db.table['fieldname']). Not difficult to fix anyway.

On Apr 5, 2:13 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 I get this traceback when attempting to access a reference field.

 rows = db().select(db.table.ALL)
 for r in rows:
   r.id
   r.title
   r.reference_field.name
   r.reference_field.description

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
 line 84, in module
     {{=db.field[column].represent(d.B[column])}}
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
 in __getattr__
     self.__allocate()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
 in __allocate
     self._record = self._table[int(self)]
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
 in __getitem__
     return self._db(self.id == key).select()._first()
 AttributeError: 'Rows' object has no attribute '_first'

 I get this traceback from form = SQLFORM(db.mytable)

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 278, in module
   File 
 /home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
 line 28, in compress_response
     d = d()
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 15, in index
     return dict(hi='hi', form=SQLFORM(db.mytable))
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 688, in __init__
     inp = self.widgets.multiple.widget(field, default)
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 211, in widget
     return OptionsWidget.widget(field, value, **attributes)
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 187, in widget
     options = requires[0].options()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 2227, in _options
     options = self.other.options()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 385, in options
     self.build_set()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 369, in build_set
     records = self.dbset.select(*self.fields, **dd)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
     return self._db._adapter.select(self._query,*fields,**attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 501, in select
     query = self.SELECT(query,*fields, **attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 432, in SELECT
     tablenames.append(f._tablename)
 AttributeError: 'str' object has no attribute '_tablename'

 -Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] DAL query count patch

2010-04-05 Thread Thadeus Burgess
Attached is a patch to allow the dal.py to keep track of query counts and types.

Usage

 db.qry_count()
{'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

Massimo, do you accept?

-Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

diff -r ef8d90c29480 gluon/dal.py
--- a/gluon/dal.py	Fri Mar 26 22:59:54 2010 -0500
+++ b/gluon/dal.py	Mon Apr 05 14:15:40 2010 -0500
@@ -571,10 +571,25 @@
 return False
 
 def log_execute(self,*a,**b):
+# Make sure its defined!
+if not self.__dict__.has_key('qry_count'):
+self.qry_count = {}
+
 self.db._lastsql = a[0]
 self.db._logger.write(datetime.datetime.now().isoformat()+'\n'+a[0]+'\n')
 try:
 ret = self.cursor.execute(*a,**b)
+
+# Get the type of the query,
+# This is usually the first
+# word of the SQL statement
+qry_type = a[0].split(' ')[0]
+
+# Add to our counter
+if self.qry_count.has_key(qry_type):
+self.qry_count[qry_type] += 1
+else:
+self.qry_count[qry_type] = 1
 finally:
 self.db._logger.write(traceback.format_exc())
 return ret
@@ -2016,6 +2031,13 @@
 if name.upper() in self.RSK[backend]:
 raise SyntaxError, 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())
 
+def qry_count(self):
+if self._adapter.__dict__.has_key('qry_count'):
+ret = self._adapter.qry_count
+else:
+ret = None
+return ret
+
 def define_table(
 self,
 tablename,


[web2py] Re: DAL query count patch

2010-04-05 Thread mdipierro
I do not see any reason against except that I do not see any reason in
favor either. Why do you need it?

Massimo

On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Attached is a patch to allow the dal.py to keep track of query counts and 
 types.

 Usage

  db.qry_count()

 {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

 Massimo, do you accept?

 -Thadeus

  qry_count.hg.diff
 1KViewDownload

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread Thadeus Burgess
Now I get this for reference field

Traceback (most recent call last):
  File /home/tburgess/Applications/web2py/gluon/restricted.py, line
173, in restricted
exec ccode in environment
  File 
/home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
line 84, in module
{{=db.table[column].represent(d.B[column])}}
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
in __getattr__
self.__allocate()
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
in __allocate
self._record = self._table[int(self)]
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
in __getitem__
return self._db(self.id == key).select().first()
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
return self._db._adapter.select(self._query,*fields,**attributes)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in select
return self.parse(rows,self._colnames)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 707, in parse
colset[fieldname] = rid = Reference(value)
TypeError: int() argument must be a string or a number, not 'NoneType'

-Thadeus





On Mon, Apr 5, 2010 at 2:20 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 I fixed the former. I did not fix the latter. It is a known problem
 with the new dal and one of the few things that needs to be ironed
 out: it does not like select('fieldname') only
 select(db.table['fieldname']). Not difficult to fix anyway.

 On Apr 5, 2:13 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 I get this traceback when attempting to access a reference field.

 rows = db().select(db.table.ALL)
 for r in rows:
   r.id
   r.title
   r.reference_field.name
   r.reference_field.description

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
 line 84, in module
     {{=db.field[column].represent(d.B[column])}}
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
 in __getattr__
     self.__allocate()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
 in __allocate
     self._record = self._table[int(self)]
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
 in __getitem__
     return self._db(self.id == key).select()._first()
 AttributeError: 'Rows' object has no attribute '_first'

 I get this traceback from form = SQLFORM(db.mytable)

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 278, in module
   File 
 /home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
 line 28, in compress_response
     d = d()
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 15, in index
     return dict(hi='hi', form=SQLFORM(db.mytable))
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 688, in __init__
     inp = self.widgets.multiple.widget(field, default)
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 211, in widget
     return OptionsWidget.widget(field, value, **attributes)
   File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
 187, in widget
     options = requires[0].options()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 2227, in _options
     options = self.other.options()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 385, in options
     self.build_set()
   File /home/tburgess/Applications/web2py/gluon/validators.py, line
 369, in build_set
     records = self.dbset.select(*self.fields, **dd)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in 
 select
     return self._db._adapter.select(self._query,*fields,**attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 501, in select
     query = self.SELECT(query,*fields, **attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 432, in SELECT
     tablenames.append(f._tablename)
 AttributeError: 'str' object has no attribute '_tablename'

 -Thadeus

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 

Re: [web2py] Re: DAL query count patch

2010-04-05 Thread Thadeus Burgess
Novelty. Many websites you see will have at the bottom time took to
process request, number of queries to database.

-Thadeus





On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 I do not see any reason against except that I do not see any reason in
 favor either. Why do you need it?

 Massimo

 On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Attached is a patch to allow the dal.py to keep track of query counts and 
 types.

 Usage

  db.qry_count()

 {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

 Massimo, do you accept?

 -Thadeus

  qry_count.hg.diff
 1KViewDownload

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: DAL query count patch

2010-04-05 Thread mdipierro
But this does not count the time, just the number of past requests (in
thread? total?). Am I wrong?
Moreover the count will be wrong if the web server restarts the
process. no?

Massimo

On Apr 5, 2:33 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Novelty. Many websites you see will have at the bottom time took to
 process request, number of queries to database.

 -Thadeus

 On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  I do not see any reason against except that I do not see any reason in
  favor either. Why do you need it?

  Massimo

  On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Attached is a patch to allow the dal.py to keep track of query counts and 
  types.

  Usage

   db.qry_count()

  {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

  Massimo, do you accept?

  -Thadeus

   qry_count.hg.diff
  1KViewDownload

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: webserver slow, misreported

2010-04-05 Thread Michael Toomim
Thanks guys.  Each time I run a test, though, it costs me money
because I'm paying people on mechanical turk.  And if it's slow, it
gives me a bad reputation.  So I don't want to run more slow tests
unless we have good request time logging in place and a good
hypothesis to test.

Wouldn't cron only make it slow every minute or something?

On Apr 5, 5:49 am, Timothy Farrell tfarr...@swgen.com wrote:
 You are right, I was going to add that feature and then forgot about
 it.  Someone reported a PyPI bug over the weekend (it would not affect
 web2py).  I'll see if I can make the logging a bit more flexible and
 release a 1.1 in the next few days.

 In the meantime, look into the cron thing.

 -tim

 On 4/4/2010 6:44 PM, Michael Toomim wrote:



  I see, thank you.  I want to measure the web server's response time
  when I deploy this on turk... Unfortunately the rocket log does not
  report time to serve a request.  Do you think it is easy to get that
  information from rocket?  Do you store the start and stop times for
  each request?  I see start times stored in connections, but I'm not
  sure that's the right object.

  On Mar 30, 6:09 am, Timothy Farrelltfarr...@swgen.com  wrote:

  I don't think upgrading will help much since Cherrypy was also slow.  
  However, doing so would help cover all your bases.

  If you want to use the http log from Rocket you can do this.  I'm
  assuming you invoke web2py.py from a bash script or just run it
  manually.  Paste the following code into the top of web2py.py

  import  logging
  import  logging.handlers
  log  =  logging.getLogger('Rocket.Requests')
  log.setLevel(logging.INFO)
  log.addHandler(logging.handlers.FileHandler('rocket.log')

  I, like Yarko, do think this has more to do with something else.  At one
  point web2py had a profiler built-in.  That could be a good tool for
  finding slow spots.

  -tim

  On 3/29/2010 7:59 PM, MichaelToomimwrote:

  Yes, this is on linux!  Do you recommend upgrading and trying again?

  mturk doesn't affect anything, I am just serving webpages that appear
  in iframes on the mturk website.  From our perspective, I'm serving
  webpages.

  Do you have a method of logging how much time it takes to serve a page
  with rocket?  Something that I can use instead of httpserver.log?  It
  seems important for me to measure real-world performance, which ab
  does not do.

  My server has 768MB ram, and the only thing it does is run this web2py
  server.  I assumed ram was not full, but did not check.  I will check
  next time.

  On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.com    wrote:

  snip/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: webserver slow, misreported

2010-04-05 Thread Michael Toomim
and I'm using postgres not sqlite.

On Apr 5, 12:44 pm, Michael Toomim too...@gmail.com wrote:
 Thanks guys.  Each time I run a test, though, it costs me money
 because I'm paying people on mechanical turk.  And if it's slow, it
 gives me a bad reputation.  So I don't want to run more slow tests
 unless we have good request time logging in place and a good
 hypothesis to test.

 Wouldn't cron only make it slow every minute or something?

 On Apr 5, 5:49 am, Timothy Farrell tfarr...@swgen.com wrote:



  You are right, I was going to add that feature and then forgot about
  it.  Someone reported a PyPI bug over the weekend (it would not affect
  web2py).  I'll see if I can make the logging a bit more flexible and
  release a 1.1 in the next few days.

  In the meantime, look into the cron thing.

  -tim

  On 4/4/2010 6:44 PM, Michael Toomim wrote:

   I see, thank you.  I want to measure the web server's response time
   when I deploy this on turk... Unfortunately the rocket log does not
   report time to serve a request.  Do you think it is easy to get that
   information from rocket?  Do you store the start and stop times for
   each request?  I see start times stored in connections, but I'm not
   sure that's the right object.

   On Mar 30, 6:09 am, Timothy Farrelltfarr...@swgen.com  wrote:

   I don't think upgrading will help much since Cherrypy was also slow.  
   However, doing so would help cover all your bases.

   If you want to use the http log from Rocket you can do this.  I'm
   assuming you invoke web2py.py from a bash script or just run it
   manually.  Paste the following code into the top of web2py.py

   import  logging
   import  logging.handlers
   log  =  logging.getLogger('Rocket.Requests')
   log.setLevel(logging.INFO)
   log.addHandler(logging.handlers.FileHandler('rocket.log')

   I, like Yarko, do think this has more to do with something else.  At one
   point web2py had a profiler built-in.  That could be a good tool for
   finding slow spots.

   -tim

   On 3/29/2010 7:59 PM, MichaelToomimwrote:

   Yes, this is on linux!  Do you recommend upgrading and trying again?

   mturk doesn't affect anything, I am just serving webpages that appear
   in iframes on the mturk website.  From our perspective, I'm serving
   webpages.

   Do you have a method of logging how much time it takes to serve a page
   with rocket?  Something that I can use instead of httpserver.log?  It
   seems important for me to measure real-world performance, which ab
   does not do.

   My server has 768MB ram, and the only thing it does is run this web2py
   server.  I assumed ram was not full, but did not check.  I will check
   next time.

   On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.com    wrote:

   snip/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: webserver slow, misreported

2010-04-05 Thread mdipierro
yes. good point.

Massimo

On Apr 5, 2:44 pm, Michael Toomim too...@gmail.com wrote:
 Thanks guys.  Each time I run a test, though, it costs me money
 because I'm paying people on mechanical turk.  And if it's slow, it
 gives me a bad reputation.  So I don't want to run more slow tests
 unless we have good request time logging in place and a good
 hypothesis to test.

 Wouldn't cron only make it slow every minute or something?

 On Apr 5, 5:49 am, Timothy Farrell tfarr...@swgen.com wrote:

  You are right, I was going to add that feature and then forgot about
  it.  Someone reported a PyPI bug over the weekend (it would not affect
  web2py).  I'll see if I can make the logging a bit more flexible and
  release a 1.1 in the next few days.

  In the meantime, look into the cron thing.

  -tim

  On 4/4/2010 6:44 PM, Michael Toomim wrote:

   I see, thank you.  I want to measure the web server's response time
   when I deploy this on turk... Unfortunately the rocket log does not
   report time to serve a request.  Do you think it is easy to get that
   information from rocket?  Do you store the start and stop times for
   each request?  I see start times stored in connections, but I'm not
   sure that's the right object.

   On Mar 30, 6:09 am, Timothy Farrelltfarr...@swgen.com  wrote:

   I don't think upgrading will help much since Cherrypy was also slow.  
   However, doing so would help cover all your bases.

   If you want to use the http log from Rocket you can do this.  I'm
   assuming you invoke web2py.py from a bash script or just run it
   manually.  Paste the following code into the top of web2py.py

   import  logging
   import  logging.handlers
   log  =  logging.getLogger('Rocket.Requests')
   log.setLevel(logging.INFO)
   log.addHandler(logging.handlers.FileHandler('rocket.log')

   I, like Yarko, do think this has more to do with something else.  At one
   point web2py had a profiler built-in.  That could be a good tool for
   finding slow spots.

   -tim

   On 3/29/2010 7:59 PM, MichaelToomimwrote:

   Yes, this is on linux!  Do you recommend upgrading and trying again?

   mturk doesn't affect anything, I am just serving webpages that appear
   in iframes on the mturk website.  From our perspective, I'm serving
   webpages.

   Do you have a method of logging how much time it takes to serve a page
   with rocket?  Something that I can use instead of httpserver.log?  It
   seems important for me to measure real-world performance, which ab
   does not do.

   My server has 768MB ram, and the only thing it does is run this web2py
   server.  I assumed ram was not full, but did not check.  I will check
   next time.

   On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.com    wrote:

   snip/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: DAL query count patch

2010-04-05 Thread Thadeus Burgess
Ah, well the real goal is for it to only be the number of statements
pending in a given transaction.

So db.commit() or db.rollback() should clear the results...

The time counting I am doing in my models, and in response._caller...
but this is not including time taken to set up the environment before
web2py executes the models.

-Thadeus





On Mon, Apr 5, 2010 at 2:43 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 But this does not count the time, just the number of past requests (in
 thread? total?). Am I wrong?
 Moreover the count will be wrong if the web server restarts the
 process. no?

 Massimo

 On Apr 5, 2:33 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Novelty. Many websites you see will have at the bottom time took to
 process request, number of queries to database.

 -Thadeus

 On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  I do not see any reason against except that I do not see any reason in
  favor either. Why do you need it?

  Massimo

  On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Attached is a patch to allow the dal.py to keep track of query counts and 
  types.

  Usage

   db.qry_count()

  {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

  Massimo, do you accept?

  -Thadeus

   qry_count.hg.diff
  1KViewDownload

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread mdipierro
try now

On Apr 5, 2:30 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Now I get this for reference field

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
 line 84, in module
     {{=db.table[column].represent(d.B[column])}}
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
 in __getattr__
     self.__allocate()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
 in __allocate
     self._record = self._table[int(self)]
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
 in __getitem__
     return self._db(self.id == key).select().first()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
     return self._db._adapter.select(self._query,*fields,**attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in select
     return self.parse(rows,self._colnames)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 707, in parse
     colset[fieldname] = rid = Reference(value)
 TypeError: int() argument must be a string or a number, not 'NoneType'

 -Thadeus

 On Mon, Apr 5, 2010 at 2:20 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  I fixed the former. I did not fix the latter. It is a known problem
  with the new dal and one of the few things that needs to be ironed
  out: it does not like select('fieldname') only
  select(db.table['fieldname']). Not difficult to fix anyway.

  On Apr 5, 2:13 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  I get this traceback when attempting to access a reference field.

  rows = db().select(db.table.ALL)
  for r in rows:
    r.id
    r.title
    r.reference_field.name
    r.reference_field.description

  Traceback (most recent call last):
    File /home/tburgess/Applications/web2py/gluon/restricted.py, line
  173, in restricted
      exec ccode in environment
    File 
  /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
  line 84, in module
      {{=db.field[column].represent(d.B[column])}}
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
  in __getattr__
      self.__allocate()
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
  in __allocate
      self._record = self._table[int(self)]
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
  in __getitem__
      return self._db(self.id == key).select()._first()
  AttributeError: 'Rows' object has no attribute '_first'

  I get this traceback from form = SQLFORM(db.mytable)

  Traceback (most recent call last):
    File /home/tburgess/Applications/web2py/gluon/restricted.py, line
  173, in restricted
      exec ccode in environment
    File 
  /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
  line 278, in module
    File 
  /home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
  line 28, in compress_response
      d = d()
    File 
  /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
  line 15, in index
      return dict(hi='hi', form=SQLFORM(db.mytable))
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  688, in __init__
      inp = self.widgets.multiple.widget(field, default)
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  211, in widget
      return OptionsWidget.widget(field, value, **attributes)
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  187, in widget
      options = requires[0].options()
    File /home/tburgess/Applications/web2py/gluon/validators.py, line
  2227, in _options
      options = self.other.options()
    File /home/tburgess/Applications/web2py/gluon/validators.py, line
  385, in options
      self.build_set()
    File /home/tburgess/Applications/web2py/gluon/validators.py, line
  369, in build_set
      records = self.dbset.select(*self.fields, **dd)
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in 
  select
      return self._db._adapter.select(self._query,*fields,**attributes)
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 501, in 
  select
      query = self.SELECT(query,*fields, **attributes)
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 432, in 
  SELECT
      tablenames.append(f._tablename)
  AttributeError: 'str' object has no attribute '_tablename'

  -Thadeus

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, 

[web2py] Re: DAL query count patch

2010-04-05 Thread mdipierro
Since the new DAL is a class you can define them by subclassing DAL.
What do you think? I am not convinced this is useful in general and
needs to be in trunk. It seems a very specialized application but
perhaps I am missing something. I'd like to hear what other people
think about this.

On Apr 5, 3:00 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Ah, well the real goal is for it to only be the number of statements
 pending in a given transaction.

 So db.commit() or db.rollback() should clear the results...

 The time counting I am doing in my models, and in response._caller...
 but this is not including time taken to set up the environment before
 web2py executes the models.

 -Thadeus

 On Mon, Apr 5, 2010 at 2:43 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  But this does not count the time, just the number of past requests (in
  thread? total?). Am I wrong?
  Moreover the count will be wrong if the web server restarts the
  process. no?

  Massimo

  On Apr 5, 2:33 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Novelty. Many websites you see will have at the bottom time took to
  process request, number of queries to database.

  -Thadeus

  On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   I do not see any reason against except that I do not see any reason in
   favor either. Why do you need it?

   Massimo

   On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
   Attached is a patch to allow the dal.py to keep track of query counts 
   and types.

   Usage

db.qry_count()

   {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

   Massimo, do you accept?

   -Thadeus

    qry_count.hg.diff
   1KViewDownload

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Building a query from a form

2010-04-05 Thread Johann Spies
Thanks.

Johann


-- 
   Every good gift and every perfect gift is from above,
  and cometh down from the Father of lights, with whom
  is no variableness, neither shadow of turning.
 James 1:17

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: webserver slow, misreported

2010-04-05 Thread AchipA
Can you elaborate how can cron cause database locking issues (apart
from such issues being caused by child processes)?

The content of the crontab is irrelevant, whether you only have
@reboot or more makes no difference. If there would be no check, you
could not change cron parameters without restarting.

On Apr 5, 7:46 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Since you have the problem with both cherrypy and rocket I suspect
 that this may be a database locking issues caused by cron. Even it you
 only have @reboot, still cron runs and every minute it check what
 needs to be done. I suggest try disable it completely and see what
 happens. In web2py.py replace

 gluon.widget.start(cron=True)

 with

 gluon.widget.start(cron=False)

 Let us know.

 Massimo

 On Apr 4, 11:47 pm, Michael Toomim too...@gmail.com wrote:

  I started using apache with mod_wsgi, and now it's fast!  So this
  indicates it's a problem that only occurs when using rocket or
  cherrypy, but again I'm only measuring it with firebug in my browser.

  I have 768MB of ram, ~500MB free.  I use cron for @reboot only.

  I only run it on a remote machine (on slicehost VPS).  I do not think
  it is network problems because it is fast in my web browser until I
  get hit by a bunch of users.  Of course I'd like to eliminate the
  network from my measurements, but for that I need webserver processing-
  time logs.

  On Apr 4, 9:08 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   Some more questions:

   how much ram?
   can you check memory usage? A memory leak may cause slowness.
   are you using cron? when cron starts it may spike memory usage.
   are you experience the slowness from localhost or from remote
   machines?

   On Apr 4, 6:46 pm, Michael Toomim too...@gmail.com wrote:

You are both right that I do not know where the slowness is coming
from.  My goal is to measure it so that I can narrow in on the
problem.  So far I know that it is external to web2py because it does
not show up in httpserver.log, so my reasoning is to look at rocket
which wraps the web2py part.

On Apr 4, 4:44 pm, Michael Toomim too...@gmail.com wrote:

 I see, thank you.  I want to measure the web server's response time
 when I deploy this on turk... Unfortunately the rocket log does not
 report time to serve a request.  Do you think it is easy to get that
 information from rocket?  Do you store the start and stop times for
 each request?  I see start times stored in connections, but I'm not
 sure that's the right object.

 On Mar 30, 6:09 am, Timothy Farrell tfarr...@swgen.com wrote:

  I don't think upgrading will help much since Cherrypy was also 
  slow.  
  However, doing so would help cover all your bases.

  If you want to use the http log from Rocket you can do this.  I'm
  assuming you invoke web2py.py from a bash script or just run it
  manually.  Paste the following code into the top of web2py.py

  import  logging
  import  logging.handlers
  log  =  logging.getLogger('Rocket.Requests')
  log.setLevel(logging.INFO)
  log.addHandler(logging.handlers.FileHandler('rocket.log')

  I, like Yarko, do think this has more to do with something else.  
  At one
  point web2py had a profiler built-in.  That could be a good tool for
  finding slow spots.

  -tim

  On 3/29/2010 7:59 PM, MichaelToomimwrote:

   Yes, this is on linux!  Do you recommend upgrading and trying 
   again?

   mturk doesn't affect anything, I am just serving webpages that 
   appear
   in iframes on the mturk website.  From our perspective, I'm 
   serving
   webpages.

   Do you have a method of logging how much time it takes to serve a 
   page
   with rocket?  Something that I can use instead of httpserver.log? 
    It
   seems important for me to measure real-world performance, which ab
   does not do.

   My server has 768MB ram, and the only thing it does is run this 
   web2py
   server.  I assumed ram was not full, but did not check.  I will 
   check
   next time.

   On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.com  wrote:

  snip/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Building a query from a form

2010-04-05 Thread Johann Spies
  query = 
query(db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower+
'%'))
TypeError: cannot concatenate 'str' and 'builtin_function_or_method' objects

:(

Regards
Johann

-- 
   Every good gift and every perfect gift is from above,
  and cometh down from the Father of lights, with whom
  is no variableness, neither shadow of turning.
 James 1:17

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: DAL query count patch

2010-04-05 Thread Thadeus Burgess
I would like to hear what others think as well.

I do not see how the DAL class knows, could know, might know, when a
query is being executed?

-Thadeus





On Mon, Apr 5, 2010 at 3:15 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 Since the new DAL is a class you can define them by subclassing DAL.
 What do you think? I am not convinced this is useful in general and
 needs to be in trunk. It seems a very specialized application but
 perhaps I am missing something. I'd like to hear what other people
 think about this.

 On Apr 5, 3:00 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Ah, well the real goal is for it to only be the number of statements
 pending in a given transaction.

 So db.commit() or db.rollback() should clear the results...

 The time counting I am doing in my models, and in response._caller...
 but this is not including time taken to set up the environment before
 web2py executes the models.

 -Thadeus

 On Mon, Apr 5, 2010 at 2:43 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  But this does not count the time, just the number of past requests (in
  thread? total?). Am I wrong?
  Moreover the count will be wrong if the web server restarts the
  process. no?

  Massimo

  On Apr 5, 2:33 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Novelty. Many websites you see will have at the bottom time took to
  process request, number of queries to database.

  -Thadeus

  On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   I do not see any reason against except that I do not see any reason in
   favor either. Why do you need it?

   Massimo

   On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
   Attached is a patch to allow the dal.py to keep track of query counts 
   and types.

   Usage

db.qry_count()

   {'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

   Massimo, do you accept?

   -Thadeus

    qry_count.hg.diff
   1KViewDownload

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: webserver slow, misreported

2010-04-05 Thread mdipierro
As far as I know cron cannot lock. Only child processes can lock. As
far as I know cron works fine. Yet I am trying to isolate the problem
cron is one of those few things that may differ when running with
apache or its own web server.

Massimo

On Apr 5, 3:20 pm, AchipA attila.cs...@gmail.com wrote:
 Can you elaborate how can cron cause database locking issues (apart
 from such issues being caused by child processes)?

 The content of the crontab is irrelevant, whether you only have
 @reboot or more makes no difference. If there would be no check, you
 could not change cron parameters without restarting.

 On Apr 5, 7:46 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Since you have the problem with both cherrypy and rocket I suspect
  that this may be a database locking issues caused by cron. Even it you
  only have @reboot, still cron runs and every minute it check what
  needs to be done. I suggest try disable it completely and see what
  happens. In web2py.py replace

  gluon.widget.start(cron=True)

  with

  gluon.widget.start(cron=False)

  Let us know.

  Massimo

  On Apr 4, 11:47 pm, Michael Toomim too...@gmail.com wrote:

   I started using apache with mod_wsgi, and now it's fast!  So this
   indicates it's a problem that only occurs when using rocket or
   cherrypy, but again I'm only measuring it with firebug in my browser.

   I have 768MB of ram, ~500MB free.  I use cron for @reboot only.

   I only run it on a remote machine (on slicehost VPS).  I do not think
   it is network problems because it is fast in my web browser until I
   get hit by a bunch of users.  Of course I'd like to eliminate the
   network from my measurements, but for that I need webserver processing-
   time logs.

   On Apr 4, 9:08 pm, mdipierro mdipie...@cs.depaul.edu wrote:

Some more questions:

how much ram?
can you check memory usage? A memory leak may cause slowness.
are you using cron? when cron starts it may spike memory usage.
are you experience the slowness from localhost or from remote
machines?

On Apr 4, 6:46 pm, Michael Toomim too...@gmail.com wrote:

 You are both right that I do not know where the slowness is coming
 from.  My goal is to measure it so that I can narrow in on the
 problem.  So far I know that it is external to web2py because it does
 not show up in httpserver.log, so my reasoning is to look at rocket
 which wraps the web2py part.

 On Apr 4, 4:44 pm, Michael Toomim too...@gmail.com wrote:

  I see, thank you.  I want to measure the web server's response time
  when I deploy this on turk... Unfortunately the rocket log does not
  report time to serve a request.  Do you think it is easy to get that
  information from rocket?  Do you store the start and stop times for
  each request?  I see start times stored in connections, but I'm 
  not
  sure that's the right object.

  On Mar 30, 6:09 am, Timothy Farrell tfarr...@swgen.com wrote:

   I don't think upgrading will help much since Cherrypy was also 
   slow.  
   However, doing so would help cover all your bases.

   If you want to use the http log from Rocket you can do this.  I'm
   assuming you invoke web2py.py from a bash script or just run it
   manually.  Paste the following code into the top of web2py.py

   import  logging
   import  logging.handlers
   log  =  logging.getLogger('Rocket.Requests')
   log.setLevel(logging.INFO)
   log.addHandler(logging.handlers.FileHandler('rocket.log')

   I, like Yarko, do think this has more to do with something else.  
   At one
   point web2py had a profiler built-in.  That could be a good tool 
   for
   finding slow spots.

   -tim

   On 3/29/2010 7:59 PM, MichaelToomimwrote:

Yes, this is on linux!  Do you recommend upgrading and trying 
again?

mturk doesn't affect anything, I am just serving webpages that 
appear
in iframes on the mturk website.  From our perspective, I'm 
serving
webpages.

Do you have a method of logging how much time it takes to serve 
a page
with rocket?  Something that I can use instead of 
httpserver.log?  It
seems important for me to measure real-world performance, which 
ab
does not do.

My server has 768MB ram, and the only thing it does is run this 
web2py
server.  I assumed ram was not full, but did not check.  I will 
check
next time.

On Mar 29, 12:10 pm, Timothy Farrelltfarr...@swgen.com  wrote:

   snip/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Building a query from a form

2010-04-05 Thread mdipierro
grrr

  query =
query(db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower()
+'%'))

or (equivalent)

  query =
query(db.sarua[request.vars.refine.lower()].like('%'+request.vars.value
+'%'))


On Apr 5, 3:24 pm, Johann Spies johann.sp...@gmail.com wrote:
   query = 
 query(db.sarua[request.vars.refine.lower()].like('%'+request.vars.value.lower+
 '%'))
 TypeError: cannot concatenate 'str' and 'builtin_function_or_method' objects

 :(

 Regards
 Johann

 --
        Every good gift and every perfect gift is from above,
       and cometh down from the Father of lights, with whom
       is no variableness, neither shadow of turning.
                              James 1:17

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: DAL query count patch

2010-04-05 Thread mdipierro
this is a good point. So the question is now: should we just count
calls or, for example, store them in a list the order they are
executed (per transaction), or perhaps just store the type of queries
in a list? What does the app need to know about the queries being
executed?

On Apr 5, 3:27 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 I would like to hear what others think as well.

 I do not see how the DAL class knows, could know, might know, when a
 query is being executed?

 -Thadeus

 On Mon, Apr 5, 2010 at 3:15 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  Since the new DAL is a class you can define them by subclassing DAL.
  What do you think? I am not convinced this is useful in general and
  needs to be in trunk. It seems a very specialized application but
  perhaps I am missing something. I'd like to hear what other people
  think about this.

  On Apr 5, 3:00 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Ah, well the real goal is for it to only be the number of statements
  pending in a given transaction.

  So db.commit() or db.rollback() should clear the results...

  The time counting I am doing in my models, and in response._caller...
  but this is not including time taken to set up the environment before
  web2py executes the models.

  -Thadeus

  On Mon, Apr 5, 2010 at 2:43 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   But this does not count the time, just the number of past requests (in
   thread? total?). Am I wrong?
   Moreover the count will be wrong if the web server restarts the
   process. no?

   Massimo

   On Apr 5, 2:33 pm, Thadeus Burgess thade...@thadeusb.com wrote:
   Novelty. Many websites you see will have at the bottom time took to
   process request, number of queries to database.

   -Thadeus

   On Mon, Apr 5, 2010 at 2:24 PM, mdipierro mdipie...@cs.depaul.edu 
   wrote:
I do not see any reason against except that I do not see any reason in
favor either. Why do you need it?

Massimo

On Apr 5, 2:16 pm, Thadeus Burgess thade...@thadeusb.com wrote:
Attached is a patch to allow the dal.py to keep track of query 
counts and types.

Usage

 db.qry_count()

{'SELECT': 5, 'INSERT': 2, 'DELETE': 1}

Massimo, do you accept?

-Thadeus

 qry_count.hg.diff
1KViewDownload

--
You received this message because you are subscribed to the Google 
Groups web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group 
athttp://groups.google.com/group/web2py?hl=en.

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread Thadeus Burgess
Traceback (most recent call last):
  File /home/tburgess/Applications/web2py/gluon/restricted.py, line
173, in restricted
exec ccode in environment
  File 
/home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
line 278, in module
  File /home/tburgess/Applications/web2py/gluon/globals.py, line 96,
in lambda
self._caller = lambda f: f()
  File 
/home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
line 76, in duplicates
orderby=db.potentials.A
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
return self._db._adapter.select(self._query,*fields,**attributes)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in select
return self.parse(rows,self._colnames)
  File /home/tburgess/Applications/web2py/gluon/sql.py, line 706, in parse
(rid._table, rid._record) = (db[referee], None)
NameError: global name 'db' is not defined

-Thadeus





On Mon, Apr 5, 2010 at 3:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 try now

 On Apr 5, 2:30 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Now I get this for reference field

 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
 line 84, in module
     {{=db.table[column].represent(d.B[column])}}
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
 in __getattr__
     self.__allocate()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
 in __allocate
     self._record = self._table[int(self)]
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
 in __getitem__
     return self._db(self.id == key).select().first()
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in 
 select
     return self._db._adapter.select(self._query,*fields,**attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in select
     return self.parse(rows,self._colnames)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 707, in parse
     colset[fieldname] = rid = Reference(value)
 TypeError: int() argument must be a string or a number, not 'NoneType'

 -Thadeus

 On Mon, Apr 5, 2010 at 2:20 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  I fixed the former. I did not fix the latter. It is a known problem
  with the new dal and one of the few things that needs to be ironed
  out: it does not like select('fieldname') only
  select(db.table['fieldname']). Not difficult to fix anyway.

  On Apr 5, 2:13 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  I get this traceback when attempting to access a reference field.

  rows = db().select(db.table.ALL)
  for r in rows:
    r.id
    r.title
    r.reference_field.name
    r.reference_field.description

  Traceback (most recent call last):
    File /home/tburgess/Applications/web2py/gluon/restricted.py, line
  173, in restricted
      exec ccode in environment
    File 
  /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
  line 84, in module
      {{=db.field[column].represent(d.B[column])}}
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
  in __getattr__
      self.__allocate()
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
  in __allocate
      self._record = self._table[int(self)]
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
  in __getitem__
      return self._db(self.id == key).select()._first()
  AttributeError: 'Rows' object has no attribute '_first'

  I get this traceback from form = SQLFORM(db.mytable)

  Traceback (most recent call last):
    File /home/tburgess/Applications/web2py/gluon/restricted.py, line
  173, in restricted
      exec ccode in environment
    File 
  /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
  line 278, in module
    File 
  /home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
  line 28, in compress_response
      d = d()
    File 
  /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
  line 15, in index
      return dict(hi='hi', form=SQLFORM(db.mytable))
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  688, in __init__
      inp = self.widgets.multiple.widget(field, default)
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  211, in widget
      return OptionsWidget.widget(field, value, **attributes)
    File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
  187, in widget
      options = requires[0].options()
    File /home/tburgess/Applications/web2py/gluon/validators.py, line
  2227, in _options
      options = self.other.options()
    File /home/tburgess/Applications/web2py/gluon/validators.py, line
  385, in options
      self.build_set()
    File 

[web2py] new session

2010-04-05 Thread Jonathan Lundell
I'd have thought that if I log out and then log back in I'd get a new session. 
But apparently not. Is there a reason to do it one way vs the other?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] there is a git hg plugin

2010-04-05 Thread dspiteself
Using your mercurial client you could setup 2 remotes. One remote be
github and one be your mercurial repository.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] recaptcha in LOAD not working

2010-04-05 Thread selecta
I tried to use Recaptcha in a LOAD div but I does not work

The problem is that the page stats reloading when it gets to the div
loaded with LOAD where the recaptcha javascripts are in and gets stuck
on reloading it

controller:
...
form = SQLFORM.factory(Field('tag_name'))
captcha = None
if not auth.user:
captcha = Recaptcha(request,'xxx','xxx')
form[0].append(captcha)
if request.vars.tag_name:
   
   if form.accepts(request.vars, session):
...
return dict(form=form, captcha = captcha)

view tag.html:
{{=form.custom.begin}}
...
{{=captcha}}
{{=form.custom.end}}
{{pass}}

view default.html:
LOAD('default','tag',args=(table_name,record_id),ajax=True) - does
not work

but with
LOAD('default','tag',args=(table_name,record_id))
at least the page loads

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] recaptcha in LOAD not working

2010-04-05 Thread Thadeus Burgess
It is because recaptcha uses ajax to communicate, and when using LOAD
web2py traps all ajax calls, so the recaptcha requests are not making
it to the server.

-Thadeus





On Mon, Apr 5, 2010 at 5:05 PM, selecta gr...@delarue-berlin.de wrote:
 I tried to use Recaptcha in a LOAD div but I does not work

 The problem is that the page stats reloading when it gets to the div
 loaded with LOAD where the recaptcha javascripts are in and gets stuck
 on reloading it

 controller:
 ...
 form = SQLFORM.factory(Field('tag_name'))
 captcha = None
 if not auth.user:
    captcha = Recaptcha(request,'xxx','xxx')
    form[0].append(captcha)
 if request.vars.tag_name:
   
   if form.accepts(request.vars, session):
        ...
 return dict(form=form, captcha = captcha)

 view tag.html:
 {{=form.custom.begin}}
 ...
 {{=captcha}}
 {{=form.custom.end}}
 {{pass}}

 view default.html:
 LOAD('default','tag',args=(table_name,record_id),ajax=True) - does
 not work

 but with
 LOAD('default','tag',args=(table_name,record_id))
 at least the page loads

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: new SQLFORM

2010-04-05 Thread Russell
Just a thought...

It occurs to me that, as SQLFORM is a set of fields, wouldn't it be
better if SQLFORMs had their own widget class?

It would allow for customization and, potentially you could then
combine SQLTABLE with SQLFORM into one tidy concept.  By this I mean
that SQLTABLE could deliver a set of SQLFORM objects (using a default
read-only widget).

Taking that the next step, for example, you could submit a read-only
row from an SQLTABLE via ajax, toggle the widget to return an edit
form...giving you automatic edit-in-place for the record set.


On Apr 3, 12:31 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 becase form=SQLFORM() is already a server side representation of the
 DOM. It is not an abstract object.
 after form=SQLFORM() you are supposed to be able to do
 form.element(name)[attribute](value) for example and other DOM
 manipulations.

 If form were a more abstract object and if its DOM representation were
 to be decided later (form.as_div()) you would not be able to
 manipulate the DOM. This would 1) break backward compatibility; 2)
 break everything that is good about about it.

 Massimo

 On Apr 1, 3:24 pm, Thadeus Burgess thade...@thadeusb.com wrote:

  So why formstyle instead of

  form.as_div()
  or
  form.as_ul()

  ??

  -Thadeus

  On Wed, Mar 24, 2010 at 8:18 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   Thank you!

   On Mar 24, 8:21 pm, Jose jjac...@gmail.com wrote:
   I sent a patch to Massimo

   --
   You received this message because you are subscribed to the Google Groups 
   web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: recaptcha in LOAD not working

2010-04-05 Thread selecta
tnx Thadeus

just found http://recaptcha.net/apidocs/captcha/client.html
reCAPTCHA AJAX API

will read into it 2morrow
would be nice if recaptcha works with web2pys ajax things by default

On Apr 6, 12:10 am, Thadeus Burgess thade...@thadeusb.com wrote:
 It is because recaptcha uses ajax to communicate, and when using LOAD
 web2py traps all ajax calls, so the recaptcha requests are not making
 it to the server.

 -Thadeus



 On Mon, Apr 5, 2010 at 5:05 PM, selecta gr...@delarue-berlin.de wrote:
  I tried to use Recaptcha in a LOAD div but I does not work

  The problem is that the page stats reloading when it gets to the div
  loaded with LOAD where the recaptcha javascripts are in and gets stuck
  on reloading it

  controller:
  ...
  form = SQLFORM.factory(Field('tag_name'))
  captcha = None
  if not auth.user:
     captcha = Recaptcha(request,'xxx','xxx')
     form[0].append(captcha)
  if request.vars.tag_name:
    
    if form.accepts(request.vars, session):
         ...
  return dict(form=form, captcha = captcha)

  view tag.html:
  {{=form.custom.begin}}
  ...
  {{=captcha}}
  {{=form.custom.end}}
  {{pass}}

  view default.html:
  LOAD('default','tag',args=(table_name,record_id),ajax=True) - does
  not work

  but with
  LOAD('default','tag',args=(table_name,record_id))
  at least the page loads

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: bug in dal.py _first() and SQLFORM ._tablename

2010-04-05 Thread mdipierro
uploading fix. please check it. Thanks for testing this.

On Apr 5, 3:59 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Traceback (most recent call last):
   File /home/tburgess/Applications/web2py/gluon/restricted.py, line
 173, in restricted
     exec ccode in environment
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 278, in module
   File /home/tburgess/Applications/web2py/gluon/globals.py, line 96,
 in lambda
     self._caller = lambda f: f()
   File 
 /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
 line 76, in duplicates
     orderby=db.potentials.A
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in select
     return self._db._adapter.select(self._query,*fields,**attributes)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in select
     return self.parse(rows,self._colnames)
   File /home/tburgess/Applications/web2py/gluon/sql.py, line 706, in parse
     (rid._table, rid._record) = (db[referee], None)
 NameError: global name 'db' is not defined

 -Thadeus

 On Mon, Apr 5, 2010 at 3:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  try now

  On Apr 5, 2:30 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Now I get this for reference field

  Traceback (most recent call last):
    File /home/tburgess/Applications/web2py/gluon/restricted.py, line
  173, in restricted
      exec ccode in environment
    File 
  /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
  line 84, in module
      {{=db.table[column].represent(d.B[column])}}
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
  in __getattr__
      self.__allocate()
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
  in __allocate
      self._record = self._table[int(self)]
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
  in __getitem__
      return self._db(self.id == key).select().first()
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 3258, in 
  select
      return self._db._adapter.select(self._query,*fields,**attributes)
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 512, in 
  select
      return self.parse(rows,self._colnames)
    File /home/tburgess/Applications/web2py/gluon/sql.py, line 707, in 
  parse
      colset[fieldname] = rid = Reference(value)
  TypeError: int() argument must be a string or a number, not 'NoneType'

  -Thadeus

  On Mon, Apr 5, 2010 at 2:20 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   I fixed the former. I did not fix the latter. It is a known problem
   with the new dal and one of the few things that needs to be ironed
   out: it does not like select('fieldname') only
   select(db.table['fieldname']). Not difficult to fix anyway.

   On Apr 5, 2:13 pm, Thadeus Burgess thade...@thadeusb.com wrote:
   I get this traceback when attempting to access a reference field.

   rows = db().select(db.table.ALL)
   for r in rows:
     r.id
     r.title
     r.reference_field.name
     r.reference_field.description

   Traceback (most recent call last):
     File /home/tburgess/Applications/web2py/gluon/restricted.py, line
   173, in restricted
       exec ccode in environment
     File 
   /home/tburgess/Applications/web2py/applications/pms/views/default/index.html,
   line 84, in module
       {{=db.field[column].represent(d.B[column])}}
     File /home/tburgess/Applications/web2py/gluon/sql.py, line 2210,
   in __getattr__
       self.__allocate()
     File /home/tburgess/Applications/web2py/gluon/sql.py, line 2203,
   in __allocate
       self._record = self._table[int(self)]
     File /home/tburgess/Applications/web2py/gluon/sql.py, line 2384,
   in __getitem__
       return self._db(self.id == key).select()._first()
   AttributeError: 'Rows' object has no attribute '_first'

   I get this traceback from form = SQLFORM(db.mytable)

   Traceback (most recent call last):
     File /home/tburgess/Applications/web2py/gluon/restricted.py, line
   173, in restricted
       exec ccode in environment
     File 
   /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
   line 278, in module
     File 
   /home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py,
   line 28, in compress_response
       d = d()
     File 
   /home/tburgess/Applications/web2py/applications/pms/controllers/default.py,
   line 15, in index
       return dict(hi='hi', form=SQLFORM(db.mytable))
     File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
   688, in __init__
       inp = self.widgets.multiple.widget(field, default)
     File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
   211, in widget
       return OptionsWidget.widget(field, value, **attributes)
     File /home/tburgess/Applications/web2py/gluon/sqlhtml.py, line
   187, in widget
       options = requires[0].options()
     File /home/tburgess/Applications/web2py/gluon/validators.py, 

[web2py] Re: new session

2010-04-05 Thread mdipierro
Yes. To recycle session and to keep track of what visitors do, even
when they are not logged in. You can change it. Try this:

auth.settings.login_accept =lambda form:
(session.clear(),session.auth=auth)

On Apr 5, 4:34 pm, Jonathan Lundell jlund...@pobox.com wrote:
 I'd have thought that if I log out and then log back in I'd get a new 
 session. But apparently not. Is there a reason to do it one way vs the other?

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: there is a git hg plugin

2010-04-05 Thread mdipierro
hmmm. I do not object but I do not want to do any extra work. I do not
use a client except the shell one. If you send me a script to do it, I
will use it.

On Apr 5, 5:04 pm, dspiteself dspites...@gmail.com wrote:
 Using your mercurial client you could setup 2 remotes. One remote be
 github and one be your mercurial repository.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: new SQLFORM

2010-04-05 Thread mdipierro
interesting I will think about it. Should be possible.

On Apr 5, 5:23 pm, Russell russell.mcmur...@gmail.com wrote:
 Just a thought...

 It occurs to me that, as SQLFORM is a set of fields, wouldn't it be
 better if SQLFORMs had their own widget class?

 It would allow for customization and, potentially you could then
 combine SQLTABLE with SQLFORM into one tidy concept.  By this I mean
 that SQLTABLE could deliver a set of SQLFORM objects (using a default
 read-only widget).

 Taking that the next step, for example, you could submit a read-only
 row from an SQLTABLE via ajax, toggle the widget to return an edit
 form...giving you automatic edit-in-place for the record set.

 On Apr 3, 12:31 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  becase form=SQLFORM() is already a server side representation of the
  DOM. It is not an abstract object.
  after form=SQLFORM() you are supposed to be able to do
  form.element(name)[attribute](value) for example and other DOM
  manipulations.

  If form were a more abstract object and if its DOM representation were
  to be decided later (form.as_div()) you would not be able to
  manipulate the DOM. This would 1) break backward compatibility; 2)
  break everything that is good about about it.

  Massimo

  On Apr 1, 3:24 pm, Thadeus Burgess thade...@thadeusb.com wrote:

   So why formstyle instead of

   form.as_div()
   or
   form.as_ul()

   ??

   -Thadeus

   On Wed, Mar 24, 2010 at 8:18 PM, mdipierro mdipie...@cs.depaul.edu 
   wrote:
Thank you!

On Mar 24, 8:21 pm, Jose jjac...@gmail.com wrote:
I sent a patch to Massimo

--
You received this message because you are subscribed to the Google 
Groups web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group 
athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Unicode characters problem (Dreamhost installation)

2010-04-05 Thread Alexei Vinidiktov
2010/4/6 Yarko Tymciurak resultsinsoftw...@gmail.com:
 On Apr 5, 11:55 am, Yarko Tymciurak resultsinsoftw...@gmail.com
 wrote:
 On Apr 5, 3:23 am, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:

  I think I got it to work! I deleted the domain from the control panel
  altogether and then readded it, and web2py 1.76.5 started working.
  Problem solved for the time being. I don't know what what the exact
  cause though.

 I'm guessing here, as you did not explicitly say - maybe you did not
 stop / restart the server (i.e. Apache...).  Not sure how Dreamhost
 has it configured, but removing the app and re-installing it would
 have that effect also.

 The general thing to remember:

 Your app is read on a per-request basis:   first models, then the
 controller, and the function call;
 If you change any core modules, you need to restart the server
 (otherwise, just reload the page!).
 Getting used to developing by just updating the code, I sometimes
 forget when a restart needs to happen.
 I'm not sure, but in the past I think adding a module (?) also needed
 a server restart (not sure exactly why; correct me if I'm wrong).

 - Yarko

Thanks, Yarko!

I didn't realize I could reboot my VPS at Dreamhost, but I've now
found that there is such functionality in the control panel.

[...]


-- 
Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: recaptcha in LOAD not working

2010-04-05 Thread Thadeus Burgess
Maybe the web2py_ajax_trap can have a write-through put in so it will
not intercept communications for recaptcha?

-Thadeus





On Mon, Apr 5, 2010 at 5:28 PM, selecta gr...@delarue-berlin.de wrote:
 tnx Thadeus

 just found http://recaptcha.net/apidocs/captcha/client.html
 reCAPTCHA AJAX API

 will read into it 2morrow
 would be nice if recaptcha works with web2pys ajax things by default

 On Apr 6, 12:10 am, Thadeus Burgess thade...@thadeusb.com wrote:
 It is because recaptcha uses ajax to communicate, and when using LOAD
 web2py traps all ajax calls, so the recaptcha requests are not making
 it to the server.

 -Thadeus



 On Mon, Apr 5, 2010 at 5:05 PM, selecta gr...@delarue-berlin.de wrote:
  I tried to use Recaptcha in a LOAD div but I does not work

  The problem is that the page stats reloading when it gets to the div
  loaded with LOAD where the recaptcha javascripts are in and gets stuck
  on reloading it

  controller:
  ...
  form = SQLFORM.factory(Field('tag_name'))
  captcha = None
  if not auth.user:
     captcha = Recaptcha(request,'xxx','xxx')
     form[0].append(captcha)
  if request.vars.tag_name:
    
    if form.accepts(request.vars, session):
         ...
  return dict(form=form, captcha = captcha)

  view tag.html:
  {{=form.custom.begin}}
  ...
  {{=captcha}}
  {{=form.custom.end}}
  {{pass}}

  view default.html:
  LOAD('default','tag',args=(table_name,record_id),ajax=True) - does
  not work

  but with
  LOAD('default','tag',args=(table_name,record_id))
  at least the page loads

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Rows don't serialize well if unicode in _extra

2010-04-05 Thread fgpy
More details here:

I have 2 tables: shop (2 fields) and enquete (18 fields).

I use an inner join like the one bellow.
'shop.shop_code' is what I call a fully qualified name
'hht_q_1' is what I call a short name. All those names end to be in
_extra and as they contain some unicode, the __str__ method of Rows
fails.

Putting 'enquete' in front of all the names makes the code less
readable, therefore using short names linking to the colums returned
by the inner join.

rows = db(db.enquete.shop_code==db.shop.shop_code).select(
'shop.shop_code', 'shop.shop_name',
'hht_q_1', 'hht_q_2', 'hht_q_3', 'hht_q_4', 'hht_q_5',
'hht_q_6', 'hht_q_7', 'hht_q_8', 'hht_q_9',
'pc_q_1', 'pc_q_2', 'pc_q_3', 'pc_q_4', 'pc_q_5',
'pc_q_6',  'pc_q_7',
)

Please advise.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Rows don't serialize well if unicode in _extra

2010-04-05 Thread Thadeus Burgess
When dealing with 1 table, names are short names

When dealing with multiple tables, all names are fully qualified.

-Thadeus





On Mon, Apr 5, 2010 at 8:22 PM, fgpy franck...@gmail.com wrote:
 More details here:

 I have 2 tables: shop (2 fields) and enquete (18 fields).

 I use an inner join like the one bellow.
 'shop.shop_code' is what I call a fully qualified name
 'hht_q_1' is what I call a short name. All those names end to be in
 _extra and as they contain some unicode, the __str__ method of Rows
 fails.

 Putting 'enquete' in front of all the names makes the code less
 readable, therefore using short names linking to the colums returned
 by the inner join.

    rows = db(db.enquete.shop_code==db.shop.shop_code).select(
                'shop.shop_code', 'shop.shop_name',
                'hht_q_1', 'hht_q_2', 'hht_q_3', 'hht_q_4', 'hht_q_5',
                'hht_q_6', 'hht_q_7', 'hht_q_8', 'hht_q_9',
                'pc_q_1', 'pc_q_2', 'pc_q_3', 'pc_q_4', 'pc_q_5',
                'pc_q_6',  'pc_q_7',
                )

 Please advise.

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: recaptcha in LOAD not working

2010-04-05 Thread mdipierro
I am not sure that is the problem. ajax_trap does not trap ajax
requests but form submissions. I need to give this a try.

Massimo



On Apr 5, 8:15 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Maybe the web2py_ajax_trap can have a write-through put in so it will
 not intercept communications for recaptcha?

 -Thadeus

 On Mon, Apr 5, 2010 at 5:28 PM, selecta gr...@delarue-berlin.de wrote:
  tnx Thadeus

  just foundhttp://recaptcha.net/apidocs/captcha/client.html
  reCAPTCHA AJAX API

  will read into it 2morrow
  would be nice if recaptcha works with web2pys ajax things by default

  On Apr 6, 12:10 am, Thadeus Burgess thade...@thadeusb.com wrote:
  It is because recaptcha uses ajax to communicate, and when using LOAD
  web2py traps all ajax calls, so the recaptcha requests are not making
  it to the server.

  -Thadeus

  On Mon, Apr 5, 2010 at 5:05 PM, selecta gr...@delarue-berlin.de wrote:
   I tried to use Recaptcha in a LOAD div but I does not work

   The problem is that the page stats reloading when it gets to the div
   loaded with LOAD where the recaptcha javascripts are in and gets stuck
   on reloading it

   controller:
   ...
   form = SQLFORM.factory(Field('tag_name'))
   captcha = None
   if not auth.user:
      captcha = Recaptcha(request,'xxx','xxx')
      form[0].append(captcha)
   if request.vars.tag_name:
     
     if form.accepts(request.vars, session):
          ...
   return dict(form=form, captcha = captcha)

   view tag.html:
   {{=form.custom.begin}}
   ...
   {{=captcha}}
   {{=form.custom.end}}
   {{pass}}

   view default.html:
   LOAD('default','tag',args=(table_name,record_id),ajax=True) - does
   not work

   but with
   LOAD('default','tag',args=(table_name,record_id))
   at least the page loads

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Basic authentication question

2010-04-05 Thread Alexei Vinidiktov
Hello,

I'm trying to make a desktop client written in Python 2.5 (on Windows)
communicate with a web2py 1.76.5 based app using services. It works
fine with services that don't require authentication, but I was
wondering if I could make it authenticate the user with Basic
authentication.

I've read in the Python docs that xmlrpclib supports Basic authentication:


Both the HTTP and HTTPS transports support the URL syntax extension
for HTTP Basic Authentication: http://user:p...@host:port/path. The
user:pass portion will be base64-encoded as an HTTP `Authorization'
header, and sent to the remote server as part of the connection
process when invoking an XML-RPC method.


In my modified Welcome web2py app I've added the setting
auth.settings.allow_basic_authentication = True in
welcome/models/db.py

I've decorated the private_call action like so:

@auth.requires_login()
def private_call():
return private_service()

And I've added a test action getstring:

@private_service.xmlrpc
def getstring():
if auth.is_logged_in():
return logged in!
else:
return not logged in!

In my desktop app I'm calling the service like this:

self.server = 
xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
print self.server.getstring()

and I'm getting this traceback:

Traceback (most recent call last):
  File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 137
, in OnButton4Button
print self.server3.getstring()
  File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
return self.__send(self.__name, args)
  File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
verbose=self.__verbose
  File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 185
, in request
headers
xmlrpclib.ProtocolError: ProtocolError for myem...@gmail.com:mypassword@
127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

I'm obviously doing something wrong. Could you point me in the right direction?

Thanks.

-- 
Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Vim snippets for web2py

2010-04-05 Thread DenesL

Leonardo Vidarte, one of the users in the spanish language group, has
created some snippets [0] for Vim, for the snipMate plugin [1] to be
exact, with all the API of web2py 1.76.3, including some basic
snippets for template creation.

Hopefully they will be useful to somebody. Additions are welcome.

[0] http://github.com/lvidarte/web2py-snippets
[1] http://www.vim.org/scripts/script.php?script_id=2540


-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Basic authentication question

2010-04-05 Thread mdipierro
you need in db.py

auth.settings.allow_basic_login = True

it defaults to False


On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
wrote:
 Hello,

 I'm trying to make a desktop client written in Python 2.5 (on Windows)
 communicate with a web2py 1.76.5 based app using services. It works
 fine with services that don't require authentication, but I was
 wondering if I could make it authenticate the user with Basic
 authentication.

 I've read in the Python docs that xmlrpclib supports Basic authentication:

 
 Both the HTTP and HTTPS transports support the URL syntax extension
 for HTTP Basic Authentication:http://user:p...@host:port/path. The
 user:pass portion will be base64-encoded as an HTTP `Authorization'
 header, and sent to the remote server as part of the connection
 process when invoking an XML-RPC method.
 

 In my modified Welcome web2py app I've added the setting
 auth.settings.allow_basic_authentication = True in
 welcome/models/db.py

 I've decorated the private_call action like so:

 @auth.requires_login()
 def private_call():
     return private_service()

 And I've added a test action getstring:

 @private_service.xmlrpc
 def getstring():
     if auth.is_logged_in():
         return logged in!
     else:
         return not logged in!

 In my desktop app I'm calling the service like this:

 self.server = 
 xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
 print self.server.getstring()

 and I'm getting this traceback:

 Traceback (most recent call last):
   File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
 137
 , in OnButton4Button
     print self.server3.getstring()
   File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
     return self.__send(self.__name, args)
   File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
     verbose=self.__verbose
   File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
 185
 , in request
     headers
 xmlrpclib.ProtocolError: ProtocolError for myem...@gmail.com:mypassword@
 127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

 I'm obviously doing something wrong. Could you point me in the right 
 direction?

 Thanks.

 --
 Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Basic authentication question

2010-04-05 Thread Alexei Vinidiktov
Thanks a lot, Massimo! It worked!

On Tue, Apr 6, 2010 at 10:36 AM, mdipierro mdipie...@cs.depaul.edu wrote:
 you need in db.py

 auth.settings.allow_basic_login = True

 it defaults to False


 On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:
 Hello,

 I'm trying to make a desktop client written in Python 2.5 (on Windows)
 communicate with a web2py 1.76.5 based app using services. It works
 fine with services that don't require authentication, but I was
 wondering if I could make it authenticate the user with Basic
 authentication.

 I've read in the Python docs that xmlrpclib supports Basic authentication:

 
 Both the HTTP and HTTPS transports support the URL syntax extension
 for HTTP Basic Authentication:http://user:p...@host:port/path. The
 user:pass portion will be base64-encoded as an HTTP `Authorization'
 header, and sent to the remote server as part of the connection
 process when invoking an XML-RPC method.
 

 In my modified Welcome web2py app I've added the setting
 auth.settings.allow_basic_authentication = True in
 welcome/models/db.py

 I've decorated the private_call action like so:

 @auth.requires_login()
 def private_call():
     return private_service()

 And I've added a test action getstring:

 @private_service.xmlrpc
 def getstring():
     if auth.is_logged_in():
         return logged in!
     else:
         return not logged in!

 In my desktop app I'm calling the service like this:

 self.server = 
 xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
 print self.server.getstring()

 and I'm getting this traceback:

 Traceback (most recent call last):
   File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
 137
 , in OnButton4Button
     print self.server3.getstring()
   File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
     return self.__send(self.__name, args)
   File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
     verbose=self.__verbose
   File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
 185
 , in request
     headers
 xmlrpclib.ProtocolError: ProtocolError for myem...@gmail.com:mypassword@
 127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

 I'm obviously doing something wrong. Could you point me in the right 
 direction?

 Thanks.

 --
 Alexei Vinidiktov

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.





-- 
Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Basic authentication question

2010-04-05 Thread mdipierro
thank you for trying it. It is one of those features that not many
people are using but should be solid.

Massimo

On Apr 5, 9:44 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
wrote:
 Thanks a lot, Massimo! It worked!



 On Tue, Apr 6, 2010 at 10:36 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  you need in db.py

  auth.settings.allow_basic_login = True

  it defaults to False

  On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  Hello,

  I'm trying to make a desktop client written in Python 2.5 (on Windows)
  communicate with a web2py 1.76.5 based app using services. It works
  fine with services that don't require authentication, but I was
  wondering if I could make it authenticate the user with Basic
  authentication.

  I've read in the Python docs that xmlrpclib supports Basic authentication:

  
  Both the HTTP and HTTPS transports support the URL syntax extension
  for HTTP Basic Authentication:http://user:p...@host:port/path. The
  user:pass portion will be base64-encoded as an HTTP `Authorization'
  header, and sent to the remote server as part of the connection
  process when invoking an XML-RPC method.
  

  In my modified Welcome web2py app I've added the setting
  auth.settings.allow_basic_authentication = True in
  welcome/models/db.py

  I've decorated the private_call action like so:

  @auth.requires_login()
  def private_call():
      return private_service()

  And I've added a test action getstring:

  @private_service.xmlrpc
  def getstring():
      if auth.is_logged_in():
          return logged in!
      else:
          return not logged in!

  In my desktop app I'm calling the service like this:

  self.server = 
  xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
  print self.server.getstring()

  and I'm getting this traceback:

  Traceback (most recent call last):
    File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
  line 137
  , in OnButton4Button
      print self.server3.getstring()
    File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
      return self.__send(self.__name, args)
    File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
      verbose=self.__verbose
    File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
  line 185
  , in request
      headers
  xmlrpclib.ProtocolError: ProtocolError for myem...@gmail.com:mypassword@
  127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

  I'm obviously doing something wrong. Could you point me in the right 
  direction?

  Thanks.

  --
  Alexei Vinidiktov

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] GAE native types.

2010-04-05 Thread Matt
Hi there,

In the features not in the book section it lists since version
1.74.5

* support for all native types on GAE (e.g. StringListProperty)

Are there any examples demonstrating the use of these available?

Thanks,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: GAE native types.

2010-04-05 Thread mdipierro
For example:

from gluon.contrib.gql import gae

db.define_table('tablename',,Field('name',gae.StringListProperty),)

You can use any native type but forms may not work because you have to
make sure you insert the corresponding type (in the example a list of
strings). Sorry there is not much documentation about this.

Massimo

On Apr 5, 10:34 pm, Matt mjwat...@gmail.com wrote:
 Hi there,

 In the features not in the book section it lists since version
 1.74.5

 * support for all native types on GAE (e.g. StringListProperty)

 Are there any examples demonstrating the use of these available?

 Thanks,
 Matt

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Basic authentication question

2010-04-05 Thread Alexei Vinidiktov
I just tried it with this json-rpc lib (
http://www.desfrenes.com/python-json-rpc ) , and it also seems to work
fine.

I have many more open questions about authentication and
authorization. I'm exploring different approaches for my application:
cookie-based, basic, token authentication, and different protocols
also (xmlrpc, jsonrpc, json).

Another question: If the authentication fails, my client application
receives error 303 See Other.

It is my understanding that this error means that the user visiting
the website is redirected to a different page (apparently the page
defined in auth.settings.login_url).

Can I customize the error message such that the client application can
understand that the error results from the failed login attempt?

On Tue, Apr 6, 2010 at 10:55 AM, mdipierro mdipie...@cs.depaul.edu wrote:
 thank you for trying it. It is one of those features that not many
 people are using but should be solid.

 Massimo

 On Apr 5, 9:44 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:
 Thanks a lot, Massimo! It worked!



 On Tue, Apr 6, 2010 at 10:36 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  you need in db.py

  auth.settings.allow_basic_login = True

  it defaults to False

  On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  Hello,

  I'm trying to make a desktop client written in Python 2.5 (on Windows)
  communicate with a web2py 1.76.5 based app using services. It works
  fine with services that don't require authentication, but I was
  wondering if I could make it authenticate the user with Basic
  authentication.

  I've read in the Python docs that xmlrpclib supports Basic authentication:

  
  Both the HTTP and HTTPS transports support the URL syntax extension
  for HTTP Basic Authentication:http://user:p...@host:port/path. The
  user:pass portion will be base64-encoded as an HTTP `Authorization'
  header, and sent to the remote server as part of the connection
  process when invoking an XML-RPC method.
  

  In my modified Welcome web2py app I've added the setting
  auth.settings.allow_basic_authentication = True in
  welcome/models/db.py

  I've decorated the private_call action like so:

  @auth.requires_login()
  def private_call():
      return private_service()

  And I've added a test action getstring:

  @private_service.xmlrpc
  def getstring():
      if auth.is_logged_in():
          return logged in!
      else:
          return not logged in!

  In my desktop app I'm calling the service like this:

  self.server = 
  xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
  print self.server.getstring()

  and I'm getting this traceback:

  Traceback (most recent call last):
    File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
  line 137
  , in OnButton4Button
      print self.server3.getstring()
    File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
      return self.__send(self.__name, args)
    File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
      verbose=self.__verbose
    File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
  line 185
  , in request
      headers
  xmlrpclib.ProtocolError: ProtocolError for myem...@gmail.com:mypassword@
  127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

  I'm obviously doing something wrong. Could you point me in the right 
  direction?

  Thanks.

  --
  Alexei Vinidiktov

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 Alexei Vinidiktov

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/web2py?hl=en.





-- 
Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: GAE native types.

2010-04-05 Thread Matt
Thanks for your prompt response :)

Trying your example:

from gluon.contrib.gql import gae

db.define_table('example',
db.Field('title', 'string'),
db.Field('name', gae.StringListProperty))

as a quick test but I'm getting an error:

Traceback (most recent call last):
  File /Apps/web2py/testing/gluon/restricted.py, line 173, in
restricted
exec ccode in environment
  File /Apps/web2py/testing/applications/init/models/db_tables.py,
line 55, in module
db.Field('name', gae.StringListProperty))
  File /Apps/web2py/testing/gluon/contrib/gql.py, line 128, in
define_table
t._create()
  File /Apps/web2py/testing/gluon/contrib/gql.py, line 216, in
_create
elif field.type[:2] == 'id':
TypeError: 'type' object is unsubscriptable

What am I doing wrong here?

Thanks,
Matt

On Apr 6, 3:43 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 For example:

 from gluon.contrib.gql import gae

 db.define_table('tablename',,Field('name',gae.StringListProperty),)

 You can use any native type but forms may not work because you have to
 make sure you insert the corresponding type (in the example a list of
 strings). Sorry there is not much documentation about this.

 Massimo

 On Apr 5, 10:34 pm, Matt mjwat...@gmail.com wrote:

  Hi there,

  In the features not in the book section it lists since version
  1.74.5

  * support for all native types on GAE (e.g. StringListProperty)

  Are there any examples demonstrating the use of these available?

  Thanks,
  Matt

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Basic authentication question

2010-04-05 Thread mdipierro
you can try define something like ths

def catch303(f):
try: return f()
except HTTP, http:
   if http.status==303: return 'error'
   raise http

and appy the additional decorator on top of auth.requires_login

@catch303
@auth.requires_login()

Massimo

On Apr 5, 10:50 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
wrote:
 I just tried it with this json-rpc lib 
 (http://www.desfrenes.com/python-json-rpc) , and it also seems to work
 fine.

 I have many more open questions about authentication and
 authorization. I'm exploring different approaches for my application:
 cookie-based, basic, token authentication, and different protocols
 also (xmlrpc, jsonrpc, json).

 Another question: If the authentication fails, my client application
 receives error 303 See Other.

 It is my understanding that this error means that the user visiting
 the website is redirected to a different page (apparently the page
 defined in auth.settings.login_url).

 Can I customize the error message such that the client application can
 understand that the error results from the failed login attempt?



 On Tue, Apr 6, 2010 at 10:55 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  thank you for trying it. It is one of those features that not many
  people are using but should be solid.

  Massimo

  On Apr 5, 9:44 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  Thanks a lot, Massimo! It worked!

  On Tue, Apr 6, 2010 at 10:36 AM, mdipierro mdipie...@cs.depaul.edu wrote:
   you need in db.py

   auth.settings.allow_basic_login = True

   it defaults to False

   On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
   wrote:
   Hello,

   I'm trying to make a desktop client written in Python 2.5 (on Windows)
   communicate with a web2py 1.76.5 based app using services. It works
   fine with services that don't require authentication, but I was
   wondering if I could make it authenticate the user with Basic
   authentication.

   I've read in the Python docs that xmlrpclib supports Basic 
   authentication:

   
   Both the HTTP and HTTPS transports support the URL syntax extension
   for HTTP Basic Authentication:http://user:p...@host:port/path. The
   user:pass portion will be base64-encoded as an HTTP `Authorization'
   header, and sent to the remote server as part of the connection
   process when invoking an XML-RPC method.
   

   In my modified Welcome web2py app I've added the setting
   auth.settings.allow_basic_authentication = True in
   welcome/models/db.py

   I've decorated the private_call action like so:

   @auth.requires_login()
   def private_call():
       return private_service()

   And I've added a test action getstring:

   @private_service.xmlrpc
   def getstring():
       if auth.is_logged_in():
           return logged in!
       else:
           return not logged in!

   In my desktop app I'm calling the service like this:

   self.server = 
   xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
   print self.server.getstring()

   and I'm getting this traceback:

   Traceback (most recent call last):
     File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
   line 137
   , in OnButton4Button
       print self.server3.getstring()
     File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
       return self.__send(self.__name, args)
     File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
       verbose=self.__verbose
     File C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, 
   line 185
   , in request
       headers
   xmlrpclib.ProtocolError: ProtocolError for 
   myem...@gmail.com:mypassword@
   127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

   I'm obviously doing something wrong. Could you point me in the right 
   direction?

   Thanks.

   --
   Alexei Vinidiktov

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  Alexei Vinidiktov

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 Alexei Vinidiktov

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Basic authentication question

2010-04-05 Thread Alexei Vinidiktov
Thanks, Massimo. I'll try.

On Tue, Apr 6, 2010 at 12:26 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 you can try define something like ths

 def catch303(f):
    try: return f()
    except HTTP, http:
       if http.status==303: return 'error'
       raise http

 and appy the additional decorator on top of auth.requires_login

 @catch303
 @auth.requires_login()

 Massimo

 On Apr 5, 10:50 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
 wrote:
 I just tried it with this json-rpc lib 
 (http://www.desfrenes.com/python-json-rpc) , and it also seems to work
 fine.

 I have many more open questions about authentication and
 authorization. I'm exploring different approaches for my application:
 cookie-based, basic, token authentication, and different protocols
 also (xmlrpc, jsonrpc, json).

 Another question: If the authentication fails, my client application
 receives error 303 See Other.

 It is my understanding that this error means that the user visiting
 the website is redirected to a different page (apparently the page
 defined in auth.settings.login_url).

 Can I customize the error message such that the client application can
 understand that the error results from the failed login attempt?



 On Tue, Apr 6, 2010 at 10:55 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  thank you for trying it. It is one of those features that not many
  people are using but should be solid.

  Massimo

  On Apr 5, 9:44 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
  wrote:
  Thanks a lot, Massimo! It worked!

  On Tue, Apr 6, 2010 at 10:36 AM, mdipierro mdipie...@cs.depaul.edu 
  wrote:
   you need in db.py

   auth.settings.allow_basic_login = True

   it defaults to False

   On Apr 5, 9:21 pm, Alexei Vinidiktov alexei.vinidik...@gmail.com
   wrote:
   Hello,

   I'm trying to make a desktop client written in Python 2.5 (on Windows)
   communicate with a web2py 1.76.5 based app using services. It works
   fine with services that don't require authentication, but I was
   wondering if I could make it authenticate the user with Basic
   authentication.

   I've read in the Python docs that xmlrpclib supports Basic 
   authentication:

   
   Both the HTTP and HTTPS transports support the URL syntax extension
   for HTTP Basic Authentication:http://user:p...@host:port/path. The
   user:pass portion will be base64-encoded as an HTTP `Authorization'
   header, and sent to the remote server as part of the connection
   process when invoking an XML-RPC method.
   

   In my modified Welcome web2py app I've added the setting
   auth.settings.allow_basic_authentication = True in
   welcome/models/db.py

   I've decorated the private_call action like so:

   @auth.requires_login()
   def private_call():
       return private_service()

   And I've added a test action getstring:

   @private_service.xmlrpc
   def getstring():
       if auth.is_logged_in():
           return logged in!
       else:
           return not logged in!

   In my desktop app I'm calling the service like this:

   self.server = 
   xmlrpclib.Server(http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc;)
   print self.server.getstring()

   and I'm getting this traceback:

   Traceback (most recent call last):
     File 
   C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
   137
   , in OnButton4Button
       print self.server3.getstring()
     File C:\Python25\lib\xmlrpclib.py, line 1147, in __call__
       return self.__send(self.__name, args)
     File C:\Python25\lib\xmlrpclib.py, line 1437, in __request
       verbose=self.__verbose
     File 
   C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py, line 
   185
   , in request
       headers
   xmlrpclib.ProtocolError: ProtocolError for 
   myem...@gmail.com:mypassword@
   127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER

   I'm obviously doing something wrong. Could you point me in the right 
   direction?

   Thanks.

   --
   Alexei Vinidiktov

   --
   You received this message because you are subscribed to the Google 
   Groups web2py-users group.
   To post to this group, send email to web...@googlegroups.com.
   To unsubscribe from this group, send email to 
   web2py+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/web2py?hl=en.

  --
  Alexei Vinidiktov

  --
  You received this message because you are subscribed to the Google Groups 
  web2py-users group.
  To post to this group, send email to web...@googlegroups.com.
  To unsubscribe from this group, send email to 
  web2py+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/web2py?hl=en.

 --
 Alexei Vinidiktov

 --
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to 
 

[web2py] Re: GAE native types.

2010-04-05 Thread mdipierro
odd. The code there says:

if isinstance(field.type, gluon.sql.SQLCustomType):
ftype = self._db._translator[field.type.native or
field.type.type](**attr)
elif isinstance(field.type, gae.Property):
ftype = field.type
elif field.type[:2] == 'id':
continue

since field.type is, in your case,  gaeStringListProperty and it
extends gae.Property the previous elif should have been True. It is
for me.
Do you have those lines? What GAE version?



On Apr 5, 11:19 pm, Matt mjwat...@gmail.com wrote:
 Thanks for your prompt response :)

 Trying your example:

 from gluon.contrib.gql import gae

 db.define_table('example',
     db.Field('title', 'string'),
     db.Field('name', gae.StringListProperty))

 as a quick test but I'm getting an error:

 Traceback (most recent call last):
   File /Apps/web2py/testing/gluon/restricted.py, line 173, in
 restricted
     exec ccode in environment
   File /Apps/web2py/testing/applications/init/models/db_tables.py,
 line 55, in module
     db.Field('name', gae.StringListProperty))
   File /Apps/web2py/testing/gluon/contrib/gql.py, line 128, in
 define_table
     t._create()
   File /Apps/web2py/testing/gluon/contrib/gql.py, line 216, in
 _create
     elif field.type[:2] == 'id':
 TypeError: 'type' object is unsubscriptable

 What am I doing wrong here?

 Thanks,
 Matt

 On Apr 6, 3:43 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  For example:

  from gluon.contrib.gql import gae

  db.define_table('tablename',,Field('name',gae.StringListProperty),)

  You can use any native type but forms may not work because you have to
  make sure you insert the corresponding type (in the example a list of
  strings). Sorry there is not much documentation about this.

  Massimo

  On Apr 5, 10:34 pm, Matt mjwat...@gmail.com wrote:

   Hi there,

   In the features not in the book section it lists since version
   1.74.5

   * support for all native types on GAE (e.g. StringListProperty)

   Are there any examples demonstrating the use of these available?

   Thanks,
   Matt

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Flatpages plugin

2010-04-05 Thread Mariano Reingart
Hi, attached is plugin_flatpages, a dynamic wiki/html user editable
pages plugin.

It supports:
 * page edition by users (in the same page)
 * page history
 * preview
 * format conversion (markdown/html)
 * internationalization (a page for each language)

It was based on:
 * my web2py2-wiki branch:
https://code.launchpad.net/~reingart/web2py-wiki/spanish-site
 * wyswyg markdown slice: http://www.web2pyslices.com/main/slices/take_slice/54
  * http://code.google.com/p/jwysiwyg/
  * http://www.aaronsw.com/2002/html2text/

Installation:
 * Just upload web2py.plugin.flatpages.w2p in your app via the web
admin interface
 * create a auth_group plugin_flatpages and grant permission via
auth_membership if you want some users to be able to edit pages

Usage:
 * in the controller simply call the plugin like: def index(): return
plugin_flatpage()

Customization:
 * look at view plugin_flatpages.html
 * install module html2text.py for html to markdown format conversion to work


Suggestions and comments are welcome


Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



web2py.plugin.flatpages.w2p
Description: Binary data


[web2py] Re: GAE native types.

2010-04-05 Thread Matt
Just had a quick look into gql.py and yes in the _create method around
line 214 I've got those lines you mentioned.

I'm running web2py 1.76.5 (2010-03-11 15:19:08)  with GAE launcher
version 1.3.2

Matt

On Apr 6, 4:31 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 odd. The code there says:

             if isinstance(field.type, gluon.sql.SQLCustomType):
                 ftype = self._db._translator[field.type.native or
 field.type.type](**attr)
             elif isinstance(field.type, gae.Property):
                 ftype = field.type
             elif field.type[:2] == 'id':
                 continue

 since field.type is, in your case,  gaeStringListProperty and it
 extends gae.Property the previous elif should have been True. It is
 for me.
 Do you have those lines? What GAE version?

 On Apr 5, 11:19 pm, Matt mjwat...@gmail.com wrote:

  Thanks for your prompt response :)

  Trying your example:

  from gluon.contrib.gql import gae

  db.define_table('example',
      db.Field('title', 'string'),
      db.Field('name', gae.StringListProperty))

  as a quick test but I'm getting an error:

  Traceback (most recent call last):
    File /Apps/web2py/testing/gluon/restricted.py, line 173, in
  restricted
      exec ccode in environment
    File /Apps/web2py/testing/applications/init/models/db_tables.py,
  line 55, in module
      db.Field('name', gae.StringListProperty))
    File /Apps/web2py/testing/gluon/contrib/gql.py, line 128, in
  define_table
      t._create()
    File /Apps/web2py/testing/gluon/contrib/gql.py, line 216, in
  _create
      elif field.type[:2] == 'id':
  TypeError: 'type' object is unsubscriptable

  What am I doing wrong here?

  Thanks,
  Matt

  On Apr 6, 3:43 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   For example:

   from gluon.contrib.gql import gae

   db.define_table('tablename',,Field('name',gae.StringListProperty),)

   You can use any native type but forms may not work because you have to
   make sure you insert the corresponding type (in the example a list of
   strings). Sorry there is not much documentation about this.

   Massimo

   On Apr 5, 10:34 pm, Matt mjwat...@gmail.com wrote:

Hi there,

In the features not in the book section it lists since version
1.74.5

* support for all native types on GAE (e.g. StringListProperty)

Are there any examples demonstrating the use of these available?

Thanks,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.