Re: [web2py] Any one intergrated Indian Payment Systems with web2py app?

2014-07-02 Thread Kiran Subbaraman

Sarbjit,
Unfortunately, can't share the integration code, because PayU does not 
make the integration details public. But it is rather a straight forward 
piece of code - you include transaction details, a merchant id, a 
transaction id, and some form a hash in a HTTPS POST to one of their 
APIs. The integration requirements are rather straight forward, and can 
be accomplished with standard libraries.


You should just go ahead and call these guys, and ask them / negotiate 
about their offers and how you can use their gateway. Do not be put off 
by only for ecommerce or some such thing.

Good luck with the payment integration.


Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Wed, 02-07-2014 10:42 AM, Sarbjit wrote:

Thanks Kiran for the reply and sharing the knowledgeable link.

I found zaapakpay.com and payu.in to be promising. zaapakpay has their 
legal terms to accept an application which includes the application to 
be submitted on behalf of company and it is a must that the website 
should be an ecommerce store.


I am building my application on own and is not affiliated with any 
company as such, I need the payment setup just for receiving the 
registration fees.


I do not have any experience with integration of payment gateway with 
website, Will it be possible for you to share an example code of payu 
integration, that might be useful for others as well.


Thanks in advance,
Sarbjit

On Tuesday, July 1, 2014 9:41:59 PM UTC+5:30, Kiran Subbaraman wrote:

I integrated a web2py app with payu (payu.com http://payu.com).
Each of these payment gateways have their own integration API.
This blog is a useful read:
http://gaganpreet.in/blog/2013/09/18/how-secure-are-indian-payment-gateways/

http://gaganpreet.in/blog/2013/09/18/how-secure-are-indian-payment-gateways/


Kiran Subbaraman
http://subbaraman.wordpress.com/about/  
http://subbaraman.wordpress.com/about/

On Tue, 01-07-2014 8:24 PM, Sarbjit wrote:

Hi All,

Has any one integrated Indian Payment System with web2py app. In
India, ccavenue seems to be more popular
(http://www.ccavenue.com/quick.jsp
http://www.ccavenue.com/quick.jsp) but they doesn't appears to
provide python support.

But apparently, I found few Django app's integarted with ccavenue
on google, has any one implemented any Indian Payment System with
web2py.

I am no-voice to Payment Integration.

-Sarbjit
-- 
Resources:

- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py
http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list
https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout
https://groups.google.com/d/optout.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 
mailto:web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Silent dal failure with missing field def. Maybe a bug?

2014-07-02 Thread Cliff Kachinske
Thank you.

On Tuesday, July 1, 2014 6:16:18 PM UTC-4, Anthony wrote:

 That particular method of updating calls:

 .update(**self._filter_fields(value))

 So no exception is raised because the fields are filtered to include only 
 those in the table definition. If you want to catch such errors, use the 
 more explicit .update() method.

 Anthony

 On Tuesday, July 1, 2014 5:39:36 PM UTC-4, Cliff Kachinske wrote:

 I would have thought DAL would raise an exception here, but the failure 
 was silent.

 The postgres table contains these fields:

  quantity_used | numeric(12,3)   | 
  container_count   | integer | 
  container_id  | integer | 
  restock   | integer | 

 An ajax request was attempting to update the quantity_used, 
 container_count and restock fields.

 The updating code looks like this: All the variables were there.
 db.repacks_reruns_container[rrc_id] = dict(
 container_count=count,
 quantity_used=pounds,
 restock=restock,
 )

 db._lastsql looked like this:

 UPDATE repacks_reruns_container SET quantity_used=1.000,
 container_count=2 WHERE ((repacks_reruns_container.id = 1) AND (
 repacks_reruns_container.is_active = 'T'));

 Note restock not updated in the query.

 It happened because the model for repacks_reruns_container was missing 
 the restock field.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] {{=XML(row.contents, sanitize=True)}} and em/em

2014-07-02 Thread Annet
In a view I have the following line:

{{=XML(row.contents, sanitize=True)}}

When 'contents' contains an em/em element add by tinymce, this element 
isn't being rendered:

emMy text /em

Other elements like p/p strong/strong are being rendered correctly, 
is there a way
to solve this issue.


Regards,

Annet

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: {{=XML(row.contents, sanitize=True)}} and em/em

2014-07-02 Thread Cliff Kachinske
You can tune the tags and attributes that XML will allow.

XML has a parameter called permitted_tags.  It is a list of tags that XML 
will not escape.

You could, at the top of your controller, create your own list of permitted 
tags.  Then call XML like this:

XML(row.contents, sanitize=True, permitted_tags=permitted_tags)

This is what the permitted_tags parameter looks like with the added entry 
for em. You can find it in gluon/html.py around line 1536.

   permitted_tags=[
'a', 
'b', 
'blockquote',
'br/',
'i', 
'li',
'ol',
'ul',
'p', 
'cite',
'code',
'pre',
'img/',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'table', 'tr', 'td', 'div',
'strong','span',
# entry below added
'em'
],   

If you look at the XML class in html.py you will see another parameter 
called allowed_attributes. I suppose you could make your own dictionary 
to allow a style attribute for some html tags and pass it in when you call 
XML. 




On Wednesday, July 2, 2014 5:30:18 AM UTC-4, Annet wrote:

 In a view I have the following line:

 {{=XML(row.contents, sanitize=True)}}

 When 'contents' contains an em/em element add by tinymce, this element 
 isn't being rendered:

 emMy text /em

 Other elements like p/p strong/strong are being rendered correctly.

 Furthermore, when tinymce adds a style to an element:

 p style=text-align: center;My text /p

 This is being rendered without the style:

 pMy text .../p

 Is there a way to solve these issues.


 Regards,

 Annet


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Create a database table on submission of a form

2014-07-02 Thread Shubham Jain
Thank you Massimo and Manuele..

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: question about onvalidation function

2014-07-02 Thread overstandnigeria
Thanks Massimo , i have used this code and its works fine , 

On Friday, December 23, 2011 10:13:04 PM UTC+1, Massimo Di Pierro wrote:

 onvalidation = my_form_processing 

 registers a callback (called after validation and before accepting). 
 This does not work 

 def my_form_processing(table_name, form): form.vars.field1 = 
 table_name # I know useless, it just 

 because the callback function must take a single parameter, the form. 
 You can do instead 

 def my_form_processing(form): 
 form.vars.field1 = form.table.name # I know useless, it just 

 Hope this helps. 


 On Dec 23, 1:32 pm, Richard ml.richard.vez...@gmail.com wrote: 
  Hello, 
  
  In the book there is this example : 
  
  db.define_table('numbers', 
  Field('a', 'integer'), 
  Field('b', 'integer'), 
  Field('c', 'integer', readable=False, writable=False)) 
  
  def my_form_processing(form): 
  c = form.vars.a * form.vars.b 
  if c  0: 
 form.errors.b = 'a*b cannot be negative' 
  else: 
 form.vars.c = c 
  
  def insert_numbers(): 
 form = SQLFORM(db.numbers) 
 if form.process(onvalidation=my_form_processing).accepted: 
 session.flash = 'record inserted' 
 redirect(URL()) 
 return dict(form=form) 
  
  Where my_form_processing function is called without bracket and 
  arguments... 
  
  I try to do this that failed : 
  
  def my_form_processing(table_name, form): 
  form.vars.field1 = table_name # I know useless, it just 
  demonstration for purpose of my question... 
  
  ... 
  
   if form.process(onvalidation=my_form_processing(request.args(0), 
  form)).accepted: 
  
  Then I did : 
  
  def my_form_processing(form): 
  form.vars.field1 = request.args(0) 
  
  ... 
  
   if form.process(onvalidation=my_form_processing).accepted: 
  
  That actually works... 
  
  I would like to make sure that I understand onvalidation properly... 
  
  Is my_form_processing just a extension of the insert_numbers() 
  function? 
  
  And if so, does it have access to all the same variables 
  (environnement) of inser_numbers()?? 
  
  Thank you! 
  
  Richard

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Does python IN operator works for DAL?

2014-07-02 Thread Pham Quang Dung
Hi,
Below are the DAL query and its SQLite version, the bold expression was 
always 1 (true) which made me think its not working?

recs = db(m.mt_account==184901310)(*m.name[:2] in 
['cr','bu','se']*)(m.writetime 
lastupdate)(m.name[-4:]=='LOTs').select(
m.mt_account,m.name,'ROUND(SUM(m.searchvalue),2)',m.writetime,groupby=m.name[2:8])
 SELECT  m.mt_account, m.name, ROUND(SUM(m.searchvalue),2), m.writetime 
FROM any
info AS m WHERE m.mt_account = 184901310) AND (m.writetime  
'2014-07-02 13:
13:56')) AND (SUBSTR(m.name,(LENGTH(m.name) - 3),LENGTH(m.name)) = 'LOTs')) 
AND *1*) GROUP BY SUBSTR(m.name,3,(9 - 3));

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] create an update page (similar to profile page in default application)

2014-07-02 Thread Shubham Jain
I want to create an update page just like profile page in default 
application. Actually I am passing the primary key of a table by a button 
click to the product_update page. In the controller of the update page I 
tried these 2 codes.

def product_edit():
db.products.product_id.writable=FALSE   # to make product_id 
non editable
db.products.product_id.readable=TRUE
testform = 
SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(), 
fields=['product_id','price','pro_type','tags','category','description']))
return dict(form=testform)

  
 
--OR-

dform = 
SQLFORM(db.products,record=db(db.products.product_id==request.post_vars.pid).select(),
 
fields=['product_id','price','pro_type','tags','category','description'])
return dict(form=dform)

  pid - name of the input which has the product_id.
But these don't work.

Error Generated: TypeError: list indices must be integers, not str

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Error : unable to open database file

2014-07-02 Thread Sandeep Kumar
I checked for the multiple instances of web2py. There are 10 main processes 
running which should be actually scheduler workers.. i changed those to 
scheduler workers again with -K option. It seems the app is working fine.

Thank you for your solution.. 

On Friday, 27 June 2014 12:33:38 UTC+5:30, Massimo Di Pierro wrote:

 Do you have a background process? Do you have multiple web2py's running in 
 the same instance?
 sqlite is not client server and each instance locks the database. If the 
 database is locked for too long and another process/thread/request tries to 
 access, it may timeout.

 On Thursday, 26 June 2014 16:29:05 UTC-5, Sandeep Kumar wrote:

 Hi,
  I am getting this strange error one in 10 times in my app. The error 
 is class 'sqlite3.OperationalError' unable to open database file. I 
 am getting this error after i replaced the *databases* folder with one 
 from my backup app which is running on a different server. I think the 
 plugin_wiki is has some problem. I want to uninstall this plugin_wiki and 
 reinstall it but then i fear of losing all the pages that were created 
 using plugin_wiki. Can someone help me out on this?

 The error traceback is as follows : 

  Traceback (most recent call last):

   File /backup1/web2py/gluon/restricted.py, line 212, in restricted
 exec ccode in environment
   File /backup1/web2py/applications/lims/models/plugin_wiki.py 
 https://metabolomics.iiit.ac.in/admin/edit/lims/models/plugin_wiki.py, 
 line 715, in module
 plugin_wiki=PluginWiki()
   File /backup1/web2py/applications/lims/models/plugin_wiki.py 
 https://metabolomics.iiit.ac.in/admin/edit/lims/models/plugin_wiki.py, 
 line 534, in __init__
 code_page = db(db.plugin_wiki_page.slug=='meta-code').select().first()
   File /backup1/web2py/gluon/dal.py, line 9958, in select
 return adapter.select(self.query,fields,attributes)
   File /backup1/web2py/gluon/dal.py, line 2245, in select
 return super(SQLiteAdapter, self).select(query, fields, attributes)
   File /backup1/web2py/gluon/dal.py, line 1704, in select
 return self._select_aux(sql,fields,attributes)
   File /backup1/web2py/gluon/dal.py, line 1669, in _select_aux
 self.execute(sql)
   File /backup1/web2py/gluon/dal.py, line 1784, in execute
 return self.log_execute(*a, **b)
   File /backup1/web2py/gluon/dal.py, line 1778, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 OperationalError: unable to open database file



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: with_alias unexpectedly converts field type to string

2014-07-02 Thread Pham Quang Dung
Thanks Massimo,
Yes I changed the field type so I know why now.

On Monday, June 30, 2014 11:44:28 AM UTC+7, Pham Quang Dung wrote:

 Can anyone explain to me what I did wrongly to have the unexpected string 
 test field, instead of double?

  x=db().select(tb.searchvalue.with_alias('test'))
  x[0]
 Row {'test': u'3', '_extra': {'tb.searchvalue AS test': 3.0}}
 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Does python IN operator works for DAL?

2014-07-02 Thread Massimo Di Pierro
No. But you can do:

recs = db(m.mt_account==184901310)(*m.name 
http://m.name/[:2].contains(['cr','bu','se'])*)(m.writetime lastupdate)(
m.name[-4:]=='LOTs').select(
m.mt_account,m.name,'ROUND(SUM(m.searchvalue),2)',m.writetime,groupby=m.name
[2:8])

On Wednesday, 2 July 2014 01:31:28 UTC-5, Pham Quang Dung wrote:

 Hi,
 Below are the DAL query and its SQLite version, the bold expression was 
 always 1 (true) which made me think its not working?

 recs = db(m.mt_account==184901310)(*m.name http://m.name[:2] in 
 ['cr','bu','se']*)(m.writetime lastupdate)(m.name[-4:]=='LOTs').select(
 m.mt_account,m.name,'ROUND(SUM(m.searchvalue),2)',m.writetime,groupby=
 m.name[2:8])
  SELECT  m.mt_account, m.name, ROUND(SUM(m.searchvalue),2), m.writetime 
 FROM any
 info AS m WHERE m.mt_account = 184901310) AND (m.writetime  
 '2014-07-02 13:
 13:56')) AND (SUBSTR(m.name,(LENGTH(m.name) - 3),LENGTH(m.name)) = 
 'LOTs')) AND *1*) GROUP BY SUBSTR(m.name,3,(9 - 3));


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] create an update page (similar to profile page in default application)

2014-07-02 Thread Fabiano Almeida
Need convert request to int:
int(request.post_vars.pid)

Fabiano.


2014-07-02 8:05 GMT-03:00 Shubham Jain shub.jain1...@gmail.com:

 I want to create an update page just like profile page in default
 application. Actually I am passing the primary key of a table by a button
 click to the product_update page. In the controller of the update page I
 tried these 2 codes.

 def product_edit():
 db.products.product_id.writable=FALSE   # to make product_id
 non editable
 db.products.product_id.readable=TRUE
 testform =
 SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(),
  fields=['product_id','price','pro_type','tags','category','description']))
 return dict(form=testform)


  
 --OR-

 dform =
 SQLFORM(db.products,record=db(db.products.product_id==request.post_vars.pid).select(),
 fields=['product_id','price','pro_type','tags','category','description'])
 return dict(form=dform)

   pid - name of the input which has the product_id.
 But these don't work.

 Error Generated: TypeError: list indices must be integers, not str

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: create an update page (similar to profile page in default application)

2014-07-02 Thread Massimo Di Pierro
The problem is that here:

testform = 
SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(), 
fields=['product_id','price','pro_type','tags','category','description']))

the result of a select is a Rows and not a Row. Do you know there is a 
single matching record? In this case:

testform = 
SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select().first(),
 fields=['product_id','price','pro_type','tags','category','description']))

or

testform = SQLFORM(db.products, 
db.products(product_id=request.post_vars.pid), 
fields=['product_id','price','pro_type','tags','category','description']))

Mind that the pid of the product you want to edit should not be a POST 
parameter but a GET parameter. According to REST it is used to identify the 
resource you want to edit therefore it belongs to the URL not to the posted 
data.

Massimo



On Wednesday, 2 July 2014 06:05:31 UTC-5, Shubham Jain wrote:

 I want to create an update page just like profile page in default 
 application. Actually I am passing the primary key of a table by a button 
 click to the product_update page. In the controller of the update page I 
 tried these 2 codes.

 def product_edit():
 db.products.product_id.writable=FALSE   # to make product_id 
 non editable
 db.products.product_id.readable=TRUE
 testform = 
 SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(),
  fields=['product_id','price','pro_type','tags','category','description']))
 return dict(form=testform)

   
  
 --OR-

 dform = 
 SQLFORM(db.products,record=db(db.products.product_id==request.post_vars.pid).select(),
  
 fields=['product_id','price','pro_type','tags','category','description'])
 return dict(form=dform)

   pid - name of the input which has the product_id.
 But these don't work.

 Error Generated: TypeError: list indices must be integers, not str



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: for i,row in enumerate(rows) second condition

2014-07-02 Thread Annet
Hi Simone,

Wouldn't all this brain-hurting nested loops with inclusion within the view 
 be infinitely easier if you could just have THE correct structure BEFORE 
 fiddling with HTML ?


That's what I thought, hence my question in the workgroup. Thanks for 
answering it, your solution is useful in a number of cases.


Best,

Annet
 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] How to pass an array from jQuery to controller

2014-07-02 Thread Chris
Eval can be used to crash a Python app or hack into it, so *please don't 
use it*, as tempting as it may be!! 
(http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html)

I spent some time working on this and found that something like this is a 
decent way to do it:

script
//http://stackoverflow.com/questions/8890524/pass-array-to-ajax-request-in-ajax
info = [];
info[0] = 'hi';
info[1] = 'hello';


$.ajax({
 type: POST,
 data: {info:info},
 url: index.php,
 success: function(msg){
 $('.answer').html(msg);
 }
});

/script


In web2py:


def getRequestVars(name):
varValue = request.vars[name + '[]']
if type(varValue) == str:
return [varValue] #check for single value
else:
return varValue


info = getRequestVars('info')

This approach is nice because you can use both web2py and jQuery's 
automatic array handling. :)


On Wednesday, August 31, 2011 2:18:09 AM UTC-4, rochacbruno wrote:

 I dont know if this is the best approach, but I juste tested here and 
 works.

 On Wed, Aug 31, 2011 at 2:17 AM, Noel Villamor noe...@gmail.com 
 javascript: wrote:

 I wanted to pass an array from jQuery to a controller.

 script
 var xyz= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
 $(function() {
 $(body).click(function(event) {
   
  ajax({{=URL('default','mycontroller')}}+?array=+xyz,[],'target'); 

 });
 });
 /script

 the above will call this url:
 /default/mycontroller?array=['Sun','Mon','Tue','Wed','Thu','Fri','Sat']

  

 def mycontroller():
# Here, I wanted to receive xyz as an array.


   myarray = eval(request.vars.array)


 the above will receive the string and evaluate as a Python list.

 (BUT, BE CAREFUL!! it can be used to crash your app)

 another solution may be better than the above, is to split the array as 
 args and pass it separated.

 script

 var xyz= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
 args = xyz.join(/)

  $(function() {
  $(body).click(function(event) {
 ajax({{=URL('default','mycontroller')}}+args ,[],'target'); 

  });
 });

 /script

 the url will be called as

 /default/mycontroller/Sun/Mon/Tue/Wed/Thu/'Fri/Sat

 in controller

 def mycrontroller():

 array = request.args
 array[0] # Sun

 The second approach is better ans safe.
 -- 



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: How to pass an array from jQuery to controller

2014-07-02 Thread Noel Villamor
Nice one Chris and thanks for reviewing this post. Web2py has indeed come a 
long way from 2 years ago and is worthy of a revisit. Cheers!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] bootstrap readonly

2014-07-02 Thread Annet
Bootstrap has the following option to render a field read only:

input class=form-control type=text placeholder=Readonly input here… 
readonly

Is ther a way to add readonly to input?


Regards,

Annet


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] bootstrap readonly

2014-07-02 Thread Marco Mansilla
El Wed, 2 Jul 2014 11:46:18 -0700 (PDT)
Annet anneve...@googlemail.com escribió:

 Bootstrap has the following option to render a field read only:
 
 input class=form-control type=text placeholder=Readonly input
 here… readonly
 
 Is ther a way to add readonly to input?
 
 
 Regards,
 
 Annet
 


Have you tried:

   db.my_table.my_field.writable=False

or:

   setting with jquery $(#field_id).attr('readonly',true) 


I have noticed that if I need to change some field value's using
javascript, setting writable to false in fiel definition throws
tickets, and solved with jquery option...


hope it helps.

Marco.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: bootstrap readonly

2014-07-02 Thread Anthony
You can do:

INPUT(..., _readonly=True)

which will produce:

input ... readonly=readonly

which I believe should work in most browsers.

Anthony

On Wednesday, July 2, 2014 2:46:18 PM UTC-4, Annet wrote:

 Bootstrap has the following option to render a field read only:

 input class=form-control type=text placeholder=Readonly input here… 
 readonly

 Is ther a way to add readonly to input?


 Regards,

 Annet




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: what are the12 core objects

2014-07-02 Thread 'tomt' via web2py-users
- thanks for the response

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.