Re: [web2py] Re: SQLFORM field validator

2011-03-03 Thread Manuele Pesenti

Il 03/03/2011 08:27, pbreit ha scritto:

What is it doing and what are you expecting?
as I said after I need that only if null the two fields has to be the 
same. And I want to use a form builded via SQLFORM.factory because my 
form is not stricly related to a db table. I hope I've been more clear :)


Cheers
Manuele



I don't understand exactly what you are trying to achieve. You have 
two form fields, a and b? And whatever is entered in b must match what 
is entered in a?




[web2py] sqlform form.accept bug? I am confused

2011-03-03 Thread sipiatti
Hi all,

I am still a newbie to web2py so could be that this is my fault.
I am making a warehouse stock registry app. At present I try to make a
procedure where the worker can input the new received gadgets. The
form have quantity field. If it is greater than 1, I need to do
additional inserts to the db with the same data (the id will be
different of course).

The current situation that the form and the controller works, but not
always and I can't find the reasons. In the most of the cases when I
visit the page for the first time, fill in the fields and submit,
usually I get back the page without any errors, but no insert made on
the database. I see that the form.accept is false, but form.errors is
empty. If I fill in the form again it usually accepts and makes the
inserts, but also not always sometimes it never accepts does not
matter how many times I try.
On the other hand, if I make a validation error at will, and I get the
error messages of the validation, and then I input the correct datas
it usually accepts (sometimes not but that is rare).
I suppose that this behavor comes from a web2py feature, e.g caching
or the preventing of booking the same form times due to user error. It
is also could happen that I misunderstood something related to forms.

Can somebody help me to solve this issue?

Here is the related function in the controller (konyveles.py). I
insert several  objects to the returned dict to check their content in
the view for debug purposes:
def beerkeztetes():
form=SQLFORM(db.eszkozok,
 
fields=[eszkozszam,aleszkozszam,darab,koltseghely,megnevezes,egyediazon,aktivalas,tipus_id],
col3={'darab':'Ennyi új eszköz fog
létrejönni!','egyediazon':'Pl. gyári szám, sorozatszám'})
faccept=None
if len(request.vars)0:
darab=int(request.vars.darab)
if darab1:
request.vars.darab='1'
faccept=form.accepts(request.vars)
if faccept:
response.flash = '%s db új eszköz felvéve' % darab
 
db.naplo.insert(datum=datetime.date.today().isoformat(),eszkoz_id=form.vars.id,mozgas_id=1,user_id=auth.user_id)
if darab1:
for i in range(1,darab):
 
id=db.eszkozok.insert(eszkozszam=request.vars.eszkozszam,aleszkozszam=request.vars.aleszkozszam,darab=1,koltseghely=request.vars.koltseghely,megnevezes=request.vars.megnevezes,egyediazon=request.vars.egyediazon,aktivalas=datetime.datetime.strptime(request.vars.aktivalas,%Y.
%m.%d.).date().isoformat(),tipus_id=int(request.vars.tipus_id))
 
db.naplo.insert(datum=datetime.date.today().isoformat(),eszkoz_id=id,mozgas_id=1,user_id=auth.user_id)
db.commit()

elif form.errors:
response.flash = 'Kitöltési hiba'
beerkalattlista=db((db.eszkozok.allapot_id==1) 
(db.eszkozok.tipus_id==db.eszkoztipus.id) 
(db.eszkozok.allapot_id==db.eszkozallapot.id) 
(db.eszkozok.hely_id==db.eszkozhelyek.id)).select(db.eszkozok.ALL,db.eszkoztipus.nev,db.eszkozallapot.nev,db.eszkozhelyek.nev,orderby=db.eszkozok.eszkozszam)
return
dict(beerkalattlista=beerkalattlista,form=form,rvars=request.vars,lastid=form.vars.id,sess=session,faccept=faccept)

This is the view:
{{extend 'layout.html'}}
h1Eszköz beérkeztetése/h1
hr /
pUser ID: {{=auth.user_id}}/p
prvars: {{=rvars}}/p
plen rvars 1: {{=(len(rvars)1)}}/p
pdarab: {{=rvars.darab}}/p
pfaccept: {{=faccept}}/p
{{if rvars.darabNone:}}
pdarab1: {{=(int(rvars.darab)1)}}/p
{{pass}}
plastid: {{=lastid}}/p
psession: {{=sess}}/p
perrors: {{=form.errors}}/p
h3Új beérkezés/h3
{{=form}}
hr /
h3Beérkezés alatt lévő eszközök/h3
table
tr
th{{=db.eszkozok.id.label}}/th
th{{=db.eszkozok.eszkozszam.label}}/th
th{{=db.eszkozok.aleszkozszam.label}}/th
th{{=db.eszkozok.darab.label}}/th
th{{=db.eszkozok.koltseghely.label}}/th
th{{=db.eszkozok.megnevezes.label}}/th
th{{=db.eszkozok.egyediazon.label}}/th
th{{=db.eszkozok.aktivalas.label}}/th
th{{=db.eszkozok.tipus_id.label}}/th
th{{=db.eszkozok.allapot_id.label}}/th
th{{=db.eszkozok.hely_id.label}}/th
thMűvelet/th
/tr
{{for row in beerkalattlista:}}
tr
td{{=row.eszkozok.id}}/td
td{{=row.eszkozok.eszkozszam}}/td
td{{=row.eszkozok.aleszkozszam}}/td
td{{=row.eszkozok.darab}}/td
td{{=row.eszkozok.koltseghely}}/td
td{{=row.eszkozok.megnevezes}}/td
td{{=row.eszkozok.egyediazon}}/td
td{{=row.eszkozok.aktivalas}}/td
td{{=row.eszkoztipus.nev}}/td
td{{=row.eszkozallapot.nev}}/td
td{{=row.eszkozhelyek.nev}}/td
td{{=A('raktárra
vétel',_href=URL('raktarra',args=row.eszkozok.id))}}/td
/tr
{{pass}}
table


[web2py] Re: sqlform form.accept bug? I am confused

2011-03-03 Thread sipiatti
additional info:
I keep trying to find the reasons :)
I realized that after the failed submit the form gets a new hidden
input with name=_formname and value=eszkozok_create, but the old
field datas are resetted to defaults. When this hidden field exists
the form.accept is OK.
How can I make sqlform to create this hidden field for the first visit
also?


[web2py] Re: no json - cont.

2011-03-03 Thread darkblue_b
 The problem is that not everything is json and rss serializable. What
 does your action look like?

 a controller has a function called get_companies()
The companies table was chosen because it is readable as flat, for
learning..
(interested in .html .json and then perhaps .csv)

def get_companies():
rows = db().select(
  db.companies.ALL,
  orderby=db.companies.company_short_name)

return dict(rows=rows, description='description')

##-

  I *do* use dates, but surprisingly, there are none here...

db.define_table('companies',
Field('pkey', type='integer'),
Field('company_full_name', type='text'),
Field('company_short_name', type='text'),
Field('net_sales', type='integer'),
primarykey=['pkey'],
migrate=migrate)

##---

  so I am not sure what is not serializable about companies
as a beginner, it does look like there is some room for improvement
here..
.html  .json  .xml  etc is a powerful facility. would be great to be
bulletproofed!




[web2py] Re: no json - cont.

2011-03-03 Thread darkblue_b

  @jonathan: Yes, a more detailed error messages than no json would be 
  awesome.

 generic.json now says:

 {{
 ###
 # response._vars contains the dictionary returned by the controller action
 ###
 try:
    from gluon.serializers import json
    response.write(json(response._vars),escape=False)
    response.headers['Content-Type']='text/json'
 except:
    raise HTTP(405,'no json')

 }}

 I suggest this instead:

 {{
 ###
 # response._vars contains the dictionary returned by the controller action
 ###
 try:
         from gluon.serializers import json
         response.write(json(response._vars), escape=False)
         response.headers['Content-Type'] = 'application/json'
 except (TypeError, ValueError):
         raise HTTP(405, 'JSON serialization error')
 except ImportError:
         raise HTTP(405, 'JSON not available')
 except:
         raise HTTP(405, 'JSON error')

 }}

I patched that in, and changed the last one to say

except Exception, E:
raise HTTP(405, 'JSON error: ' + str(E))

and got in my case
   JSON error: 'id'

  -Brian



[web2py] Re: sqlform form.accept bug? I am confused

2011-03-03 Thread sipiatti
Problem solved.
form.accept didn't reached if request.vars were empty so it could not
create the hidden fields.
I've moved it out from the if block and everything is ok now.


Re: [web2py] Re: should this be in the scaffolding app?

2011-03-03 Thread Martín Mulone
I like the idea, we can have it like plugins-widgets (plugins). So we can
choose widgets, for example if I want jgrowl instead of flash, add buttons,
menu, etc. How can we load the plugins in layout, but automaticaly without
coding in controllers, or in views?. Starting from a Hello World page.

2011/3/2 Michele Comitini michele.comit...@gmail.com

 It is nice to have as much features as we like at disposal, but a more
 modular approach would be nice.

 Web2py should have a directory containing all js , css , artwork
 like this buttons css framework.
 When a new application is created there should be a way to choose only
 the  needed pieces.  The chosen
 parts are then copied to the new application (otherwise upgrading
 web2py could break something)

 2011/3/2 pbreit pbreitenb...@gmail.com:
  That should be thin scaffold.




-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: LOAD auth.change_password form and over-ride the Redirect on success

2011-03-03 Thread Ab...
Okay, I modified my code as follows:

#
# Controller: ACCOUNT
#

def changePassword():
change_password = auth.change_password()
if change_password.accepts(request.vars, session,
onvalidation=validateChangePassword):
response.flash = Password updated
return change_password

def validateChangePassword(form):


old_pass  = form.vars.old_password
new_pass  = form.vars.new_password
new_pass2 = form.vars.new_password2

if not new_pass or new_pass.strip() == '':
form.errors.new_password = 'Can not be empty'
return False

if not new_pass2 or new_pass2.strip() == '':
form.errors.new_password2 = 'Can not be empty'
return False

return True

# End of Controller


Now validation works as desired and response.flash says Password
Updated when validation is passed. Only that the database doesn't get
updated and password doesn't really get updated. I am lost.

On Feb 26, 2:37 am, Carlos carlosgali...@gmail.com wrote:
 Isn't the redirect automatically happening via 
 auth.settings.change_password_next?,
 if this is the case, I believe you would need session.flash.

 Why are you using javascript's document.location=... instead of web2py's
 redirect?.

 The session.flash might be lost because of these javascript redirection.

On Feb 26, 2:37 am, Carlos carlosgali...@gmail.com wrote:
 Isn't the redirect automatically happening via 
 auth.settings.change_password_next?,
 if this is the case, I believe you would need session.flash.

 Why are you using javascript's document.location=... instead of web2py's
 redirect?.

 The session.flash might be lost because of these javascript redirection.


[web2py] Re: LOAD auth.change_password form and over-ride the Redirect on success

2011-03-03 Thread Ab...
Sorry, this is my def changePassword():

def changePassword():
change_password = auth.change_password()
if change_password.accepts(request.vars, session,
onvalidation=validateChangePassword):
response.flash = Password updated
return change_password


Re: [web2py] Re: should this be in the scaffolding app?

2011-03-03 Thread contatogilson...@gmail.com
Recommend this for plugin calendar:

http://jqueryui.com/demos/datepicker/

http://jqueryui.com/demos/datepicker/Att,
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/3/3 Martín Mulone mulone.mar...@gmail.com

 I like the idea, we can have it like plugins-widgets (plugins). So we can
 choose widgets, for example if I want jgrowl instead of flash, add buttons,
 menu, etc. How can we load the plugins in layout, but automaticaly without
 coding in controllers, or in views?. Starting from a Hello World page.

 2011/3/2 Michele Comitini michele.comit...@gmail.com

 It is nice to have as much features as we like at disposal, but a more

 modular approach would be nice.

 Web2py should have a directory containing all js , css , artwork
 like this buttons css framework.
 When a new application is created there should be a way to choose only
 the  needed pieces.  The chosen
 parts are then copied to the new application (otherwise upgrading
 web2py could break something)

 2011/3/2 pbreit pbreitenb...@gmail.com:
  That should be thin scaffold.




 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)
 http://www.tecnodoc.com.ar/

 My blog: http://martin.tecnodoc.com.ar
 Expert4Solution Profile:
 http://www.experts4solutions.com/e4s/default/expert/6





[web2py] plugin_wiki editor automatic formatting

2011-03-03 Thread Plumo
I want to embed some JavaScript in my plugin_wiki page but when I click 
Submit the script tags are removed. The Rich Text Editor often tries to 
help like this - changing tags, adding quotes, etc. 
For now I am using a plain text box. Is there a way to disable this 
automatic formatting?


[web2py] web2py powerpoint or slide presentation

2011-03-03 Thread Martín Mulone
Sometime ago I remember there was some .ppt web2py presentation, but I
couldn't find anymore. Anyone has it?

-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Please help me test this: plugins in wizard

2011-03-03 Thread Massimo Di Pierro
Get web2py trunk.

Use the wizard.

In Step 1 there is a new option at the bottom of the form that lets
you choose which plugins to install (try wiki for example).

Please report what works and what does not work.

Massimo


Re: [web2py] Please help me test this: plugins in wizard

2011-03-03 Thread Albert Abril
I created a new app with the wizard, chose mediaplayer plugin and worked
well.
Gonna test more plugins.

On Thu, Mar 3, 2011 at 3:58 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Get web2py trunk.

 Use the wizard.

 In Step 1 there is a new option at the bottom of the form that lets
 you choose which plugins to install (try wiki for example).

 Please report what works and what does not work.

 Massimo


Re: [web2py] web2py powerpoint or slide presentation

2011-03-03 Thread danto
here's another: http://ompldr.org/vN241Yg
ftr: despite is a very old version of web2py as you already know

2011/3/3 danto web2py.n...@gmail.com

 te lo envío en formato estándar. saludos.
 i sent you in standard format. greetings.

 2011/3/3 Martín Mulone mulone.mar...@gmail.com

 Sometime ago I remember there was some .ppt web2py presentation, but I
 couldn't find anymore. Anyone has it?

 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)
 http://www.tecnodoc.com.ar/

 My blog: http://martin.tecnodoc.com.ar
 Expert4Solution Profile:
 http://www.experts4solutions.com/e4s/default/expert/6






Re: [web2py] web2py powerpoint or slide presentation

2011-03-03 Thread Martín Mulone
Thanks danto,

2011/3/3 danto web2py.n...@gmail.com

 here's another: http://ompldr.org/vN241Yg
 ftr: despite is a very old version of web2py as you already know

 2011/3/3 danto web2py.n...@gmail.com

 te lo envío en formato estándar. saludos.
 i sent you in standard format. greetings.

 2011/3/3 Martín Mulone mulone.mar...@gmail.com

 Sometime ago I remember there was some .ppt web2py presentation, but I
 couldn't find anymore. Anyone has it?

 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)
 http://www.tecnodoc.com.ar/

 My blog: http://martin.tecnodoc.com.ar
 Expert4Solution Profile:
 http://www.experts4solutions.com/e4s/default/expert/6







-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Programmatically Build Table in View

2011-03-03 Thread Ross Peoples
I have begun to move from models, modules, and controllers into actually 
writing the view for my application. Now, I am at the point where I need to 
loop through a Rows object, building a TR for each row. I wrote a version 
that works by writing it in HTML, using {{=x}} where needed, but it looks 
all cluttered and difficult to read. This is the original code that works:

{{extend 'layout.html'}}
h1Time Clock for {{=user.first_name}} {{=user.last_name}}/h1
{{if len(rows)  0:}}
{{
def get_day_of_year(the_date):
return the_date.timetuple().tm_yday

def full_date_name(the_date):
return the_date.strftime('%A, %B %d, %Y')

def time_string(the_date):
return the_date.strftime('%I:%M %p')

prev_day_of_year = None
table_open = False
for row in rows:
if get_day_of_year(row.calculated_start) != prev_day_of_year:}}
{{if table_open:}}
/tbody/table
{{pass}}
h4{{=full_date_name(row.calculated_start)}}/h4
tabletheadtrthTime in:/ththTime 
out:/th/tr/theadtbody
   
 
trtd{{=time_string(row.calculated_start)}}/tdtd{{=time_string(row.calculated_end)}}/td/tr
{{table_open = True}}
{{prev_day_of_year = get_day_of_year(row.calculated_start)}}
{{else:}}
   
 
trtd{{=time_string(row.calculated_start)}}/tdtd{{=time_string(row.calculated_end)}}/td/tr
{{pass}}
{{pass}}
/tbody/table
h5Total hours worked this week: {{=hours_worked}}/h5
{{else:}}
h5No time clock entries for this week./h5
{{pass}}

I know that web2py has HTML helpers like TABLE(), TR(), etc, but how would I 
build a table in this way, while in a for loop? This is what I tried so far, 
but it fails so horribly I don't even know where the error is:

{{extend 'layout.html'}}
h1Time Clock for {{=user.first_name}} {{=user.last_name}}/h1
{{if len(rows)  0:}}
{{
def get_day_of_year(the_date):
return the_date.timetuple().tm_yday

def full_date_name(the_date):
return the_date.strftime('%A, %B %d, %Y')

def time_string(the_date):
return the_date.strftime('%I:%M %p')

prev_day_of_year = None
tables = []
trs = None
for row in rows:
if get_day_of_year(row.calculated_start) != prev_day_of_year:
if trs is not None:
tables[] = (H4(full_date_name(row.calculated_start)), 
trs)
trs = []

trs[] = TR((TD(time_string(row.calculated_start)), 
TD(time_string(row.calculated_end
prev_day_of_year = get_day_of_year(row.calculated_start)
else:
trs[] = TR((TD(time_string(row.calculated_start)), 
TD(time_string(row.calculated_end

for table in tables:
response.write(table[0])
response.write(TABLE(
(THEAD(
TR(
(TH('Time in:), TH('Time out'))
)
),
TBODY(

))
))
}}
h5Total hours worked this week: {{=hours_worked}}/h5
{{else:}}
h5No time clock entries for this week./h5
{{pass}}


Re: [web2py] Re: no json - cont.

2011-03-03 Thread Jonathan Lundell
On Mar 3, 2011, at 1:46 AM, darkblue_b wrote:
 
 
 @jonathan: Yes, a more detailed error messages than no json would be 
 awesome.
 
 generic.json now says:
 
 {{
 ###
 # response._vars contains the dictionary returned by the controller action
 ###
 try:
from gluon.serializers import json
response.write(json(response._vars),escape=False)
response.headers['Content-Type']='text/json'
 except:
raise HTTP(405,'no json')
 
 }}
 
 I suggest this instead:
 
 {{
 ###
 # response._vars contains the dictionary returned by the controller action
 ###
 try:
 from gluon.serializers import json
 response.write(json(response._vars), escape=False)
 response.headers['Content-Type'] = 'application/json'
 except (TypeError, ValueError):
 raise HTTP(405, 'JSON serialization error')
 except ImportError:
 raise HTTP(405, 'JSON not available')
 except:
 raise HTTP(405, 'JSON error')
 
 }}
 
 I patched that in, and changed the last one to say
 
 except Exception, E:
raise HTTP(405, 'JSON error: ' + str(E))
 
 and got in my case
   JSON error: 'id'

Ah. Let's find out a little more. I suggest two experiments.

The easier one: include E.__class__.__name__ in the string, so we can see 
what's being raised.

Then I'd like to see if we can force a ticket. Try changing the last raise to: 
raise SyntaxError, and if you get a stack trace, let's see where the exception 
is coming from.

When I took a look through the code, it looked to me like serialization errors 
were all causing Type or Value exceptions, but I might have missed something.

[web2py] Re: Testing accions that access the database.

2011-03-03 Thread howesc
I have been playing with this somewhat myself.

if you use doctests and run them via the admin interface then 
request.function == '_TEST'.  you can use that in db.py to set a different 
db connection string.  if the population of this db is quick you can do it 
in the doctest itself, or come up with a way to pre-populate it.  I'm still 
working on different ways to pre-populate my test database, and don't have 
anything very clean right now.

good luck!

christian


Re: [web2py] Please help me test this: plugins in wizard

2011-03-03 Thread Martín Mulone
I don't get it working.  Plugins

2011/3/3 Albert Abril albert.ab...@gmail.com

 I created a new app with the wizard, chose mediaplayer plugin and worked
 well.
 Gonna test more plugins.


 On Thu, Mar 3, 2011 at 3:58 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Get web2py trunk.

 Use the wizard.

 In Step 1 there is a new option at the bottom of the form that lets
 you choose which plugins to install (try wiki for example).

 Please report what works and what does not work.

 Massimo





-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread pbreit
I usually try to put less logic in my views. For one, I try to assemble all 
the data fields ahead of time either in the controller or with virtual 
fields.

Then in the view, I try to just end up looping through the dict. I normally 
use HTML tags but using Web2py tag helpers should be fine as well.

See example below. Notice that I have a sliver of logic in there to display 
no results if there are no items. Also note that I have a couple fields 
like item.last_date that I have generated as a virtual field. In this way, 
you keep your views looking mostly like regular pages of HTML with some 
logic here and there.

table width=100%
 thead
 tr
 th/th
 th class=ttlDescription/th
 th class=prcCurrent Price/th
 th class=prcFinal Price/th
 /tr
 /thead
tbody
{{if len(items)==0:}}
trtd colspan=4 align=middlebrNo items/td/tr
{{else:}}
{{for item in items:}}
tr
 td
 {{if len(item.image)==0:}}
{{=A(IMG(_src=URL('static','images/no-photo.png'), 
_width='80px'), _href=URL(c='default', f='item', extension='', args=item.id, 
))}}
{{else:}}   
{{=A(IMG(_src=URL(c='default', f='download', 
args=item.image), _width='100px'), _href=URL(c='default', f='item', 
extension='', args=item.id))}} 
{{pass}}
/td
 td class=ttl{{=A(item.title, _href=URL(c='default', 
f='item', extension='', args=item.id))}}/td
 td class=prcb${{=item.current_price}}/b/td
 td class=prc${{=item.last_price}} on 
{{=item.last_date}}/td
/tr
{{pass}}
{{pass}}
/tbody
/table


[web2py] Re: revised plugin_wiki

2011-03-03 Thread Massimo Di Pierro
Suggestions for a better name?

On Mar 2, 4:21 pm, villas villa...@gmail.com wrote:
 I think you may have deleted field 'active' by mistake.  If you re-
 instate it, could you call it something else please  :)

 On Mar 2, 10:02 pm, villas villa...@gmail.com wrote:







  Thanks for the upgrade. My immediate issues are...

  *** Reserved fieldname 'file' is still a problem (change to filename?)
  *** check_reserved=['all'] -- not working in DAL??


[web2py] Re: SocketTimeout: Socket timed out before request

2011-03-03 Thread Massimo Di Pierro
Thanks I was already in panic mode. ;-)

On Mar 2, 11:27 pm, Lennon lpru...@hotmail.com wrote:
 PROBLEM SOLVED

 Stupid Mistake.

 Please close/delete thread if possible or let me know how I can
 accomplish that.

 On Mar 3, 12:07 am, Lennon lpru...@hotmail.com wrote:







  Let me also add that I have:

  num_trav -= 1

  in the appropriate place to prevent an infinite loop that might be
  causing this.  But according to the debugger, the function isn't
  making it past:

  for k, v in request.vars.items()

  anyway.

  On Mar 2, 11:58 pm, Lennon lpru...@hotmail.com wrote:

   The following code got me a socket timeout error:

   for trip in session.trip_cart:
       t_id = trip['trip_instance']
       num_trav = trip['quantity'] - 1
       while num_trav  0:
           new_trav = dict()
           for k, v in request.vars.items():
               #get the field's trip_instance number
               #rest of code omitted.

   Traceback (most recent call last):
     File C:\Users\Lennon\workspace\web2py_source\gluon\rocket.py, line
   1064, in run
       self.run_app(conn)
     File C:\Users\Lennon\workspace\web2py_source\gluon\rocket.py, line
   1531, in run_app
       self.environ = environ = self.build_environ(sock_file, conn)
     File C:\Users\Lennon\workspace\web2py_source\gluon\rocket.py, line
   1363, in build_environ
       request = self.read_request_line(sock_file)
     File C:\Users\Lennon\workspace\web2py_source\gluon\rocket.py, line
   1138, in read_request_line
       raise SocketTimeout(Socket timed out before request.)
   SocketTimeout: Socket timed out before request.

   Through use of the debugger I've determined that the line that is
   causing the error is:

   for k, v in request.vars.items()

   This is strange to me because I've used that same line in other places
   but I've never had a problem with it.

   One possibility is that this code is part of a larger function (so now
   the function maybe takes too long?), but a the function ran fine
   before the above code was added.  I see that the socket times out
   after 10 seconds but this error seems to happen almost instantaneously
   when I submit my form.

   One last strange occurrence is that when I clicked the ticket for the
   above error, Google Chrome opened the ticket and also popped up the
   following message in an alert box:

   Exception during snapshot rendering: Traceback (most recent call
   last):
   File
   C:path_to_my_web2py/admin/viewsdefault/ticket.html, line
   170, in module
   KeyError: 'request'

   I've never had Google Chrome pop up an alert for any of my tickets
   although this might be unrelated.


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Ross Peoples
That was a very helpful example. Thank you. So using the web2py TABLE helpers 
is best used for creating simple, static tables where the rows aren't 
generated? I guess that's ok, I always thought that the controller was meant to 
get the data, while the views format the data. But if the web2py way is to 
format in the controller and make the views contain as little Python code as 
possible, then that's they way I'll write it.

On Mar 3, 2011, at 11:36 AM, pbreit wrote:

 I usually try to put less logic in my views. For one, I try to assemble all 
 the data fields ahead of time either in the controller or with virtual fields.
 
 Then in the view, I try to just end up looping through the dict. I normally 
 use HTML tags but using Web2py tag helpers should be fine as well.
 
 See example below. Notice that I have a sliver of logic in there to display 
 no results if there are no items. Also note that I have a couple fields 
 like item.last_date that I have generated as a virtual field. In this way, 
 you keep your views looking mostly like regular pages of HTML with some logic 
 here and there.
 
 table width=100%
   thead
   tr
   th/th
   th class=ttlDescription/th
   th class=prcCurrent Price/th
   th class=prcFinal Price/th
   /tr
   /thead
 tbody
 {{if len(items)==0:}}
 trtd colspan=4 align=middlebrNo items/td/tr
 {{else:}}
 {{for item in items:}}
 tr
   td
   {{if len(item.image)==0:}}
 {{=A(IMG(_src=URL('static','images/no-photo.png'), 
 _width='80px'), _href=URL(c='default', f='item', extension='', args=item.id, 
 ))}}
 {{else:}}   
 {{=A(IMG(_src=URL(c='default', f='download', 
 args=item.image), _width='100px'), _href=URL(c='default', f='item', 
 extension='', args=item.id))}} 
 {{pass}}
 /td
   td class=ttl{{=A(item.title, _href=URL(c='default', 
 f='item', extension='', args=item.id))}}/td
   td class=prcb${{=item.current_price}}/b/td
   td class=prc${{=item.last_price}} on 
 {{=item.last_date}}/td
 /tr
 {{pass}}
 {{pass}}
 /tbody
 /table



[web2py] Re: Please help me test this: plugins in wizard

2011-03-03 Thread Massimo Di Pierro
?

On Mar 3, 10:32 am, Martín Mulone mulone.mar...@gmail.com wrote:
 I don't get it working.  Plugins

 2011/3/3 Albert Abril albert.ab...@gmail.com









  I created a new app with the wizard, chose mediaplayer plugin and worked
  well.
  Gonna test more plugins.

  On Thu, Mar 3, 2011 at 3:58 PM, Massimo Di Pierro 
  massimo.dipie...@gmail.com wrote:

  Get web2py trunk.

  Use the wizard.

  In Step 1 there is a new option at the bottom of the form that lets
  you choose which plugins to install (try wiki for example).

  Please report what works and what does not work.

  Massimo

 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/

 My blog:http://martin.tecnodoc.com.ar
 Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: plugin_wiki editor automatic formatting

2011-03-03 Thread Massimo Di Pierro
If you are using plugin wiki with level=2 than you can embed script:

``script/script``:template

you can even use {{...}} inside ``...``.

On Mar 3, 7:55 am, Plumo richar...@gmail.com wrote:
 I want to embed some JavaScript in my plugin_wiki page but when I click
 Submit the script tags are removed. The Rich Text Editor often tries to
 help like this - changing tags, adding quotes, etc.
 For now I am using a plain text box. Is there a way to disable this
 automatic formatting?


[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-03 Thread pbreit
I think you can pass in the delimiter:

export_to_csv(delimiter = ',', quotechar = '', quoting = csv.QUOTE_MINIMAL)



[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-03 Thread Massimo Di Pierro
You cannot change the default bahavior. You need to call these
functions yourself in your code with the delimiter argument.
You can also edit the appadmin.py in your app.

On Mar 3, 10:33 am, Eduardo meketr...@gmail.com wrote:
 Hi,

 What function in what file should I modify to change the default
 behaviour of both import_from_csv( ) and export_to_csv( )? I need to
 make delimiter=\t the default behaviour.

 I modified those functions within dal.py with no success.

 Thanks,

 Eduardo


[web2py] Re: Please help me test this: plugins in wizard

2011-03-03 Thread Anthony
On Thursday, March 3, 2011 9:58:50 AM UTC-5, Massimo Di Pierro wrote: 

 Get web2py trunk. 

 Use the wizard. 

 In Step 1 there is a new option at the bottom of the form that lets 
 you choose which plugins to install (try wiki for example). 

 Please report what works and what does not work.

 
It's not quite working for me (on Windows 7). It appears the plugins are 
being downloaded to my /deposit/ folder, but they are not then being 
installed into the application (though I don't receive any error message or 
ticket). I notice that the downloaded files do not have the full w2p plugin 
name (e.g., 'web2py.plugin.wiki.w2p') -- instead, they just have the name of 
the plugin itself without any prefix or extension (e.g., 'wiki'). Not sure 
if that's intended or makes a difference.
 
Also, it would be nice if the list of plugins could be sorted alphabetically 
in the select box.
 
As an aside, it is not at all obvious that the way to get back to the wizard 
to edit an application is to start a new wizard session and simply enter the 
name of an existing app. It might be helpful if there was an Edit in 
Wizard button somewhere, either on the site page or the application's 
design page (with appropriate warnings that the application will be 
overwritten).
 
Anthony


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread danto
2011/3/3 Ross Peoples ross.peop...@gmail.com

 (...)But if the web2py way is to format in the controller and make the
 views contain as little Python code as possible, then that's they way I'll
 write it.

 is not web2py's way, is MVC (Model-View-Controller) paradigm. it's all
about separating logic from what end users view considerating some
abstraction layers (model  controller  view). wikipedia could bring a some
info too.

regards


[web2py] changing export_to_csv( )'s default behaviour

2011-03-03 Thread Eduardo
Hi,

What function in what file should I modify to change the default
behaviour of both import_from_csv( ) and export_to_csv( )? I need to
make delimiter=\t the default behaviour.

I modified those functions within dal.py with no success.

Thanks,

Eduardo


Re: [web2py] Re: Please help me test this: plugins in wizard

2011-03-03 Thread Martín Mulone
The same as anthony

2011/3/3 Anthony abasta...@gmail.com

 On Thursday, March 3, 2011 9:58:50 AM UTC-5, Massimo Di Pierro wrote:

 Get web2py trunk.

 Use the wizard.

 In Step 1 there is a new option at the bottom of the form that lets
 you choose which plugins to install (try wiki for example).

 Please report what works and what does not work.


 It's not quite working for me (on Windows 7). It appears the plugins are
 being downloaded to my /deposit/ folder, but they are not then being
 installed into the application (though I don't receive any error message or
 ticket). I notice that the downloaded files do not have the full w2p plugin
 name (e.g., 'web2py.plugin.wiki.w2p') -- instead, they just have the name of
 the plugin itself without any prefix or extension (e.g., 'wiki'). Not sure
 if that's intended or makes a difference.

 Also, it would be nice if the list of plugins could be sorted
 alphabetically in the select box.

 As an aside, it is not at all obvious that the way to get back to the
 wizard to edit an application is to start a new wizard session and simply
 enter the name of an existing app. It might be helpful if there was an Edit
 in Wizard button somewhere, either on the site page or the application's
 design page (with appropriate warnings that the application will be
 overwritten).

 Anthony




-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: web2py hangs with multiple users due to sqllite

2011-03-03 Thread Massimo Di Pierro
I do not know. I do not think it was a corrupt system but if the
problem comes back let us know.

On Mar 3, 1:09 am, Markus Schmitz mschm...@soft-impact.com wrote:
 Hi Massimo and everybody else,

 sorry for my late reply. I was out for two days presenting a prototype
 based on web2py on a conference and just came back to the office. As a
 quick feedback: Attendees were really impressed and excited about,
 what they saw.

 Now back to my problem:

 I am a bit embarrassed and also confused. Today in the morning I first
 reproduced the problem a couple of times. I started the first browser
 (chrome). web2py answers immediately. I started the second (firefox)
 and it hangs for around 2 minutes and then comes back.

 Then I tried the session unlock bit and the behavior vanished. But now
 it comes, I removed the session unlock from the code and now I can not
 reproduce the problem anymore

 What is going on? Did I have a hanging/corrupt session? That session
 is somehow on disk as it even survived a restart of my development
 machine?

 Confused, as I do not understand, and embarrassed, as I can reproduce
 my own problems.

 :-)

 Thanks

 Markus

 On Mar 1, 8:56 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  Try add

  session._unlock(request)

  at the top of the controller. Does it still lock?

  On Mar 1, 12:55 am, Markus Schmitz mschm...@soft-impact.com wrote:

   Hi everybody,

   on my development system I use sqllite, because it allows me to
   conveniently backup my database, which contains a good amount of
   configuration data.

   In principle and as long as I access the web site alone, this works
   fine. But as soon as two users or I myself access the web site with
   two different browsers, the second browser hangs, when fetching the
   page.

   More or less all my pages write some data to a table for logging
   purposes on access, so when the first browser connects, sqllite locks
   the DB. When the second browser connects, the DB is still locked, even
   though the page of the first request is long delivered.

   This only happens under sqllite, not MySQL etc. Also when I disable
   the logging (ie. the write access) it does not happen.

   Any ideas? Do I have to explicitly commit or close the DB connection?

   Thanks

   Markus


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread pbreit
Well, I wouldn't necessarily say that's the web2py way. I just like to 
keep the logic in my views minimal. For example, the virtual fields are 
actually in the models which is also a good place to prepare your data.

One reason to limit logic in views is if you ever have graphic designers 
working on your views which is common in larger projects.

Some people like to have their code generate all of the HTML. I tend to 
prefer making it look like HTML with limited substitutions via code.


[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-03 Thread pbreit
I would think it'd at least be possible to edit the code directly if not 
subclass/override it? Is that a problem because other components depend on 
its default behavior?

Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Anthony
On Thursday, March 3, 2011 11:44:41 AM UTC-5, Ross Peoples wrote: 

 That was a very helpful example. Thank you. So using the web2py TABLE 
 helpers is best used for creating simple, static tables where the rows 
 aren't generated?

 
I think you should be able to build a table programmatically using helpers. 
See the TABLE, TR, TD section here: 
http://www.web2py.com/book/default/chapter/05#Built-in-Helpers (shows an 
example using a list comprehension).
 

 I guess that's ok, I always thought that the controller was meant to get 
 the data, while the views format the data.

 
That's probably the right way to think about it (from an MVC perspective), 
though I suppose what it means for the view to get the data can be a 
judgment call. You have to decide how you want to structure the data before 
passing it to the view for presentation. In your case, it looks like you've 
got a single set of rows, which you are then breaking into multiple tables 
-- so you have to ask yourself whether it makes sense for the controller 
(business logic) to decide how to break up the rows into separate tables, or 
whether that's purely a presentation issue. If the former, then maybe create 
a data structure that breaks up the rows in the controller, and have the 
view simply build the table for each set of rows returned by the controller. 
You might also think about what you would want the controller to return in 
case its output was going to a different view (e.g., JSON) -- if you need to 
structure the data differently depending on the view, then it might make 
sense to do the structuring in the view rather than the controller.
 
Anthony


[web2py] Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
I tested my app with version 1.92.1 and it works. I then copied it to trunk 
and I can no longer connect to the PostgreSQL database I use.

I looked at the code in dal.py for the PostgreSQL adapter and driver_args 
defaults to empty dict {}, adding some debug print code shows it is set on 
the class construction to be {'check_same_thread': False} and when this is 
passed to the driver an invalid keyword argument error occurs

Here is a traceback from the ticket.

web2py™ Version 1.92.1 (2011-03-03 08:26:32)  Python Python 2.6.5: 
/usr/bin/python  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File /home/camcentral/Dev/web2py-hg/gluon/restricted.py, line 188, in 
restricted
exec ccode in environment
  File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py 
http://127.0.0.1:8000/admin/default/edit/ccims/models/A_db.py, line 22, in 
module
db = DAL('postgres://user:password@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
  File /home/camcentral/Dev/web2py-hg/gluon/dal.py, line 3529, in __init__
raise RuntimeError, Failure to connect, tried 5 times:\n%s % error
RuntimeError: Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function

 Error snapshot [image: help] Detailed traceback description 

type 'exceptions.RuntimeError'(Failure to connect, tried 5 times: 
'check_same_thread' is an invalid keyword argument for this function) 
Frames

   -  
   
   *File /home/camcentral/Dev/web2py-hg/gluon/restricted.py in restricted at 
   line 188* code arguments variables 
Function argument list 
   
   (code='# -*- coding: utf-8 -*- \n# this file is 
   released...sion.table_name.requires = IS_IN_SET(db.tables)\n\n', 
   environment={'A': class 'gluon.html.A', 'B': class 'gluon.html.B', 
   'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 
   'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 
   'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': 
   class 'gluon.html.CODE', 'COUPLE_MENUS': True, 'CRYPT': class 
   'gluon.validators.CRYPT', ...}, 
   layer='/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py')
Code listing 
   
   183.
   184.
   185.
   186.
   187.
   188.
   
   189.
   190.
   191.
   192.
   
   if type(code) == types.CodeType:
   ccode = code
   else:
   ccode = compile2(code,layer)
   
   exec ccode in environment
   
   except HTTP:
   raise
   except Exception:
   # XXX Show exception in Wing IDE if running in debugger
   
Variables  environment {'A': class 'gluon.html.A', 'B': class 
   'gluon.html.B', 'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 
   'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 
   'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': 
   class 'gluon.html.CODE', 'COUPLE_MENUS': True, 'CRYPT': class 
   'gluon.validators.CRYPT', ...}  ccode code object module at 
   0x30bda08, file /home/...py-hg/applications/ccims/models/A_db.py, line 8  
-  
   
   *File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py in 
   module at line 22* code arguments variables 
Function argument list 
   
   ()
Code listing 
   
   17.
   18.
   19.
   20.
   21.
   22.
   
   23.
   24.
   25.
   26.
   
   # else use a normal relational database
   #*** Add customization
   #   db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or other 
DB
   # CamCentral IMS configuration database
   #   db = DAL('mysql://root:pass@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
   db = DAL('postgres://user:password@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
   
   ## if no need for session
   # session.forget()
   
   #
   
Variables  DAL class 'gluon.dal.DAL'  check_reserved undefined  
   POOL_SIZE 0  db undefined  check_reserved_value ['all']  
-  
   
   *File /home/camcentral/Dev/web2py-hg/gluon/dal.py in __init__ at line 
   3529* code arguments variables 
Function argument list 
   
   (self=DAL {'_lastsql': '', '_db_codec': 'UTF-8', '_ur...cc_ims', 
   '_pool_size': 0, '_dbname': 'postgres'}, 
   uri='postgres://user:password@localhost/cc_ims', pool_size=0, folder=None, 
   db_codec='UTF-8', check_reserved=['all'], migrate=True, fake_migrate=False, 
   decode_credentials=False, driver_args={'check_same_thread': False})
   



[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-03 Thread Eduardo
Thank you all. Editing appadmin will do. I am, however, having a hard
time identifying export_to_csv( ) either in views/appadmin.html or
appadmin.py. While import_from_csv is clearly called from within
appadmin.import_csv, I am unable to identify how export_to_csv is
called there.

Thanks for your time,

Eduardo

On 3 mar, 13:49, Massimo Di Pierro massimo.dipie...@gmail.com wrote:
 You cannot change the default bahavior. You need to call these
 functions yourself in your code with the delimiter argument.
 You can also edit the appadmin.py in your app.

 On Mar 3, 10:33 am, Eduardo meketr...@gmail.com wrote:

  Hi,

  What function in what file should I modify to change the default
  behaviour of both import_from_csv( ) and export_to_csv( )? I need to
  make delimiter=\t the default behaviour.

  I modified those functions within dal.py with no success.

  Thanks,

  Eduardo




[web2py] FYI jQuery 1.5.1 breaks jQueryUI buttonsets

2011-03-03 Thread ron_m
The latest web2py trunk jQuery is 1.5.1

If using a buttonset from the jQueryUI Button widget the Javascript trips on 
the label tag 'for' attribute and throws an error leaving the buttonset as a 
set of radio boxes instead of making them into buttons. This can be seen in 
the jQueryUI Button Toolbar demo as an example 
(http://jqueryui.com/demos/button/).

I haven't figured it out yet and I am not discouraging web2py from moving 
forward to 1.5.1, I am just mentioning this to document it. I can keep my 
application at jQuery 1.4.4 until this is fixed by the jQuery/jQueryUI 
group.


[web2py] Losing session vars

2011-03-03 Thread Joe Barnhart
My fledgling app is driving users crazy.  I use the session to store a
list of strings, and then use prev and next controllers to
redirect to a page by indexing into that list.  Ever since I enabled
this feature, users randomly lose their auth and are forced to re-
logon.  This blows away the list and index and forces them to restart
the sequence.

I've read all about session vars and how they need to be serialized.
The list is a simple Python list of either ints or strings (I've tried
both).  I also store the current index pointer into the list, again as
either a string or int.  The effect is completely random -- sometimes
it will let you next or prev without complaint and then *bam*
suddenly it forces you to re-logon with every click of next or
prev.

Here is the string version of next:

def event_next():
if  session.eventlist and (int(session.eventptr)=0):
tmp=int(session.eventptr)+1
if tmp=len(session.eventlist):
tmp=0
session.eventptr=str(tmp)
 
redirect(URL('meet','signup',args=[int(session.eventlist[tmp])]))
session.flash=Lost sync with events!
redirect(URL('meet','index'))

Is there a better way?  These session vars are driving me crazy!

-- Joe


Re: [web2py] Re: Please help me test this: plugins in wizard

2011-03-03 Thread Albert Abril
I had no problem, I've run web2py from google code repository, with an
updated ubuntu 10.10.

On Thu, Mar 3, 2011 at 5:55 PM, Martín Mulone mulone.mar...@gmail.comwrote:

 The same as anthony

 2011/3/3 Anthony abasta...@gmail.com

 On Thursday, March 3, 2011 9:58:50 AM UTC-5, Massimo Di Pierro wrote:

 Get web2py trunk.

 Use the wizard.

 In Step 1 there is a new option at the bottom of the form that lets
 you choose which plugins to install (try wiki for example).

 Please report what works and what does not work.


 It's not quite working for me (on Windows 7). It appears the plugins are
 being downloaded to my /deposit/ folder, but they are not then being
 installed into the application (though I don't receive any error message or
 ticket). I notice that the downloaded files do not have the full w2p plugin
 name (e.g., 'web2py.plugin.wiki.w2p') -- instead, they just have the name of
 the plugin itself without any prefix or extension (e.g., 'wiki'). Not sure
 if that's intended or makes a difference.

 Also, it would be nice if the list of plugins could be sorted
 alphabetically in the select box.

 As an aside, it is not at all obvious that the way to get back to the
 wizard to edit an application is to start a new wizard session and simply
 enter the name of an existing app. It might be helpful if there was an Edit
 in Wizard button somewhere, either on the site page or the application's
 design page (with appropriate warnings that the application will be
 overwritten).

 Anthony




 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)
 http://www.tecnodoc.com.ar/

 My blog: http://martin.tecnodoc.com.ar
 Expert4Solution Profile:
 http://www.experts4solutions.com/e4s/default/expert/6





Re: [web2py] Please help me test this: plugins in wizard

2011-03-03 Thread Bruno Rocha
I am running Ubuntu 11.04, for me if I try with just one plugin it works,
when I select multiple plugins this installs just plugin_layout, other
plugins are downladed to deposit but not unpacked.


--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] Re: Losing session vars

2011-03-03 Thread ron_m
Is eventlist constant for the application? If so put it in the model or if 
in a module use local_import. Then all you need in session is the current 
index into the array the user is at.

If eventlist changes then there is no code showing how it is manipulated so 
it difficult to help. I would also believe that a variable eventlist would 
be difficult to debug.

On the redirect call above I am not sure why you are converting 
session.eventlist[tmp] to an int. It might be converted back to a str by the 
URL function but for sure it ultimately ends up as part of a larger string 
to form the full URL.

Finally are users opening the application more than once from the same 
client PC? If so the same browser tabs/windows will all use the same 
session. Also not sure if this is a problem but are the users behind a NAT 
box (typical of small office and home routers) and the server is elsewhere 
because this will put all the PCs behind the NAT at the same client IP which 
I believe causes sessions to be shared.



[web2py] [new slice] Flickr API photosets and web2py

2011-03-03 Thread Bruno Rocha
Flickr API by photoset
http://web2pyslices.com/main/slices/take_slice/122


--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] Slice requests

2011-03-03 Thread Bruno Rocha
Hi all, in web2pyslices.com we have a slice request page, I see many people
requesting slices there, but not all have answer,
this system is being modified for the web2pyslices2.0, but, if somebody here
has ideas for the current slice requests.

take a look at: http://web2pyslices.com/main/slices/request_slice
 http://web2pyslices.com/main/slices/make_slice?slice_request=3


--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread pbreit
And furthering my example, in that very same view I have another table that 
displays the same set of items in grid format. Note I included a counter i 
and a modulo 4 to insert a /trtr to break it up into rows of 4 
columns. Also note the logic that inserts a placeholder image if an image is 
not present.

So it's not that there is no logic in the view, it's just keeping it sort of 
minimal. Also, I expect to move the styles into css files at some point.


table
tbody
{{if len(items)==0:}}
trtd colspan=4 align=middlebrNo items/td/tr
{{else:}}
tr
{{i=1}}
{{for item in items:}}
 td width=180
p{{if len(item.image)==0:}}
   
 {{=A(IMG(_src=URL('static','images/no-photo.png'), _width='160px'), 
_href=URL(c='default', f='item', extension='', args=item.id, ))}}
{{else:}}   
{{=A(IMG(_src=URL(c='default', f='download', 
args=item.image), _width='160px'), _href=URL(c='default', f='item', 
extension='', args=item.id))}} 
{{pass}}/p
p style=min-height: 34px;{{=A(item.title, 
_href=URL(c='default', f='item', extension='', args=item.id))}}/p
ptable width=100%trtd style=padding: 2px 0px 
2px 2px;b${{=item.current_price}}/bbr/td
td align=right style=padding: 2px 8px 2px 
2px;${{=item.last_price}} on {{=item.last_date}}/td/tr/table
 /td/p
{{if i%4==0:}}
/tr
tr
{{pass}}
{{i+=1}}
{{pass}}
/tr
{{pass}}
/tbody
/table


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread pbreit
I probably could modulo the size of dict instead of using a counter but I 
didn't take the time to figure that out. Any assistance on that?

[web2py] Re: Losing session vars

2011-03-03 Thread Joe Barnhart
Hi Ron --

The eventlist is populated by a database query that returns the ids of
a set of objects.  The prev and next page flips thru the database
ids one at a time and allows adding objects through the database
entry.  It's a little complicated.  The application is a signup app
for a high-school swim meet, and each database id represents one
event.  At each event, users (coaches) are allowed to add records that
represent swimmers signing up for that event.

I don't believe it matters how the eventlist is created -- it's just a
Python list object containing strings or integers (not at the same
time -- I tried each to see if it affects the session var).  It is
established once when the coach clicks on the meet he wants to sign up
for, and then does not change until he chooses another meet.

The problem is that the user gets logged off sometimes when next or
prev is clicked.  My guess is that something in the session variable
is not pickleable and is causing the session read-back to fail, thus
forcing the re-logon and loss of the session vars.  But I've been
careful to not add anything but simple Python objects to session
vars.  (At least that I can find!)

-- Joe B.

P.S.  Good tip on the URL and int.  I just converted from using ints
to strings and didn't think thru the URL function.  You're probably
right -- I'll bet it converts to str when it emits which will save me
the int call.

On Mar 3, 10:50 am, ron_m ron.mco...@gmail.com wrote:
 Is eventlist constant for the application? If so put it in the model or if
 in a module use local_import. Then all you need in session is the current
 index into the array the user is at.

 If eventlist changes then there is no code showing how it is manipulated so
 it difficult to help. I would also believe that a variable eventlist would
 be difficult to debug.

 On the redirect call above I am not sure why you are converting
 session.eventlist[tmp] to an int. It might be converted back to a str by the
 URL function but for sure it ultimately ends up as part of a larger string
 to form the full URL.

 Finally are users opening the application more than once from the same
 client PC? If so the same browser tabs/windows will all use the same
 session. Also not sure if this is a problem but are the users behind a NAT
 box (typical of small office and home routers) and the server is elsewhere
 because this will put all the PCs behind the NAT at the same client IP which
 I believe causes sessions to be shared.


[web2py] Re: Flickr API photosets and web2py

2011-03-03 Thread Massimo Di Pierro
+1 can you make a plugin (just call it plugin_flikr.py) and email it
to me?

On Mar 3, 12:53 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Flickr API by photosethttp://web2pyslices.com/main/slices/take_slice/122

 --
 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]


[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Joe Barnhart
One thing I find handy about the helper objects is that they can be
treated as lists:

{{t=TABLE()}}
...
{{t.append(TR(val11,val12,val13))
...
{{t.append(TR(val21,val22,val23))
...
{{=t}}  -- this is when the table is added to the response

Note that you also do not need to use TD objects specifically (unless
you want to add class, etc.)  TR will take multiple args and wrap each
with a TD automatically.

-- Joe

On Mar 3, 11:06 am, pbreit pbreitenb...@gmail.com wrote:
 I probably could modulo the size of dict instead of using a counter but I
 didn't take the time to figure that out. Any assistance on that?


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Ross Peoples
Thanks Joe, I was wondering about this.

On Mar 3, 2011, at 2:44 PM, Joe Barnhart wrote:

 One thing I find handy about the helper objects is that they can be
 treated as lists:
 
 {{t=TABLE()}}
 ...
 {{t.append(TR(val11,val12,val13))
 ...
 {{t.append(TR(val21,val22,val23))
 ...
 {{=t}}  -- this is when the table is added to the response
 
 Note that you also do not need to use TD objects specifically (unless
 you want to add class, etc.)  TR will take multiple args and wrap each
 with a TD automatically.
 
 -- Joe
 
 On Mar 3, 11:06 am, pbreit pbreitenb...@gmail.com wrote:
 I probably could modulo the size of dict instead of using a counter but I
 didn't take the time to figure that out. Any assistance on that?



[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
Additional information:

I added a print to the front end of DAL.__init__ and was surprised to find 
driver_args was set to {'check_same_thread': False} but I did not set it in 
my db = DAL() class constructor call.

So here is the issue. I start up the development environment on Linux with a 
terminal command python web2py.py sitting in the correct web2py directory. 
Because I have Tcl/TK installed on the system it comes up, solicits an admin 
password and then I start the server.

This in turn brings up a browser window running the welcome application. The 
welcome application as written uses SQLLite as the database and since it is 
default installed in Python = 2.5 I have the driver and a connection 
succeeds. The SQLLite adapter does use this driver_args parameter and if it 
is not set forces it to the value I am seeing.

Somehow driver_args gets stored globally and becomes the default for all 
other adapter calls to __init__ on any other driver as well.

To test this theory I commented out the db=DAL(...) line in db.py in the 
welcome application and restarted the server. This caused the welcome app to 
crash during the TclTk solicited start of the welcome app when the browser 
is opened but at least the DAL did not get initialized using the SQLLite 
database.

Now I am able to run my own application and the driver_args = {} which would 
be correct for the PostgreSQL adapter.

Hope that helps isolate it a little better.

Ron




Re: [web2py] Re: Flickr API photosets and web2py

2011-03-03 Thread Bruno Rocha
2011/3/3 Massimo Di Pierro massimo.dipie...@gmail.com

 +1 can you make a plugin (just call it plugin_flikr.py) and email it
 to me?


Yes! I put it in my TODO, in this slice I am using the API method
photosets.getPhotos
I will try to include the option to get photo by search for tags and by
username.

I will pack it in a plugin ASAP.


[web2py] Re: Deleting a cookie

2011-03-03 Thread Lord Ezrik
Hey there, Dane.

I ran in to this same problem, needing to delete a cookie.  Just
wanted to let you know the solution that worked for me was to ALSO set
the path just as you would when you were setting the cookie.

For instance:

- Setting the cookie:

response.cookies['test_cookie'] = 'valid'
response.cookies['test_cookie']['expires'] = 3600
response.cookies['test_cookie']['path'] = '/'

- Delete cookie

response.cookies['test_cookie'] = 'invalid'
response.cookies['test_cookie']['expires'] = -10
response.cookies['test_cookie']['path'] = '/'

Works for me. Let me know if you have any luck.

Hope that helps!

-Oliver

On Feb 7, 2:11 pm, Dane dane.schnei...@gmail.com wrote:
 Ok, now I'm using this code:

 for r in [request, response]:
         if r.cookies.has_key('user'):
             r.cookies['user']['expires'] =
 datetime.datetime.strftime(datetime.datetime(2011,1,1,0,0), %a, %d-%b-
 %Y %H:%M:%S GMT)
             print 'remove %s usercookie' % ('request' if r == request
 else 'response')

 And still mycookieisn't going away...

 On Feb 7, 9:28 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







 http://msdn.microsoft.com/en-us/library/ms178195.aspx

  You cannot directlydeleteacookieon a user's computer. However,
  you can direct the user's browser todeletethecookieby setting the
 cookie'sexpiration date to a past date. The next time a user makes a
  request to a page within the domain or path that set thecookie, the
  browser will determine that thecookiehas expired and remove it.

  On Feb 7, 1:28 am, Dane dane.schnei...@gmail.com wrote:

   Hello,

   I've got my own user system (not using Auth), and I'm trying to
   implement a Remember Me option with cookies. It's working fine when
   the user selects 'Yes' for remember me. Setting and detecting the
  cookieis no problem, but I can't find a way todeletethecookiewhen
   the user logs out or selects 'No'. Here's my code which attempts
   everything I can think of.

   if request.cookies.has_key('user'):
           request.cookies['user'].clear()
           del request.cookies['user']
           print 'remove request usercookie'
   if response.cookies.has_key('user'):
           response.cookies['user'].clear()
           del response.cookies['user']
           print 'remove response usercookie'

   After running this, request.cookies.has_key('user') is still returning
   true and thecookie'sdata is still present.

   Ideas? Thanks.


[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Anthony
On Thursday, March 3, 2011 10:31:18 AM UTC-5, Ross Peoples wrote: 

 I know that web2py has HTML helpers like TABLE(), TR(), etc, but how would 
 I build a table in this way, while in a for loop? This is what I tried so 
 far, but it fails so horribly I don't even know where the error is: 

  {{extend 'layout.html'}}
 h1Time Clock for {{=user.first_name}} {{=user.last_name}}/h1
 {{if len(rows)  0:}}
 {{
 def get_day_of_year(the_date):
 return the_date.timetuple().tm_yday
 
 def full_date_name(the_date):
 return the_date.strftime('%A, %B %d, %Y')
 
 def time_string(the_date):
 return the_date.strftime('%I:%M %p')
 
 prev_day_of_year = None
 tables = []
 trs = None
 for row in rows:
 if get_day_of_year(row.calculated_start) != prev_day_of_year:
 if trs is not None:
 tables[] = (H4(full_date_name(row.calculated_start)), 
 trs)
 trs = []
 
 trs[] = TR((TD(time_string(row.calculated_start)), 
 TD(time_string(row.calculated_end
 prev_day_of_year = get_day_of_year(row.calculated_start)
 else:
 trs[] = TR((TD(time_string(row.calculated_start)), 
 TD(time_string(row.calculated_end

 
Am I missing something here? Where are you building a table -- I don't see 
any calls to TABLE(), just TR(). Also, I'm not sure about your syntax. It 
looks like you are passing a tuple of TD's to TR instead of passing the TD's 
as separate arguments (i.e., there's an extra set of parentheses inside TR). 
Finally, what is 'trs[] =' doing -- I think that will raise a syntax error. 
You should be able to create a table object (e.g., table = TABLE()), and 
then append TR's to it via append -- e.g., table.append(TR('cell 1', 'cell 
2')).
 
Anthony
 


[web2py] Re: revised plugin_wiki

2011-03-03 Thread villas
Well I used 'activated'.  I suppose 'visible' or 'live' might also be
suitable (but I didn't check those yet).


On Mar 3, 4:33 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Suggestions for a better name?

 On Mar 2, 4:21 pm, villas villa...@gmail.com wrote:

  I think you may have deleted field 'active' by mistake.  If you re-
  instate it, could you call it something else please  :)

  On Mar 2, 10:02 pm, villas villa...@gmail.com wrote:

   Thanks for the upgrade. My immediate issues are...

   *** Reserved fieldname 'file' is still a problem (change to filename?)
   *** check_reserved=['all'] -- not working in DAL??




[web2py] Re: revised plugin_wiki

2011-03-03 Thread villas
And of course 'is_active' matches 'is_public'...

On Mar 3, 4:33 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Suggestions for a better name?

 On Mar 2, 4:21 pm, villas villa...@gmail.com wrote:

  I think you may have deleted field 'active' by mistake.  If you re-
  instate it, could you call it something else please  :)

  On Mar 2, 10:02 pm, villas villa...@gmail.com wrote:

   Thanks for the upgrade. My immediate issues are...

   *** Reserved fieldname 'file' is still a problem (change to filename?)
   *** check_reserved=['all'] -- not working in DAL??




Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Ross Peoples
After seeing all the other posts, I completely rewrote the whole thing. I 
grouped the data in the controller so that entries on the same day will be in 
the same list, making easier to put each day of entries into its own table. I 
have really advanced the whole thing since my original post. Here is my 
controller:

def format_minutes(minutes):
hours = round(minutes / 60)
if hours == 0:
return 00:%02d % (minutes)
else:
minutes -= minutes * hours
return %02d:%02d % (hours, minutes)

def format_full_date(the_date):
return the_date.strftime('%A, %B %d, %Y')

# get information from database
week_start, week_end = timeclock.get_week_range_for_date()
rows = timeclock.list_for_user(auth.user, week_start, week_end)
minutes_worked = timeclock.get_minutes_for_this_week(auth.user)
minutes_vacation = timeclock.get_minutes_for_this_week(auth.user, 2)
minutes_personal = timeclock.get_minutes_for_this_week(auth.user, 3)
minutes_sick = timeclock.get_minutes_for_this_week(auth.user, 4)
minutes_total = minutes_worked + minutes_vacation + minutes_personal + 
minutes_sick

# begin formatting minutes for the week
hours_worked = format_minutes(minutes_worked)
hours_vacation = format_minutes(minutes_vacation)
hours_personal = format_minutes(minutes_personal)
hours_sick = format_minutes(minutes_sick)
hours_total = format_minutes(minutes_total)

# group entries together to make it easier for the view
grouped_entries = dict()
for row in rows:
full_date = format_full_date(row.calculated_start)
if full_date in grouped_entries:
grouped_entries[full_date].append(row)
else:
grouped_entries[full_date] = [row]

return dict(grouped_entries=grouped_entries,
hours_worked=hours_worked, hours_vacation=hours_vacation,
hours_personal=hours_personal, hours_sick=hours_sick, 
hours_total=hours_total
)


And this is my view:

{{extend 'layout.html'}}
{{import datetime}}
h1Time Clock for {{=auth.user.first_name}} {{=auth.user.last_name}}/h1

{{still_clocked_in = False}}
div id=timeclock_list
{{if len(grouped_entries)  0:}}
{{
def format_time_string(the_date):
if the_date is None: return 'Still clocked in'
return the_date.strftime('%I:%M %p')

def format_minutes(minutes):
hours = round(minutes / 60)
if hours == 0:
return 00:%02d % (minutes)
else:
minutes -= minutes * hours
return %02d:%02d % (hours, minutes)
pass
}}

{{for k, v in grouped_entries.iteritems():}}
h4{{=k}}/h4
tabletheadtrthTime in:/ththTime 
out:/ththType:/ththHours:/th/tr/theadtbody

{{total_for_day = 0}}

{{for entry in v:}}
{{
if entry.calculated_minutes is None:
   still_clocked_in = True
   entry_hours = ''
else:
total_for_day += entry.calculated_minutes
entry_hours = format_minutes(entry.calculated_minutes)
pass

date_start = format_time_string(entry.calculated_start)
date_end = format_time_string(entry.calculated_end)
entry_type = db.timeclock_events[entry.event_type]
}}

trtd{{=date_start}}/tdtd{{=date_end}}/tdtd{{=entry_type}}/tdtd 
class=center{{=entry_hours}}/td/tr
{{pass}}

{{total_for_day_formatted = format_minutes(total_for_day)}}
/tbodytfoottrth class=right colspan=3Total for 
day:/thth{{=total_for_day_formatted}}/th/tr/tfoot/table
{{pass}}
/div

div id=timeclock_totals
h4Totals for week/h4
tabletbody

{{if hours_worked != '00:00':}}
trtdTotal hours worked this week:/tdtd 
class=center{{=hours_worked}}/td/tr
{{pass}}

{{if hours_vacation != '00:00':}}
trtdTotal hours of vacation this week:/tdtd 
class=center{{=hours_vacation}}/td/tr
{{pass}}

{{if hours_personal != '00:00':}}
trtdTotal hours of personal time this week:/tdtd 
class=center{{=hours_personal}}/td/tr
{{pass}}

{{if hours_sick != '00:00':}}
trtdTotal hours sick this week:/tdtd 
class=center{{=hours_sick}}/td/tr
{{pass}}

/tbodytfoot
trth class=rightGrand total for this 
week:/thth{{=hours_total}}/th/tr
/tfoot/table
{{else:}}
h5No time clock entries for this week./h5
{{pass}}
/div

{{
if still_clocked_in:
punch_text = 'Clock out'
else:
punch_text = 'Clock in'
pass

response.write(A(punch_text, _href=URL('punch'), _id='timeclock_punch', 
_class='no_print'))
}}

There is a lot more code because I have since added a lot functionality, but I 
think the code itself is fairly 

[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread pbreit
Yeah, I got kind of lost, too. The thing that threw me off were trs[] = 
and tables[] =. The = sign is for assignment, not adding or appending. 
Each trs[] = is re-assigning the whole variable each time, overwriting 
anything that was already there (if I'm not mistaken).

But building tables with functions is more difficult for me in general. That 
may be because I learned HTML tables first.


Re: [web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Ross Peoples
Yea, for some reason I thought that 'tables[] = ' would append to the list. I'm 
not sure which language that's from, but it doesn't matter now, as it is 
certainly much more readable to me. Before, the view had a hacky way of 
grouping the data into a table and I was confused about the meaning of the code 
seconds after I wrote it, so I figured a cleaner rewrite was in order :)

On Mar 3, 2011, at 4:19 PM, pbreit wrote:

 Yeah, I got kind of lost, too. The thing that threw me off were trs[] = and 
 tables[] =. The = sign is for assignment, not adding or appending. Each 
 trs[] = is re-assigning the whole variable each time, overwriting anything 
 that was already there (if I'm not mistaken).
 
 But building tables with functions is more difficult for me in general. That 
 may be because I learned HTML tables first.



[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Anthony
On Thursday, March 3, 2011 4:19:06 PM UTC-5, pbreit wrote: 

 Yeah, I got kind of lost, too. The thing that threw me off were trs[] = 
 and tables[] =. The = sign is for assignment, not adding or appending. 
 Each trs[] = is re-assigning the whole variable each time, overwriting 
 anything that was already there (if I'm not mistaken).

 
Actually, I think that simply raises a syntax error.


[web2py] Socket Error Using FCGI;

2011-03-03 Thread David J.

Traceback (most recent call last):
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
self.process_input()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in 
process_input

self._do_params(rec)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in 
_do_params

self._start_request(req)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in 
_start_request

req.run()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
self._flush()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in 
_flush

self.stdout.close()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in 
close

self._conn.writeRecord(rec)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in 
writeRecord

rec.write(self._sock)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in 
write

self._sendall(sock, header)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in 
_sendall

sent = sock.send(data)
socket.error: [Errno 32] Broken pipe
Unhandled exception in thread started by bound method Connection.run of 
gluon.contrib.gateways.fcgi.Connection object at 0x7f1ac57c3950

Traceback (most recent call last):
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
self.process_input()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in 
process_input

self._do_params(rec)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in 
_do_params

self._start_request(req)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in 
_start_request

req.run()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
self._flush()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in 
_flush

self.stdout.close()
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in 
close

self._conn.writeRecord(rec)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in 
writeRecord

rec.write(self._sock)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in 
write

self._sendall(sock, header)
  File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in 
_sendall

sent = sock.send(data)
socket.error: [Errno 32] Broken pipe



[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread Anthony
On Thursday, March 3, 2011 4:26:19 PM UTC-5, Anthony wrote: 

 On Thursday, March 3, 2011 4:19:06 PM UTC-5, pbreit wrote: 

 Yeah, I got kind of lost, too. The thing that threw me off were trs[] = 
 and tables[] =. The = sign is for assignment, not adding or appending. 
 Each trs[] = is re-assigning the whole variable each time, overwriting 
 anything that was already there (if I'm not mistaken).

  
 Actually, I think that simply raises a syntax error.

 
I think
 
trs[:] = something
 
would overwrite trs, as long as 'something' is an iterable.
 


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread Massimo Di Pierro
You must be using trunk. I think this is a bug in trunk but not
stable. Thanks for reporting it.

Massimo

On Mar 3, 2:02 pm, ron_m ron.mco...@gmail.com wrote:
 Additional information:

 I added a print to the front end of DAL.__init__ and was surprised to find
 driver_args was set to {'check_same_thread': False} but I did not set it in
 my db = DAL() class constructor call.

 So here is the issue. I start up the development environment on Linux with a
 terminal command python web2py.py sitting in the correct web2py directory.
 Because I have Tcl/TK installed on the system it comes up, solicits an admin
 password and then I start the server.

 This in turn brings up a browser window running the welcome application. The
 welcome application as written uses SQLLite as the database and since it is
 default installed in Python = 2.5 I have the driver and a connection
 succeeds. The SQLLite adapter does use this driver_args parameter and if it
 is not set forces it to the value I am seeing.

 Somehow driver_args gets stored globally and becomes the default for all
 other adapter calls to __init__ on any other driver as well.

 To test this theory I commented out the db=DAL(...) line in db.py in the
 welcome application and restarted the server. This caused the welcome app to
 crash during the TclTk solicited start of the welcome app when the browser
 is opened but at least the DAL did not get initialized using the SQLLite
 database.

 Now I am able to run my own application and the driver_args = {} which would
 be correct for the PostgreSQL adapter.

 Hope that helps isolate it a little better.

 Ron


[web2py] Re: revised plugin_wiki

2011-03-03 Thread Massimo Di Pierro
I do not like

db.table.is_active = True

although I do not strongly oppose either.
is this any better?

db.table.enabled = True

or

db.table.disabled = False


On Mar 3, 3:08 pm, villas villa...@gmail.com wrote:
 And of course 'is_active' matches 'is_public'...

 On Mar 3, 4:33 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  Suggestions for a better name?

  On Mar 2, 4:21 pm, villas villa...@gmail.com wrote:

   I think you may have deleted field 'active' by mistake.  If you re-
   instate it, could you call it something else please  :)

   On Mar 2, 10:02 pm, villas villa...@gmail.com wrote:

Thanks for the upgrade. My immediate issues are...

*** Reserved fieldname 'file' is still a problem (change to filename?)
*** check_reserved=['all'] -- not working in DAL??


[web2py] Re: Socket Error Using FCGI;

2011-03-03 Thread Massimo Di Pierro
How often? is this occasional? reproducible? Do you find it in the
logs or bothers users?

On Mar 3, 3:29 pm, David J. da...@styleflare.com wrote:
 Traceback (most recent call last):
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
      self.process_input()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
 process_input
      self._do_params(rec)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
 _do_params
      self._start_request(req)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
 _start_request
      req.run()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
      self._flush()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
 _flush
      self.stdout.close()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
 close
      self._conn.writeRecord(rec)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
 writeRecord
      rec.write(self._sock)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
 write
      self._sendall(sock, header)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
 _sendall
      sent = sock.send(data)
 socket.error: [Errno 32] Broken pipe
 Unhandled exception in thread started by bound method Connection.run of
 gluon.contrib.gateways.fcgi.Connection object at 0x7f1ac57c3950
 Traceback (most recent call last):
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
      self.process_input()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
 process_input
      self._do_params(rec)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
 _do_params
      self._start_request(req)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
 _start_request
      req.run()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
      self._flush()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
 _flush
      self.stdout.close()
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
 close
      self._conn.writeRecord(rec)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
 writeRecord
      rec.write(self._sock)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
 write
      self._sendall(sock, header)
    File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
 _sendall
      sent = sock.send(data)
 socket.error: [Errno 32] Broken pipe


Re: [web2py] Re: Socket Error Using FCGI;

2011-03-03 Thread David J.

I'll watch it;

It seems like the server is hanging for bit;

I see it in the console as I am running

python fcgihandler.py 

so I guess when that exception is thrown it writes to the console;



On 3/3/11 4:42 PM, Massimo Di Pierro wrote:

How often? is this occasional? reproducible? Do you find it in the
logs or bothers users?

On Mar 3, 3:29 pm, David J.da...@styleflare.com  wrote:

Traceback (most recent call last):
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
  self.process_input()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
process_input
  self._do_params(rec)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
_do_params
  self._start_request(req)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
_start_request
  req.run()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
  self._flush()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
_flush
  self.stdout.close()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
close
  self._conn.writeRecord(rec)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
writeRecord
  rec.write(self._sock)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
write
  self._sendall(sock, header)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
_sendall
  sent = sock.send(data)
socket.error: [Errno 32] Broken pipe
Unhandled exception in thread started bybound method Connection.run of
gluon.contrib.gateways.fcgi.Connection object at 0x7f1ac57c3950
Traceback (most recent call last):
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 664, in run
  self.process_input()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
process_input
  self._do_params(rec)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
_do_params
  self._start_request(req)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
_start_request
  req.run()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 592, in run
  self._flush()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
_flush
  self.stdout.close()
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
close
  self._conn.writeRecord(rec)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
writeRecord
  rec.write(self._sock)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
write
  self._sendall(sock, header)
File /apps/web/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
_sendall
  sent = sock.send(data)
socket.error: [Errno 32] Broken pipe




[web2py] Re: Losing session vars

2011-03-03 Thread ron_m
The default session timeout is 1 hour and is set in seconds by adding a line 
like this to a model such as db.py after auth = Auth()

auth.settings.expiration = 3600 # default 1 hour

but the user would have to sit idle on the app for over one hour and then 
click next or prev to finish a signup. Is that a possible situation gien 
people sitting at their desk get phone calls or other distractions or is 
this immediate during normal work flow?

What is your environment? I am used to running from the command line on 
Linux when in development mode and so starting with rocket as the web server 
as in

python web2py.py

from the command line I can just add print statements in the controller to 
try and follow what is going on.

print response.session_id, other_variables_as_needed






[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
I just downloaded the nightly build, unpacked it, copied over my application 
and get the same problem.
I don't have a problem with 1.92.1. I don't normally use trunk but test it 
once in a while to see what is coming. :-)

Ron


[web2py] Re: Programmatically Build Table in View

2011-03-03 Thread mart
hey,


here is what I do with plugin_wiki (usually for automated reports, but
here is a simplified sample):


header = ['First_Name', 'Last_Name', 'Age', 'Description']
data = \
'''fred,Flintstone,32,always gets into trouble,
   Barney,Rubble,33,is always willing to help Fred
   Mr,Slate,31,good businees man but not a people person
   Dino,dinosaur,3,looks like he should be a dog
   Pebbles,Flintstone,2,Great kid but does not talk much'''


if isinstance(data,str):
rows = [row.strip().split(',')  for row in data.splitlines()]
if header is not None:
nHeader = []
for h in header:
nHeader.append('**{0}**'.format(h))
markminTable = table_lists2Markmin([nHeader] + rows)
else:
markminTable = table_lists2Markmin([header] + rows)
print markminTable


# here is the function that makes a markmin table (sorry if the
formatting looks bad here):

def table_lists2Markmin(rows):
tableRows = deque()
for tRows in [([[sStr for sStr in item] for item in map(None,
   *[item.split('\n') for item in row])]) for
row in rows]:
for tableRow in tRows:
tableRows.append('{0}'.format(' |
'.join([string.join(string.strip(item),
  '')
for item in tableRow])))
return '---\n{0}\n---'.format(string.join(tableRows,'\n'))


Usually the string data (it can be a list or a table as well) gets
passed to a function that will make use (not shown here be it has too
many lines) of anything we have in markmin by doing something like
below.

data = \
'''fred,Flintstone,32,always gets into trouble,
   Barney,Rubble,33,is always willing to help Fred
   Mr,Slate,31,good business man and this is his {0}
   Dino,dinosaur,3,looks like he should be a dog
   Pebbles,Flintstone,2,Great kid but does not talk much
'''.format(mmObj.mLink('favorite link','http:/www.google.com'))


makes automating Markmin tables easy through automation and decorating
the fileds as well.

hope it helps,
Mart :)

On Mar 3, 4:30 pm, Anthony abasta...@gmail.com wrote:
 On Thursday, March 3, 2011 4:26:19 PM UTC-5, Anthony wrote:

  On Thursday, March 3, 2011 4:19:06 PM UTC-5, pbreit wrote:

  Yeah, I got kind of lost, too. The thing that threw me off were trs[] =
  and tables[] =. The = sign is for assignment, not adding or appending.
  Each trs[] = is re-assigning the whole variable each time, overwriting
  anything that was already there (if I'm not mistaken).

  Actually, I think that simply raises a syntax error.

 I think

 trs[:] = something

 would overwrite trs, as long as 'something' is an iterable.


[web2py] Re: bug? - boolean field automatically toggles in forms when validation fails

2011-03-03 Thread Massimo Di Pierro
I cannot reproduce this. Which web2py version? Which browser?

On Mar 2, 5:14 pm, Carlos carlosgali...@gmail.com wrote:
 Hi,

 Boolean fields are automatically toggling in forms when validation fails.

 (model)
    db.define_table('xxx', Field('xstring',requires=IS_NOT_EMPTY()),
 Field('xboolean','boolean'))

 (controller)
    def xxx(): return dict(form=crud.create(db.xxx))

 (url)
    http://localhost:8000/test/default/xxx

 When form is initially loaded, the boolean field is OFF, but after hitting
 submit (with a failed validation, e.g. xstring empty), it automatically
 toggles its value to ON, then hit submit again and it toggles to OFF, and so
 on.

 This occurs in both: creates and updates.

 Is this a bug?.

 Thanks,

    Carlos


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread Massimo Di Pierro
please try change line  in dal

args =
(self,uri,pool_size,folder,db_codec,credential_decoder,driver_args)

to

args =
(self,uri,pool_size,folder,db_codec,credential_decoder,driver_args or
{})


On Mar 3, 4:07 pm, ron_m ron.mco...@gmail.com wrote:
 I just downloaded the nightly build, unpacked it, copied over my application
 and get the same problem.
 I don't have a problem with 1.92.1. I don't normally use trunk but test it
 once in a while to see what is coming. :-)

 Ron


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
Wow that fixed it. You are a Python Ninja :-)

I would sure like to know what the mechanism was that caused driver_args to 
bleed from SQLLite to the other adapters even though it is defaulted it to 
an empty dict on the class initializer. I also printed driver_args as the 
first line of code in DAL.__init__() and it had the value left over from 
SQLLite so how driver_args or {} produces {} when there is a value in 
driver_args.

But you are very busy so if you don't have time no problem.


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread Massimo Di Pierro
class DAL:
   def __init__(self,...,driver_args={})

so because this is defined in a module, every time driver_args is not
passed it is set to {}, the same {}. If one app changes, the default
changes for all apps. It is kind of counter intuitive but it works
that way.

It is very dangerous to set a default in a function to a list of
dictionary, because if somewhere downstream the object changed for one
instance, it changes the default for all future instances.

Massimo

On Mar 3, 5:12 pm, ron_m ron.mco...@gmail.com wrote:
 Wow that fixed it. You are a Python Ninja :-)

 I would sure like to know what the mechanism was that caused driver_args to
 bleed from SQLLite to the other adapters even though it is defaulted it to
 an empty dict on the class initializer. I also printed driver_args as the
 first line of code in DAL.__init__() and it had the value left over from
 SQLLite so how driver_args or {} produces {} when there is a value in
 driver_args.

 But you are very busy so if you don't have time no problem.


[web2py] Re: FYI jQuery 1.5.1 breaks jQueryUI buttonsets

2011-03-03 Thread ron_m
I fixed the problem for my application, the label attribute for=1/8x was 
somehow being interpreted as an expression, changed it to for=1_8x and it 
works properly again. Wasn't a problem for jQuery 1.4.4. The odd looking 
string came from a relative speed designation for video playback.


[web2py] Re: plugin_wiki editor automatic formatting

2011-03-03 Thread Plumo
I am at level 2 and when I disable the Rich Text Editor and use a plain 
textarea it works fine. Just the Rich Text Editor is removing the script and 
other tags on submission.

[web2py] Re: auth.is_logged_in(), session.auth does exist, but auth.user is None

2011-03-03 Thread Carlos
Hi,

Can anybody please confirm this is a bug or not?.

Thanks,

   Carlos



[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
Ah Ok, I was trying to reproduce with a simple program containing a couple 
of classes with a main all in one file but it did not exhibit the problem 
behaviour. So having the classes in a module is part of the recipe and lists 
and dicts are passed around as object references to the container leaving 
the contents open to modification.


[web2py] Re: bug? - boolean field automatically toggles in forms when validation fails

2011-03-03 Thread Carlos
Hi Massimo,

web2py's source latest stable version 1.92.1 @ win7.

It happens in all browsers: ie, firefox, chrome, opera, safari.

Thanks,

   Carlos



[web2py] Unexpected dash in URL

2011-03-03 Thread pbreit
I have a strange problem where a URL() tag is switching an underscore in the 
function name to a dash.

Code:
{{=A('contact %s' % (item.seller.name), _href=URL(c='default', 
f='contact_seller', args=item.id))}}
sam with {{=A('contact %s' % (item.seller.name), _href=URL('default', 
'contact_seller', args=item.id))}}

HTML:
a href=/contact-seller/1contact cheekob/a

I have not done anything to my routes or anything else to swap 
underscores/dashes as far as I know.

Mac Version 1.92.1 (2011-02-16 15:04:40)


[web2py] Re: Unexpected dash in URL

2011-03-03 Thread pbreit
This is my routes.py:

routers = dict(

# base router
BASE = dict(
default_application = 'init',
applications = 'ALL',
),

# 'admin' application router
admin = dict(
controllers = [],   # don't remove controller names from admin URLs
map_hyphen = False, # don't map hyphens to underscores
),
)


Re: [web2py] Unexpected dash in URL

2011-03-03 Thread Jonathan Lundell
On Mar 3, 2011, at 4:13 PM, pbreit wrote:
 I have a strange problem where a URL() tag is switching an underscore in the 
 function name to a dash.

This is the default behavior for the new router: hyphens in the URL for a/c/f 
become underscores internally. You can turn it off if you want. BTW, you don't 
need the admin router; it was an artifact of doctesting, and is gone in the 
trunk. Try this (everything else you had set is the default):

routers = dict(
BASE = dict(
map_hyphen = False, # don't map hyphens to underscores
),
)


 
 Code:
 {{=A('contact %s' % (item.seller.name), _href=URL(c='default', 
 f='contact_seller', args=item.id))}}
 sam with {{=A('contact %s' % (item.seller.name), _href=URL('default', 
 'contact_seller', args=item.id))}}
 
 HTML:
 a href=/contact-seller/1contact cheekob/a
 
 I have not done anything to my routes or anything else to swap 
 underscores/dashes as far as I know.
 
 Mac Version 1.92.1 (2011-02-16 15:04:40)




Re: [web2py] Unexpected dash in URL

2011-03-03 Thread pbreit
Ah, ok, thanks. I figured that might be the case but it didn't cross my mind 
that hyphen mapping could be the default. But I guess I do prefer hyphens.

Re: [web2py] Unexpected dash in URL

2011-03-03 Thread Jonathan Lundell
On Mar 3, 2011, at 4:55 PM, pbreit wrote:
 Ah, ok, thanks. I figured that might be the case but it didn't cross my mind 
 that hyphen mapping could be the default. But I guess I do prefer hyphens.

That was my thinking. Underscores in URLs are ugly.

The mapping applies only to a/c/f, since they generally need to be Python 
identifiers. Static file paths and args are never mapped.

[web2py] Re: revised plugin_wiki

2011-03-03 Thread villas
I see what you mean, it could cause a little confusion if people think
it is referring to the table. There again, you were originally happy
to use 'active',  so now maybe you are getting too picky :-)

Maybe 'functional', 'switched_on', 'ready'.
My own previous choice was 'activated' and I'm still happy enough with
that.



On Mar 3, 9:42 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I do not like

 db.table.is_active = True

 although I do not strongly oppose either.
 is this any better?

 db.table.enabled = True

 or

 db.table.disabled = False

 On Mar 3, 3:08 pm, villas villa...@gmail.com wrote:

  And of course 'is_active' matches 'is_public'...

  On Mar 3, 4:33 pm, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   Suggestions for a better name?

   On Mar 2, 4:21 pm, villas villa...@gmail.com wrote:

I think you may have deleted field 'active' by mistake.  If you re-
instate it, could you call it something else please  :)

On Mar 2, 10:02 pm, villas villa...@gmail.com wrote:

 Thanks for the upgrade. My immediate issues are...

 *** Reserved fieldname 'file' is still a problem (change to filename?)
 *** check_reserved=['all'] -- not working in DAL??




[web2py] Re: SQLFORM field validator

2011-03-03 Thread villas
How about making a function for 'onvalidation'. e.g.

if form.accepts(request.vars,session,onvalidation=your_function)

See the book.

On Mar 3, 8:04 am, Manuele Pesenti manuele.pese...@gmail.com wrote:
 Il 03/03/2011 08:27, pbreit ha scritto: What is it doing and what are you 
 expecting?

 as I said after I need that only if null the two fields has to be the
 same. And I want to use a form builded via SQLFORM.factory because my
 form is not stricly related to a db table. I hope I've been more clear :)

 Cheers
      Manuele



  I don't understand exactly what you are trying to achieve. You have
  two form fields, a and b? And whatever is entered in b must match what
  is entered in a?




[web2py] Re: no json - cont.

2011-03-03 Thread darkblue_b


On Mar 3, 7:38 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Mar 3, 2011, at 1:46 AM, darkblue_b wrote:


  @jonathan: Yes, a more detailed error messages than no json would be 
  awesome.

  generic.json now says:

  {{
  ###
  # response._vars contains the dictionary returned by the controller action
  ###
  try:
     from gluon.serializers import json
     response.write(json(response._vars),escape=False)
     response.headers['Content-Type']='text/json'
  except:
     raise HTTP(405,'no json')

  }}

  I suggest this instead:

  {{
  ###
  # response._vars contains the dictionary returned by the controller action
  ###
  try:
          from gluon.serializers import json
          response.write(json(response._vars), escape=False)
          response.headers['Content-Type'] = 'application/json'
  except (TypeError, ValueError):
          raise HTTP(405, 'JSON serialization error')
  except ImportError:
          raise HTTP(405, 'JSON not available')
  except:
          raise HTTP(405, 'JSON error')

  }}

  I patched that in, and changed the last one to say

  except Exception, E:
     raise HTTP(405, 'JSON error: ' + str(E))

  and got in my case
    JSON error: 'id'

 Ah. Let's find out a little more. I suggest two experiments.

 The easier one: include E.__class__.__name__ in the string, so we can see 
 what's being raised.

 Then I'd like to see if we can force a ticket. Try changing the last raise 
 to: raise SyntaxError, and if you get a stack trace, let's see where the 
 exception is coming from.

 When I took a look through the code, it looked to me like serialization 
 errors were all causing Type or Value exceptions, but I might have missed 
 something.

ok, in order
  E.__class__.__name__  = KeyError

then, substituting SyntaxError does indeed create a stack trace
  File /web2py/gluon/restricted.py, line 188, in restricted
exec ccode in environment
  File  (the view I am testing)
SyntaxError: None




[web2py] Re: changing export_to_csv( )'s default behaviour

2011-03-03 Thread Anthony

On Thursday, March 3, 2011 1:19:14 PM UTC-5, Eduardo wrote: 

 Thank you all. Editing appadmin will do. I am, however, having a hard 
 time identifying export_to_csv( ) either in views/appadmin.html or 
 appadmin.py. While import_from_csv is clearly called from within 
 appadmin.import_csv, I am unable to identify how export_to_csv is 
 called there.

 
The export is done by the csv() function in appadmin.py: 
http://code.google.com/p/web2py/source/browse/applications/welcome/controllers/appadmin.py#142
 
That function returns:
 
str(db(query).select())
 
The db(query).select() is a DAL Rows object, and since it is passed to 
str(), the __str__ method of the Rows class is applied. You can see the 
__str__ method of the Rows class in dal.py here: 
http://code.google.com/p/web2py/source/browse/gluon/dal.py#4850
 
http://code.google.com/p/web2py/source/browse/gluon/dal.py#4850As 
As you can see, the __str__ method ultimately calls the export_to_csv_file 
method, which is here: 
http://code.google.com/p/web2py/source/browse/gluon/dal.py#4947
 
I suppose you could write your own export_tab_delimited function that works 
like __str__ but passes delimiter='\t' to export_to_csv_file. Maybe 
something like this added to appadmin.py:
 
import cStringIO
def export_tab_delimited(rows):
s = cStringIO.StringIO()
rows.export_to_csv_file(s, delimiter='\t')
return s.getvalue()
 
And then change the last line of the csv() function to:
 
return export_tab_delimited(db(query).select())
 
 
Anthony


[web2py] Re: auth.is_logged_in(), session.auth does exist, but auth.user is None

2011-03-03 Thread Massimo Di Pierro
This is now fixed in trunk.

On Mar 3, 5:49 pm, Carlos carlosgali...@gmail.com wrote:
 Hi,

 Can anybody please confirm this is a bug or not?.

 Thanks,

    Carlos


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-03 Thread Massimo Di Pierro
 def f(a={}): return a
...
 x=f()
 x[1]=1
 print x
{1: 1}
 y=f()
 print y
{1: 1}


On Mar 3, 5:49 pm, ron_m ron.mco...@gmail.com wrote:
 Ah Ok, I was trying to reproduce with a simple program containing a couple
 of classes with a main all in one file but it did not exhibit the problem
 behaviour. So having the classes in a module is part of the recipe and lists
 and dicts are passed around as object references to the container leaving
 the contents open to modification.


[web2py] Re: bug? - boolean field automatically toggles in forms when validation fails

2011-03-03 Thread Massimo Di Pierro
Can you please try the latest nightly build? Try tomorrow since I will
redo it tonight.

On Mar 3, 5:57 pm, Carlos carlosgali...@gmail.com wrote:
 Hi Massimo,

 web2py's source latest stable version 1.92.1 @ win7.

 It happens in all browsers: ie, firefox, chrome, opera, safari.

 Thanks,

    Carlos


[web2py] attention plugin_wiki users

2011-03-03 Thread Massimo Di Pierro
A number of things have been fixed in plugin_wiki. One of them is the
naming of the fields to make sure there are no conflicts with
production databases. One of the changes is the field file was
renamed filename. If you upgrade you WILL lose data in this field.

Massimo


[web2py] Re: no json - cont.

2011-03-03 Thread darkblue_b
oh - I bet it is that web2py is expecting a field called id
whereas I define my own primary key 'pkey' and there is no 'id'

assuming that is true, then tables with no primary key 'id'
 are not serializable by json, but xml works ?
 seems like a side effect and not intended behavior



[web2py] Re: auth.is_logged_in(), session.auth does exist, but auth.user is None

2011-03-03 Thread Carlos
thanks!

Re: [web2py] Re: no json - cont.

2011-03-03 Thread Jonathan Lundell
On Mar 3, 2011, at 8:44 PM, darkblue_b wrote:
 
 oh - I bet it is that web2py is expecting a field called id
 whereas I define my own primary key 'pkey' and there is no 'id'
 
 assuming that is true, then tables with no primary key 'id'
 are not serializable by json, but xml works ?
 seems like a side effect and not intended behavior

That's possible. KeyError is hard to track down, because it's probably being 
raised implicitly from a failed dictionary access. Why it happens with json and 
not xml I have no idea, but the xml encoding logic is significantly different 
from the json code.



[web2py] potential memory leak???

2011-03-03 Thread VP
My app has utilized much RAM over time, so I created a simple app to
replicate the problem.  This is what I found out.

First of all, the app:

++ Model (database is postgres):
db.define_table('data',
Field('body','text',requires=IS_LENGTH(262144)),
Field('body1','text',requires=IS_LENGTH(262144)),
Field('body2','text',requires=IS_LENGTH(262144)),
Field('body3','text',requires=IS_LENGTH(262144)))

### I populate the database with about 1500 entries
#from gluon.contrib.populate import populate
#populate(db.data,100)

++ Controller:
def index():
return dict( data = db().select(db.data.ALL) )

++ View/default/index.html:
{{extend 'layout.html'}}
{{i=1}}
{{ for d in data: }}
{{=i}}. {{=d.body}} {{=d.body1}} {{=d.body2}} {{=d.body3}}.
{{i+=1}}
{{ pass }}

==

Apache configuration: 5 processes, 1 thread   (more than 1 threads
will cause WSGI premature script error as previously described).

==

Result (this is with 1.92.1; 1.91.6 had same problem)

A fresh apache restart gives each of 5 processes about 43MB.

After using ab to stress test with 20 connections, 10 seconds,
repeated several times, RAM starts crawling up to about 130MB per
process.

The RAM appears to be stuck there at 130MB/process and not released.

At this point the RAM per process does not get increased with repeated
testing... BUT Apache starts getting this error:


IOError: failed to write data
mod_wsgi (pid=12689): Exception occurred processing WSGI script '/home/
vphan/web2py/wsgihandler.py'.


==

This is with the simple app above.  With my real app, RAM keeps
getting increased and not released.

It seems that if I load many rows (each with much data) into memory,
we see this problem.

Does the DAL leak memory?