[web2py] Re: what can we use this for...?

2011-08-13 Thread Massimo Di Pierro
CSS can do this:

http://www.gesteves.com/experiments/starwars.html

I have a web2py app so you can write your own text. Will post it soon.

On 12 Ago, 19:41, weheh richard_gor...@verizon.net wrote:
 Fascinating! I never thought CSS could do that. However, I wouldn't be
 so quick to jump on the bandwagon. In practice, they don't seem work
 so well, although it's possible I'm not using it as intended. For
 instance, DIV shapes that are inlined will not display properly. I'm
 sure there are many other pathological cases, given how wretchedly
 difficult it is to control CSS at times. My 2 cents: don't waste your
 time.

 On Aug 12, 8:03 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  So... a plugin_shapes which contains a CSS file?

  On 12 Ago, 15:18, Cliff cjk...@gmail.com wrote:

   #triangle-right {
           width: 0;
           height: 0;
           border-top: 50px solid transparent;
           border-left: 100px solid red;
           border-bottom: 50px solid transparent;

   }

   script
   $('#triangle-right').click(function(){
     do_stuff();

   })

   On Aug 12, 3:17 pm, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:

   http://css-tricks.com/examples/ShapesOfCSS/?=derp


[web2py] Re: what can we use this for...?

2011-08-13 Thread weheh
Massimo, this is cute, but it only works on Chrome. If you could grant
me one wish, it would be to make LOAD work native with mulipart forms.
Fancy stuff with CSS would be low on the list.

On Aug 13, 3:52 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 CSS can do this:

 http://www.gesteves.com/experiments/starwars.html

 I have a web2py app so you can write your own text. Will post it soon.

 On 12 Ago, 19:41, weheh richard_gor...@verizon.net wrote:







  Fascinating! I never thought CSS could do that. However, I wouldn't be
  so quick to jump on the bandwagon. In practice, they don't seem work
  so well, although it's possible I'm not using it as intended. For
  instance, DIV shapes that are inlined will not display properly. I'm
  sure there are many other pathological cases, given how wretchedly
  difficult it is to control CSS at times. My 2 cents: don't waste your
  time.

  On Aug 12, 8:03 pm, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   So... a plugin_shapes which contains a CSS file?

   On 12 Ago, 15:18, Cliff cjk...@gmail.com wrote:

#triangle-right {
        width: 0;
        height: 0;
        border-top: 50px solid transparent;
        border-left: 100px solid red;
        border-bottom: 50px solid transparent;

}

script
$('#triangle-right').click(function(){
  do_stuff();

})

On Aug 12, 3:17 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

http://css-tricks.com/examples/ShapesOfCSS/?=derp


[web2py] Problem using MySQL with scheduler.py

2011-08-13 Thread G
Hello,
I just tried to use scheduler.py with MySQL instead of SQLite and ran
into this error:

NotSupportedError: (1235, This version of MySQL doesn't yet support
'LIMIT  IN/ALL/ANY/SOME subquery')

The MySQL server version is 5.0.77. Searching on the web, it seems
this limitation is common. Is there a way to work around the issue?
The offending SQL looks like this:

UPDATE task_scheduled SET
status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
(task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
(task_scheduled.next_run_time  '2011-08-13 09:33:01')) AND
(((task_scheduled.assigned_worker_name = '') OR
(task_scheduled.assigned_worker_name IS NULL)) OR
(task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
OFFSET 0));

I'm pretty sure this is coming from the massively complex query in
assign_next_task.

Thanks,
G


[web2py] Enable and disable buttons

2011-08-13 Thread Michele Alzetta
I'm trying to make a web2py app in which users have to insert a lot of
different types of data. Once all the data have been added the user should
be able to click on a button to get the app to elaborate the data and
produce the final output.

What would be the simplest way to disable the button until all the relevant
data have been added, and to activate it automatically once everything is
ready?

Or would you suggest a different type of approach altogether?

Michele


[web2py] Re: Problem using MySQL with scheduler.py

2011-08-13 Thread Massimo Di Pierro
I have MySQL, it is full of caveats like this. Can somebody check
postgresql?
If this is just a mysql issue, we'll deal with it as an exception and
find a workaround.

On 13 Ago, 04:56, G glenn.calt...@gmail.com wrote:
 Hello,
 I just tried to use scheduler.py with MySQL instead of SQLite and ran
 into this error:

 NotSupportedError: (1235, This version of MySQL doesn't yet support
 'LIMIT  IN/ALL/ANY/SOME subquery')

 The MySQL server version is 5.0.77. Searching on the web, it seems
 this limitation is common. Is there a way to work around the issue?
 The offending SQL looks like this:

 UPDATE task_scheduled SET
 status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
 b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
 (task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
 WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
 'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
 (task_scheduled.next_run_time  '2011-08-13 09:33:01')) AND
 (((task_scheduled.assigned_worker_name = '') OR
 (task_scheduled.assigned_worker_name IS NULL)) OR
 (task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
 b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
 OFFSET 0));

 I'm pretty sure this is coming from the massively complex query in
 assign_next_task.

 Thanks,
 G


[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-13 Thread Niphlod
I'm testing with postgres, anyway in sqlite this is the traceback from
the workers

Traceback (most recent call last):
  File /usr/lib/python2.6/multiprocessing/process.py, line 232, in
_bootstrap
self.run()
  File /usr/lib/python2.6/multiprocessing/process.py, line 88, in
run
self._target(*self._args, **self._kwargs)
  File /home/niphlod/Scrivania/web2py/gluon/shell.py, line 211, in
run
exec(python_code, _env)
  File string, line 1, in module
  File /home/niphlod/Scrivania/web2py/gluon/scheduler.py, line 358,
in worker_loop
while self.run_next_task(group_names=group_names): pass
  File /home/niphlod/Scrivania/web2py/gluon/scheduler.py, line 271,
in run_next_task
result=dumps(result))
  File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 5521, in
update
return self.db._adapter.update(tablename,self.query,fields)
  File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1024, in
update
self.execute(sql)
  File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1276, in
execute
return self.log_execute(*a, **b)
  File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1271, in
log_execute
ret = self.cursor.execute(*a,**b)
OperationalError: database is locked


[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-13 Thread Massimo Di Pierro
added some try catch but this should not be happening. If database is
locked it should just wait.

Massimo

On 13 Ago, 07:07, Niphlod niph...@gmail.com wrote:
 I'm testing with postgres, anyway in sqlite this is the traceback from
 the workers

 Traceback (most recent call last):
   File /usr/lib/python2.6/multiprocessing/process.py, line 232, in
 _bootstrap
     self.run()
   File /usr/lib/python2.6/multiprocessing/process.py, line 88, in
 run
     self._target(*self._args, **self._kwargs)
   File /home/niphlod/Scrivania/web2py/gluon/shell.py, line 211, in
 run
     exec(python_code, _env)
   File string, line 1, in module
   File /home/niphlod/Scrivania/web2py/gluon/scheduler.py, line 358,
 in worker_loop
     while self.run_next_task(group_names=group_names): pass
   File /home/niphlod/Scrivania/web2py/gluon/scheduler.py, line 271,
 in run_next_task
     result=dumps(result))
   File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 5521, in
 update
     return self.db._adapter.update(tablename,self.query,fields)
   File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1024, in
 update
     self.execute(sql)
   File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1276, in
 execute
     return self.log_execute(*a, **b)
   File /home/niphlod/Scrivania/web2py/gluon/dal.py, line 1271, in
 log_execute
     ret = self.cursor.execute(*a,**b)
 OperationalError: database is locked


[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-13 Thread Niphlod
clearly with multiple threads maybe sqlite api is going to wait ,
but with multiple processes trying to insert data at the same time I'm
starting to think that can't keep up

BTW, there's no way to come around the problem of task executed
multiple times if I'm trying to assign workers in the same process
that fetches and execute it
Any ideas ?


[web2py] how to generate PDF (with data) using PDF static forms?

2011-08-13 Thread Carlos
Hi,

I will soon need to generate PDF files by filling the blanks in an already 
existing PDF static form ('template').

It's like a merge of a PDF file (static form) with my dynamic data, filling 
blanks in specific positions.

Is there any way to accomplish this with web2py / utils?.

Many thanks,

   Carlos



[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-13 Thread Massimo Di Pierro
http://hartshorne.ca/2009/02/16/sqlite_database_is_locked/

On 13 Ago, 08:31, Niphlod niph...@gmail.com wrote:
 clearly with multiple threads maybe sqlite api is going to wait ,
 but with multiple processes trying to insert data at the same time I'm
 starting to think that can't keep up

 BTW, there's no way to come around the problem of task executed
 multiple times if I'm trying to assign workers in the same process
 that fetches and execute it
 Any ideas ?


[web2py] Re: Problem using MySQL with scheduler.py

2011-08-13 Thread G
As a quick workaround, this change in assign_next_task seems to do the
trick:

subselect = db(query).select(
db.task_scheduled.id,limitby=(0,1),
orderby=db.task_scheduled.next_run_time)
for row in subselect:
db(db.task_scheduled.id == row.id).update(
status=RUNNING,
assigned_worker_name=self.worker_name,
last_run_time=datetime.now)

On Aug 13, 11:47 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I have MySQL, it is full of caveats like this. Can somebody check
 postgresql?
 If this is just a mysql issue, we'll deal with it as an exception and
 find a workaround.

 On 13 Ago, 04:56, G glenn.calt...@gmail.com wrote:

  Hello,
  I just tried to use scheduler.py with MySQL instead of SQLite and ran
  into this error:

  NotSupportedError: (1235, This version of MySQL doesn't yet support
  'LIMIT  IN/ALL/ANY/SOME subquery')

  The MySQL server version is 5.0.77. Searching on the web, it seems
  this limitation is common. Is there a way to work around the issue?
  The offending SQL looks like this:

  UPDATE task_scheduled SET
  status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
  b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
  (task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
  WHERE (task_scheduled.enabled = 'T') AND (task_scheduled.status =
  'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
  (task_scheduled.next_run_time  '2011-08-13 09:33:01')) AND
  (((task_scheduled.assigned_worker_name = '') OR
  (task_scheduled.assigned_worker_name IS NULL)) OR
  (task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
  b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
  OFFSET 0));

  I'm pretty sure this is coming from the massively complex query in
  assign_next_task.

  Thanks,
  G




[web2py] MySQL query not reflecting actual state of db

2011-08-13 Thread G
Hello,
I am using a loop like this to wait for a scheduled task to complete:

query = schdb.task_scheduled.id == id
query = ((schdb.task_scheduled.status == 'queued') |
(schdb.task_scheduled.status == 'running'))

while schdb(query).count():
 time.sleep(0.1) #wait for task to run

This worked perfectly when schdb was on SQLite, but now I am using
MySQL so the workers can run on different machines. The loop goes on
forever. If I display the contents of schdb(query).select() in the
loop, I see that it does indeed continuously show the status is
'running'. However, when I look at the database with MysQL Query
Browser, I can see that the task completed normally and updated the
status to 'completed'. I checked to make sure there are no missing
db.commit() statements.

Any ideas what could be causing schdb(query) to not reflect the true
state of the database?

Thanks,
G


[web2py] Re: Authentication for services in iPhone not work

2011-08-13 Thread howesc
Relsi,

i have not done xml-rpc with iphone, but i know that the iphone will accept 
and store a cookie, so you could do an oauth implementation where the deice 
logs in and gets a cookie which is then submitted with each request.

i have done the DB (web2py) side of an iphone app that makes use of the 
authorization header with a custom validation (i dare not say 
authentication) mechanism.

once there is a nice clean solution i'm sure massimo would take a patch to 
update core web2py. :)

christian


[web2py] Virtual Fields. Strange behavior when saving db result sets Build in types

2011-08-13 Thread Santiago
Hello,

I have the following definitions in db.py

class ElectionVirtualField(object):
  ...
  def is_presidential(self):
def lazy(self=self):
  return self.election.category == 'P'
return lazy
  ...

db.define_table('election',
  ...
  Field('category', length=1, label=T('Category')
  ...

The problem I have is that when I add a bunch of elections in dict()
(key = election.id, value = election row) and then traverse the dict,
I get wrong values from is_presidential()

Example:

elections = dict()
for election in db(db.election).select():
   elections[election.id] = election

for (k, v) in elections.items():
  print k , ' ', v.category, ' ', v.is_presidential()

Output:
81   D   True
79   P   True

As you can see, it returns True for both, but for the first one, it
should return False.

If I change the code to reload the election from the database, the
output is different:

Example:

elections = dict()
for election in db(db.election).select():
   elections[election.id] = election

for (k, v) in elections.items():
  reloaded_election = db.election(k)
  print k , ' ', v.category, ' ', v.is_presidential()

Output:

81   D   False
79   P   True

Does this mean that we can't save rows from DB on Build in types ?

Thanks in advance,
Santiago


[web2py] GAE deployment issue on Ubuntu

2011-08-13 Thread Pystar
Hi,
I am running Web2py 1.98.2 on Ubuntu 11.04, when I try to deploy my
application to Google app engine via the deploy to GAE in the web2py
web console, I do not get any GAE output no matter how long I try. I
know there is a disclaimer that response from GAE depends on network
speed but I havent gotten any response from GAE after trying to deploy
for some hours now. I would like to know if anyone has had success
deploying to GAE from web2py. Thanks
Pystar


[web2py] Re: MySQL query not reflecting actual state of db

2011-08-13 Thread G
Hello again,
It seems that db.commit() is necessary to get the query to reflect the
changed state of the database for some reason.

The simple code at the end of this message illustrates the problem.
Starting two ipython sessions, and running side1() in one, and then
side2() in the other, if the db.commit() line in the side1 loop is
removed, it will loop forever even though the database is actually
updated by side2.

This work around works, but I'd like to understand what's going on.

Thanks,
G


 dbtest.py ===

from gluon import *
import time
db = DAL('mysql://web2py:web2py@localhost:33306/web2py',
   folder = '/home/dl/trunkw2p/web2py/applications/
devel/databases')

db.define_table(
'test',
Field('status',requires=IS_NOT_EMPTY()))

def side1():

id = db.test.insert(status='queued')
db.commit()
query = (db.test.id == id)  ((db.test.status == 'start') |
(db.test.status == 'queued'))
while db(query).count():
print query, [str(x) for x in db(query).select()]
db.commit()  # !!! Comment out this line and this while loop
will never exit
time.sleep(0.1)
print done

def side2():
id = db(db.test.id0).select().last().id
print found id,id
time.sleep(5)
db(db.test.id == id).update(status='start')
db.commit()
print finishing
time.sleep(5)
db(db.test.id == id).update(status='done')
db.commit()
print finished


[web2py] Re: GAE deployment issue on Ubuntu

2011-08-13 Thread Pystar
I just decided to use the appcfg.py tool to deploy my app and it was
successful. Anyone who has had success deploying an app from inside
web2py to GAE should comment.
thanks

On Aug 14, 12:14 am, Pystar aitoehi...@gmail.com wrote:
 Hi,
 I am running Web2py 1.98.2 on Ubuntu 11.04, when I try to deploy my
 application to Google app engine via the deploy to GAE in the web2py
 web console, I do not get any GAE output no matter how long I try. I
 know there is a disclaimer that response from GAE depends on network
 speed but I havent gotten any response from GAE after trying to deploy
 for some hours now. I would like to know if anyone has had success
 deploying to GAE from web2py. Thanks
 Pystar


[web2py] Re: Problem with multiple forms

2011-08-13 Thread Karthik
Is there a way to dynamically name the forms?
I don't know how many forms I'll need to display, it depends on an
external factor.
(I have a textarea and depending on the lines filled in the textarea
by the user, I need to create that many forms).

Is this possible withing web2py's FORM() helper or would using the
default HTML be a better idea?

Thanks!

On May 6 2010, 9:17 am, mdipierro mdipie...@cs.depaul.edu wrote:
 If you have two forms you have to name them:

 if form_back.accepts(request.vars, session, formname='back'):
 ...
 if form_membership.accepts(request.vars,
 session,formname='membership'):

 On May 6, 7:19 am, Sverre sverreodeg...@gmail.com wrote:







  I'm using this design  in a controller to have buttons on the page:
  
      form_membership = FORM('', INPUT(_type='submit',_value='New'))
      form_back = FORM('', INPUT(_type='submit',_value='Back to user'))
      if form_back.accepts(request.vars, session):

  redirect(URL(r=request,c='sysuser',f='edit_user',args=userid))
      if form_membership.accepts(request.vars, session):

  redirect(URL(r=request,c='sysuser',f='new_membership',args=userid))
      return
  dict(msg=rows,form_membership=form_membership,form_back=form_back)
  
  But this isn't working. I'm don't get the right redirections. The
  Back to user' button gives me the redirection of the other button.
  Has someone a clue?


[web2py] Re: MongoDb and web2py

2011-08-13 Thread Karthik
I'm still looking for a solution to simulate connection pooling, any
responses would be great - thanks!

On Jul 21, 4:53 pm, Karthik karthikparameswa...@gmail.com wrote:
 Hi Massimo,

 Thanks for this. Do you know if it will hold up in a high performance
 situation though?
 As in, if multiple connections originate at the same time, won't there
 be a queue?
 Is it possible to simulate the connection pooling mechanism in
 web2py's DAL?

 Thanks,Karthik

 On Jul 31 2010, 4:13 am, mdipierro mdipie...@cs.depaul.edu wrote:







  how about this? (None below means cache forever)

  def make_connection():
      from pymongo import Connection
      connection = Connection('localhost', 27017)
      return connection

  connection = cache.ram('mongodb',make_connection,None)

  On Jul 31, 3:11 am, David Marko dma...@tiscali.cz wrote:

   Hi Massimo, can you give ua a hint how to impelement persistent
   connection in web2py for pyMongo? PyMongo requires database connection
   and to use it efficiently the connection has to be persistent and
   shared among requests like a connection pool for database connections
   as DAL has. But how to do it in web2py?

   e.g.
   from pymongo import Connection
   connection = Connection('localhost', 27017)

   ### how to keep this connection object?

   David

   On 31 čnc, 09:57, mdipierro mdipie...@cs.depaul.edu wrote:

yes. Just set dbio=False in forms and do your own mymongo IO after
accepts:

On Jul 30, 11:18 am, Amit Ambardekar amit...@gmail.com wrote:

 I want to use web2py with pymongo.
 I don't need ORM or or anything. I just want to connect use pymongo
 from Web2Py.
 How can I use it inside web2py. I need it for high performance use.

 Amit


[web2py] Table creation in GAE

2011-08-13 Thread ram
Is the following statement correct?
A Table is created in  GAE only when the first record is inserted.


[web2py] Noob question - Choices definition in Field - DAL

2011-08-13 Thread ram
Is it possible to this using DAL, using Field definition?

role = db.StringProperty(required=True, choices=set([executive,
manager, producer]))

Best regards
Ram


Re: [web2py] how to generate PDF (with data) using PDF static forms?

2011-08-13 Thread Mariano Reingart
I think that not even ReportLab could merge an existing PDF, IIRC
there are other tools to open and possibly modifiy files.
If you can make your design and fill it, then you can use PyFPDF
(there is an Invoice example).
Also, sometimes I put an image as background (+-300dpi) and then I
only complete the text fields.

YMMV

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



On Sat, Aug 13, 2011 at 11:06 AM, Carlos carlosgali...@gmail.com wrote:
 Hi,

 I will soon need to generate PDF files by filling the blanks in an already
 existing PDF static form ('template').
 It's like a merge of a PDF file (static form) with my dynamic data, filling
 blanks in specific positions.
 Is there any way to accomplish this with web2py / utils?.
 Many thanks,
    Carlos



[web2py] Re: Problem with multiple forms

2011-08-13 Thread weheh
Each form needs to have a unique name. I suppose you could use uuid to
make a unique name. Then something like this pseudocode  might work:

allforms=dict(form_id=new_form_id(),form=SQLFORM(...))
for f in allforms:
if f['form'].accepts(request.vars,formname=f['form_id']):
# do something if form accepts
else:
# do something else if form doesn't accept
return dict(allforms=allforms)

Then in views you will need to loop on allforms to make your form. You
will probably want a custom form and make sure you have a hidden input
with id=f['form_id']

Obviously, if the order of forms is important, you will want to modify
this code to make the forms into a list instead of a dict.

Hope this helps. Good luck.



On Aug 13, 9:24 pm, Karthik karthikparameswa...@gmail.com wrote:
 Is there a way to dynamically name the forms?
 I don't know how many forms I'll need to display, it depends on an
 external factor.
 (I have a textarea and depending on the lines filled in the textarea
 by the user, I need to create that many forms).

 Is this possible withing web2py's FORM() helper or would using the
 default HTML be a better idea?

 Thanks!

 On May 6 2010, 9:17 am, mdipierro mdipie...@cs.depaul.edu wrote:







  If you have two forms you have to name them:

  if form_back.accepts(request.vars, session, formname='back'):
  ...
  if form_membership.accepts(request.vars,
  session,formname='membership'):

  On May 6, 7:19 am, Sverre sverreodeg...@gmail.com wrote:

   I'm using this design  in a controller to have buttons on the page:
   
       form_membership = FORM('', INPUT(_type='submit',_value='New'))
       form_back = FORM('', INPUT(_type='submit',_value='Back to user'))
       if form_back.accepts(request.vars, session):

   redirect(URL(r=request,c='sysuser',f='edit_user',args=userid))
       if form_membership.accepts(request.vars, session):

   redirect(URL(r=request,c='sysuser',f='new_membership',args=userid))
       return
   dict(msg=rows,form_membership=form_membership,form_back=form_back)
   
   But this isn't working. I'm don't get the right redirections. The
   Back to user' button gives me the redirection of the other button.
   Has someone a clue?