[web2py] Re: Autoincrement field

2013-01-29 Thread szimszon
Something about this issue? Should it work?

2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
írta:

 Hi!

 I wonder if somebody could help me.

 The

 definet_table('sometable',
 Field('otherid', compute=lambda r: r['id'])
 )


 doesn't work for me. :( Sould it work? With other than r['id'] it's 
 working.

 Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17


 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a következőt 
 írta:

 yes 

 On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com wrote: 
  I guess that one may want some more constraints on the autoincrement 
 field. 
  For example, it shall begin at 100  for ecample. 
  It may be because for example, before the application exists some paper 
  records where made which were referenced by number  100) 
  
  For such a problem, I've set up with: 
  
  Field('ref_number', compute=lambda r: r['id'] + 100) 
  
  Which I hope would eliminate the race solution as it is calculate upon 
  insertion in the database... Is it the case ? 
  
  -Mathieu 
  
  On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu 
 wrote: 
   What is wrong with the default id field that web2py creates for every 
   table? 
  
   On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: 
Hello, 
 I'm finding this message in a thread from February... 
  
 I thought that autoincremented field would guaranty unicity in the 
table. 
 I'm afraid the provided solution would allow two record to have 
 the 
same autonumber field (think about an access from two users at the 
same time). 
 I guess the autoincrement should be done on the DAL or database 
 side, 
inside a transaction 
  
 What do you think about it ? 
  
On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: 
  
 max_id=   db(db.table.autonumber1).select(db.table.autonumber, 
  # 
 select all records, and only pull the autonumber column 
 orderby=~db.table.autonumber, # 
 descending sort on the autonumber, (highest first) 
 limitby=(0,1) # limit the query 
 and 
 only select the first record 
 ).first().autonumber # pull the first 
 record 
 from the web2py rows object, and get its autonumber member 
  
 db.table.autonumber.default = max_id + 1 # Set the table default 
 as 
 the last autonumber and incremented by one. 
 db.table.autonumber.writable = False 
  
 form = crud.create(db.table) 
  
 -Thadeus 
  
 On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com 
 wrote: 
  thanks for the reply but i'm not a good web2py programmer ... i 
  writing my first real app 
  you can write the code for my request? (i can't understand the 
 post 
   of 
  your link) 
  
  -- 
  You received this message because you are subscribed to the 
 Google 
   Groups web2py-users group. 
  To post to this group, send email to web...@googlegroups.com. 
  To unsubscribe from this group, send email to 
   web2py+un...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com 
   . 
  For more options, visit this group athttp:// 
   groups.google.com/group/web2py?hl=en.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autoincrement field

2013-01-29 Thread szimszon
The really ugly thing is that compute can silently fail and you could end 
up with None in the db table cell :(

2013. január 29., kedd 9:13:29 UTC+1 időpontban szimszon a következőt írta:

 Something about this issue? Should it work?

 2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
 írta:

 Hi!

 I wonder if somebody could help me.

 The

 definet_table('sometable',
 Field('otherid', compute=lambda r: r['id'])
 )


 doesn't work for me. :( Sould it work? With other than r['id'] it's 
 working.

 Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17


 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a következőt 
 írta:

 yes 

 On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com wrote: 
  I guess that one may want some more constraints on the autoincrement 
 field. 
  For example, it shall begin at 100  for ecample. 
  It may be because for example, before the application exists some 
 paper 
  records where made which were referenced by number  100) 
  
  For such a problem, I've set up with: 
  
  Field('ref_number', compute=lambda r: r['id'] + 100) 
  
  Which I hope would eliminate the race solution as it is calculate upon 
  insertion in the database... Is it the case ? 
  
  -Mathieu 
  
  On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu 
 wrote: 
   What is wrong with the default id field that web2py creates for 
 every 
   table? 
  
   On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: 
Hello, 
 I'm finding this message in a thread from February... 
  
 I thought that autoincremented field would guaranty unicity in 
 the 
table. 
 I'm afraid the provided solution would allow two record to have 
 the 
same autonumber field (think about an access from two users at the 
same time). 
 I guess the autoincrement should be done on the DAL or database 
 side, 
inside a transaction 
  
 What do you think about it ? 
  
On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: 
  
 max_id=   db(db.table.autonumber1).select(db.table.autonumber, 
  # 
 select all records, and only pull the autonumber column 
 orderby=~db.table.autonumber, # 
 descending sort on the autonumber, (highest first) 
 limitby=(0,1) # limit the query 
 and 
 only select the first record 
 ).first().autonumber # pull the first 
 record 
 from the web2py rows object, and get its autonumber member 
  
 db.table.autonumber.default = max_id + 1 # Set the table default 
 as 
 the last autonumber and incremented by one. 
 db.table.autonumber.writable = False 
  
 form = crud.create(db.table) 
  
 -Thadeus 
  
 On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com 
 wrote: 
  thanks for the reply but i'm not a good web2py programmer ... 
 i 
  writing my first real app 
  you can write the code for my request? (i can't understand the 
 post 
   of 
  your link) 
  
  -- 
  You received this message because you are subscribed to the 
 Google 
   Groups web2py-users group. 
  To post to this group, send email to web...@googlegroups.com. 
  To unsubscribe from this group, send email to 
   web2py+un...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com 

   . 
  For more options, visit this group athttp:// 
   groups.google.com/group/web2py?hl=en.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autoincrement field

2013-01-29 Thread szimszon
Some other issue: 

db:
import datetime
db.define_table('sometable',
Field('otherid',
  compute=lambda r: 'SPPRIME%s' % (
datetime.date.today().strftime('%y%m%d'
))
)




If I insert a db row from modules

current.db.sometable.insert()


The new record has otherid==None :(


2013. január 29., kedd 9:17:38 UTC+1 időpontban szimszon a következőt írta:

 The really ugly thing is that compute can silently fail and you could end 
 up with None in the db table cell :(

 2013. január 29., kedd 9:13:29 UTC+1 időpontban szimszon a következőt írta:

 Something about this issue? Should it work?

 2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
 írta:

 Hi!

 I wonder if somebody could help me.

 The

 definet_table('sometable',
 Field('otherid', compute=lambda r: r['id'])
 )


 doesn't work for me. :( Sould it work? With other than r['id'] it's 
 working.

 Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17


 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a következőt 
 írta:

 yes 

 On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com wrote: 
  I guess that one may want some more constraints on the autoincrement 
 field. 
  For example, it shall begin at 100  for ecample. 
  It may be because for example, before the application exists some 
 paper 
  records where made which were referenced by number  100) 
  
  For such a problem, I've set up with: 
  
  Field('ref_number', compute=lambda r: r['id'] + 100) 
  
  Which I hope would eliminate the race solution as it is calculate 
 upon 
  insertion in the database... Is it the case ? 
  
  -Mathieu 
  
  On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu 
 wrote: 
   What is wrong with the default id field that web2py creates for 
 every 
   table? 
  
   On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: 
Hello, 
 I'm finding this message in a thread from February... 
  
 I thought that autoincremented field would guaranty unicity in 
 the 
table. 
 I'm afraid the provided solution would allow two record to have 
 the 
same autonumber field (think about an access from two users at 
 the 
same time). 
 I guess the autoincrement should be done on the DAL or database 
 side, 
inside a transaction 
  
 What do you think about it ? 
  
On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: 
  
 max_id=   db(db.table.autonumber1).select(db.table.autonumber, 
  # 
 select all records, and only pull the autonumber column 
 orderby=~db.table.autonumber, # 
 descending sort on the autonumber, (highest first) 
 limitby=(0,1) # limit the query 
 and 
 only select the first record 
 ).first().autonumber # pull the first 
 record 
 from the web2py rows object, and get its autonumber member 
  
 db.table.autonumber.default = max_id + 1 # Set the table 
 default as 
 the last autonumber and incremented by one. 
 db.table.autonumber.writable = False 
  
 form = crud.create(db.table) 
  
 -Thadeus 
  
 On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com 
 wrote: 
  thanks for the reply but i'm not a good web2py programmer ... 
 i 
  writing my first real app 
  you can write the code for my request? (i can't understand 
 the post 
   of 
  your link) 
  
  -- 
  You received this message because you are subscribed to the 
 Google 
   Groups web2py-users group. 
  To post to this group, send email to web...@googlegroups.com. 

  To unsubscribe from this group, send email to 
   web2py+un...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com 

   . 
  For more options, visit this group athttp:// 
   groups.google.com/group/web2py?hl=en.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Update on multiple tables with one form

2013-01-29 Thread Angelo Compagnucci
Hi guys,

I'm looking for a clean way to make an update on mutiple tables with only
one form and cannot find anything clean/simple searching the mailing list.

Tables could be related (in parent-child relation) or not related at all.

I'm missing something or there is no easy way to do that?

Thanks in advance!

-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Insert works using SQLite, not GAE/Datastore

2013-01-29 Thread Alan Etkin
 OK, it seems that GAE isn't fond of floats, but is quite happy with 
doubles

Good to know, but, how did you fix GAE?. Have you changed your model? This 
might be a bug in the DAL adapter

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: retail web application using web2py

2013-01-29 Thread steve van christie
i've already tried that appliance and learn a lot from it.
actually that i want is to be able to add multiple form field and then put
it on multiple tables.
the one that i've found is sheepit jquery plugins.
the problem that i found when i learn from shopping cart concept it's hard
to use 1 form for multiple table (header and detail) for store the
transaction

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] routes.py in case of second application.

2013-01-29 Thread Annet
In my application every registered user has a shortname stored in 
auth_user, which he can use to reference his home page. For this purpose I 
have the following code in 00_db.py:


if request.controller == 'default' and request.function == 'index' and 
request.args(0) == 'nl':
 
row=db(db.auth_user.shortname==request.args(1)).select(db.auth_user.nodeID).first()
 
## check the db and do a redirect
 if row:
 redirect(URL('addressbook','router',args=row.nodeID))
 else:
 session.flash='Shortname unknown'
 redirect(URL('addressbook','index'))


... and in routes.py in the root /web2py folder:


routers = dict(
   BASE = dict(
   default_application = 'init',
   applications = 'ALL',
   default_controller = 'default',
   controllers = 'DEFAULT',
   default_function = 'index',
   ),
   init = dict(
default_function = 'index',
functions =  
['index','user','register','download','call','data','error']
   )
)


For demo purposes I'd like to make a copy of part of my init application, 
call it demo and have it connect to a different database, which I can use 
freely to insert demo records. How do I have to adjust routes.py to make 
this work, just add:


demo= dict(
default_function = 'index',
functions =  ['index','user','download','call','data','error']
   )


... or do I need to make more adjustments?


Kind regards,

Annet.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Some controllers over https

2013-01-29 Thread Annet
In my application I have the following pattern of controllers:

addressbook
cmsaddressbook

about
cmsabout

calendar
cmscalendar

I am going to host this application at webfaction, where you can choose to 
create a secure website, however, I don't want the entire site to be 
secure, just cmsaddressbook, cmsabout and cmscalendar. Is that possible?


Kind regards,

Annet.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Alan Etkin
I think we could make the script work also for 6.x (not sure about the 
minimalist option, that would perhaps require another script)

The changes would be:
- Have the script detect the os version
- If it's 6.x don't compile python/uwsgi (does 6.x provide precompiled 
python 2.7 and an updated version of uwsgi?)
- Use variables for switching from the custom paths to the precompiled 
installation paths for configuration/init files

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Update on multiple tables with one form

2013-01-29 Thread Annet
I solved a similar problem the following way:


# retrieve records
node=db(db.node.id==id).select(db.node.ALL).first()
address=db(db.address.nodeID==id).select(db.address.ALL).first()
telecom=db(db.telecom.nodeID==id).select(db.telecom.ALL).first()
# build form
form=SQLFORM.factory(db.node,db.address,db.telecom)
# prepopulate the form
form.vars.field1=node.field1
...
form.vars.field5=address.field5
...
form.vars.field9=telecom.field9
# process form
if form.process().accepted:
node.update_record(**db.node._filter_fields(form.vars)
address.update_record(**db.address._filter_fields(form.vars)
telecom.update_record(**db.telecom._filter_fields(form.vars)


I hope this helps you solve the problem.

Kind regards,

Annet

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Ivan Gazzola
I've deleted the db but error still remains ...



Il giorno lunedì 28 gennaio 2013 16:32:10 UTC+1, Massimo Di Pierro ha 
scritto:

 I think your problem is corrupted data. You have Pippo Pippo in a field 
 that is either integer or reference. This can happen with sqlite if you 
 change a field type. Delete the database and start again. I do not think 
 there is anything wrong with your code.

 On Sunday, 27 January 2013 15:51:33 UTC-6, Ivan Gazzola wrote:

 Il giorno giovedì 24 gennaio 2013 18:56:59 UTC+1, Massimo Di Pierro ha 
 scritto:


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 db.Relation.contact.widget=SQLFORM.widgetsre.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 should be


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
 db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)




 I forgot to write name in previus post  but the model was ok. Really my 
 model is more complex:

 db.define_table('Nominativi',
 Field('nome',notnull=True, represent=lambda nome:nome.title()),
 Field('categoria',db.Categorie_Nominativi,default='1'),
 Field('sesso',requires=IS_NULL_OR(IS_IN_SET(['maschio','femmina']))),
 Field('mail',requires=IS_NULL_OR(IS_EMAIL(error_message=T('Inserire 
 Una Mail Valida',
 Field('indirizzo'),
 Field('localita', label='Località'),
 Field('cap',requires=IS_NULL_OR(IS_LENGTH(5,5, 
 error_message=T('Inserire Un CAP valido',
 Field('provincia',requires=IS_NULL_OR(IS_IN_SET(Elenco_Province, 
 zero=T('Selezionare una Provincia',
 Field('codice_fiscale',length=20),
 Field('partita_iva',length=20),
 Field('data_di_nascita','date'),
 Field('professione'),
 Field('padre'),
 Field('madre'),
 Field('inviato_da'),
 Field('id_precendente','integer'),
 format=lambda 
 r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])



 db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
 db.Nominativi.categoria.represent = lambda id,row: row.categoria
 db.Nominativi.nome.represent = lambda nome,row: nome.title()

 db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)


 db.define_table('Relazioni',
 Field('nominativo',db.Nomiantivi,required=True),
 Field('referente',db.Nominativi,required=True))

 db.Relazioni.nominativo.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 The error log:
 type 'exceptions.ValueError' invalid literal for int() with base 10: 
 'Pippo Pippo'
 and 'pippo pippo' was the value of 'referente'.

 If i try a simplified model like that i posted before, i can insert the 
 new record but the 'contact' value is stored in 'name' field and 'contact' 
 field is always '0'.

 db.define_table('Person', Field('name'), format='%(name)s')
 db.define_table('Relation', Field('name',db.Person), 
 ('contact',db.Person))
 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)

 I suppose that ajax request lose some data, it would store only the last 
 call to table Person ...



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Arnon Marcus
Ok, we have progress (!)

Now the installation completes fine, and the service uwsgi exists, but 
crashes when I run it...

[root@harmonica2 ~]# service iptables status
 iptables: Firewall is not running.
 [root@harmonica2 ~]# service nginx status
 nginx (pid  1295) is running...
 [root@harmonica2 ~]# service uwsgi start
 Starting uwsgi: [uWSGI] getting INI configuration from 
 /opt/uwsgi-python/uwsgi_for_nginx.conf
[  OK  ]
 [root@harmonica2 ~]# service uwsgi status
 uwsgi dead but pid file exists



My uwsgi.log says:

*** Starting uWSGI 1.2.4 (64bit) on [Tue Jan 29 12:00:10 2013] ***
 compiled with version: 4.4.6 20120305 (Red Hat 4.4.6-4) on 29 January 2013 
 11:57:14
 detected number of CPU cores: 1
 current working directory: /
 writing pidfile to /var/run/uwsgi.pid
 detected binary path: /opt/uwsgi-python/uwsgi
 setuid() to 500
 your memory page size is 4096 bytes
  *** WARNING: you have enabled harakiri without post buffering. Slow 
 upload could be rejected on post-unbuffered webservers *** 
 detected max file descriptor number: 1024
 lock engine: pthread robust mutexes
 shared area mapped at 0x7f43e2462000, you can access it with 
 uwsgi.sharedarea* functions.
 uwsgi socket 0 bound to TCP address 127.0.0.1:9001 fd 3
 Python version: 2.6.6 (r266:84292, Jan 29 2013, 11:55:29)  [GCC 4.4.6 
 20120305 (Red Hat 4.4.6-4)]
 Python main interpreter initialized at 0x22a7510
 python threads support enabled
 your server socket listen backlog is limited to 100 connections
 *** Operational MODE: preforking ***
 added /opt/web-apps/web2py to pythonpath.
 *ImportError: No module named wsgihandler
 *unable to load app 0 (mountpoint='') (callable not found or import error)
 Loading paste environment: config:/opt/uwsgi-python/uwsgi_for_nginx.conf
 *ImportError: No module named paste.deploy*


What now?

On Tuesday, January 29, 2013 4:48:12 AM UTC+2, Massimo Di Pierro wrote:

 LOL

 On Monday, 28 January 2013 15:45:17 UTC-6, Alan Etkin wrote:

  Alns - I don't understand - your link doesn't work (at least for me)...

 No. It's just that Simon Carr said Niphlod is like Batman, and I cannot 
 help addressing him that way whenever I can.

 For more details, see this post
 https://groups.google.com/d/msg/web2py/51GY81Wkp0w/QIUyFfvVsPAJ



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Arnon Marcus
Wait a minute - this is not good... :

Install web2py
   % Total% Received % Xferd  Average Speed   TimeTime Time 
  Current
  Dload  Upload   Total   SpentLeft 
  Speed
 100 8690k  100 8690k0 0  1973k  0  0:00:04  0:00:04 --:--:-- 
 2296k
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 93: unzip: command not found
 Set the ownership for web2py application to uwsgi
 chown: cannot access `/opt/web-apps/web2py': No such file or directory
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 97: cd: 
 /opt/web-apps/web2py: No such file or directory
 chmod: cannot access `./applications': No such file or directory
 Now creating the admin password and creating the scaffolding app package
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 101: sudo: command not found

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Update on multiple tables with one form

2013-01-29 Thread Angelo Compagnucci
Hi Annet!

This is freaking awesome and it worked like a charm!

I found a way to add automatically variables to form.vars, hope this helps!

record = db(...).select().first()

for table in [db.table1, db.table2]:
for field in table.fields:
form.vars[field] = record[table][field]


2013/1/29 Annet anneve...@googlemail.com

 I solved a similar problem the following way:


 # retrieve records
 node=db(db.node.id==id).select(db.node.ALL).first()
 address=db(db.address.nodeID==id).select(db.address.ALL).first()
 telecom=db(db.telecom.nodeID==id).select(db.telecom.ALL).first()
 # build form
 form=SQLFORM.factory(db.node,db.address,db.telecom)
 # prepopulate the form
 form.vars.field1=node.field1
 ...
 form.vars.field5=address.field5
 ...
 form.vars.field9=telecom.field9
 # process form
 if form.process().accepted:
 node.update_record(**db.node._filter_fields(form.vars)
 address.update_record(**db.address._filter_fields(form.vars)
 telecom.update_record(**db.telecom._filter_fields(form.vars)


 I hope this helps you solve the problem.

 Kind regards,

 Annet

  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Niphlod
add 

unzip sudo

to the requirement lines.

On Tuesday, January 29, 2013 11:31:14 AM UTC+1, Arnon Marcus wrote:

 Wait a minute - this is not good... :

 Install web2py
   % Total% Received % Xferd  Average Speed   TimeTime Time 
  Current
  Dload  Upload   Total   SpentLeft 
  Speed
 100 8690k  100 8690k0 0  1973k  0  0:00:04  0:00:04 --:--:-- 
 2296k
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 93: unzip: command not found
 Set the ownership for web2py application to uwsgi
 chown: cannot access `/opt/web-apps/web2py': No such file or directory
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 97: cd: 
 /opt/web-apps/web2py: No such file or directory
 chmod: cannot access `./applications': No such file or directory
 Now creating the admin password and creating the scaffolding app package
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 101: sudo: command not found



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Lamps902
Thank you for the replies, guys! I think my abstract/trivial example may 
have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
in combination with a custom validator (yet to be fully written) to make it 
so that all the elements of a dropdown menu/select are taken from a given 
set of options (a list of file formats), and for the selected option (file 
format), the custom validator will make sure the file is in that format. 
Something like this might be a better description than the initial post:

Field('f_file_format, type='list:string', 
  
requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
selection'), error_message=T(some_error_message)),
  CUSTOM_VALIDATOR(request.vars.f_file_format, 
request.vars.file, error_message=T(some_error_message2))]

 )

To clarify - I'm not seeking to let the user be able to select multiple 
options from the drop down list. Maybe it's better to implement the custom 
validator functionality I'm looking for in the controller, or can it be 
done in the model? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Update on multiple tables with one form

2013-01-29 Thread Angelo Compagnucci
To Massimo,

I think this should be in the book after this
http://web2py.com/books/default/chapter/29/07#One-form-for-multiple-tables

Thanks!


2013/1/29 Angelo Compagnucci angelo.compagnu...@gmail.com

 Hi Annet!

 This is freaking awesome and it worked like a charm!

 I found a way to add automatically variables to form.vars, hope this helps!

 record = db(...).select().first()

 for table in [db.table1, db.table2]:
 for field in table.fields:
 form.vars[field] = record[table][field]


 2013/1/29 Annet anneve...@googlemail.com

 I solved a similar problem the following way:


 # retrieve records
 node=db(db.node.id==id).select(db.node.ALL).first()
 address=db(db.address.nodeID==id).select(db.address.ALL).first()
 telecom=db(db.telecom.nodeID==id).select(db.telecom.ALL).first()
 # build form
 form=SQLFORM.factory(db.node,db.address,db.telecom)
 # prepopulate the form
 form.vars.field1=node.field1
 ...
 form.vars.field5=address.field5
 ...
 form.vars.field9=telecom.field9
 # process form
 if form.process().accepted:
 node.update_record(**db.node._filter_fields(form.vars)
 address.update_record(**db.address._filter_fields(form.vars)
 telecom.update_record(**db.telecom._filter_fields(form.vars)


 I hope this helps you solve the problem.

 Kind regards,

 Annet

  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 Profile: http://it.linkedin.com/in/compagnucciangelo




-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Arnon Marcus
Yeah, already done, it's running...

On Tuesday, January 29, 2013 12:38:49 PM UTC+2, Niphlod wrote:

 add 

 unzip sudo

 to the requirement lines.

 On Tuesday, January 29, 2013 11:31:14 AM UTC+1, Arnon Marcus wrote:

 Wait a minute - this is not good... :

 Install web2py
   % Total% Received % Xferd  Average Speed   TimeTime Time 
  Current
  Dload  Upload   Total   SpentLeft 
  Speed
 100 8690k  100 8690k0 0  1973k  0  0:00:04  0:00:04 --:--:-- 
 2296k
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 93: unzip: command not 
 found
 Set the ownership for web2py application to uwsgi
 chown: cannot access `/opt/web-apps/web2py': No such file or directory
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 97: cd: 
 /opt/web-apps/web2py: No such file or directory
 chmod: cannot access `./applications': No such file or directory
 Now creating the admin password and creating the scaffolding app package
 ./setup-web2py-nginx-uwsgi-on-centos.sh: line 101: sudo: command not 
 found



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: where to post problems/feedback on web2py.com?

2013-01-29 Thread Sean Murphy
Thanks Massimo - I think it would be good to modify

http://www.web2py.com/appliances

to reflect this.

BR,
Seán.

On Monday, January 28, 2013 5:21:30 PM UTC+1, Massimo Di Pierro wrote:

 Please use the github issues: 
 https://github.com/mdipierro/web2py-appliances

 On Monday, 28 January 2013 08:15:08 UTC-6, Sean Murphy wrote:

 Hi,

 I have an issue with one of the appliances on web2py.com.

 On the page:

 http://www.web2py.com/appliances

 it says that we should report any issues we find. However,
 it's not clear where/to whom we report them.

 Any pointers?

 BR,
 Seán.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Update on multiple tables with one form

2013-01-29 Thread Annet
Hi Angelo,

I am glad you solved your problem.

I found a way to add automatically variables to form.vars, hope this helps!

 record = db(...).select().first()

 for table in [db.table1, db.table2]:
 for field in table.fields:
 form.vars[field] = record[table][field]



I'll give it a try, thanks.

Annet. 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Date comparison in datetime field

2013-01-29 Thread Pradeeshnarayan
In my table I have a datetime field. In one condition I have to check only 
date in that field, so I have tried as below

db(db.table_name.timestamp.date()==datetime.today.date())

but it is throwing error as 'AttributeError: 'Field' object has no 
attribute 'date''.

I have tried both 'date()' and 'date' didnt work. 
I have also noticed that the datetime field has some other attributes (day, 
month, year). I can check for attributes day, month, year with the current 
date. But I would like to know if there is any direct way.
I would greatly appreciate any suggestions.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-01-29 Thread Alan Etkin


 I am attempting to write a function that will eventually go in to a 
 migration script to upload legacy data files. As you can see I 


Unable to handle load is too generic for this case. I'd better 
temporarily let dal not to catch the error so there's a more precise 
description of it. Perhaps there are encoding errors when writing the 
stream output?. BTW, Is that the recommended way of adding upload fields 
data programatically (calling the .store method)?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Date comparison in datetime field

2013-01-29 Thread Alan Etkin


 db(db.table_name.timestamp.date()==datetime.today.date())


Dal supports the year, month and day operators. You could split the query 
by the three values using 

db((db... .year()==..date().year)(db ... .month()== ...date().month ...) 
...

Not sure as I never tried it, but should work.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread DenesL

You have found a bug.

The problem is that identical field names are being generated in the form 
for both Relation fields:
input autocomplete=off class=string id=Relation_contact 
name=_autocomplete_Person_name_aux ...
input autocomplete=off class=string id=Relation_name 
name=_autocomplete_Person_name_aux ...
input id=_autocomplete_Person_name_auto name=name type=hidden 
value= /
input id=_autocomplete_Person_name_auto name=contact type=hidden 
value= /



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Reporting server side calculation progress via ajax

2013-01-29 Thread Andriy
I have a time consuming server side calculation, which is triggered by 
edit-form submitting and can run up to several minutes (its a sports event 
data recalculation if rules are changed). During this time I want to 
receive messages via ajax from server and post them in a div for a progress 
visualization. So far I`v done this using DB table for recording log 
messages:

*db.py:*
#here I store messages 
db.define_table('log', Field('message', 'string')) 

*controller #1:*
def editForm():
...
if form.process().accepted:
event=db(db.event.id==request.get_vars.id).select().first()
recalculateEvent(event)

*myModel.py:*
#recalculation must be accessible from all controller files, so I put it in 
a Model 
import myModule

recalculateEvent(event): 
db.log.truncate() #clear log
session._unlock(response)  #without this, this function does not 
allow functions in other controllers to run
db.log.insert(message='Starting Calculation') 
db.commit()  #if I do not commit after every 
insert, messages do not appear in DB table
myModule.calculateSomeMoreData()
for p in players:
db.log.insert(message='Calculating player '+p.name) 
db.commit()
...more calculations...
p.update_record()

*controller#2:*
#ajax calls this function every .5 seconds for messages
def getProgress():
m=' '.join([l.message for l in db(db.log).select()])
return json.dumps(dict(m=m))

*View, javascript:*
$(#submit_button).click(function(e){
$('#progress').show();
GetProgres();
$(#myForm).submit();
});
function GetProgres() {
$.ajax({
type: POST,
url: '{{=URL('controller#2', 'getProgress')}}',
dataType: json,
success: function(data) {
$('#progress').html(data.m);
setTimeout(function() { GetProgres(); }, 500);
},
error: function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(xhr.statusText);
alert(thrownError);
}
});
}

I have 2 problems with this:

1. Every other time web2py throws this error after recalculateEvent(event) 
function completes:
Traceback (most recent call last):
File gluon/main.py, line 576, in wsgibase
File gluon/globals.py, line 749, in _try_store_in_cookie_or_file
File gluon/globals.py, line 768, in _try_store_in_file
IOError: [Errno 13] Permission denied

If I remove db.log.insert+db.commit lines - no error. But how else can I 
transfer live data between running real-time function in a model and 
function in a controller? I tried storing messages in a session, but it 
does not update until model function is finished.

2. Ajax call from view works only when hosting on my local machine and only 
in Opera and IE. It does not call controller#2/getProgress function in 
Chrome and Firefox on localhost. When hosting on outside server it does not 
work on any browser... Only Firefox triggers ajax error, with 
xhr.statusText='error'.

I guess this is something to do with that I`m triggering form submission, 
calculation function and at the same time polling sever. But I have no idea 
what to do.

May be if my approach is totally wrong somebody can suggest how to 
implement this in other way.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reporting server side calculation progress via ajax

2013-01-29 Thread Niphlod
can't reproduce right now, but usually for this kind of stuff I'd use a 
totally external process. 
Beware that several minutes standing requests may be killed by your 
webserver to free up resources (usually governed by the timeout* 
parameters).

If you'd like to have that running inside your webserver process, I'd adopt 
a slightly different pattern

1. page that display and process form
2. upon correct submission, call another function with the recalculateEvent 
via ajax
3. open a div somewhere to poll for status progress

So you'd have:
a) a thread that processes the form and then return ASAP rendering your 
template page
b) a thread that does recalculateEvent, called one-time-only by the a) 
rendered page
c) a thread that reports execution and returns ASAP, called several times 
by the a) rendered page, filling a component within the template page

for b) and c) putting a session.forget() at the top should do no harm.

On Tuesday, January 29, 2013 12:29:03 PM UTC+1, Andriy wrote:

 I have a time consuming server side calculation, which is triggered by 
 edit-form submitting and can run up to several minutes (its a sports event 
 data recalculation if rules are changed). During this time I want to 
 receive messages via ajax from server and post them in a div for a progress 
 visualization. So far I`v done this using DB table for recording log 
 messages:

 *db.py:*
 #here I store messages 
 db.define_table('log', Field('message', 'string')) 

 *controller #1:*
 def editForm():
 ...
 if form.process().accepted:
 event=db(db.event.id==request.get_vars.id).select().first()
 recalculateEvent(event)

 *myModel.py:*
 #recalculation must be accessible from all controller files, so I put it 
 in a Model 
 import myModule

 recalculateEvent(event): 
 db.log.truncate() #clear log
 session._unlock(response)  #without this, this function does not 
 allow functions in other controllers to run
 db.log.insert(message='Starting Calculation') 
 db.commit()  #if I do not commit after every 
 insert, messages do not appear in DB table
 myModule.calculateSomeMoreData()
 for p in players:
 db.log.insert(message='Calculating player '+p.name) 
 db.commit()
 ...more calculations...
 p.update_record()

 *controller#2:*
 #ajax calls this function every .5 seconds for messages
 def getProgress():
 m=' '.join([l.message for l in db(db.log).select()])
 return json.dumps(dict(m=m))

 *View, javascript:*
 $(#submit_button).click(function(e){
 $('#progress').show();
 GetProgres();
 $(#myForm).submit();
 });
 function GetProgres() {
 $.ajax({
 type: POST,
 url: '{{=URL('controller#2', 'getProgress')}}',
 dataType: json,
 success: function(data) {
 $('#progress').html(data.m);
 setTimeout(function() { GetProgres(); }, 500);
 },
 error: function (xhr, ajaxOptions, thrownError){
 alert(xhr.status);
 alert(xhr.statusText);
 alert(thrownError);
 }
 });
 }

 I have 2 problems with this:

 1. Every other time web2py throws this error after recalculateEvent(event) 
 function completes:
 Traceback (most recent call last):
 File gluon/main.py, line 576, in wsgibase
 File gluon/globals.py, line 749, in _try_store_in_cookie_or_file
 File gluon/globals.py, line 768, in _try_store_in_file
 IOError: [Errno 13] Permission denied

 If I remove db.log.insert+db.commit lines - no error. But how else can I 
 transfer live data between running real-time function in a model and 
 function in a controller? I tried storing messages in a session, but it 
 does not update until model function is finished.

 2. Ajax call from view works only when hosting on my local machine and 
 only in Opera and IE. It does not call controller#2/getProgress function in 
 Chrome and Firefox on localhost. When hosting on outside server it does not 
 work on any browser... Only Firefox triggers ajax error, with 
 xhr.statusText='error'.

 I guess this is something to do with that I`m triggering form submission, 
 calculation function and at the same time polling sever. But I have no idea 
 what to do.

 May be if my approach is totally wrong somebody can suggest how to 
 implement this in other way.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Insert works using SQLite, not GAE/Datastore

2013-01-29 Thread Scott Hunter
Sorry - yes, I changed the model, replacing the floats with doubles.

On Tuesday, January 29, 2013 4:33:12 AM UTC-5, Alan Etkin wrote:

  OK, it seems that GAE isn't fond of floats, but is quite happy with 
 doubles

 Good to know, but, how did you fix GAE?. Have you changed your model? This 
 might be a bug in the DAL adapter


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: how to install plugin_wiki?

2013-01-29 Thread Massimo Di Pierro
Plugin wiki has to die. Almost all of its functionalities are now in web2py 
core (auth.wiki). It will be removed from the book.

On Tuesday, 29 January 2013 03:02:11 UTC-6, Paul Whipp wrote:

 This is an old thread but there is still the same issue with the 
 documentation which is very worrying. Is there a documentation update 
 somewhere?

 The link in the documentation (
 http://127.0.0.1:8000/myapp/plugin_wiki/index) implies that the plug in 
 is added to your own app called myapp (contradicting the preceding 
 paragraph) but http://127.0.0.1:8000/welcome/plugin_wiki/index does work 
 and you can proceed from there (as long as you apply the plugin to the 
 welcome scaffolding as suggested).

 On Thursday, 21 October 2010 08:28:29 UTC+10, Timmie wrote:

  Make a new app.
  Open the app in design/admin.
  Install the plug-in by scrolling down to the bottom of the admin page
  to where it says install plug-in.
 Could you please add this to the book online?
 It's not descibed there.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autoincrement field

2013-01-29 Thread Massimo Di Pierro
Please open a ticket about this.

On Tuesday, 29 January 2013 03:05:17 UTC-6, szimszon wrote:

 Some other issue: 

 db:
 import datetime
 db.define_table('sometable',
 Field('otherid',
   compute=lambda r: 'SPPRIME%s' % (
 datetime.date.today().strftime(
 '%y%m%d'))
 )




 If I insert a db row from modules

 current.db.sometable.insert()


 The new record has otherid==None :(


 2013. január 29., kedd 9:17:38 UTC+1 időpontban szimszon a következőt írta:

 The really ugly thing is that compute can silently fail and you could end 
 up with None in the db table cell :(

 2013. január 29., kedd 9:13:29 UTC+1 időpontban szimszon a következőt 
 írta:

 Something about this issue? Should it work?

 2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
 írta:

 Hi!

 I wonder if somebody could help me.

 The

 definet_table('sometable',
 Field('otherid', compute=lambda r: r['id'])
 )


 doesn't work for me. :( Sould it work? With other than r['id'] it's 
 working.

 Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17


 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a 
 következőt írta:

 yes 

 On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com 
 wrote: 
  I guess that one may want some more constraints on the autoincrement 
 field. 
  For example, it shall begin at 100  for ecample. 
  It may be because for example, before the application exists some 
 paper 
  records where made which were referenced by number  100) 
  
  For such a problem, I've set up with: 
  
  Field('ref_number', compute=lambda r: r['id'] + 100) 
  
  Which I hope would eliminate the race solution as it is calculate 
 upon 
  insertion in the database... Is it the case ? 
  
  -Mathieu 
  
  On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu 
 wrote: 
   What is wrong with the default id field that web2py creates for 
 every 
   table? 
  
   On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: 
Hello, 
 I'm finding this message in a thread from February... 
  
 I thought that autoincremented field would guaranty unicity in 
 the 
table. 
 I'm afraid the provided solution would allow two record to have 
 the 
same autonumber field (think about an access from two users at 
 the 
same time). 
 I guess the autoincrement should be done on the DAL or database 
 side, 
inside a transaction 
  
 What do you think about it ? 
  
On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com 
 wrote: 
  
 max_id=   
 db(db.table.autonumber1).select(db.table.autonumber,  # 
 select all records, and only pull the autonumber column 
 orderby=~db.table.autonumber, 
 # 
 descending sort on the autonumber, (highest first) 
 limitby=(0,1) # limit the 
 query and 
 only select the first record 
 ).first().autonumber # pull the first 
 record 
 from the web2py rows object, and get its autonumber member 
  
 db.table.autonumber.default = max_id + 1 # Set the table 
 default as 
 the last autonumber and incremented by one. 
 db.table.autonumber.writable = False 
  
 form = crud.create(db.table) 
  
 -Thadeus 
  
 On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com 
 wrote: 
  thanks for the reply but i'm not a good web2py programmer 
 ... i 
  writing my first real app 
  you can write the code for my request? (i can't understand 
 the post 
   of 
  your link) 
  
  -- 
  You received this message because you are subscribed to the 
 Google 
   Groups web2py-users group. 
  To post to this group, send email to web...@googlegroups.com. 

  To unsubscribe from this group, send email to 
   web2py+un...@googlegroups.com
 web2py%2bunsubscr...@googlegroups.com 
   . 
  For more options, visit this group athttp:// 
   groups.google.com/group/web2py?hl=en.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Update on multiple tables with one form

2013-01-29 Thread Anthony
On Tuesday, January 29, 2013 4:40:04 AM UTC-5, AngeloC wrote:

 Hi Steve,

 Great suggestion, but the problem remains. How can I update a record that 
 I cannot select?

 The SQLFORM.factory way cannot permits to select a record to prepopulate 
 the forms, so you only can insert, but not update a record ...


I think you should be able to construct a dict (or Storage object) to pass 
to SQLFORM.factory as a record. The keys of the dict should be the same as 
the names of the fields you pass in, and the dict should also include a 
dummy id key (its value doesn't matter, as it will be ignored in 
constructing the form if you set showid=False). Something like:

record = dict(id=1, field1=value1, field2=value2, ...) 
form = SQLFORM.factory(Field('field1'), Field('field2'), ..., 
record=record,showid
=False)

I haven't tried it, but that might work.

Anthony

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Massimo Di Pierro
Can you submit a patch?

On Tuesday, 29 January 2013 05:36:53 UTC-6, DenesL wrote:


 You have found a bug.

 The problem is that identical field names are being generated in the form 
 for both Relation fields:
 input autocomplete=off class=string id=Relation_contact 
 name=_autocomplete_Person_name_aux ...
 input autocomplete=off class=string id=Relation_name 
 name=_autocomplete_Person_name_aux ...
 input id=_autocomplete_Person_name_auto name=name type=hidden 
 value= /
 input id=_autocomplete_Person_name_auto name=contact type=hidden 
 value= /





-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Massimo Di Pierro
Mind I think it should be possible to do:

auto = 
SQLFORM.widgets.autocomplete(request,db.Person,id_field=db.Person.idhttp://db.person.id/
)

db.define_table('Person', Field('name'), format='%(name)s')
db.define_table('Relation', Field('name',db.Person), ('contact',db.Person))
db.Relation.name.widget=auto
db.Relation.contact.widget=auto

On Tuesday, 29 January 2013 05:36:53 UTC-6, DenesL wrote:


 You have found a bug.

 The problem is that identical field names are being generated in the form 
 for both Relation fields:
 input autocomplete=off class=string id=Relation_contact 
 name=_autocomplete_Person_name_aux ...
 input autocomplete=off class=string id=Relation_name 
 name=_autocomplete_Person_name_aux ...
 input id=_autocomplete_Person_name_auto name=name type=hidden 
 value= /
 input id=_autocomplete_Person_name_auto name=contact type=hidden 
 value= /





-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py world conference 2013

2013-01-29 Thread Bill Thayer
I'll mention it on my Dallas Python mailing list too. Don't know how many 
web2py users we have in Texas though.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Update on multiple tables with one form

2013-01-29 Thread Angelo Compagnucci
Thanks Antony,

I think the previous solution is the most simple and clean way to make
multiple updates on Web2py and worked wonderfully. Anyway, thank you for
your intrest!


2013/1/29 Anthony abasta...@gmail.com

 On Tuesday, January 29, 2013 4:40:04 AM UTC-5, AngeloC wrote:

 Hi Steve,

 Great suggestion, but the problem remains. How can I update a record that
 I cannot select?

 The SQLFORM.factory way cannot permits to select a record to prepopulate
 the forms, so you only can insert, but not update a record ...


 I think you should be able to construct a dict (or Storage object) to pass
 to SQLFORM.factory as a record. The keys of the dict should be the same as
 the names of the fields you pass in, and the dict should also include a
 dummy id key (its value doesn't matter, as it will be ignored in
 constructing the form if you set showid=False). Something like:

 record = dict(id=1, field1=value1, field2=value2, ...)
 form = SQLFORM.factory(Field('field1'), Field('field2'), ..., record=
 record, showid=False)

 I haven't tried it, but that might work.

 Anthony

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Anthony
If you don't want to allow the user to select multiple options, then why is 
the field type list:string rather than just string? If you make it just a 
string type, then you will be able to apply a list of validators, as below.

Anthony

On Tuesday, January 29, 2013 5:39:59 AM UTC-5, Lamps902 wrote:

 Thank you for the replies, guys! I think my abstract/trivial example may 
 have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
 in combination with a custom validator (yet to be fully written) to make it 
 so that all the elements of a dropdown menu/select are taken from a given 
 set of options (a list of file formats), and for the selected option (file 
 format), the custom validator will make sure the file is in that format. 
 Something like this might be a better description than the initial post:

 Field('f_file_format, type='list:string', 
   
 requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
 selection'), error_message=T(some_error_message)),
   CUSTOM_VALIDATOR(request.vars.f_file_format, 
 request.vars.file, error_message=T(some_error_message2))]

 )

 To clarify - I'm not seeking to let the user be able to select multiple 
 options from the drop down list. Maybe it's better to implement the custom 
 validator functionality I'm looking for in the controller, or can it be 
 done in the model? Thank you.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] python 2.5 problem: ValueError: Invalid boundary in multipart form: ''

2013-01-29 Thread select
When uploading zip files in a form I get this error
Traceback (most recent call last):
File gluon/main.py, line 503, in wsgibase
File gluon/main.py, line 321, in parse_get_post_vars
File cgi.pyc, line 534, in __init__
File cgi.pyc, line 659, in read_multi
File cgi.pyc, line 534, in __init__
File cgi.pyc, line 650, in read_multi
ValueError: Invalid boundary in multipart form: ''

It seems to be an error of python 2.5 (see the discussion here 
http://trac.edgewall.org/ticket/9880)
Upgrading to a higher python version solves this problem (e.g. to 2.7) 
Now the problem is that we are building packages from the binary 
distributions for osx and windows - 
http://web2py.com/examples/default/download

Is there a chance that you build the packages with a higher python version?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Update on multiple tables with one form

2013-01-29 Thread Richard Vézina
And what about .as_dict()?

record = select_something.as_dict()

?

Richard


On Tue, Jan 29, 2013 at 9:28 AM, Angelo Compagnucci 
angelo.compagnu...@gmail.com wrote:

 Thanks Antony,

 I think the previous solution is the most simple and clean way to make
 multiple updates on Web2py and worked wonderfully. Anyway, thank you for
 your intrest!


 2013/1/29 Anthony abasta...@gmail.com

 On Tuesday, January 29, 2013 4:40:04 AM UTC-5, AngeloC wrote:

 Hi Steve,

 Great suggestion, but the problem remains. How can I update a record
 that I cannot select?

 The SQLFORM.factory way cannot permits to select a record to prepopulate
 the forms, so you only can insert, but not update a record ...


 I think you should be able to construct a dict (or Storage object) to
 pass to SQLFORM.factory as a record. The keys of the dict should be the
 same as the names of the fields you pass in, and the dict should also
 include a dummy id key (its value doesn't matter, as it will be ignored
 in constructing the form if you set showid=False). Something like:

 record = dict(id=1, field1=value1, field2=value2, ...)
 form = SQLFORM.factory(Field('field1'), Field('field2'), ..., record=
 record, showid=False)

 I haven't tried it, but that might work.

 Anthony

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 Profile: http://it.linkedin.com/in/compagnucciangelo

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Autoincrement field

2013-01-29 Thread szimszon
http://code.google.com/p/web2py/issues/detail?id=1307

and

http://code.google.com/p/web2py/issues/detail?id=1308

Tnx.


2013. január 29., kedd 15:15:59 UTC+1 időpontban Massimo Di Pierro a 
következőt írta:

 Please open a ticket about this.

 On Tuesday, 29 January 2013 03:05:17 UTC-6, szimszon wrote:

 Some other issue: 

 db:
 import datetime
 db.define_table('sometable',
 Field('otherid',
   compute=lambda r: 'SPPRIME%s' % (
 datetime.date.today().strftime(
 '%y%m%d'))
 )




 If I insert a db row from modules

 current.db.sometable.insert()


 The new record has otherid==None :(


 2013. január 29., kedd 9:17:38 UTC+1 időpontban szimszon a következőt 
 írta:

 The really ugly thing is that compute can silently fail and you could 
 end up with None in the db table cell :(

 2013. január 29., kedd 9:13:29 UTC+1 időpontban szimszon a következőt 
 írta:

 Something about this issue? Should it work?

 2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
 írta:

 Hi!

 I wonder if somebody could help me.

 The

 definet_table('sometable',
 Field('otherid', compute=lambda r: r['id'])
 )


 doesn't work for me. :( Sould it work? With other than r['id'] it's 
 working.

 Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17


 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a 
 következőt írta:

 yes 

 On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com 
 wrote: 
  I guess that one may want some more constraints on the 
 autoincrement field. 
  For example, it shall begin at 100  for ecample. 
  It may be because for example, before the application exists some 
 paper 
  records where made which were referenced by number  100) 
  
  For such a problem, I've set up with: 
  
  Field('ref_number', compute=lambda r: r['id'] + 100) 
  
  Which I hope would eliminate the race solution as it is calculate 
 upon 
  insertion in the database... Is it the case ? 
  
  -Mathieu 
  
  On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu 
 wrote: 
   What is wrong with the default id field that web2py creates for 
 every 
   table? 
  
   On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: 
Hello, 
 I'm finding this message in a thread from February... 
  
 I thought that autoincremented field would guaranty unicity in 
 the 
table. 
 I'm afraid the provided solution would allow two record to 
 have the 
same autonumber field (think about an access from two users at 
 the 
same time). 
 I guess the autoincrement should be done on the DAL or 
 database side, 
inside a transaction 
  
 What do you think about it ? 
  
On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com 
 wrote: 
  
 max_id=   
 db(db.table.autonumber1).select(db.table.autonumber,  # 
 select all records, and only pull the autonumber column 
 orderby=~db.table.autonumber, 
 # 
 descending sort on the autonumber, (highest first) 
 limitby=(0,1) # limit the 
 query and 
 only select the first record 
 ).first().autonumber # pull the first 
 record 
 from the web2py rows object, and get its autonumber member 
  
 db.table.autonumber.default = max_id + 1 # Set the table 
 default as 
 the last autonumber and incremented by one. 
 db.table.autonumber.writable = False 
  
 form = crud.create(db.table) 
  
 -Thadeus 
  
 On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com 
 wrote: 
  thanks for the reply but i'm not a good web2py programmer 
 ... i 
  writing my first real app 
  you can write the code for my request? (i can't understand 
 the post 
   of 
  your link) 
  
  -- 
  You received this message because you are subscribed to the 
 Google 
   Groups web2py-users group. 
  To post to this group, send email to 
 web...@googlegroups.com. 
  To unsubscribe from this group, send email to 
   web2py+un...@googlegroups.com
 web2py%2bunsubscr...@googlegroups.com 
   . 
  For more options, visit this group athttp:// 
   groups.google.com/group/web2py?hl=en.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reporting server side calculation progress via ajax

2013-01-29 Thread Andriy
I wrote a reply, but pressed replay to author by mistake. Now I do not 
know if it was PM or not and message is gone, this interface is confusing...

The thing is, what Niphlod suggested works on localhost, but does not work 
on free pythonanywhere account. Server does not return 200OK for any 
request while _recalculate function is running. I searched their forums and 
indeed threads are disabled on pythonanywhere. So I guess it does not work 
because of that. I have no other hosting options right now to check...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: .update_or_insert not optimized!!

2013-01-29 Thread Christian Espinoza
Hi all, I'm wondering about if .update_or_insert was enhanced or not yet?

Thanks in advance.
Christian.

El jueves, 3 de mayo de 2012 09:46:46 UTC-4, Anthony escribió:

 You're manual version updates only two fields, whereas update_or_insert 
 updates six fields -- maybe that's the difference.

 Anthony 


 Yes, but I want to insert a new record with six fields, but update only 
 two if the record exists. How to do that with .update_or_insert?


 Looks like you can't. Might be a nice enhancement, though. Maybe it could 
 take _insert_fields and _update_fields arguments, which could be lists 
 of field names to insert and update, respectively.

 Anthony 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] routes.py in case of second application.

2013-01-29 Thread Jonathan Lundell
On 29 Jan 2013, at 1:44 AM, Annet anneve...@googlemail.com wrote:
 In my application every registered user has a shortname stored in auth_user, 
 which he can use to reference his home page. For this purpose I have the 
 following code in 00_db.py:
 
 
 if request.controller == 'default' and request.function == 'index' and 
 request.args(0) == 'nl':
  
 row=db(db.auth_user.shortname==request.args(1)).select(db.auth_user.nodeID).first()
  ## check the db and do a redirect
  if row:
  redirect(URL('addressbook','router',args=row.nodeID))
  else:
  session.flash='Shortname unknown'
  redirect(URL('addressbook','index'))
 
 
 ... and in routes.py in the root /web2py folder:
 
 
 routers = dict(
BASE = dict(
default_application = 'init',
applications = 'ALL',
default_controller = 'default',
controllers = 'DEFAULT',
default_function = 'index',
),
init = dict(
 default_function = 'index',
 functions =  
 ['index','user','register','download','call','data','error']
)
 )
 
 
 For demo purposes I'd like to make a copy of part of my init application, 
 call it demo and have it connect to a different database, which I can use 
 freely to insert demo records. How do I have to adjust routes.py to make this 
 work, just add:
 
 
 demo= dict(
 default_function = 'index',
 functions =  ['index','user','download','call','data','error']
)
 
 
 ... or do I need to make more adjustments?

I think that's all you need.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] embed image from variable

2013-01-29 Thread BlueShadow
Hi,
I like to add Graphs with matplotlib directly into my sites. I used a 
web2py slice to get an image into a variable:
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
import cStringIO

def plot(title='title',xlab='x',ylab='y',mode='plot',
 data={'xxx':[(0,0),(1,1),(1,2),(3,3)],
   'yyy':[(0,0,.2,.2),(2,1,0.2,0.2),(2,2,0.2,0.2),(3,3,0.2,0.3
)]}):
fig=Figure()
fig.set_facecolor('white')
ax=fig.add_subplot(111)
if title: ax.set_title(title)
if xlab: ax.set_xlabel(xlab)
if ylab: ax.set_ylabel(ylab)
legend=[]
keys=sorted(data)
for key in keys:
stream = data[key]
(x,y)=([],[])
for point in stream:
x.append(point[0])
y.append(point[1])
if mode=='plot':
ell=ax.plot(x, y)
legend.append((ell,key))
if mode=='hist':
ell=ax.hist(y,20)
#if legend:
#ax.legend([x for (x,y) in legend], [y for (x,y) in legend], 
#  'upper right', shadow=True)
canvas=FigureCanvas(fig)
stream=cStringIO.StringIO()
canvas.print_png(stream)
return stream.getvalue()

def pcolor2d(title='title',xlab='x',ylab='y',
 z=[[1,2,3,4],[2,3,4,5],[3,4,5,6],[4,5,6,7]]):
fig=Figure()
fig.set_facecolor('white')
ax=fig.add_subplot(111)
if title: ax.set_title(title)
if xlab: ax.set_xlabel(xlab)
if ylab: ax.set_ylabel(ylab)
image=ax.imshow(z)
image.set_interpolation('bilinear')
canvas=FigureCanvas(fig)
stream=cStringIO.StringIO()
canvas.print_png(stream)
return stream.getvalue()


this is my controler:
def Testimg():
plotimg=plot()
return dict(plotimg=plotimg)

and this is my view:
{{extend 'layout.html'}}
Some Content
table
{{=TR(TD(Test),TD('Value'))}}
/table
{{=plotimg}}

I managed to view the plot but I cant get it embedded into my page with 
some content above and below.
And I get (probably) the binary png displayed as text

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] embed image from variable

2013-01-29 Thread Bruno Rocha
I guess you can try


 {{=IMG(_src=plotimg)}}


or

img src={{=plotimg}} /

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Update on multiple tables with one form

2013-01-29 Thread Anthony
On Tuesday, January 29, 2013 10:36:39 AM UTC-5, Richard wrote:

 And what about .as_dict()?

 record = select_something.as_dict()


Actually, you wouldn't need to use .as_dict() if you already have a Row 
object -- you can submit that directly as the record. The problem is that 
if the Row object is based on a join between multiple linked tables, the 
field names will be of the form [tablename].[fieldname] rather than just 
[fieldname].

Anthony 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: python 2.5 problem: ValueError: Invalid boundary in multipart form: ''

2013-01-29 Thread Niphlod
windows build should be against python 2.7.3

On Tuesday, January 29, 2013 3:52:27 PM UTC+1, select wrote:

 When uploading zip files in a form I get this error
 Traceback (most recent call last):
 File gluon/main.py, line 503, in wsgibase
 File gluon/main.py, line 321, in parse_get_post_vars
 File cgi.pyc, line 534, in __init__
 File cgi.pyc, line 659, in read_multi
 File cgi.pyc, line 534, in __init__
 File cgi.pyc, line 650, in read_multi
 ValueError: Invalid boundary in multipart form: ''

 It seems to be an error of python 2.5 (see the discussion here 
 http://trac.edgewall.org/ticket/9880)
 Upgrading to a higher python version solves this problem (e.g. to 2.7) 
 Now the problem is that we are building packages from the binary 
 distributions for osx and windows - 
 http://web2py.com/examples/default/download

 Is there a chance that you build the packages with a higher python version?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] embed image from variable

2013-01-29 Thread BlueShadow
I tried that but it doesn't show an image it puts the img tag in the html 
code and fills the src= with the pinary stuff but no image is displayed

On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:

 I guess you can try
  

 {{=IMG(_src=plotimg)}}


 or 

 img src={{=plotimg}} / 




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
Hi,

I am trying to use web2py to manage a database and display the resulting 
JSON in AngularJS.  To render an angular compatible view I need to pass raw 
html in a view (for example the html needs to start with 'html ng-app' 
and so forth). Of course I could place the files in the static folder, but 
then I can't protect the files via @auth.requires_login() etc.

What would be the best way to achieve that?

Thank you,
  Dirk

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Open generated file from action function

2013-01-29 Thread Luca Zacchetti
Hi everybody, I've a problem and need your help.
I have a view which contains many things including an SQLFORM.factory used 
to set the query for a report generation.
The first time I submit the form the report is correctly opened, the second 
time the page is just reloaded...how can I fix the problem?
Here is my code snippet...

def index():   
form = SQLFORM.factory(...)
if form.accepts(request.vars, session): 
#report generation...
response.headers['Content-Type']='application/vnd.ms-excel'
response.headers['Content-Disposition']='attachment; 
filename=%s.xls'%filename
response.headers['Content-Title']='%s.xls'%filename 
return data #otherwise the file isn't opened   
return locals()

Many thanks!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Reporting server side calculation progress via ajax

2013-01-29 Thread Vinicius Assef
Your problem number 1 is because you are commiting before
p.update_record(). Put your db.commit() after p.update_record() and
see what happens.

Your problem number 2 probably is because your GetProgres() function
should send a GET request. But your  controller#2/GetProgress() is
reading more rows than is needed. Try to return a simple timestamp to
check if the request is touching your web2py controller.


On Tue, Jan 29, 2013 at 9:29 AM, Andriy unhappyhardc...@gmail.com wrote:
 I have a time consuming server side calculation, which is triggered by
 edit-form submitting and can run up to several minutes (its a sports event
 data recalculation if rules are changed). During this time I want to receive
 messages via ajax from server and post them in a div for a progress
 visualization. So far I`v done this using DB table for recording log
 messages:

 db.py:
 #here I store messages
 db.define_table('log', Field('message', 'string'))

 controller #1:
 def editForm():
 ...
 if form.process().accepted:
 event=db(db.event.id==request.get_vars.id).select().first()
 recalculateEvent(event)

 myModel.py:
 #recalculation must be accessible from all controller files, so I put it in
 a Model
 import myModule

 recalculateEvent(event):
 db.log.truncate() #clear log
 session._unlock(response)  #without this, this function does not
 allow functions in other controllers to run
 db.log.insert(message='Starting Calculation')
 db.commit()  #if I do not commit after every insert,
 messages do not appear in DB table
 myModule.calculateSomeMoreData()
 for p in players:
 db.log.insert(message='Calculating player '+p.name)
 db.commit()
 ...more calculations...
 p.update_record()

 controller#2:
 #ajax calls this function every .5 seconds for messages
 def getProgress():
 m=' '.join([l.message for l in db(db.log).select()])
 return json.dumps(dict(m=m))

 View, javascript:
 $(#submit_button).click(function(e){
 $('#progress').show();
 GetProgres();
 $(#myForm).submit();
 });
 function GetProgres() {
 $.ajax({
 type: POST,
 url: '{{=URL('controller#2', 'getProgress')}}',
 dataType: json,
 success: function(data) {
 $('#progress').html(data.m);
 setTimeout(function() { GetProgres(); }, 500);
 },
 error: function (xhr, ajaxOptions, thrownError){
 alert(xhr.status);
 alert(xhr.statusText);
 alert(thrownError);
 }
 });
 }

 I have 2 problems with this:

 1. Every other time web2py throws this error after recalculateEvent(event)
 function completes:
 Traceback (most recent call last):
 File gluon/main.py, line 576, in wsgibase
 File gluon/globals.py, line 749, in _try_store_in_cookie_or_file
 File gluon/globals.py, line 768, in _try_store_in_file
 IOError: [Errno 13] Permission denied

 If I remove db.log.insert+db.commit lines - no error. But how else can I
 transfer live data between running real-time function in a model and
 function in a controller? I tried storing messages in a session, but it does
 not update until model function is finished.

 2. Ajax call from view works only when hosting on my local machine and only
 in Opera and IE. It does not call controller#2/getProgress function in
 Chrome and Firefox on localhost. When hosting on outside server it does not
 work on any browser... Only Firefox triggers ajax error, with
 xhr.statusText='error'.

 I guess this is something to do with that I`m triggering form submission,
 calculation function and at the same time polling sever. But I have no idea
 what to do.

 May be if my approach is totally wrong somebody can suggest how to implement
 this in other way.

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Can I change a boolean field widget to a button?

2013-01-29 Thread Jim S
I have a form that is going to hold a number of boolean fields.  I want to 
change them to buttons instead of checkboxes so I can use the bootstrap 
button widgets.  How can I chance the boolean widget from a checkbox to a 
button and have the value properly put back into the database?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] About unary operator consistency in queries

2013-01-29 Thread Alan Etkin
With trunk, I have tested the behavior of the ~ operator, and doesn't seem 
consistent to me:

Here Bruno gives a working example of belongs negation
https://groups.google.com/d/msg/web2py/fCB9a4K9FqU/GBLwfzNnkjMJ

But the book uses this example:

rows = db((~db.person.name=='Alex') | (db.person.id3)).select()


This is wat I get in the console (with SQLite/Python 2.7.3)

 q = ~db.auth_user.id.belongs(1,2,3)
 q
Query (NOT (auth_user.id IN (1,2,3)))

 q = ~db.auth_user.id==0
 q
Query (auth_user.id DESC = 0)

 q = ~db.auth_user.id0
 q
Query (auth_user.id DESC  0)
 q.select()
Traceback (most recent call last):
  File console, line 1, in module
AttributeError: 'Query' object has no attribute 'select'
 db(q).select()
Traceback (most recent call last):
...
OperationalError: near DESC: syntax error


Note that the second and third query would return an OperationalError (the 
INVERT operator is used instead of NOT)

To avoid the error the syntax must be ~(db.auth_user.id==0), with 
parethesis.

Is this an problem with the sqlite adapter only?


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: About unary operator consistency in queries

2013-01-29 Thread Alan Etkin
Sorry, here's the actual error:

 db(q).select()
...
OperationalError: near DESC: syntax error

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] embed image from variable

2013-01-29 Thread BlueShadow
I did some experimenting the problem is putting the image into the return 
dict() or into any variable.
I got no clue how to fix it or why that is the problem.

On Tuesday, January 29, 2013 5:07:16 PM UTC+1, BlueShadow wrote:

 I tried that but it doesn't show an image it puts the img tag in the html 
 code and fills the src=binary with the pinary stuff but no image is 
 displayed

 On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:

 I guess you can try
  

 {{=IMG(_src=plotimg)}}


 or 

 img src={{=plotimg}} / 




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] need bootstrap-tooltip.js v2.2.1

2013-01-29 Thread Richard
Hello,

I found tooltip (no new line) issue with new bootstrap 2.2.2...

I would have look at the differences between bootstrap-tooltip.js v2.2.1 
and bootstrap-tooltip.js v2.2.2, but I can't get a zip on the web of 
bootstrap 2.2.1. I try download the github repo and revert to 2.2.1, but I 
start messing with git that I don't really know.

If someone have this file : bootstrap-tooltip.js v2.2.1

Thanks

Richard

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: web2py world conference 2013

2013-01-29 Thread Vinicius Assef
I share Bruno ideas, too.

On Mon, Jan 28, 2013 at 2:41 PM, Bruno Rocha rochacbr...@gmail.com wrote:
 I think it is ok to have different dates on each places.

 Each country/place can do in preferred data since it is in the same week.

 Lets say:

 place_here - May 16 (Thu)
 place_here - May 17 (Fri)
 Chicago - May 18 (Sat)
 Brasil - May 19 (Sun)

 Of course we can have more than one place at the same day, no problem but we
 can schedule the days from 16 to 19 May.

 My proposal on how it can work:

 Each organizer needs a physical room, local advertisement,  Internet
 connection, recording equipment.

 Vanue and registration
 The event has to exist in a Physical place, people needs to register and
 submit proposals on the conference website.

 Funding
 The organizers can sell sponsorship or call for funding in order to pay
 for event bills (as recording, coffee and lunch) - But this is
 responsibility of reach organizer, but all the sponsorship will advertising
 on the main website and mailing or other promotion material.

 Proposals
 The proposals will be voted online, people from any place can vote and this
 will be used to choose which presentations will be recorded to be included
 on the website track.

 The event
 Its a normal local meetup, people goes there, have coffee break and
 networking, attend to presentations etc... The only difference is that all
 the presentation and activities needs to be recorded in a good audio/video
 quality. (optionally transmitted via hangout on air if the place has good
 Internet connection)

 The videos:
 Video need to be in a good quality, uploaded to YouTube conference account.
 If not presented in English, the video will need to be subtitled to English
 using the YouTube (Amara) tools, for this we count on local volunteers.

 The Conference
 Ok, in this case the conference will be just a set of videos, organized in
 tracks and for each track/video we can have a forum like place for people
 to interact about that content. So anybody can watch the videos from other
 places.


 Thats it! 3 or 4 days of local meetups, recorded and putted together on a
 conference website for everyone to see and interact, also optionally each
 meetup can have their local event transmitted alive.


 I cannot think on another format.








 --

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



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] need bootstrap-tooltip.js v2.2.1

2013-01-29 Thread Niphlod
https://github.com/twitter/bootstrap/blob/v2.2.1/js/bootstrap-tooltip.js ?

On Tuesday, January 29, 2013 5:55:59 PM UTC+1, Richard wrote:

 Hello,

 I found tooltip (no new line) issue with new bootstrap 2.2.2...

 I would have look at the differences between bootstrap-tooltip.js v2.2.1 
 and bootstrap-tooltip.js v2.2.2, but I can't get a zip on the web of 
 bootstrap 2.2.1. I try download the github repo and revert to 2.2.1, but I 
 start messing with git that I don't really know.

 If someone have this file : bootstrap-tooltip.js v2.2.1

 Thanks

 Richard


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: About unary operator consistency in queries

2013-01-29 Thread Marin Pranjić
~ is an unary operator and has precedence over binary operators, that's why
the error pops out.

~db.person.name=='Alex' should be db.person.name!='Alex', and ~db.person.
name should be used in orderby=...

I don't like the ~(db.auth_user.id==0). I'm not even sure if it works.

Marin


On Tue, Jan 29, 2013 at 5:52 PM, Alan Etkin spame...@gmail.com wrote:

 Sorry, here's the actual error:

  db(q).select()

 ...
 OperationalError: near DESC: syntax error

  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reporting server side calculation progress via ajax

2013-01-29 Thread Niphlod



 The thing is, what Niphlod suggested works on localhost, but does not work 
 on free pythonanywhere account. Server does not return 200OK for any 
 request while _recalculate function is running. I searched their forums and 
 indeed threads are disabled on pythonanywhere. So I guess it does not work 
 because of that. I have no other hosting options right now to check...


I find hard to believe that accounts are restricted to one request only at 
a time. 

I used the word threads because by default web2py executes every request 
(and db transaction) in a separate thread. 
Be sure that what you read on the forum is that pythonanywhere doesn't let 
you to open a new thread inside your code, that is all a different story.

Anyway, if pythonanywhere really has the limitation of one request at a 
time, basically you can't get what you want, because you need at least two 
requests alive at the same time (the one that does the long processing and 
the one reporting progress)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: About unary operator consistency in queries

2013-01-29 Thread Alan Etkin
It works:

 q = ~(db.auth_user.id == 1)
Query (NOT (auth_user.id = 1))

I don't like that way either, but is the example in the book correct or it 
should be fixed?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] need bootstrap-tooltip.js v2.2.1

2013-01-29 Thread Richard Vézina
Thanks Niphold,

Think I will need to learn github as well :-)

Richard


On Tue, Jan 29, 2013 at 12:04 PM, Niphlod niph...@gmail.com wrote:

 https://github.com/twitter/bootstrap/blob/v2.2.1/js/bootstrap-tooltip.js ?


 On Tuesday, January 29, 2013 5:55:59 PM UTC+1, Richard wrote:

 Hello,

 I found tooltip (no new line) issue with new bootstrap 2.2.2...

 I would have look at the differences between bootstrap-tooltip.js v2.2.1
 and bootstrap-tooltip.js v2.2.2, but I can't get a zip on the web of
 bootstrap 2.2.1. I try download the github repo and revert to 2.2.1, but I
 start messing with git that I don't really know.

 If someone have this file : bootstrap-tooltip.js v2.2.1

 Thanks

 Richard

  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reporting server side calculation progress via ajax

2013-01-29 Thread Andriy
Ok, maybe I misunderstood this. Here is topic on pythonanywhere forum - 
https://www.pythonanywhere.com/forums/topic/432/
I will continue trying tomorrow.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] About unary operator consistency in queries

2013-01-29 Thread Jonathan Lundell
On 29 Jan 2013, at 8:50 AM, Alan Etkin spame...@gmail.com wrote:
 With trunk, I have tested the behavior of the ~ operator, and doesn't seem 
 consistent to me:
 
 Here Bruno gives a working example of belongs negation
 https://groups.google.com/d/msg/web2py/fCB9a4K9FqU/GBLwfzNnkjMJ
 
 But the book uses this example:
 rows = db((~db.person.name=='Alex') | (db.person.id3)).select()
 
 This is wat I get in the console (with SQLite/Python 2.7.3)
 
  q = ~db.auth_user.id.belongs(1,2,3)
  q
 Query (NOT (auth_user.id IN (1,2,3)))
 
  q = ~db.auth_user.id==0
  q
 Query (auth_user.id DESC = 0)
 
  q = ~db.auth_user.id0
  q
 Query (auth_user.id DESC  0)
  q.select()
 Traceback (most recent call last):
   File console, line 1, in module
 AttributeError: 'Query' object has no attribute 'select'
  db(q).select()
 Traceback (most recent call last):
 ...
 OperationalError: near DESC: syntax error
 
 
 Note that the second and third query would return an OperationalError (the 
 INVERT operator is used instead of NOT)
 
 To avoid the error the syntax must be ~(db.auth_user.id==0), with parethesis.
 
 Is this an problem with the sqlite adapter only?

It's an issue with the precedence of Python operators. ~ has higher precedence 
than comparisons, so the parens are required. Python objects can override the 
functionality of operators, but not their precedence.

A similar caveat applies to the use of | or  in queries.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Arnon Marcus
Damn... A whole day and I still have nothing to show for it...

The problem is complicated, so I've broken-up the script into 6 separate 
installation scripts:
1. Yum packages
2. Python
3. uwsgi
4. web2py
5. nginx
6. configurations

My strategy, since I have it on a VM on Hyper-V, is to run each script and 
then save a snapshot of the VM after successful completion.
This way I can always revert the VM to a previous state, and not have to 
re-run the entire long-script over and over again,
when trouble-shooting a specific section of the whole script.

So far, I could get up-to and not-including the web2py installation.
There seems to be a problem when recompiling python - it brakes the yum 
installation somehow...
I don't actually need to install python at all, since the default for 
Cent-OS 6.3 is python 2.6.6.
But apparently if I don't recompile it, it can-not compile uwsgi using it 
afterwords.
If I don't re-install python, though, than web2py does manage to get 
installed and the script finishes, but with no valid uwsgi...

Currently, after uwsgi gets compiled, when trying to install web2py, or 
even testing yum in any way, I get this:
 
[root@harmonica2 opt]# which yum
/usr/bin/yum
[root@harmonica2 opt]# yum -v
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.6.6 (r266:84292, Jan 29 2013, 17:36:35)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq


I have fount that this is a known problem:


When typing:
[root@harmonica2 opt]# rpm -qa --qf 
%{name}-%{version}-%{release}.%{arch}.rpm\n | grep -i ^python\|yum | 
sort

I get:
python-2.6.6-29.el6_3.3.x86_64.rpm
python-iniparse-0.3.1-2.1.el6.noarch.rpm
python-libs-2.6.6-29.el6_3.3.x86_64.rpm
python-pycurl-7.19.0-8.el6.x86_64.rpm
python-urlgrabber-3.9.1-8.el6.noarch.rpm
yum-3.2.29-30.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
yum-presto-0.6.2-1.el6.noarch.rpm

When comparing to other people's output, there seems to be a lot missing in 
this...

When typing:
[root@harmonica2 opt]# /usr/local/bin/python -V

I get:
-bash: /usr/local/bin/python: No such file or directory


When typing:
[root@harmonica2 opt]# echo 
/opt/python2.6/lib/etc/ld.so.conf.d/opt-python2.6.conf
[root@harmonica2 opt]# ldconfig
[root@harmonica2 opt]# alias -p python2.6=/opt/python$/bin/python2.6

I get:
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot 
--show-tilde'


It looks as if the parameter-names changed from centos5 to centos6...

What should go in here?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] About unary operator consistency in queries

2013-01-29 Thread Alan Etkin


 A similar caveat applies to the use of | or  in queries.


Ok, thanks for the tips Marin and Jonathan.

I assume then that the book's example should use parenthesis for negation, 
since web2py cannot change the Python operator precedence.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] About unary operator consistency in queries

2013-01-29 Thread Jonathan Lundell
On 29 Jan 2013, at 9:42 AM, Alan Etkin spame...@gmail.com wrote:
 A similar caveat applies to the use of | or  in queries.
 
 Ok, thanks for the tips Marin and Jonathan.
 
 I assume then that the book's example should use parenthesis for negation, 
 since web2py cannot change the Python operator precedence.

Yes. Instead of:

rows = db((~db.person.name=='Alex') | (db.person.id3)).select()

it should read:

rows = db(~(db.person.name=='Alex') | (db.person.id3)).select()

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] About unary operator consistency in queries

2013-01-29 Thread Jonathan Lundell
On 29 Jan 2013, at 9:46 AM, Jonathan Lundell jlund...@pobox.com wrote:
 On 29 Jan 2013, at 9:42 AM, Alan Etkin spame...@gmail.com wrote:
 A similar caveat applies to the use of | or  in queries.
 
 Ok, thanks for the tips Marin and Jonathan.
 
 I assume then that the book's example should use parenthesis for negation, 
 since web2py cannot change the Python operator precedence.
 
 Yes. Instead of:
 
 rows = db((~db.person.name=='Alex') | (db.person.id3)).select()
 
 it should read:
 
 rows = db(~(db.person.name=='Alex') | (db.person.id3)).select()
 

I pushed a fix, along with adding a note to the existing note on operator 
precedence.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How can I disable the delete confirmation in SQLFORM.grid ?

2013-01-29 Thread François Delpierre


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Lamps902
Thanks, Anthony. I was under the impression that list:string is the 
convention if you want the field to render as a selector with SQLFORM(). 
You're right that it's possible to change the field from list:string to 
string and use IS_IN_SET() to maintain the field as a select element. 
However, I still cannot apply a list of validators after doing this. Having 
changed the field from list:string to string, when I apply the validators 
as such: Field(... requires=[IS_IN_SET(...)] ...), SQLFORM now renders the 
field as an input field rather than a drop-down menu/select element. 

On Tuesday, January 29, 2013 9:39:09 AM UTC-5, Anthony wrote:

 If you don't want to allow the user to select multiple options, then why 
 is the field type list:string rather than just string? If you make it just 
 a string type, then you will be able to apply a list of validators, as 
 below.

 Anthony

 On Tuesday, January 29, 2013 5:39:59 AM UTC-5, Lamps902 wrote:

 Thank you for the replies, guys! I think my abstract/trivial example may 
 have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
 in combination with a custom validator (yet to be fully written) to make it 
 so that all the elements of a dropdown menu/select are taken from a given 
 set of options (a list of file formats), and for the selected option (file 
 format), the custom validator will make sure the file is in that format. 
 Something like this might be a better description than the initial post:

 Field('f_file_format, type='list:string', 
   
 requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
 selection'), error_message=T(some_error_message)),
   CUSTOM_VALIDATOR(request.vars.f_file_format, 
 request.vars.file, error_message=T(some_error_message2))]

 )

 To clarify - I'm not seeking to let the user be able to select multiple 
 options from the drop down list. Maybe it's better to implement the custom 
 validator functionality I'm looking for in the controller, or can it be 
 done in the model? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
Hi, Jim. What about doing the following:

form.elements('input',_id='checkbox_field_n')[0]['_type'] = 'button'


I imagine the value can then be toggled with, for example, javascript's 
'onclick' functionality, and stored in the db as usual.

On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want to 
 change them to buttons instead of checkboxes so I can use the bootstrap 
 button widgets.  How can I chance the boolean widget from a checkbox to a 
 button and have the value properly put back into the database?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Jim S
The research I've done is telling me that IE won't allow you to change the 
type of an element.  Therefore, I need to generate it as a type=button 
from the start.  The bootstrap example also shows this as a button 
element and not an input.  Not sure if that is relevant though.

-Jim

On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, javascript's 
 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want 
 to change them to buttons instead of checkboxes so I can use the bootstrap 
 button widgets.  How can I chance the boolean widget from a checkbox to a 
 button and have the value properly put back into the database?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
Just tried the code I posted above with IE 9, and it did change the 
checkbox to a button. Did you give it a shot?


On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change the 
 type of an element.  Therefore, I need to generate it as a type=button 
 from the start.  The bootstrap example also shows this as a button 
 element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, javascript's 
 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want 
 to change them to buttons instead of checkboxes so I can use the bootstrap 
 button widgets.  How can I chance the boolean widget from a checkbox to a 
 button and have the value properly put back into the database?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Alan Etkin


 Damn... A whole day and I still have nothing to show for it...


There's a recipe that seems to solve the yum conflict

http://stackoverflow.com/questions/10624511/upgrade-python-without-breaking-yum
http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
I have to apologize for my stupid question.

Of course web2py *does* deliver raw html. But AngularJS uses the same 
brackets convention as web2py - that's what caused the conflict (I should 
write a book: 'The Art of Reading Error Messages' ... *facepalm*)

There seems to be a workaround, since you can change the markup in angular 
according to this:
http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags

I'll try this next.

Am Dienstag, 29. Januar 2013 17:12:30 UTC+1 schrieb Dirk Krause:

 Hi,

 I am trying to use web2py to manage a database and display the resulting 
 JSON in AngularJS.  To render an angular compatible view I need to pass raw 
 html in a view (for example the html needs to start with 'html ng-app' 
 and so forth). Of course I could place the files in the static folder, but 
 then I can't protect the files via @auth.requires_login() etc.

 What would be the best way to achieve that?

 Thank you,
   Dirk


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Jim Steil
Nope, but will now!

Thanks

-Jim

On Tue, Jan 29, 2013 at 1:15 PM, Lamps902 dheap@gmail.com wrote:

 Just tried the code I posted above with IE 9, and it did change the
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change
 the type of an element.  Therefore, I need to generate it as a
 type=button from the start.  The bootstrap example also shows this as a
 button element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, javascript's
 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want
 to change them to buttons instead of checkboxes so I can use the bootstrap
 button widgets.  How can I chance the boolean widget from a checkbox to a
 button and have the value properly put back into the database?

  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: log out user

2013-01-29 Thread Alan Etkin


 It may be if you want to always clean everything in the session (auth info 
 etc.)


I belive session.clear() is not documented in the book. Would it be 
possible to add a general description of what it does and how to use it?

Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: log out user

2013-01-29 Thread Jonathan Lundell
On 29 Jan 2013, at 12:28 PM, Alan Etkin spame...@gmail.com wrote:
 It may be if you want to always clean everything in the session (auth info 
 etc.)
 
 I belive session.clear() is not documented in the book. Would it be possible 
 to add a general description of what it does and how to use it?

Not to mention is_new() and is_expired()...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Richard Vézina
You can also just send the each command directly in terminal, once you are
sure the command execute correctly you translate it in bash script. Most of
the time, the command can be transfert in a script directly, sometimes when
there is parameters to pass to a command you need to google a bit to learn
how to write it properly in bash...

Don't give up!

Richard


On Tue, Jan 29, 2013 at 12:35 PM, Arnon Marcus a.m.mar...@gmail.com wrote:

 Damn... A whole day and I still have nothing to show for it...

 The problem is complicated, so I've broken-up the script into 6 separate
 installation scripts:
 1. Yum packages
 2. Python
 3. uwsgi
 4. web2py
 5. nginx
 6. configurations

 My strategy, since I have it on a VM on Hyper-V, is to run each script and
 then save a snapshot of the VM after successful completion.
 This way I can always revert the VM to a previous state, and not have to
 re-run the entire long-script over and over again,
 when trouble-shooting a specific section of the whole script.

 So far, I could get up-to and not-including the web2py installation.
 There seems to be a problem when recompiling python - it brakes the yum
 installation somehow...
 I don't actually need to install python at all, since the default for
 Cent-OS 6.3 is python 2.6.6.
 But apparently if I don't recompile it, it can-not compile uwsgi using it
 afterwords.
 If I don't re-install python, though, than web2py does manage to get
 installed and the script finishes, but with no valid uwsgi...

 Currently, after uwsgi gets compiled, when trying to install web2py, or
 even testing yum in any way, I get this:

 [root@harmonica2 opt]# which yum
 /usr/bin/yum
 [root@harmonica2 opt]# yum -v
 There was a problem importing one of the Python modules
 required to run yum. The error leading to this problem was:

No module named yum

 Please install a package which provides this module, or
 verify that the module is installed correctly.

 It's possible that the above module doesn't match the
 current version of Python, which is:
 2.6.6 (r266:84292, Jan 29 2013, 17:36:35)
 [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

 If you cannot solve this problem yourself, please go to
 the yum faq at:
   http://yum.baseurl.org/wiki/Faq


 I have fount that this is a known problem:


 When typing:
 [root@harmonica2 opt]# rpm -qa --qf
 %{name}-%{version}-%{release}.%{arch}.rpm\n | grep -i ^python\|yum |
 sort

 I get:
 python-2.6.6-29.el6_3.3.x86_64.rpm
 python-iniparse-0.3.1-2.1.el6.noarch.rpm
 python-libs-2.6.6-29.el6_3.3.x86_64.rpm
 python-pycurl-7.19.0-8.el6.x86_64.rpm
 python-urlgrabber-3.9.1-8.el6.noarch.rpm
 yum-3.2.29-30.el6.centos.noarch.rpm
 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
 yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
 yum-presto-0.6.2-1.el6.noarch.rpm

 When comparing to other people's output, there seems to be a lot missing
 in this...

 When typing:
 [root@harmonica2 opt]# /usr/local/bin/python -V

 I get:
 -bash: /usr/local/bin/python: No such file or directory


 When typing:
 [root@harmonica2 opt]# echo
 /opt/python2.6/lib/etc/ld.so.conf.d/opt-python2.6.conf
 [root@harmonica2 opt]# ldconfig
 [root@harmonica2 opt]# alias -p python2.6=/opt/python$/bin/python2.6

 I get:
 alias cp='cp -i'
 alias l.='ls -d .* --color=auto'
 alias ll='ls -l --color=auto'
 alias ls='ls --color=auto'
 alias mv='mv -i'
 alias rm='rm -i'
 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot
 --show-tilde'


 It looks as if the parameter-names changed from centos5 to centos6...

 What should go in here?

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Open generated file from action function

2013-01-29 Thread Massimo Di Pierro
I do not understand what you are trying to do. If the form is accepted you 
should probably reload, not return different data.

On Tuesday, 29 January 2013 10:00:56 UTC-6, Luca Zacchetti wrote:

 Hi everybody, I've a problem and need your help.
 I have a view which contains many things including an SQLFORM.factory used 
 to set the query for a report generation.
 The first time I submit the form the report is correctly opened, the 
 second time the page is just reloaded...how can I fix the problem?
 Here is my code snippet...

 def index():   
 form = SQLFORM.factory(...)
 if form.accepts(request.vars, session): 
 #report generation...
 response.headers['Content-Type']='application/vnd.ms-excel'
 response.headers['Content-Disposition']='attachment; 
 filename=%s.xls'%filename
 response.headers['Content-Title']='%s.xls'%filename 
 return data #otherwise the file isn't opened   
 return locals()

 Many thanks!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] embed image from variable

2013-01-29 Thread Massimo Di Pierro
You do not return the image that way. You need two actions, one only 
returns plot() (the binary data) and another would be a regular action 
which display a link to the other action.

def myimage(): return plot()

def Testing(): return dict() # in view img src={{=URL('myimage')}}/ ...

On Tuesday, 29 January 2013 10:53:03 UTC-6, BlueShadow wrote:

 I did some experimenting the problem is putting the image into the return 
 dict() or into any variable.
 I got no clue how to fix it or why that is the problem.

 On Tuesday, January 29, 2013 5:07:16 PM UTC+1, BlueShadow wrote:

 I tried that but it doesn't show an image it puts the img tag in the html 
 code and fills the src=binary with the pinary stuff but no image is 
 displayed

 On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:

 I guess you can try
  

 {{=IMG(_src=plotimg)}}


 or 

 img src={{=plotimg}} / 




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Open generated file from action function

2013-01-29 Thread Bruno Rocha
I think the problem may be the session preventing the duplicate submission
of the same form data.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: log out user

2013-01-29 Thread Alan Etkin


 Not to mention is_new() and is_expired()...

 
They are self-explanatory, but one has to search the api docs or this group 
or dir(session) to find them. clear seems to be inherited from dict, but 
there's no guarantee of what it does as it could overridden by the Session 
class, etc, etc, etc... . Also a use might want to know what does the 
framework do in a lower level when a session is cleared, like removing 
files for the case of calling clear ... . And a comparison with .forget 
would be useful ... . This is the docstring output for .clear ... . So it's 
not so obvious what .clear does for a web2py app ...

Help on method clear in module gluon.globals:

clear(self) method of gluon.globals.Session instance

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How can I disable the delete confirmation in SQLFORM.grid ?

2013-01-29 Thread Massimo Di Pierro
The confirmation is handled via js. You need to edit web2py.js.

On Tuesday, 29 January 2013 12:21:12 UTC-6, François Delpierre wrote:




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Massimo Di Pierro
You can also change the delimiters in web2py with:

response.delimiters = ('?','?')



On Tuesday, 29 January 2013 14:10:04 UTC-6, Dirk Krause wrote:

 I have to apologize for my stupid question.

 Of course web2py *does* deliver raw html. But AngularJS uses the same 
 brackets convention as web2py - that's what caused the conflict (I should 
 write a book: 'The Art of Reading Error Messages' ... *facepalm*)

 There seems to be a workaround, since you can change the markup in angular 
 according to this:

 http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags

 I'll try this next.

 Am Dienstag, 29. Januar 2013 17:12:30 UTC+1 schrieb Dirk Krause:

 Hi,

 I am trying to use web2py to manage a database and display the resulting 
 JSON in AngularJS.  To render an angular compatible view I need to pass raw 
 html in a view (for example the html needs to start with 'html ng-app' 
 and so forth). Of course I could place the files in the static folder, but 
 then I can't protect the files via @auth.requires_login() etc.

 What would be the best way to achieve that?

 Thank you,
   Dirk



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
and it works.

links that helped:
http://jsfiddle.net/Bvc62/3/
http://stackoverflow.com/questions/12923521/angular-js-custom-delimiter


This would be your view
!DOCTYPE html
html
head
  meta http-equiv=content-type content=text/html; charset=UTF-8
  titleAngular demo/title
  script type='text/javascript' 
src='https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js'/script
script type='text/javascript'//![CDATA[ 

var myApp = angular.module('myApp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});

function MyCtrl($scope) {
$scope.name = 'Superhero';
}
//]]  
/script

/head
body ng-app=myApp
  div ng-controller=MyCtrl
Hello, [[name]]
/div
/body/html




Am Dienstag, 29. Januar 2013 21:10:04 UTC+1 schrieb Dirk Krause:

 I have to apologize for my stupid question.

 Of course web2py *does* deliver raw html. But AngularJS uses the same 
 brackets convention as web2py - that's what caused the conflict (I should 
 write a book: 'The Art of Reading Error Messages' ... *facepalm*)

 There seems to be a workaround, since you can change the markup in angular 
 according to this:

 http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags

 I'll try this next.

 Am Dienstag, 29. Januar 2013 17:12:30 UTC+1 schrieb Dirk Krause:

 Hi,

 I am trying to use web2py to manage a database and display the resulting 
 JSON in AngularJS.  To render an angular compatible view I need to pass raw 
 html in a view (for example the html needs to start with 'html ng-app' 
 and so forth). Of course I could place the files in the static folder, but 
 then I can't protect the files via @auth.requires_login() etc.

 What would be the best way to achieve that?

 Thank you,
   Dirk



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-01-29 Thread Bill Thayer

Hi Allen,

Yes the book has the example as written because I am uploading directly to 
the database. Otherwise I get an error that store requires a value for 
uploadfolder.

Sorry but I've been looking for how t temporarily not let the dal catch the 
error. I tried running my app with the -S option but it's the same result.


Regards,
Bill





On Tuesday, January 29, 2013 5:20:08 AM UTC-6, Alan Etkin wrote:

 I am attempting to write a function that will eventually go in to a 
 migration script to upload legacy data files. As you can see I 


 Unable to handle load is too generic for this case. I'd better 
 temporarily let dal not to catch the error so there's a more precise 
 description of it. Perhaps there are encoding errors when writing the 
 stream output?. BTW, Is that the recommended way of adding upload fields 
 data programatically (calling the .store method)?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Arnon Marcus
I already tried that - breaking it up to 6 parts was the next step...
Copying and pasting the entire thing line by line would be insane...

I f@#n hate linux...


On Tue, Jan 29, 2013 at 12:45 PM, Richard Vézina 
ml.richard.vez...@gmail.com wrote:

 You can also just send the each command directly in terminal, once you are
 sure the command execute correctly you translate it in bash script. Most of
 the time, the command can be transfert in a script directly, sometimes when
 there is parameters to pass to a command you need to google a bit to learn
 how to write it properly in bash...

 Don't give up!

 Richard


 On Tue, Jan 29, 2013 at 12:35 PM, Arnon Marcus a.m.mar...@gmail.comwrote:

 Damn... A whole day and I still have nothing to show for it...

 The problem is complicated, so I've broken-up the script into 6 separate
 installation scripts:
 1. Yum packages
 2. Python
 3. uwsgi
 4. web2py
 5. nginx
 6. configurations

 My strategy, since I have it on a VM on Hyper-V, is to run each script
 and then save a snapshot of the VM after successful completion.
 This way I can always revert the VM to a previous state, and not have to
 re-run the entire long-script over and over again,
 when trouble-shooting a specific section of the whole script.

 So far, I could get up-to and not-including the web2py installation.
 There seems to be a problem when recompiling python - it brakes the yum
 installation somehow...
 I don't actually need to install python at all, since the default for
 Cent-OS 6.3 is python 2.6.6.
 But apparently if I don't recompile it, it can-not compile uwsgi using it
 afterwords.
 If I don't re-install python, though, than web2py does manage to get
 installed and the script finishes, but with no valid uwsgi...

 Currently, after uwsgi gets compiled, when trying to install web2py, or
 even testing yum in any way, I get this:

 [root@harmonica2 opt]# which yum
 /usr/bin/yum
 [root@harmonica2 opt]# yum -v
 There was a problem importing one of the Python modules
 required to run yum. The error leading to this problem was:

No module named yum

 Please install a package which provides this module, or
 verify that the module is installed correctly.

 It's possible that the above module doesn't match the
 current version of Python, which is:
 2.6.6 (r266:84292, Jan 29 2013, 17:36:35)
 [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

 If you cannot solve this problem yourself, please go to
 the yum faq at:
   http://yum.baseurl.org/wiki/Faq


 I have fount that this is a known problem:


 When typing:
 [root@harmonica2 opt]# rpm -qa --qf
 %{name}-%{version}-%{release}.%{arch}.rpm\n | grep -i ^python\|yum |
 sort

 I get:
 python-2.6.6-29.el6_3.3.x86_64.rpm
 python-iniparse-0.3.1-2.1.el6.noarch.rpm
 python-libs-2.6.6-29.el6_3.3.x86_64.rpm
 python-pycurl-7.19.0-8.el6.x86_64.rpm
 python-urlgrabber-3.9.1-8.el6.noarch.rpm
 yum-3.2.29-30.el6.centos.noarch.rpm
 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
 yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
 yum-presto-0.6.2-1.el6.noarch.rpm

 When comparing to other people's output, there seems to be a lot missing
 in this...

 When typing:
 [root@harmonica2 opt]# /usr/local/bin/python -V

 I get:
 -bash: /usr/local/bin/python: No such file or directory


 When typing:
 [root@harmonica2 opt]# echo
 /opt/python2.6/lib/etc/ld.so.conf.d/opt-python2.6.conf
 [root@harmonica2 opt]# ldconfig
 [root@harmonica2 opt]# alias -p python2.6=/opt/python$/bin/python2.6

 I get:
 alias cp='cp -i'
 alias l.='ls -d .* --color=auto'
 alias ll='ls -l --color=auto'
 alias ls='ls --color=auto'
 alias mv='mv -i'
 alias rm='rm -i'
 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot
 --show-tilde'


 It looks as if the parameter-names changed from centos5 to centos6...

 What should go in here?

 --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: CentOS 6.3 + nginx = 502 Bad gateway

2013-01-29 Thread Richard Vézina
haha!

I can say for others, but I would say we all do that once in a while to
learn/understand/debug...

I found that approach much less cumbersum then create destroy vm clone all
the time for each part of a script.

Anyway, you do the way you want.

Richard


On Tue, Jan 29, 2013 at 4:43 PM, Arnon Marcus a.m.mar...@gmail.com wrote:

 I already tried that - breaking it up to 6 parts was the next step...
 Copying and pasting the entire thing line by line would be insane...

 I f@#n hate linux...


 On Tue, Jan 29, 2013 at 12:45 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 You can also just send the each command directly in terminal, once you
 are sure the command execute correctly you translate it in bash script.
 Most of the time, the command can be transfert in a script directly,
 sometimes when there is parameters to pass to a command you need to google
 a bit to learn how to write it properly in bash...

 Don't give up!

 Richard


 On Tue, Jan 29, 2013 at 12:35 PM, Arnon Marcus a.m.mar...@gmail.comwrote:

 Damn... A whole day and I still have nothing to show for it...

 The problem is complicated, so I've broken-up the script into 6 separate
 installation scripts:
 1. Yum packages
 2. Python
 3. uwsgi
 4. web2py
 5. nginx
 6. configurations

 My strategy, since I have it on a VM on Hyper-V, is to run each script
 and then save a snapshot of the VM after successful completion.
 This way I can always revert the VM to a previous state, and not have to
 re-run the entire long-script over and over again,
 when trouble-shooting a specific section of the whole script.

 So far, I could get up-to and not-including the web2py installation.
 There seems to be a problem when recompiling python - it brakes the
 yum installation somehow...
 I don't actually need to install python at all, since the default for
 Cent-OS 6.3 is python 2.6.6.
 But apparently if I don't recompile it, it can-not compile uwsgi using
 it afterwords.
 If I don't re-install python, though, than web2py does manage to get
 installed and the script finishes, but with no valid uwsgi...

 Currently, after uwsgi gets compiled, when trying to install web2py, or
 even testing yum in any way, I get this:

 [root@harmonica2 opt]# which yum
 /usr/bin/yum
 [root@harmonica2 opt]# yum -v
 There was a problem importing one of the Python modules
 required to run yum. The error leading to this problem was:

No module named yum

 Please install a package which provides this module, or
 verify that the module is installed correctly.

 It's possible that the above module doesn't match the
 current version of Python, which is:
 2.6.6 (r266:84292, Jan 29 2013, 17:36:35)
 [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

 If you cannot solve this problem yourself, please go to
 the yum faq at:
   http://yum.baseurl.org/wiki/Faq


 I have fount that this is a known problem:


 When typing:
 [root@harmonica2 opt]# rpm -qa --qf
 %{name}-%{version}-%{release}.%{arch}.rpm\n | grep -i ^python\|yum |
 sort

 I get:
 python-2.6.6-29.el6_3.3.x86_64.rpm
 python-iniparse-0.3.1-2.1.el6.noarch.rpm
 python-libs-2.6.6-29.el6_3.3.x86_64.rpm
 python-pycurl-7.19.0-8.el6.x86_64.rpm
 python-urlgrabber-3.9.1-8.el6.noarch.rpm
 yum-3.2.29-30.el6.centos.noarch.rpm
 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
 yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
 yum-presto-0.6.2-1.el6.noarch.rpm

 When comparing to other people's output, there seems to be a lot missing
 in this...

 When typing:
 [root@harmonica2 opt]# /usr/local/bin/python -V

 I get:
 -bash: /usr/local/bin/python: No such file or directory


 When typing:
 [root@harmonica2 opt]# echo
 /opt/python2.6/lib/etc/ld.so.conf.d/opt-python2.6.conf
 [root@harmonica2 opt]# ldconfig
 [root@harmonica2 opt]# alias -p python2.6=/opt/python$/bin/python2.6

 I get:
 alias cp='cp -i'
 alias l.='ls -d .* --color=auto'
 alias ll='ls -l --color=auto'
 alias ls='ls --color=auto'
 alias mv='mv -i'
 alias rm='rm -i'
 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot
 --show-tilde'


 It looks as if the parameter-names changed from centos5 to centos6...

 What should go in here?

 --

 ---
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit 

[web2py] Re: Open generated file from action function

2013-01-29 Thread Luca Zacchetti
Just trying to return an excel file on SQLFORM submission

Il giorno martedì 29 gennaio 2013 22:13:18 UTC+1, Massimo Di Pierro ha 
scritto:

 I do not understand what you are trying to do. If the form is accepted you 
 should probably reload, not return different data.

 On Tuesday, 29 January 2013 10:00:56 UTC-6, Luca Zacchetti wrote:

 Hi everybody, I've a problem and need your help.
 I have a view which contains many things including an SQLFORM.factory 
 used to set the query for a report generation.
 The first time I submit the form the report is correctly opened, the 
 second time the page is just reloaded...how can I fix the problem?
 Here is my code snippet...

 def index():   
 form = SQLFORM.factory(...)
 if form.accepts(request.vars, session): 
 #report generation...
 response.headers['Content-Type']='application/vnd.ms-excel'
 response.headers['Content-Disposition']='attachment; 
 filename=%s.xls'%filename
 response.headers['Content-Title']='%s.xls'%filename 
 return data #otherwise the file isn't opened   
 return locals()

 Many thanks!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Auth login causing closed database

2013-01-29 Thread pinwc4
Recently I upgraded to 2.32 from an older 1.99 version and have been 
running into an odd auth problem.  I have 2 copies of an application hosted 
on a VM under one instance of web2py using Apache/WSGI.  I can log into one 
of the apps however if I then try to login to the other copy I instead get 
a Ticket with the error ProgrammingError: Cannot operate on a closed 
database.  The database in this case is SQLite.  

It does not matter which copy of the app I log into, it happens either 
direction.  Once I start getting that error on one of the apps the error 
continues until I reset Apache.  However the error only occurs with the 
Auth, other portions of the app that use database access work fine.  The 
applications themselves are identical copies outside of some layout 
differences for looks and I use different DNS names for each.  They do not 
share any auth through CAS etc. the auth_user tables are independent.  I 
thought maybe it was session related since I was logging in from the same 
browser so I tried different session storage, cookies/db/files but that did 
not make a difference.  The problem even happens if I log into one site 
from Firefox and then log into the second site with IE.  The second site 
will then start giving this error.

Does any have any ideas why logging into the second site would cause the 
database connection to close?  I did not have this problem with 1.99 but I 
do not want to downgrade as I am starting to use newer features introduced.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-01-29 Thread Alan Etkin
I did not explain well what I meant:

File C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py, line 8258, 
in _attempt_upload
raise RuntimeError(Unable to handle upload)

It seems that dal is returning a generic message so my idea was to take out 
any exception handling in the dal.py module that does the file writing. 
Well, actually there is not such exception handling clause. It's just that 
the method called requires that:

a) if the object passed has a file attribute, it is supposed to have a 
filename attribute
b) if the object has a .read method, then it looks for a name attribute

Other cases raise the OperationalError output you are getting.

Perhaps this can help debugging the code to create the files.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Open generated file from action function

2013-01-29 Thread Massimo Di Pierro
The proper way is to pass the input data to the another action which 
returns the excel file and display a link to that action. You can pass the 
data by storing it into a session and retrieving it.

On Tuesday, 29 January 2013 16:06:15 UTC-6, Luca Zacchetti wrote:

 Just trying to open the generated excel file on SQLFORM submission

 Il giorno martedì 29 gennaio 2013 22:13:18 UTC+1, Massimo Di Pierro ha 
 scritto:

 I do not understand what you are trying to do. If the form is accepted 
 you should probably reload, not return different data.

 On Tuesday, 29 January 2013 10:00:56 UTC-6, Luca Zacchetti wrote:

 Hi everybody, I've a problem and need your help.
 I have a view which contains many things including an SQLFORM.factory 
 used to set the query for a report generation.
 The first time I submit the form the report is correctly opened, the 
 second time the page is just reloaded...how can I fix the problem?
 Here is my code snippet...

 def index():   
 form = SQLFORM.factory(...)
 if form.accepts(request.vars, session): 
 #report generation...
 response.headers['Content-Type']='application/vnd.ms-excel'
 response.headers['Content-Disposition']='attachment; 
 filename=%s.xls'%filename
 response.headers['Content-Title']='%s.xls'%filename 
 return data #otherwise the file isn't opened   
 return locals()

 Many thanks!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] What is the right way to specialize an application?

2013-01-29 Thread Paul Whipp
I'm new to web2py but not to Python or web application frameworks.

I love the dry pythonic nature of web2py. I'm less enamoured by its use of 
magic but the convenient REP makes this mostly forgivable. I'm giving 
web2py a go on a couple of real projects.

As I use emacs, it looks like it would be straightforward to modify the 
admin app to pass a file to an emacs service (if available) for editing. 
Its also easy to copy the admin application, call it myadmin and make the 
change there. These are both bad things to do because; in the first case an 
upgrade will overwrite my change (yes I use source control but its still 
going to be a pain), and in the second case I've copied a large slice of 
code and lost the benefit of upgrades in myadmin which could lead to all 
sorts of problems in the long term.

What I want to do is specialize the admin app such that I just use my 
specialised default controller with its single specialized edit method (the 
latter specialisation is a little tricky because the method is a bit 
monolithic but you can see what I'm aiming at).

The result would be a specialization of the admin app called myadmin 
containing virtually nothing but the specialized default controller and 
edit method. I cannot see any obvious way to do this. Am I going to have to 
make like a PHP programmer and copy the whole application to make one small 
change or is there some cool way to unravel the magic a bit and point the 
myadmin file lookups to admin, except for my controllers/default.py?

For the time being I'll stick with navigating the file structure and 
invoking emacs directly, so my question is more of a How would I. I've 
tried google to no avail and I'll be happy for an RTFM response if you can 
point me at the FM (or an example) that covers this.

Cheers,
Paul

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py book now free in PDF

2013-01-29 Thread Monte Milanuk
Is the PDF version going to get updated occasionally?  HTML version 
currently @ 4.9, PDF is still @ 4.1...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Jim S
Please forgive me for not knowing this, but here is what I tried:

$('.web2py_form').elements('input',_id='rebates_tiered')[0]['_type'] = 
'button';

But, I get:

TypeError: $(...).elements is not a function

Any clues on what I'm specifying incorrectly?

-Jim

On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the 
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change 
 the type of an element.  Therefore, I need to generate it as a 
 type=button from the start.  The bootstrap example also shows this as a 
 button element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, javascript's 
 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I 
 want to change them to buttons instead of checkboxes so I can use the 
 bootstrap button widgets.  How can I chance the boolean widget from a 
 checkbox to a button and have the value properly put back into the 
 database?

  -- 
  
 --- 

  




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
It looks like you might be sort of conflating javascript and python code 
there. Before you do anything with javascript, modify the checkbox element 
in the [controller_name].py file, as I described above. For example, if you 
used SQLFORM() to generate your form from a database table, in your 
controller, you should have something like:

form = SQLFORM( ... )
form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

This will turn the checkbox with the id rebates_tiered into a button. 
Then, whatever functionality you need from javascript, if any, is 
implemented in the appropriate view (html) file.

On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('input',_id='rebates_tiered')[0]['_type'] = 
 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the 
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change 
 the type of an element.  Therefore, I need to generate it as a 
 type=button from the start.  The bootstrap example also shows this as a 
 button element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, 
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I 
 want to change them to buttons instead of checkboxes so I can use the 
 bootstrap button widgets.  How can I chance the boolean widget from a 
 checkbox to a button and have the value properly put back into the 
 database?

  -- 
  
 --- 

  




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-01-29 Thread Alan Etkin
Replacing the store call with this should avoid the error:

file_id=db.wiki_media.insert(filename=db.wiki_media.filename.store(stream,filename
=a file name, path=file_path)


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Jim Steil
Yes, I was thinking this was javascript code.  Sorry I missed that, it's
been a long day...

On Tue, Jan 29, 2013 at 7:59 PM, Lamps902 dheap@gmail.com wrote:

 It looks like you might be sort of conflating javascript and python code
 there. Before you do anything with javascript, modify the checkbox element
 in the [controller_name].py file, as I described above. For example, if you
 used SQLFORM() to generate your form from a database table, in your
 controller, you should have something like:

 form = SQLFORM( ... )
 form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

 This will turn the checkbox with the id rebates_tiered into a button.
 Then, whatever functionality you need from javascript, if any, is
 implemented in the appropriate view (html) file.


 On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('**input',_id='rebates_tiered')[**0]['_type']
 = 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change
 the type of an element.  Therefore, I need to generate it as a
 type=button from the start.  The bootstrap example also shows this as a
 button element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**che**ckbox_field_n')[0]['_type'] =
 'button'


 I imagine the value can then be toggled with, for example,
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I
 want to change them to buttons instead of checkboxes so I can use the
 bootstrap button widgets.  How can I chance the boolean widget from a
 checkbox to a button and have the value properly put back into the 
 database?

  --

 ---




  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Jim Steil
Yup, worked just as you stated.  Thanks for carrying me along...

-Jim


On Tue, Jan 29, 2013 at 8:02 PM, Jim Steil ato.st...@gmail.com wrote:

 Yes, I was thinking this was javascript code.  Sorry I missed that, it's
 been a long day...


 On Tue, Jan 29, 2013 at 7:59 PM, Lamps902 dheap@gmail.com wrote:

 It looks like you might be sort of conflating javascript and python code
 there. Before you do anything with javascript, modify the checkbox element
 in the [controller_name].py file, as I described above. For example, if you
 used SQLFORM() to generate your form from a database table, in your
 controller, you should have something like:

 form = SQLFORM( ... )
 form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

 This will turn the checkbox with the id rebates_tiered into a button.
 Then, whatever functionality you need from javascript, if any, is
 implemented in the appropriate view (html) file.


 On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('**input',_id='rebates_tiered')[**0]['_type']
 = 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to
 change the type of an element.  Therefore, I need to generate it as a
 type=button from the start.  The bootstrap example also shows this as a
 button element and not an input.  Not sure if that is relevant 
 though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**che**ckbox_field_n')[0]['_type'] =
 'button'


 I imagine the value can then be toggled with, for example,
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I
 want to change them to buttons instead of checkboxes so I can use the
 bootstrap button widgets.  How can I chance the boolean widget from a
 checkbox to a button and have the value properly put back into the 
 database?

  --

 ---




  --

 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
No problem. I think I see where the misunderstanding came from - it's 
possible that javascript can't be used to change an element's type in IE, 
since that would be done after the element has been rendered. In the python 
controller, the element's type is changed before the element is rendered, 
so there's no problem. Glad it worked out!


On Tuesday, January 29, 2013 9:11:31 PM UTC-5, Jim S wrote:

 Yup, worked just as you stated.  Thanks for carrying me along...

 -Jim


 On Tue, Jan 29, 2013 at 8:02 PM, Jim Steil ato@gmail.comjavascript:
  wrote:

 Yes, I was thinking this was javascript code.  Sorry I missed that, it's 
 been a long day...


 On Tue, Jan 29, 2013 at 7:59 PM, Lamps902 dhea...@gmail.comjavascript:
  wrote:

 It looks like you might be sort of conflating javascript and python code 
 there. Before you do anything with javascript, modify the checkbox element 
 in the [controller_name].py file, as I described above. For example, if you 
 used SQLFORM() to generate your form from a database table, in your 
 controller, you should have something like:

 form = SQLFORM( ... )
 form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

 This will turn the checkbox with the id rebates_tiered into a button. 
 Then, whatever functionality you need from javascript, if any, is 
 implemented in the appropriate view (html) file.


 On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('**input',_id='rebates_tiered')[**0]['_type'] 
 = 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the 
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to 
 change the type of an element.  Therefore, I need to generate it as a 
 type=button from the start.  The bootstrap example also shows this as 
 a 
 button element and not an input.  Not sure if that is relevant 
 though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**che**ckbox_field_n')[0]['_type'] = 
 'button'


 I imagine the value can then be toggled with, for example, 
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I 
 want to change them to buttons instead of checkboxes so I can use the 
 bootstrap button widgets.  How can I chance the boolean widget from a 
 checkbox to a button and have the value properly put back into the 
 database?

  -- 
  
 --- 

  


  -- 
  
 --- 
 You received this message because you are subscribed to the Google 
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  





-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: What is the right way to specialize an application?

2013-01-29 Thread Anthony
Maybe look into plugins: 
http://web2py.com/books/default/chapter/29/12#Plugins

On Tuesday, January 29, 2013 6:39:44 PM UTC-5, Paul Whipp wrote:

 I'm new to web2py but not to Python or web application frameworks.

 I love the dry pythonic nature of web2py. I'm less enamoured by its use of 
 magic but the convenient REP makes this mostly forgivable. I'm giving 
 web2py a go on a couple of real projects.

 As I use emacs, it looks like it would be straightforward to modify the 
 admin app to pass a file to an emacs service (if available) for editing. 
 Its also easy to copy the admin application, call it myadmin and make the 
 change there. These are both bad things to do because; in the first case an 
 upgrade will overwrite my change (yes I use source control but its still 
 going to be a pain), and in the second case I've copied a large slice of 
 code and lost the benefit of upgrades in myadmin which could lead to all 
 sorts of problems in the long term.

 What I want to do is specialize the admin app such that I just use my 
 specialised default controller with its single specialized edit method (the 
 latter specialisation is a little tricky because the method is a bit 
 monolithic but you can see what I'm aiming at).

 The result would be a specialization of the admin app called myadmin 
 containing virtually nothing but the specialized default controller and 
 edit method. I cannot see any obvious way to do this. Am I going to have to 
 make like a PHP programmer and copy the whole application to make one small 
 change or is there some cool way to unravel the magic a bit and point the 
 myadmin file lookups to admin, except for my controllers/default.py?

 For the time being I'll stick with navigating the file structure and 
 invoking emacs directly, so my question is more of a How would I. I've 
 tried google to no avail and I'll be happy for an RTFM response if you can 
 point me at the FM (or an example) that covers this.

 Cheers,
 Paul


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   >