Re: [web2py] Re: create new record and update status simultaneously

2011-04-22 Thread Bruno Rocha
You can try to set default before the creation of the form, something like:

db.booking.status.default=Booked
form = crud.create(db.booking)

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



On Fri, Apr 22, 2011 at 2:24 AM, Stifan Kristi steve.van.chris...@gmail.com
 wrote:

 a, i c, thank you so much for your pointer anthony, is there any others way
 to that without using update() or update_record()?

 thank you very much


 On Fri, Apr 22, 2011 at 1:33 AM, Anthony abasta...@gmail.com wrote:

 I think onaccept has to be a function.

 On Thursday, April 21, 2011 1:12:24 PM UTC-4, 黄祥 wrote:

 hi,

 is it possible to create new record and update status simultaneously?
 e.g. update()
 def __add_2():
 form = crud.create(db.booking, next = URL(request.application,
 request.controller, 'index'), onaccept = db.room(db.room.id ==
 request.vars.room_id).update(status = 'Booked'))
 return dict(form = form)

 an error occured said:
 AttributeError: 'NoneType' object has no attribute 'update'

 i've tried another (update_record):
 def __add_2():
 form = crud.create(db.booking, next = URL(request.application,
 request.controller, 'index'), onaccept = db.room(db.room.id ==
 request.vars.room_id).update_record(status = 'Booked'))
 return dict(form = form)

 an error occured said:
 AttributeError: 'NoneType' object has no attribute 'update_record'

 i know i was wrong, but i'm not understand where is my fault code,
 could there anybody give me a pointer and shows me how to fix it?

 thank you so much before





Re: [web2py] Re: create new record and update status simultaneously

2011-04-22 Thread Stifan Kristi
thank you so much for your pointer, bruno, it seems onaccept, can't receive
request.vars that been passed during form submit, because when i tried to
replace the request.vars into the value id (1, 2, etc), no errors occured.
did anyone have meet the same problem?

thank you very much before

On Fri, Apr 22, 2011 at 1:29 PM, Bruno Rocha rochacbr...@gmail.com wrote:

 You can try to set default before the creation of the form, something like:

 db.booking.status.default=Booked
 form = crud.create(db.booking)

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



 On Fri, Apr 22, 2011 at 2:24 AM, Stifan Kristi 
 steve.van.chris...@gmail.com wrote:

 a, i c, thank you so much for your pointer anthony, is there any others
 way to that without using update() or update_record()?

 thank you very much


  On Fri, Apr 22, 2011 at 1:33 AM, Anthony abasta...@gmail.com wrote:

 I think onaccept has to be a function.

 On Thursday, April 21, 2011 1:12:24 PM UTC-4, 黄祥 wrote:

 hi,

 is it possible to create new record and update status simultaneously?
 e.g. update()
 def __add_2():
 form = crud.create(db.booking, next = URL(request.application,
 request.controller, 'index'), onaccept = db.room(db.room.id ==
 request.vars.room_id).update(status = 'Booked'))
 return dict(form = form)

 an error occured said:
 AttributeError: 'NoneType' object has no attribute 'update'

 i've tried another (update_record):
 def __add_2():
 form = crud.create(db.booking, next = URL(request.application,
 request.controller, 'index'), onaccept = db.room(db.room.id ==
 request.vars.room_id).update_record(status = 'Booked'))
 return dict(form = form)

 an error occured said:
 AttributeError: 'NoneType' object has no attribute 'update_record'

 i know i was wrong, but i'm not understand where is my fault code,
 could there anybody give me a pointer and shows me how to fix it?

 thank you so much before






[web2py] db field date time compare validation

2011-04-22 Thread 黄祥
hi,

is it possible to compare db field datetime during form validation?
e.g.
db.define_table('duration',
Field('from',
  'datetime',
  requires = IS_DATE()
  ),
Field('to',
  'datetime',
  requires = [IS_DATE(),
  request.vars.from  request.vars.to]
  )
)

an error occured said:
TypeError: 'bool' object is not callable

also i tried:

db.define_table('duration',
Field('from',
  'datetime',
  requires = IS_DATE()
  ),
Field('to',
  'datetime',
  requires = [IS_DATE(),
  form.vars.from  form.vars.to]
  )
)

an error occured said :
NameError: name 'form' is not defined

does anyone have a clue to solve it?

thank you very much for your kind attention


[web2py] Variables in javascript function.

2011-04-22 Thread annet
In web2py_ajax.html I have the following function:

function details(url) {
detailswindow=window.open(url,'details','toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=792,height=696');
if (window.focus) detailswindow.focus();
return false;
}


... which I call in a view:

td
{{=A(row.company.name,_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s')%URL(r=request,f='details',args=[row.company.id]))}}
/td


I would like to replace the details function with a more generic one,
I tried:

function openwindow(url,name,width,height) {
name=window.open(url,name,'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=width,height=height');
if (window.focus) detailswindow.focus();
return false;
}


... and in the view:

td
{{=A(row.company.name,_onmouseover=this.style.cursor='pointer';,_onclick=javascript:openwindow('%s','detailswindow',
792,696)%URL(r=request,f='details',args=[row.company.id]))}}
/td

... but that doesn't work, the window opens, but doesn't have the
desired size. Is it possible to get this to work? If so, how?


Kind regards,

Annet.



[web2py] Re: [w2py-dev] Re: Problems related to keeping applications in seperate folder and not in web2py installation.

2011-04-22 Thread Arun K.Rajeevan
I use trunk (every day updates)

[web2py] Re: Variables in javascript function.

2011-04-22 Thread annet
Hi Ron,

Thanks for your reply, problem solved.


Kind regards,

Annet.


[web2py] Re: Variables in javascript function.

2011-04-22 Thread ron_m
Try changing

name=window.open(url,name,'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=width,height=height');
 


to have the variables width and height not inside the string literal quotes, 
something like this

name=window.open(url,name,'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height);
 




[web2py] Re: [w2py-dev] Re: Problems related to keeping applications in seperate folder and not in web2py installation.

2011-04-22 Thread Arun K.Rajeevan
I'm using trunk (which I pull in and update almost daily)

[web2py] Re: Funny behavior with referenced Field display if writable=False

2011-04-22 Thread szimszon
With 
Version 1.94.6 (2011-04-21 04:20:18) -- nightly build
the problem is still persist...



[web2py] Re: new web2py version

2011-04-22 Thread szimszon


  File 
/home/szimszon/fejlesztes/sajat/web2py/applications/mailadmin/models/menu.py 
http://localhost:8000/admin/default/edit/mailadmin/models/menu.py, line 9, in 
module
( T( 'Új domain' ), URL( 'default', 'domain' ).xml() == URL().xml(), URL( 
'default', 'domain' ), [] ),
AttributeError: 'str' object has no attribute 'xml'


URL( 'default', 'domain' ).xml() -- AttributeError: 'str' object has no 
attribute 'xml'



[web2py] Re: db field date time compare validation

2011-04-22 Thread Anthony
The 'requires' attribute of a field has to be a validator or list of 
validators (validators are callable objects), not just any boolean test. I 
think you'll need a custom validator: 
http://web2py.com/book/default/chapter/07#Custom-Validators. You might also 
consider using an 'onvalidation' function with your form: 
http://web2py.com/book/default/chapter/07#onvalidation.
 
Anthony
 
On Friday, April 22, 2011 3:35:22 AM UTC-4, 黄祥 wrote:

 hi, 

 is it possible to compare db field datetime during form validation? 
 e.g. 
 db.define_table('duration', 
 Field('from', 
   'datetime', 
   requires = IS_DATE() 
   ), 
 Field('to', 
   'datetime', 
   requires = [IS_DATE(), 
   request.vars.from  request.vars.to] 
   ) 
 ) 

 an error occured said: 
 TypeError: 'bool' object is not callable 

 also i tried: 

 db.define_table('duration', 
 Field('from', 
   'datetime', 
   requires = IS_DATE() 
   ), 
 Field('to', 
   'datetime', 
   requires = [IS_DATE(), 
   form.vars.from  form.vars.to] 
   ) 
 ) 

 an error occured said : 
 NameError: name 'form' is not defined 

 does anyone have a clue to solve it? 

 thank you very much for your kind attention



Re: [web2py] Re: create new record and update status simultaneously

2011-04-22 Thread Anthony
On Friday, April 22, 2011 2:46:44 AM UTC-4, 黄祥 wrote: 

 thank you so much for your pointer, bruno, it seems onaccept, can't receive 
 request.vars that been passed during form submit, because when i tried to 
 replace the request.vars into the value id (1, 2, etc), no errors occured. 
 did anyone have meet the same problem?

 
This isn't quite clear -- can you show your code? Did you try form.vars?
 
Anthony


[web2py] Re: new web2py version

2011-04-22 Thread villas
I think I read somewhere that the URL xml() method was being withdrawn/
cancelled. I think I fixed my menu.py by simply copying a replacement
line from the latest welcome/models/menu.py


On Apr 22, 11:28 am, szimszon szims...@gmail.com wrote:
   File 
 /home/szimszon/fejlesztes/sajat/web2py/applications/mailadmin/models/menu.py
  http://localhost:8000/admin/default/edit/mailadmin/models/menu.py, line 9, 
 in module
     ( T( 'Új domain' ), URL( 'default', 'domain' ).xml() == URL().xml(), URL( 
 'default', 'domain' ), [] ),
 AttributeError: 'str' object has no attribute 'xml'

 URL( 'default', 'domain' ).xml() -- AttributeError: 'str' object has no 
 attribute 'xml'


[web2py] Re: new web2py version

2011-04-22 Thread szimszon
Okay. No problem. I mentioned just because the default app. had that code 
too :-o


Re: [web2py] Re: create new record and update status simultaneously

2011-04-22 Thread Stifan Kristi
hi, anthony, thank you so much for your kind attention, problem solved now

def __add_2(table):
form = crud.create(table,
   next = URL(request.application,
  request.controller,
  index_link),
   onaccept = *__update_table_2*
   )
return dict(form = form)

*def __update_table_2(form):*
*if request.function == 'check_out_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
1)*
*elif request.function == 'booking_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
2)*
*elif request.function == 'check_in_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
3)*
*
*
or maybe you have another way out for this situation?

thank you very much.

On Fri, Apr 22, 2011 at 6:16 PM, Anthony abasta...@gmail.com wrote:

 On Friday, April 22, 2011 2:46:44 AM UTC-4, 黄祥 wrote:

 thank you so much for your pointer, bruno, it seems onaccept, can't
 receive request.vars that been passed during form submit, because when i
 tried to replace the request.vars into the value id (1, 2, etc), no errors
 occured. did anyone have meet the same problem?


 This isn't quite clear -- can you show your code? Did you try form.vars?

 Anthony



[web2py] Re: IS_IN_DB using a dal.Set

2011-04-22 Thread villas
My guess is that IS_IN_DB doesn't like joins because it needs to
identify one table to display.

On Apr 22, 5:31 am, niknok nikolai...@gmail.com wrote:
 I still couldn't find out how to do it with IS_IN_DB and a DAL Set.

 But using IS_IN_SET works:

         mp_list=gdb(gdb.municipality.province==gdb.province.id)\
                 .select(gdb.municipality.psgc_m,gdb.municipality.name,\
                         
 gdb.province.name,orderby=gdb.municipality.name).as_list()
         mp_dd2=[(i['municipality']['psgc_m'],\
                 i['municipality']['name']+' ('+i['province']['name']+')')\
                         for i in mp_list if i]

         Field('muni',requires=IS_IN_SET(mp_dd2,zero='None')

 On Apr 22, 11:02 am, niknok nikolai...@gmail.com wrote:

  I have a set

  mp_list=gdb(gdb.municipality.province==gdb.province.id)

  which I'm trying to use it in a select field but causes an error:

  Field('municipality',requires=IS_IN_DB(mp_list,'municipality.psgc_m',
                                          '%(municipality.name)s 
  (%(province.name)s)'))

  I'm trying to get it to show in the dropdown like this: municipal_name
  (province_name). How do I format the field names from a set?

  I tried and can generate a query of the rows I'd like to have :

  mp_list=gdb(gdb.municipality.province==gdb.province.id)\
                  .select(gdb.municipality.psgc_m,gdb.municipality.name,\
                          gdb.province.name,orderby=gdb.municipality.name)
  for x in mp_list: print x['municipality']['name']+' 
  ('+x['province']['name']+')'




[web2py] Re: IS_IN_DB using a dal.Set

2011-04-22 Thread Massimo Di Pierro
correct

On Apr 22, 8:36 am, villas villa...@gmail.com wrote:
 My guess is that IS_IN_DB doesn't like joins because it needs to
 identify one table to display.

 On Apr 22, 5:31 am, niknok nikolai...@gmail.com wrote:







  I still couldn't find out how to do it with IS_IN_DB and a DAL Set.

  But using IS_IN_SET works:

          mp_list=gdb(gdb.municipality.province==gdb.province.id)\
                  .select(gdb.municipality.psgc_m,gdb.municipality.name,\
                          
  gdb.province.name,orderby=gdb.municipality.name).as_list()
          mp_dd2=[(i['municipality']['psgc_m'],\
                  i['municipality']['name']+' ('+i['province']['name']+')')\
                          for i in mp_list if i]

          Field('muni',requires=IS_IN_SET(mp_dd2,zero='None')

  On Apr 22, 11:02 am, niknok nikolai...@gmail.com wrote:

   I have a set

   mp_list=gdb(gdb.municipality.province==gdb.province.id)

   which I'm trying to use it in a select field but causes an error:

   Field('municipality',requires=IS_IN_DB(mp_list,'municipality.psgc_m',
                                           '%(municipality.name)s 
   (%(province.name)s)'))

   I'm trying to get it to show in the dropdown like this: municipal_name
   (province_name). How do I format the field names from a set?

   I tried and can generate a query of the rows I'd like to have :

   mp_list=gdb(gdb.municipality.province==gdb.province.id)\
                   .select(gdb.municipality.psgc_m,gdb.municipality.name,\
                           gdb.province.name,orderby=gdb.municipality.name)
   for x in mp_list: print x['municipality']['name']+' 
   ('+x['province']['name']+')'


Re: [web2py] Re: new web2py version

2011-04-22 Thread Tito Garrido
I've updated again today and got:


Traceback (most recent call last):

  File /Users/titogarrido/Documents/Projetos/web2py/gluon/restricted.py,
line 181, in restricted

exec ccode in environment

  File 
/Users/titogarrido/Documents/Projetos/web2py/applications/loja_controle/controllers/appadmin.py
http://127.0.0.1:8000/admin/default/edit/loja_controle/controllers/appadmin.py,
line 10, in module

import copy

  File /Users/titogarrido/Documents/Projetos/web2py/gluon/custom_import.py,
line 72, in _web2py__import__

locals, fromlist, level)

  File /Users/titogarrido/Documents/Projetos/web2py/gluon/custom_import.py,
line 48, in _web2py__import__dot

result = result or new_mod.__dict__[name]
KeyError: 'copy'


On Fri, Apr 22, 2011 at 9:44 AM, szimszon szims...@gmail.com wrote:

 Okay. No problem. I mentioned just because the default app. had that code
 too :-o




-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread Stifan Kristi
thank you so much for your hints anthony, the error didn't appears anymore,
but the validation is not run

def __date_comparation(form):
if request.function == 'booking_add':
if form.vars.from_date  form.vars.to_date:
form.errors.to_date = 'To Date must greater than From Date'

i know there is a mistaken on my validation code, could you give me a
pointer how to fixed it?

thank you very much

On Fri, Apr 22, 2011 at 6:07 PM, Anthony abasta...@gmail.com wrote:

 The 'requires' attribute of a field has to be a validator or list of
 validators (validators are callable objects), not just any boolean test. I
 think you'll need a custom validator:
 http://web2py.com/book/default/chapter/07#Custom-Validators. You might
 also consider using an 'onvalidation' function with your form:
 http://web2py.com/book/default/chapter/07#onvalidation.

 Anthony

 On Friday, April 22, 2011 3:35:22 AM UTC-4, 黄祥 wrote:

 hi,

 is it possible to compare db field datetime during form validation?
 e.g.
 db.define_table('duration',
 Field('from',
   'datetime',
   requires = IS_DATE()
   ),
 Field('to',
   'datetime',
   requires = [IS_DATE(),
   request.vars.from  request.vars.to]
   )
 )

 an error occured said:
 TypeError: 'bool' object is not callable

 also i tried:

 db.define_table('duration',
 Field('from',
   'datetime',
   requires = IS_DATE()
   ),
 Field('to',
   'datetime',
   requires = [IS_DATE(),
   form.vars.from  form.vars.to]
   )
 )

 an error occured said :
 NameError: name 'form' is not defined

 does anyone have a clue to solve it?

 thank you very much for your kind attention




Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread pbreit
I think you were on the right track. I think naming the field from might 
have been a problem. I assume with your last function you had renamed the 
fields from_date and to_date? The if request.function might not be 
necessary. Remember that any functions with parameters cannot be accessed 
from the browser.

This works OK:

db.define_table('duration', 
Field('start', 'datetime'), 
Field('end', 'datetime'))

def process_duration_form(form):
if form.vars.start  form.vars.end:
form.errors.start = 'start must be before end'

def duration():
form = SQLFORM(db.duration)
if form.accepts(request.vars, session, 
onvalidation=process_duration_form):
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)


[web2py] Re: Funny behavior with referenced Field display if writable=False

2011-04-22 Thread Massimo Di Pierro
can you please open an issue on google code (add a link this thread).

On Apr 14, 3:06 am, szimszon szims...@gmail.com wrote:
 Sorry for late answer (never got an email replay...)

 So:

 -- db.py --
 db.define_table( 'mail_domain',
     Field( 'domainname', 'string')
 )

 db.define_table( 'mail_domain_alias',
     Field( 'mail_domain_id', db.mail_domain,
            requires = IS_IN_DB( db, db.mail_domain.id, '%
 (domainname)s' ),
             writable = False,
         ),
     Field( 'alias', 'string' ),
 )
 -- db.py --

 -- controller default.py --
 def index():
     if db(db.mail_domain.id1).count()==0:
         db.mail_domain.insert(domainname='oregpreshaz.eu')

 db.mail_domain_alias.mail_domain_id.default=int(db(db.mail_domain.id0).sel 
 ect(orderby=db.mail_domain.id).last().id)
     db.mail_domain_alias.mail_domain_id.writable=False
     return
 dict(form=crud.update(db.mail_domain_alias,request.args(0)))

 -- controller default.py --

 With db.mail_domain_alias.mail_domain_id.writable=False in controller
 (or in db.py) you could see only the Mail Domain Id: number like 1.
 With db.mail_domain_alias.mail_domain_id.writable=True in controller
 (or in db.py) you could see the Mail Domain Id: as domainname like
 'oregpreshaz.eu'.

 I wish I could see the domainname and not the id if .writable=False

 I think that was a behavior before. And if you make display a table
 representation of a select the reference isn't replaced with the
 format and show only the id number...

 On ápr. 4, 15:26, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  It would help to have a smaller example to understand the problem
  better. Can you reproduce it with one table with 1-2 fields and one
  action?

  On Apr 4, 5:30 am, szimszon szims...@gmail.com wrote:

   Can I help with something?

   On márc. 30, 08:55, szimszon szims...@gmail.com wrote:

Any progress / comment?

On márc. 27, 22:04, szimszon szims...@gmail.com wrote:

 Hi!

 I use Version 1.94.6 (2011-03-27 18:20:38).

 I have in db:
 -
 db.define_table( 'mail_domain',
                                                         Field( 
 'domainname', 'string',
                                                                       
           label = 'Domain név',
                                                                       
           requires = IS_NOT_EMPTY()
                                                                       
           ),
                                                         signature,
                                                         migrate = 
 settings.migrate,
                                                         )
 db.define_table( 'mail_domain_alias',
                                                         Field( 
 'mail_domain_id', db.mail_domain,
                                                                       
           label = 'Domain név',
                                                                       
           requires = IS_IN_DB( db, db.mail_domain.id, '%
 (domainname)s' ),
                                                                       
           *writable = False,*
                                                                       
           ),
                                                         Field( 
 'alias', 'string',
                                                                       
           label = 'Aliasz',
                                                                       
           requires = IS_NOT_EMPTY()
                                                                       
           ),
                                                         signature,
                                                         migrate = 
 settings.migrate,
                                                         )
 --

 controller:

 
 def domain():
         form = crud.update( db.mail_domain, request.args( 0 ) )
         return dict( form = form )
 def domainalias():
         db.mail_domain_alias.mail_domain_id.default = 
 session.domainname_id
         form = crud.update( db.mail_domain_alias, request.args( 0 ) )
         return dict( form = form )
 def setdomain():
         session.domainname_id = request.args( 0 )
         session.domainname = db( db.mail_domain.id ==
 session.domainname_id ).select( db.mail_domain.domainname 
 ).first().domainname
         redirect( URL( 'default', 'index' ) )
 -

 If the session.domainname_id is set to a valid mail_domain record ID,
 than the crud in domainalias shows the reference field as number and
 not as domainname string.

 But if I remove the writable=False in 

[web2py] Re: db field date time compare validation

2011-04-22 Thread Massimo Di Pierro
mind that end is a keyword in sql and you can have problems with a
field called end.

On Apr 22, 12:34 pm, pbreit pbreitenb...@gmail.com wrote:
 I think you were on the right track. I think naming the field from might
 have been a problem. I assume with your last function you had renamed the
 fields from_date and to_date? The if request.function might not be
 necessary. Remember that any functions with parameters cannot be accessed
 from the browser.

 This works OK:

 db.define_table('duration',
     Field('start', 'datetime'),
     Field('end', 'datetime'))

 def process_duration_form(form):
     if form.vars.start  form.vars.end:
         form.errors.start = 'start must be before end'

 def duration():
     form = SQLFORM(db.duration)
     if form.accepts(request.vars, session,
 onvalidation=process_duration_form):
         response.flash = 'form accepted'
     elif form.errors:
         response.flash = 'form has errors'
     else:
         response.flash = 'please fill out the form'
     return dict(form=form)


[web2py] Re: MySQL, migration, and lower()

2011-04-22 Thread robe...@captivation.com
Thank you for your tips - I'll work with those to find a cleaner
workaround for myself.

I do wish that a workaround wasn't needed at all, since my table
definition was and is correct and matched the database exactly.

Cheers,
:R


On Apr 20, 9:47 pm, drayco antrod...@gmail.com wrote:
 It's work for me

 On 20 abr, 23:46, drayco antrod...@gmail.com wrote:



  1.- Put in your model in every table fake_migrate=True
  2.- Remove your *name_of_your_table.table
  3.- Run web2py and go to admin application database
  4.- Remove fake_migrate

  Your rebuild your  *name_of_your_table.table

  On 20 abr, 14:15, Praneeth Bodduluri life...@gmail.com wrote:

   1) If you have no other schema changes a simpler solution would be to
   just change all your table names manually to lower.
   2) Hook the new version to a blank db and let it generate a dummy sql
   table. swap the table with the one you changed the table names in step
   1 - after turning off web2py i.e.

   --
   Praneeth
   IRC: lifeeth

   On Thu, Apr 21, 2011 at 12:32 AM, robe...@captivation.com

   gummywubb...@gmail.com wrote:
Hi Everybody,

Yesterday evening I ran into some issues updating an app from 1.89.6
to 1.94.5 -- specifically with case sensitivity in migrating tables.
This occurs on an ubuntu ec2 instance, running mysql as installed by
'aptitude install mysql-server' and accepting defaults.

An example.

The field is defined in models with

                   Field('splatToken'),

The .table file before the migration contains

p9
sS'splatToken'

The .table file after the first execution contains

p9
sS'splattoken'

The next execution yields an exception in DAL.py migrate_table
triggered off this test:
                 and not isinstance(table[key].type, SQLCustomType) \

I was able to bypass the issue and continue by removing the .lower()
calls in the sql_fields* assignments up above.

So, my app is running as it needs to be, but this really feels like a
band-aid and incorrect solution. In searching this groups archives,
I've seen some similar issues, but they all seem to have been resolved
a few months ago.

Advice? Thoughts? Questions?

Cheers,
:R


[web2py] Re: web2py in OS X - Where to put custom applications

2011-04-22 Thread Julio Schwarzbeck
I was a little skeptical at first to pollute the Mac environment
with external python packages (i.e. I use pygments for my qa-stack.com
application) this is the reason why I was relying in my (Linux) VM
image for all the dirty work, in my reality, in Linux it is easier to
manage different packages for different python versions, for example,
the mercurial version for OS X is tied up to python 2.6, now with OS X
Lion coming up soon, it will surely break hg, so this is an extra
thing to consider.

On the other hand, python is fully supported in OS X - all it took me
to install pygments in my Mac was an easy_install
pygments (setuptools is already part of the package!), they (apple)
made it extremely easy to install any python module or program
(including web2py) that it became ridiculously simple, albeit you need
to use iTerm or other console app and somewhat know what you're
doing.

Julio

On Apr 21, 1:55 pm, pbreit pbreitenb...@gmail.com wrote:
 Yeah, probably wouldn't hurt to steer more Mac users to source. From the
 Download page, it seems Mac users should download the Mac package.

 If you use version control (if you don't, you should!) it's even better to
 clone it from Google code. Then you can easily control your web2py version.


[web2py] Re: new web2py version

2011-04-22 Thread pierreth
Hello,

Can you try this patch on the nightly build and tell me if things are
now working?

http://pastebin.com/3wjuD6vA

---
Pierre


[web2py] Re: db field date time compare validation

2011-04-22 Thread pbreit
Oops. So from_date and to_date better.

It still drives me nuts that I can't name a table order. Is the naming 
conflict problem common in frameworks?


[web2py] Re: Why new auth_group automatically created with new users?

2011-04-22 Thread pbreit
What is the use case for wanting a group for each user? I am planing to turn 
this off but am wondering if I am going to lose something down the road. I 
suppose worst cas scenario is creating all the groups manually/script in the 
future?

[web2py] Re: Why new auth_group automatically created with new users?

2011-04-22 Thread David Marko


The purpose is probably to give access not directly to user himself but to 
his group. Then when you need to add access to users resources  for the 
others simply put the user into other users group.

David


[web2py] Re: IMPROVED: show error tickets directly if you are a authorized web2py admin

2011-04-22 Thread selecta
playing around with it i realised that inluding the admin css file is
not a good idea
a new css file would have to be added that works better with error
messages in web2py components, will get to that after easter, latest


Re: [web2py] Re: Open a new window and continue

2011-04-22 Thread Kenneth Lundström
Thank you for all your suggestions, the problem is that the PDF is 
created on the fly, so when I click on a link I need to run a function 
and that function creates the PDF and updates the database. After that I 
can reload the page and open the PDF file in a new window. I guess the 
right order is to open the PDF file and then with redirect reload the 
orginal page. But do I open a new window from a function?


Any ideas?


Kenneth

If you are using

def download():
 return response.download(request,db)

to download the PDF you can do

def download():
 return response.download(request,db,attachment=False)

and it will open in place (instead of downloading)


On Apr 18, 10:41 am, Anthonyabasta...@gmail.com  wrote:

On Monday, April 18, 2011 11:01:51 AM UTC-4, pbreit wrote:


How about (be careful with ' and ):
a href={{=URL('default','index')}}
onclick='window.open({{=URL(default,other)}},mywindow);'click
here/a

You might also have the href point to your PDF (and open in a new window via
target=_blank), and then reload the current page by adding:

onClick=window.location.reload()

Anthony




[web2py] Re: Why new auth_group automatically created with new users?

2011-04-22 Thread luckysmack
Another possible use case could be that each user by default gets
assigned to 2 groups. One say 'Authenticated' that all new users get,
this way you can assign global rules as normal. But also a per user
group. Say for example my nick here is luckysmack, so my group would
be called 'luckysmack' and I can assign my own permissions for other
people to access MY data. This makes me think of facebook and linux.
In linux you can assign permissions on the filesystem and you can let
others see your documents, pics, mucis, etc (i know you can do more
than that, but hear me out). And with facebook its like when you set
your own permissions for people to view your content like your wall,
personall info, images, etc. So in a web2py application I could use my
own 'luckysmack' group to manage my personal say profile permissions.
This is assuming thoug that you have programmed in some neato
permissions setup for user profiles. You would also need to
differentiate between user groups and site groups. so when you list
the sites permission groups it doesnt show ALL the users individual
groups. That could be a pain. SO thats one use case that I can think
of.

Then again in my cass i need to make actual site groups users can join
aside from permissions groups...but i think thats another problem and
i dont want to hijack. Ill make a post about it when i start working
on it. But if anyone else can figure out another way to use the per-
user permissions im all ears as thats something i may need to work out
too. Since for an app I will be starting on soon will need fairly fine
grained permissions.


On Apr 22, 12:29 pm, David Marko dma...@tiscali.cz wrote:
 The purpose is probably to give access not directly to user himself but to
 his group. Then when you need to add access to users resources  for the
 others simply put the user into other users group.

 David


Re: [web2py] Re: Open a new window and continue

2011-04-22 Thread Jonathan Lundell


On Apr 22, 2011, at 1:40 PM, Kenneth Lundström kenneth.t.lundst...@gmail.com 
wrote:

 Thank you for all your suggestions, the problem is that the PDF is created on 
 the fly, so when I click on a link I need to run a function and that function 
 creates the PDF and updates the database. After that I can reload the page 
 and open the PDF file in a new window. I guess the right order is to open the 
 PDF file and then with redirect reload the orginal page. But do I open a 
 new window from a function?
 

The easiest, if it works for you, is target=_blank in the clicked link. 
Otherwise think JavaScript; remember it's the browser that has to do the new 
window. You have to tell it somehow. 


 Any ideas?
 
 
 Kenneth
 If you are using
 
 def download():
 return response.download(request,db)
 
 to download the PDF you can do
 
 def download():
 return response.download(request,db,attachment=False)
 
 and it will open in place (instead of downloading)
 
 
 On Apr 18, 10:41 am, Anthonyabasta...@gmail.com  wrote:
 On Monday, April 18, 2011 11:01:51 AM UTC-4, pbreit wrote:
 
 How about (be careful with ' and ):
 a href={{=URL('default','index')}}
 onclick='window.open({{=URL(default,other)}},mywindow);'click
 here/a
 You might also have the href point to your PDF (and open in a new window via
 target=_blank), and then reload the current page by adding:
 
 onClick=window.location.reload()
 
 Anthony
 


[web2py] Re: Why new auth_group automatically created with new users?

2011-04-22 Thread Anthony
In web2py Auth, permissions are granted to groups, so if you want to give 
specific permissions to individual users, I think they must first belong to 
a group (even if the group includes just a single user).

On Friday, April 22, 2011 3:11:04 PM UTC-4, pbreit wrote:

 What is the use case for wanting a group for each user? I am planing to 
 turn this off but am wondering if I am going to lose something down the 
 road. I suppose worst cas scenario is creating all the groups 
 manually/script in the future?



[web2py] How to rename column name of a projection on select

2011-04-22 Thread Rafael Sales
Hello,
How can I define the column name of a field which is a projection
(like sum()) on select?
Examplo:
query = ((db.despesa.id_servico == db.servico.id))

total_gasto = (db.despesa.valor_servico *
db.despesa.quantidade).sum()
linhas = db(query).select(db.servico.descricao, total_gasto, groupby
= db.servico.id)

The return linhas have a column with name
'SUM((despesa.valor_servico * despesa.quantidade))'
When iteration by linhas array, how can I get the values of this
column?

Thanks


Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread Stifan Kristi (Kou Shou)
thank you so much for pointers pbreit and massimo, it's correct that 
before i changed my from database field into from_date because i think 
it's a keyword. i've already tried to modified my code, but the date 
validation is not run using crud, here's my code :


db.define_table('booking',
Field('from_date', 'date', requires = IS_DATE()),
Field('to_date', 'date', requires = IS_DATE()))

def __add_2(table):
form = crud.create(table, onvalidation = __date_comparation, next = 
URL(request.application, request.controller, 'index'))

return dict(form = form)

def __date_comparation(form):
if request.function == 'booking_add':
if form.vars.from_date  form.vars.to_date:
form.errors.to_date = 'To Date must start before From Date'

def booking_add():
return __add_2(db.booking)

any hints or pointers for this problem is highly appreciate.

thank you very much in advance

On 04/23/2011 12:56 AM, Massimo Di Pierro wrote:

mind that end is a keyword in sql and you can have problems with a
field called end.

On Apr 22, 12:34 pm, pbreitpbreitenb...@gmail.com  wrote:

I think you were on the right track. I think naming the field from might
have been a problem. I assume with your last function you had renamed the
fields from_date and to_date? The if request.function might not be
necessary. Remember that any functions with parameters cannot be accessed
from the browser.

This works OK:

db.define_table('duration',
 Field('start', 'datetime'),
 Field('end', 'datetime'))

def process_duration_form(form):
 if form.vars.start  form.vars.end:
 form.errors.start = 'start must be before end'

def duration():
 form = SQLFORM(db.duration)
 if form.accepts(request.vars, session,
onvalidation=process_duration_form):
 response.flash = 'form accepted'
 elif form.errors:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill out the form'
 return dict(form=form)
inline: pixel.pngattachment: steve_van_christie.vcf

[web2py] Javascrip Bug Quick Examples

2011-04-22 Thread Wanderfels
Hey,

http://127.0.0.1:8000/examples/default/examples/

clicking on one of the top links and then navigating back in history
does not go back to those links, but instead to the previous page. Do
not do things like this. dnt.

Thx for web2py. Its beautiful, except the Javascript.


[web2py] Architectural question applications/components/etc

2011-04-22 Thread Stodge
Quick architecture question. Say I have a project management
application. Typically I'm used to creating separate django apps for
tickets and requirements and then I can import modules between them as
needed. How would this be done with web2py? Is the preferred way to
create one application that includes both features, or separate
applications for each, or components? Thanks


Re: [web2py] Re: Javascrip Bug Quick Examples

2011-04-22 Thread Bruno Rocha
I guess the hash argument is missing, take a look:

http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html



On Sat, Apr 23, 2011 at 12:28 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I never noticed that. Technically this is a problem with the
 zexamples.scroll.js library that is used by the examples app and only
 by the examples app.
 I will check if there is an updated version of the jquery plugin that
 does not have the problem.

 On Apr 22, 8:27 pm, Wanderfels wanderf...@web.de wrote:
  Hey,
 
  http://127.0.0.1:8000/examples/default/examples/
 
  clicking on one of the top links and then navigating back in history
  does not go back to those links, but instead to the previous page. Do
  not do things like this. dnt.
 
  Thx for web2py. Its beautiful, except the Javascript.



Re: [web2py] Re: Javascrip Bug Quick Examples

2011-04-22 Thread Bruno Rocha
Here is an example where history works fine:
http://demos.flesler.com/jquery/localScroll/

 http://demos.flesler.com/jquery/localScroll/But, on that page I think the
plugin can be removed and keep normal anchors.


On Sat, Apr 23, 2011 at 1:04 AM, Bruno Rocha rochacbr...@gmail.com wrote:

 I guess the hash argument is missing, take a look:

 http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html




 On Sat, Apr 23, 2011 at 12:28 AM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 I never noticed that. Technically this is a problem with the
 zexamples.scroll.js library that is used by the examples app and only
 by the examples app.
 I will check if there is an updated version of the jquery plugin that
 does not have the problem.

 On Apr 22, 8:27 pm, Wanderfels wanderf...@web.de wrote:
  Hey,
 
  http://127.0.0.1:8000/examples/default/examples/
 
  clicking on one of the top links and then navigating back in history
  does not go back to those links, but instead to the previous page. Do
  not do things like this. dnt.
 
  Thx for web2py. Its beautiful, except the Javascript.





[web2py] Fwd: minor path bug in gluon/contrib/pyfpdf/fpdf.py for font.z file location

2011-04-22 Thread Chris Steel
I have been playing with Mariano Reingart's awesome port of fpdf to python
in Web2py gluon/contrib (http://code.google.com/p/pyfpdf/) and found a minor
bug that occurs when using addfont that causes it to look in

gluon/contrib/pyfpdf/font/

for added fonts and associated files but for fontname.z it looks in:

gluon/contrib/pyfpdf/font/font

If you create gluon/contrib/pyfpdf/font/font and place your fonts
corresponding fontname.z file in this directory it work just fine (In fact
it is kind of awesome!).

I did not find the location of the bug but I created a plugin at
https://code.google.com/p/uc-pyfpdf/
that can be used for testing if someone wants to check it out.

To reproduce the error message test using the plugin you can install it in a
new app (or use the one is comes with) and copy the font directory from the
plugin to the gluon/contrib implementation and test.

for example:

copy appname/static/plugin_uc_pyfpdf/pyfpdf/attic/font

to

gluon/contrib/pyfpdf/

Run the voa_super_simple function in the plugin controller to test.



Cheers,

Chris

-- 
Christopher Steel

Voice of Access



-- 
Christopher Steel

Voice of Access


[web2py] backward compatibility problem?

2011-04-22 Thread blackthorne
hi

trying to solve a problem that emerged when I moved my app from an
older (v1.92) installation to latest.

Here is the error:
  File /Users/blackthorne/Dropbox/Code/Workspaces/web2py/applications/
homepage/controllers/default.py, line 47, in get_tweets
import gluon.contrib.simplejson as sj
  File /Users/blackthorne/Dropbox/Code/Workspaces/web2py/gluon/
custom_import.py, line 70, in _web2py__import__
locals, fromlist, level)
  File /Users/blackthorne/Dropbox/Code/Workspaces/web2py/gluon/
custom_import.py, line 46, in _web2py__import__dot
result = result or new_mod.__dict__[name]
KeyError: 'gluon'

the related code seems to be:
result = None
for name in name.split(.):
new_mod = _old__import__(prefix, globals, locals,
[name], level)
result = result or new_mod.__dict__[name]
prefix += . + name
return result

that new_mod seems to come from applications/admin/modules/
__init__.py, no idea why...

Thank you
Best regards


[web2py] Pusher - Real-time push

2011-04-22 Thread Pepe Araya
Hello!

Has anyone used this with web2py? can you share your experience?

http://www.pusher.com




Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread Stifan Kristi
pardon me, the problem is solved after a few modification in function. thank
you so much for your kind help massimo. it seems that the validation on form
is run after the validation that define on the models (db.define_table).

On Sat, Apr 23, 2011 at 9:41 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I am on the road. I will take a look asap but may have to wait Sunday.

 On Apr 22, 2011, at 6:41 PM, Stifan Kristi (Kou Shou) wrote:

  thankpixel.png you so much for pointers pbreit and massimo, it's
 correct that before i changed my from database field into from_date because
 i think it's a keyword. i've already tried to modified my code, but the date
 validation is not run using crud, here's my code :

 db.define_table('booking',
 Field('from_date', 'date', requires = IS_DATE()),
 Field('to_date', 'date', requires = IS_DATE()))

 def __add_2(table):
 form = crud.create(table, onvalidation = __date_comparation, next =
 URL(request.application, request.controller, 'index'))
 return dict(form = form)

 def __date_comparation(form):
 if request.function == 'booking_add':
 if form.vars.from_date  form.vars.to_date:
 form.errors.to_date = 'To Date must start before From Date'

 def booking_add():
 return __add_2(db.booking)

 any hints or pointers for this problem is highly appreciate.

 thank you very much in advance

 On 04/23/2011 12:56 AM, Massimo Di Pierro wrote:

 mind that end is a keyword in sql and you can have problems with a
 field called end.

 On Apr 22, 12:34 pm, pbreit pbreitenb...@gmail.com pbreitenb...@gmail.com 
 wrote:

  I think you were on the right track. I think naming the field from might
 have been a problem. I assume with your last function you had renamed the
 fields from_date and to_date? The if request.function might not be
 necessary. Remember that any functions with parameters cannot be accessed
 from the browser.

 This works OK:

 db.define_table('duration',
 Field('start', 'datetime'),
 Field('end', 'datetime'))

 def process_duration_form(form):
 if form.vars.start  form.vars.end:
 form.errors.start = 'start must be before end'

 def duration():
 form = SQLFORM(db.duration)
 if form.accepts(request.vars, session,
 onvalidation=process_duration_form):
 response.flash = 'form accepted'
 elif form.errors:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill out the form'
 return dict(form=form)

   steve_van_christie.vcf