[web2py] Decoding file name.

2015-07-28 Thread Prasad Muley
Hi All,

 file name gets store as *93f00342868f4085.73716c2e6c6f67.log *in db 
field.
I've tried to decode it using base64 But didn't get the original file name.

Is there any way to decode it and get the original file name?



-- 
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] Display SQLFORM.Grid inside view of another SQLFORM.grid.

2015-07-07 Thread Prasad Muley
Hi,

  I have a SQLFORM.grid which displays information about employee 
table. Every employee may have multiple addresses. 
So I have to display multiple address in another grid (address grid) inside 
edit form of the employee grid.


*models/db.py*

db.define_table('employee',
Field('fname', 'string', label=T(First Name), 
required=True),
Field('lname', 'string', label=T(Last Name), 
required=True),
Field('email', requires=IS_EMAIL()),
format='%(email)s')

db.define_table('address',
Field('employee', db.employee),
Field('Address', 'text'))

*controllers/default.py*

def _validate_emp_records(form):
error_exist = False
if not form.vars.fname:
form.errors.fname = T(Enter First Name)
error_exist = True

if not form.vars.lname:
form.errors.lname = T('Enter last name')
error_exist = True

return not error_exist


@auth.requires_login()
def index():

example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

if you need a simple wiki simply replace the two lines below with:
return auth.wiki()

query = (db.employee.id  0)
emp_grid = SQLFORM.grid(query, showbuttontext=False, csv=False,
deletable=False)
address_grid = None

if request.args(0) == 'edit':
form = emp_grid.update_form
emp_id = request.args(2)
address_query = (db.address.employee == emp_id)
# show all address in edit form of employee
address_grid = SQLFORM.grid(address_query, deletable=False,
showbuttontext=False, csv=False)

if form.process(onvalidation=_validate_emp_records).accepted:
session.flash = T('Updated %s' % form.vars.id)
redirect(URL('default', 'index'))
elif form.errors:
response.flash = T(form has errors)

if request.args(0) == 'view':
form = emp_grid.view_form

if request.args(0) == 'new':
form = emp_grid.create_form

return dict(emp_grid=emp_grid, address_grid=address_grid)


*views/default/index.html*


{{extend 'layout.html'}}

{{=emp_grid}}

{{ if address_grid: }}
 {{ =address_grid}}
{{ pass }}


Here, 
 It shows two edit forms whenever I click on edit icon. [See 
attachment edit_records.png]

Is it possible to display SQLFORM.grid inside view of another SQLFORM.grid?


-- 
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: Display SQLFORM.Grid inside view of another SQLFORM.grid.

2015-07-07 Thread Prasad Muley
Hi stifan,

I've tried to give a different name for each SQLFORM.grid But it didn't 
work.


On Tuesday, July 7, 2015 at 5:56:18 PM UTC+5:30, 黄祥 wrote:

 had you try to give a name for each SQLFORM.grid(formname = 'form1') and 
 SQLFORM.grid(formname = 'form2')

 best regards,
 stifan


-- 
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] Re: Export to csv which is not taking label from model file, where Grid takes.

2015-05-13 Thread Prasad Muley
Hi Anthony,

   I've used the custom CSV exporter.  I tried to use *colnames* parameters
of export_to_csv_file But got an error (mentioned earlier). Am I missing
anything in following code??


class CSVExporter(object):
This class is used when grid's table contains reference key id.
   Exported CSV should contain reference key name of reference
   key not ids
file_ext = csv
content_type = text/csv

def __init__(self, rows):
self.rows = rows

def export(self):
if self.rows:
s = StringIO()
colnames = []
for colname in self.rows.colnames:
colnames.append(colname.split('.')[-1].replace('_', '
').upper())
print DEBUG: colnames, colnames
self.rows.export_to_csv_file(s, represent=True,
 colnames=colnames)
return s.getvalue()
else:
return ''


It successfully prints column name
DEBUG: ['FNAME', 'LNAME']

I got following error

127.0.0.1.2015-05-13.18-52-30.6eb87877-1bb1-49e0-9f05-8508333fa967
type 'exceptions.AttributeError' 'Row' object has no attribute '_extra'

On Wed, May 13, 2015 at 6:08 PM, Anthony abasta...@gmail.com wrote:

 You can create your own CSV exporter:

 SQLFORM.grid(...,
  exportclasses=dict(csv=(MyExporterCSV, 'CSV',
  T('Comma-separated export of visible
 columns.'

 The MyExporterCSV class can inherit from gluon.sqlhtml.ExporterCSV
 https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L3427.
 You can tweak the export method to change the column names as you like.

 Anthony


 On Tuesday, May 12, 2015 at 1:07:40 PM UTC-4, Sujata Aghor wrote:


 Hi,
 In my model file I have defined table and Label for the fields like this
 -
 db.define_table('mytable',
 Field('fname', 'string', length=12, writable=False,
   notnull=True, label='First Name'),
Field('lname', 'string', length=12, writable=False,
   notnull=True, label='Last Name'),
 ...

 1. In case of Grids, table headers are coming from  model file (shown
 above) No extra code has been written to show the labels from the model
 file.

 2. So I was expecting the same headers would come to CSV file also, but
 surprisingly when I export to CSV we dont get these labels. (I tried by
 doing CSV=true in case of grid and still gets mytable.fname)

 3. From documentation, I found Grid has additional parameter. i.e headers
 I tired to use that parameter to see if it works in export. So I defined
 headers as below :
 headers = {'db.mytable.fname': 'First Name',
'db.mytable.lname': 'Last Name'
   }

 However export to CSV is still showing headers as db.mytable.fname

 Kindly guide!
 I suspect this is BUG in web2py export to csv which is not taking label
 from model file.

 Thanks in Advance!!!

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/tJafWvYxcdw/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley

-- 
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: Export to csv which is not taking label from model file, where Grid takes.

2015-05-13 Thread Prasad Muley
Can use colnames parameter of export_to_csv_file ?

I tried to use it But got following error.

type 'exceptions.AttributeError' 'Row' object has no attribute '_extra'

What is the format for colnames?


On Wednesday, May 13, 2015 at 1:23:33 AM UTC+5:30, Niphlod wrote:

 the export are for raw processing, so they get the same result as you 
 would get - for practical purposes - from db(query).select().as_csv()

 On Tuesday, May 12, 2015 at 7:07:40 PM UTC+2, Sujata Aghor wrote:


 Hi,
 In my model file I have defined table and Label for the fields like this 
 - 
 db.define_table('mytable',
 Field('fname', 'string', length=12, writable=False,
   notnull=True, label='First Name'),
Field('lname', 'string', length=12, writable=False,
   notnull=True, label='Last Name'),
 ...

 1. In case of Grids, table headers are coming from  model file (shown 
 above) No extra code has been written to show the labels from the model 
 file.

 2. So I was expecting the same headers would come to CSV file also, but 
 surprisingly when I export to CSV we dont get these labels. (I tried by 
 doing CSV=true in case of grid and still gets mytable.fname)

 3. From documentation, I found Grid has additional parameter. i.e headers 
 I tired to use that parameter to see if it works in export. So I defined 
 headers as below :
 headers = {'db.mytable.fname': 'First Name',
'db.mytable.lname': 'Last Name'
   }

 However export to CSV is still showing headers as db.mytable.fname

 Kindly guide!
 I suspect this is BUG in web2py export to csv which is not taking label 
 from model file.

 Thanks in Advance!!!



-- 
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: Virtual fields in SQLFORM.grid and Export to CSV

2015-01-22 Thread Prasad Muley
This is a web2py bug. 



The expcolumns list contains all the table fields i.e including virtual 
fields.
for eg: [field1, field2, ..,field_N, Virtual_field_1, Virtual_field2, ..., 
Virtual_field_N]

selectable_columns list contain only the selectable fields. It actually 
removes all the virtual fields of the table.
for eg:  [ field1, field2, ... field_N]

Query is also executed without virtual_fields So rows object doesn't 
contain virtual_fields.


But *expcolumns* [which contains virtual fields ] is assigned to 
*rows.colnames*.

So It shows attribute error for virtual fields.

It should assign *selectable_columns* to *rows.colnames*

Can I create a issue for this and send the fix via pull request?


On Tuesday, January 20, 2015 at 7:36:00 PM UTC+5:30, Prasad Muley wrote:

 Hi All,

I've some virtual fields defined in a table. These are displayed on 
 grid using viewargs.

 I've provided Export to CSV But it fails because of virtual fields.

 It shows errors as '*Row'* *Object has no attribute 'virtual_field_name' *


 app settings as below:

 *controllers/default.py*


 def person_info():

  viewargs =  viewargs = {'fields': [f for f in db.person.__dict__
if isinstance(db.company[f],
  (Field, Field.Virtual))]}
  export_csv = True
  export_classes = dict(xml=False, html=False, json=False, tsv=False,
   tsv_with_hidden_cols=False,
   csv_with_hidden_cols=False)  
 grid = SQLFORM.grid(query, create=False, deletable=False,
 editable=allow_edit, maxtextlengths=maxtextlengths,
 showbuttontext=False, csv=export_csv,
 exportclasses=export_classes, viewargs=viewargs)   
  

 return dict(grid=grid)


 Is it web2py bug? or 
 Am I missing anything?



-- 
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] Virtual fields in SQLFORM.grid and Export to CSV

2015-01-20 Thread Prasad Muley
Hi All,

   I've some virtual fields defined in a table. These are displayed on 
grid using viewargs.

I've provided Export to CSV But it fails because of virtual fields.

It shows errors as '*Row'* *Object has no attribute 'virtual_field_name' *


app settings as below:

*controllers/default.py*


def person_info():

 viewargs =  viewargs = {'fields': [f for f in db.person.__dict__
   if isinstance(db.company[f],
 (Field, Field.Virtual))]}
 export_csv = True
 export_classes = dict(xml=False, html=False, json=False, tsv=False,
  tsv_with_hidden_cols=False,
  csv_with_hidden_cols=False)  
grid = SQLFORM.grid(query, create=False, deletable=False,
editable=allow_edit, maxtextlengths=maxtextlengths,
showbuttontext=False, csv=export_csv,
exportclasses=export_classes, viewargs=viewargs)

return dict(grid=grid)


Is it web2py bug? or 
Am I missing anything?

-- 
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] Re: Exporting from a SQLFORM.grid with customized search queries

2015-01-15 Thread Prasad Muley
Hi Massimo,

   Thanks for reply. I've sent you the pull request on github. Let
me know if you get any errors :)


On Thu, Jan 15, 2015 at 9:26 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Thanks. I will merge this patch!


 On Thursday, 15 January 2015 04:01:24 UTC-6, Prasad Muley wrote:

 Hello Massimo and Dexter,

 I've a fix for this issue. I've tested it and attached the diff
 file. PFA.

 Let me know if I missed anything.

 Btw Can I send pull request?

 On Saturday, October 25, 2014 at 5:17:24 AM UTC+5:30, Massimo Di Pierro
 wrote:

 Hello Dexter, I think your are right. I will review this asap.
 Meanwhile, would you be able to open an issue with a link to this thread so
 we can more easily keep track. Thanks!.

 Massimo

 On Thursday, 23 October 2014 13:23:16 UTC-5, Dexter Hadley wrote:

 Hi All,

 This is my first time posting a question, so thanks to Massimo and they
 whole community for making web2py.  Its great!

 I am trying to export results from a customized full-text search using
 SQLFORM.grid.  My backend is a Postgres db, and I successfully define
 search_widget and searchable functions that are passed to the
 SQLFORM.grid to do the full-text search.  It will works pretty well on the
 web app.  However, once I click the export button, SQLFORM.grid apparently
 recreates the query using the default SQLFORM.build_query and ignores the
 correct query which I define in searchable.  After poking around in
 sqlhtml.py, I found this is so because the exporter only conditions on
 request.vars.keywords before calling  SQLFORM.build_query, and it does not
 check for callable(searchable) which I think it should do.  In fact, I
 fixed it by editing sqlhtml.py to force the exporter to condition on
 (request.vars.keywords *and callable(searchable)*) before setting up
 the rows object to export.  The code I added is in bold below (on line 2298
 of sqlhtml.py):

 if request.vars.keywords *and callable(searchable)*:
 try:
 #the query should be constructed using
 searchable fields but not virtual fields
 sfields = reduce(lambda a, b: a + b,
 [[f for f in t if f.readable and not
 isinstance(f, Field.Virtual)] for t in tables])
 dbset = dbset(SQLFORM.build_query(
 sfields, request.vars.get('keywords', '')))
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True,
 *selectable_columns)
 except Exception, e:
 response.flash = T('Internal Error')
 rows = []
 else:
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True,
 *selectable_columns)

 Is this a bug or is there a better way to do an export of customized
 search results using SQLFORM.grid?  I'm using the current version of
 everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8).  Thx again,

 dex*

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/Td58YKBAaMo/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley

-- 
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] Re: Error: Exporting CSV file in SQLFORM.grid

2015-01-15 Thread Prasad Muley
Hi Tim,

  Export format should be CSV file. I am getting that error because of
the custom search in grid.

I got some clues from Exporting from a SQLFORM.grid with customized search
queries https://groups.google.com/forum/#!topic/web2py/Td58YKBAaMo

I'll try TSV once I fix this issue.


On Thu, Jan 15, 2015 at 1:32 PM, Tim Richardson t...@tim-richardson.net
wrote:

 A quick question: if you try the standard Tab Separated Value export, does
 it work? (you can refer back to your stack overflow link to see why I ask).



 On Thursday, 15 January 2015 04:31:56 UTC+11, Prasad Muley wrote:

 Hello All,

I've used a SQLFORM.grid for displaying table content. I've
 provided export to CSV option in grid.

 My app settings are as below:

 *models/db.py*

 db.define_table('company',
 Field('name', 'string', length=128, notnull=True,
 unique=True),
 Field('address', 'string'), format='%(name)s')


 db.define_table('document',
   Field('name', 'string', length=128,
 notnull=True),
   Field('type', 'string', notnull=True),
   Field('company', db.company, format='%(name)s')


 Here,
 document table has company as a reference key,
 *Exported CSV should contain the company names not ids*

 So I've defined a class *CSVExporter* according to anthony
 http://www.quora.com/Anthony-Bastardi  solution for
 web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields
 http://stackoverflow.com/questions/17337290/web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields

 *modules/doc_utils.py*
 from cStringIO import StringIO


 class CSVExporter(object):
 This class is used when grid's table contains reference key id.
Exported CSV should contain reference key name of reference
key not ids
 file_ext = csv
 content_type = text/csv

 def __init__(self, rows):
 self.rows = rows

 def export(self):
 if self.rows:
 s = StringIO()
 self.rows.export_to_csv_file(s, represent=True)
 return s.getvalue()
 else:
 return ''

 *#Grid uses Custom search for string*


 def search_query(fields, keywords):
  Custom search for doc grid
 if isinstance(keywords, (tuple, list)):
 keywords = keywords[0]
 request.vars.keywords = keywords
 key = keywords.strip()
 if key and not '' in key and not ' in key and key:
 SEARCHABLE_TYPES = ('string', 'text', 'list:string')
 words = key.split(' ') if key else []
 filters = []
 for field in fields:
 #apply search on company_name also
 if field.name == portfolio_company:
 #get db from current module
 db = current.db
 #get company name from record
 company_ids = [company.id for company in db(
 db.company.name.contains(words)).select(db.company.id
 )]
 if company_ids:
 filters.append(field.belongs(company_ids))
 continue
 if field.type in SEARCHABLE_TYPES:
 all_words_filters = []
 for word in words:
 all_words_filters.append(field.contains(word))
 filters.append(reduce(lambda a, b: (a  b),
 all_words_filters))
 parts = filters
 else:
 parts = None
 if parts:
 return reduce(lambda a, b: a | b, parts)
 else:
 return None

 *controllers/documents.py*
 from applications.asdf.doc_utils import CSVExporter, search_query


 def docs():
 export_csv = False
 export_classes = None
 query = valid_db_query_here
 if auth.has_membership('manager'):
  export_csv = True
  export_classes = dict(csv=(CSVExporter, 'CSV'),
 xml=False, html=False,
 json=False,
 csv_with_hidden_cols=False,
 tsv=False,
 tsv_with_hidden_cols=False)

 grid = SQLFORM.grid(query, orderby=~db.document.created_on,
  showbuttontext=False,
 csv=export_csv, deletable=False,
  searchable=search_query,
 exportclasses=export_classes)


return (grid=grid)

 If I search single keyword like Google or MicroSoft in then export works
 as expected.

 if I search multiple keywords like Google India Private Limited or Redhat
 India Pvt Ltd then it shows expected rows in grid

 But If I click on export button then it gives me *Following error*


 *Ticket ID*
 *127.0.0.1.2015-01-14.21-56-57.34fb2b60-2857-4c1a-9626-a854630fc9c7*

 *type 'exceptions.AttributeError' 'list' object has no attribute
 'colnames'*

 *Version*
 *web2py™ Version 2.9.5-stable+timestamp.2014.03.16.02.35.39*
 *Traceback*
 *1.*
 *2.*
 *3.*
 *4.*
 *5.*
 *6

[web2py] Re: Exporting from a SQLFORM.grid with customized search queries

2015-01-15 Thread Prasad Muley
Hello Massimo and Dexter,

I've a fix for this issue. I've tested it and attached the diff 
file. PFA. 

Let me know if I missed anything. 

Btw Can I send pull request?

On Saturday, October 25, 2014 at 5:17:24 AM UTC+5:30, Massimo Di Pierro 
wrote:

 Hello Dexter, I think your are right. I will review this asap. Meanwhile, 
 would you be able to open an issue with a link to this thread so we can 
 more easily keep track. Thanks!.

 Massimo

 On Thursday, 23 October 2014 13:23:16 UTC-5, Dexter Hadley wrote:

 Hi All,

 This is my first time posting a question, so thanks to Massimo and they 
 whole community for making web2py.  Its great!

 I am trying to export results from a customized full-text search using 
 SQLFORM.grid.  My backend is a Postgres db, and I successfully define 
 search_widget and searchable functions that are passed to the 
 SQLFORM.grid to do the full-text search.  It will works pretty well on the 
 web app.  However, once I click the export button, SQLFORM.grid apparently 
 recreates the query using the default SQLFORM.build_query and ignores the 
 correct query which I define in searchable.  After poking around in 
 sqlhtml.py, I found this is so because the exporter only conditions on 
 request.vars.keywords before calling  SQLFORM.build_query, and it does not 
 check for callable(searchable) which I think it should do.  In fact, I 
 fixed it by editing sqlhtml.py to force the exporter to condition on 
 (request.vars.keywords *and callable(searchable)*) before setting up the 
 rows object to export.  The code I added is in bold below (on line 2298 of 
 sqlhtml.py):

 if request.vars.keywords *and callable(searchable)*:
 try:
 #the query should be constructed using searchable 
 fields but not virtual fields
 sfields = reduce(lambda a, b: a + b,
 [[f for f in t if f.readable and not 
 isinstance(f, Field.Virtual)] for t in tables])
 dbset = dbset(SQLFORM.build_query(
 sfields, request.vars.get('keywords', '')))
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)
 except Exception, e:
 response.flash = T('Internal Error')
 rows = []
 else:
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)

 Is this a bug or is there a better way to do an export of customized 
 search results using SQLFORM.grid?  I'm using the current version of 
 everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8).  Thx again,

 dex*



-- 
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.
diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index 28c3761..6e32aa2 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -2326,7 +2326,7 @@ class SQLFORM(FORM):
  expcolumns.append(str(field))
 
 if export_type in exportManager and exportManager[export_type]:
-if keywords:
+if keywords and not callable(searchable):
 try:
 #the query should be constructed using searchable
 #fields but not virtual fields
@@ -2339,6 +2339,19 @@ class SQLFORM(FORM):
 except Exception, e:
 response.flash = T('Internal Error')
 rows = []
+elif callable(searchable):
+#use custom_query using searchable
+try:
+#the query should be constructed using searchable
+#fields but not virtual fields
+sfields = reduce(lambda a, b: a + b,
+[[f for f in t if f.readable and not isinstance(f, 
Field.Virtual)] for t in tables])
+dbset = dbset(searchable(sfields, keywords))
+rows = dbset.select(left=left, orderby=orderby,
+cacheable=True, 
*selectable_columns)
+except Exception, e:
+response.flash = T('Internal Error')
+rows = []
 else:
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 

[web2py] Re: Exporting from a SQLFORM.grid with customized search queries

2015-01-14 Thread Prasad Muley
Hi Dexter,

 I am facing the same issue. I've posted a question here 
https://groups.google.com/forum/#!topic/web2py/P2avEkVVeZg

It is throwing an exception because of following the line

*  dbset = dbset(SQLFORM.build_query(*
*sfields, request.vars.get('keywords', '')))*

I agree with you that SQLFORM.grid should use the custom search query.


I've used your condition i.e added it in sqlhtml.py

*if request.vars.keywords and not callable(searchable):*


It shows correct record counter on grid. 
But it exports all the record or rand records in exported CSV.

Looks like It is not fetching record according to custom search.



On Saturday, October 25, 2014 at 12:55:55 AM UTC+5:30, Dexter Hadley wrote:

 CORRECTION:  I got the boolean wrong below...  In fact, I fixed it by 
 editing sqlhtml.py to force the exporter to condition on 
 (request.vars.keywords *and not callable(searchable)*) before setting up 
 the rows object to export.  That is, if searchable is not defined, 
 then SQLFORM.build_query gets called, else use the query as defined by 
 searchable.  Here is the correct working code:

  if request.vars.keywords *and not callable(searchable)*:
 try:
 #the query should be constructed using searchable 
 fields but not virtual fields
 sfields = reduce(lambda a, b: a + b,
 [[f for f in t if f.readable and not 
 isinstance(f, Field.Virtual)] for t in tables])
 dbset = dbset(SQLFORM.build_query(
 sfields, request.vars.get('keywords', '')))
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)
 except Exception, e:
 response.flash = T('Internal Error')
 rows = []
 else:
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)

 My question still stands... Is this a bug or is there a better way to do 
 an export of customized search results using SQLFORM.grid?  THx,

 dex*

 On Thursday, October 23, 2014 11:23:16 AM UTC-7, Dexter Hadley wrote:

 Hi All,

 This is my first time posting a question, so thanks to Massimo and they 
 whole community for making web2py.  Its great!

 I am trying to export results from a customized full-text search using 
 SQLFORM.grid.  My backend is a Postgres db, and I successfully define 
 search_widget and searchable functions that are passed to the 
 SQLFORM.grid to do the full-text search.  It will works pretty well on the 
 web app.  However, once I click the export button, SQLFORM.grid apparently 
 recreates the query using the default SQLFORM.build_query and ignores the 
 correct query which I define in searchable.  After poking around in 
 sqlhtml.py, I found this is so because the exporter only conditions on 
 request.vars.keywords before calling  SQLFORM.build_query, and it does not 
 check for callable(searchable) which I think it should do.  In fact, I 
 fixed it by editing sqlhtml.py to force the exporter to condition on 
 (request.vars.keywords *and callable(searchable)*) before setting up the 
 rows object to export.  The code I added is in bold below (on line 2298 of 
 sqlhtml.py):

 if request.vars.keywords *and callable(searchable)*:
 try:
 #the query should be constructed using searchable 
 fields but not virtual fields
 sfields = reduce(lambda a, b: a + b,
 [[f for f in t if f.readable and not 
 isinstance(f, Field.Virtual)] for t in tables])
 dbset = dbset(SQLFORM.build_query(
 sfields, request.vars.get('keywords', '')))
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)
 except Exception, e:
 response.flash = T('Internal Error')
 rows = []
 else:
 rows = dbset.select(left=left, orderby=orderby,
 cacheable=True, 
 *selectable_columns)

 Is this a bug or is there a better way to do an export of customized 
 search results using SQLFORM.grid?  I'm using the current version of 
 everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8).  Thx again,

 dex*



-- 
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 

[web2py] Error : Exporting CSV file in SQLGRID

2015-01-14 Thread Prasad Muley
http://www.quora.com/Anthony-BastardiHi All,

   I've used a SQLFORM.grid for displaying table content. I've provided 
export to CSV option in grid.

My app settings are as below:

*models/db.py*

db.define_table('company',
Field('name', 'string', length=128, notnull=True, 
unique=True),
Field('address', 'string'), format='%(name)s')


db.define_table('document',
  Field('name', 'string', length=128, notnull=True),
  Field('type', 'string', notnull=True),
  Field('company', db.company, format='%(name)s')   


Here, 
document table has company as a reference key,
*Exported CSV should contain the company names not ids*

So I've defined a class *CSVExporter* according to anthony 
http://www.quora.com/Anthony-Bastardi  solution for 
web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields 
http://stackoverflow.com/questions/17337290/web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields

*modules/doc_utils.py*
from cStringIO import StringIO


class CSVExporter(object):
This class is used when grid's table contains reference key id.
   Exported CSV should contain reference key name of reference 
   key not ids
file_ext = csv
content_type = text/csv

def __init__(self, rows):
self.rows = rows

def export(self):
if self.rows:
s = StringIO()
self.rows.export_to_csv_file(s, represent=True)
return s.getvalue()
else:
return ''

*#Grid uses Custom search for string*


def search_query(fields, keywords):
 Custom search for doc grid
if isinstance(keywords, (tuple, list)):
keywords = keywords[0]
request.vars.keywords = keywords
key = keywords.strip()
if key and not '' in key and not ' in key and key:
SEARCHABLE_TYPES = ('string', 'text', 'list:string')
words = key.split(' ') if key else []
filters = []
for field in fields:
#apply search on company_name also
if field.name == portfolio_company:
#get db from current module
db = current.db
#get company name from record
company_ids = [company.id for company in db(
db.company.name.contains(words)).select(db.company.id)]
if company_ids:
filters.append(field.belongs(company_ids))
continue
if field.type in SEARCHABLE_TYPES:
all_words_filters = []
for word in words:
all_words_filters.append(field.contains(word))
filters.append(reduce(lambda a, b: (a  b), 
all_words_filters))
parts = filters
else:
parts = None
if parts:
return reduce(lambda a, b: a | b, parts)
else:
return None

*controllers/documents.py*
from applications.asdf.doc_utils import CSVExporter, search_query


def docs():
export_csv = False
export_classes = None
query = valid_db_query_here
if auth.has_membership('manager'): 
 export_csv = True
 export_classes = dict(csv=(CSVExporter, 'CSV'), xml=False, 
html=False,
json=False, 
csv_with_hidden_cols=False,
tsv=False, 
tsv_with_hidden_cols=False)

grid = SQLFORM.grid(query, orderby=~db.document.created_on,
 showbuttontext=False, 
csv=export_csv, deletable=False,
 searchable=search_query, 
exportclasses=export_classes)


   return (grid=grid)

If I search single keyword like Google or MicroSoft in then export works as 
expected.

if I search multiple keywords like Google India Private Limited or Redhat 
India Pvt Ltd then it shows expected rows in grid

But If I click on export button then it gives me *Following error*


*Ticket ID*
*127.0.0.1.2015-01-14.21-56-57.34fb2b60-2857-4c1a-9626-a854630fc9c7*

*type 'exceptions.AttributeError' 'list' object has no attribute 
'colnames'*

*Version*
*web2py™ Version 2.9.5-stable+timestamp.2014.03.16.02.35.39*
*Traceback*
*1.*
*2.*
*3.*
*4.*
*5.*
*6.*
*7.*
*8.*
*9.*
*10.*
*11.*
*12.*
*13.*
*14.*
*15.*
*16.*
*Traceback (most recent call last):*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/restricted.py, line 220, in 
restricted*
*exec ccode in environment*
*  File 
/home/prasad/Rootpy/web2py_2.9/applications/asdf/controllers/documents.py, 
line 137, in module*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/globals.py, line 385, in 
lambda*
*self._caller = lambda f: f()*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/tools.py, line 3287, in f*
*return action(*a, **b)*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/tools.py, line 3287, in f*
*return action(*a, **b)*

[web2py] Error: Exporting CSV file in SQLFORM.grid

2015-01-14 Thread Prasad Muley
Hello All,

   I've used a SQLFORM.grid for displaying table content. I've provided 
export to CSV option in grid.

My app settings are as below:

*models/db.py*

db.define_table('company',
Field('name', 'string', length=128, notnull=True, 
unique=True),
Field('address', 'string'), format='%(name)s')


db.define_table('document',
  Field('name', 'string', length=128, notnull=True),
  Field('type', 'string', notnull=True),
  Field('company', db.company, format='%(name)s')   


Here, 
document table has company as a reference key,
*Exported CSV should contain the company names not ids*

So I've defined a class *CSVExporter* according to anthony 
http://www.quora.com/Anthony-Bastardi  solution for 
web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields 
http://stackoverflow.com/questions/17337290/web2pygrid-csv-exports-shows-ids-not-values-for-reference-fields

*modules/doc_utils.py*
from cStringIO import StringIO


class CSVExporter(object):
This class is used when grid's table contains reference key id.
   Exported CSV should contain reference key name of reference 
   key not ids
file_ext = csv
content_type = text/csv

def __init__(self, rows):
self.rows = rows

def export(self):
if self.rows:
s = StringIO()
self.rows.export_to_csv_file(s, represent=True)
return s.getvalue()
else:
return ''

*#Grid uses Custom search for string*


def search_query(fields, keywords):
 Custom search for doc grid
if isinstance(keywords, (tuple, list)):
keywords = keywords[0]
request.vars.keywords = keywords
key = keywords.strip()
if key and not '' in key and not ' in key and key:
SEARCHABLE_TYPES = ('string', 'text', 'list:string')
words = key.split(' ') if key else []
filters = []
for field in fields:
#apply search on company_name also
if field.name == portfolio_company:
#get db from current module
db = current.db
#get company name from record
company_ids = [company.id for company in db(
db.company.name.contains(words)).select(db.company.id)]
if company_ids:
filters.append(field.belongs(company_ids))
continue
if field.type in SEARCHABLE_TYPES:
all_words_filters = []
for word in words:
all_words_filters.append(field.contains(word))
filters.append(reduce(lambda a, b: (a  b), 
all_words_filters))
parts = filters
else:
parts = None
if parts:
return reduce(lambda a, b: a | b, parts)
else:
return None

*controllers/documents.py*
from applications.asdf.doc_utils import CSVExporter, search_query


def docs():
export_csv = False
export_classes = None
query = valid_db_query_here
if auth.has_membership('manager'): 
 export_csv = True
 export_classes = dict(csv=(CSVExporter, 'CSV'), xml=False, 
html=False,
json=False, 
csv_with_hidden_cols=False,
tsv=False, 
tsv_with_hidden_cols=False)

grid = SQLFORM.grid(query, orderby=~db.document.created_on,
 showbuttontext=False, 
csv=export_csv, deletable=False,
 searchable=search_query, 
exportclasses=export_classes)


   return (grid=grid)

If I search single keyword like Google or MicroSoft in then export works as 
expected.

if I search multiple keywords like Google India Private Limited or Redhat 
India Pvt Ltd then it shows expected rows in grid

But If I click on export button then it gives me *Following error*


*Ticket ID*
*127.0.0.1.2015-01-14.21-56-57.34fb2b60-2857-4c1a-9626-a854630fc9c7*

*type 'exceptions.AttributeError' 'list' object has no attribute 
'colnames'*

*Version*
*web2py™ Version 2.9.5-stable+timestamp.2014.03.16.02.35.39*
*Traceback*
*1.*
*2.*
*3.*
*4.*
*5.*
*6.*
*7.*
*8.*
*9.*
*10.*
*11.*
*12.*
*13.*
*14.*
*15.*
*16.*
*Traceback (most recent call last):*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/restricted.py, line 220, in 
restricted*
*exec ccode in environment*
*  File 
/home/prasad/Rootpy/web2py_2.9/applications/asdf/controllers/documents.py, 
line 137, in module*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/globals.py, line 385, in 
lambda*
*self._caller = lambda f: f()*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/tools.py, line 3287, in f*
*return action(*a, **b)*
*  File /home/prasad/Rootpy/web2py_2.9/gluon/tools.py, line 3287, in f*
*return action(*a, **b)*
*  File 

[web2py] Open Redirect Vulnerability and auth.settings

2014-12-23 Thread Prasad Muley
Hi All,

We're using web2py_2.9 and There is open redirect vulnerability 
exist following pages:

  *1) **Change Profile: *
https://127.0.0.1:8000/asdf/default/user/profile?_next=http%3A%2F%2Fgoogle.com

  *2) Change Password: *
https://127.0.0.1:8000/asdf/default/user/change_password?_next=http%3A%2F%2Fgoogle.com

  *3) Log out*: 
https://127.0.0.1:8000/asdf/default/user/logout?_next=http%3A%2F%2Fgoogle.com


It successfully redirects to www.google.com 

I've set default URL for redirection in auth settings but it isn't working

*Models/db.py*

auth.settings.logout_next=URL('user', args='login')
auth.settings.profile_next=URL('index')
auth.settings.password_next=URL('index')

*Is there any way to check URL (_next) contains valid controllers function?*
   *for eg:* URL _next='http%3A%2F%2Fgoogle.com' isn't valid controllers 
function.
 but URL _next='asdf/default/index' is valid controllers 
function.

  

-- 
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: web2py and pylint

2014-12-17 Thread Prasad Muley
Hi Flagist,


 I've installed pylint-web2py plugin by downloading from 
flagist-pylint-web2py https://github.com/flagist0/pylint-web2py github.

I've checked whether pylint-web2py plugin is successfully installed or not 
using following command:

*$ pip freeze | grep pylint-web2py 
   [20:22:13]*
*pylint-web2py==0.1.2*

I am getting following an error If I run following commands.

*$ pylint -E --load-plugins pylint-web2py applications/asdf/scripts/asdf.py*

Traceback (most recent call last):
  File /usr/local/bin/pylint, line 9, in module
load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 
line 23, in run_pylint
Run(sys.argv[1:])
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py, 
line 1193, in __init__
linter.load_plugin_modules(self._plugins)
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py, 
line 469, in load_plugin_modules
module = load_module_from_name(modname)
  File 
/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py,
 
line 135, in load_module_from_name
return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
  File 
/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py,
 
line 177, in load_module_from_modpath
mp_file, mp_filename, mp_desc = imp.find_module(part, path)
*ImportError: No module named pylint-web2py*

Or

*$ pylint '--load-plugins=pylint-web2py' applications/asdf/scripts/asdf.py 
*
Traceback (most recent call last):
  File /usr/local/bin/pylint, line 9, in module
load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 
line 23, in run_pylint
Run(sys.argv[1:])
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py, 
line 1193, in __init__
linter.load_plugin_modules(self._plugins)
  File 
/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py, 
line 469, in load_plugin_modules
module = load_module_from_name(modname)
  File 
/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py,
 
line 135, in load_module_from_name
return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
  File 
/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py,
 
line 177, in load_module_from_modpath
mp_file, mp_filename, mp_desc = imp.find_module(part, path)
*ImportError: No module named pylint-web2py*



On Thursday, December 11, 2014 10:03:15 PM UTC+5:30, flagist0 wrote:



 On Wednesday, December 10, 2014 7:04:17 AM UTC+4, Massimo Di Pierro wrote:

 perhaps we should include this in script?

 Pylint expects the plugins to be installed system-wide, so it's better to 
 use this plugin as a separate package.
 But I'll register my version of the plugin on PyPI so it can be installed 
 without git.


-- 
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] Re: web2py and pylint

2014-12-17 Thread Prasad Muley
Hi Mandar,

  I've installed those packages. Pylint is working as expected but
Pylint-web2py plugin isn't working as explained above.

*$ pip freeze | grep logilab*

logilab-astng==0.24.3
logilab-common==0.63.2


*$ pip freeze | grep astroid
   *
astroid==1.3.2



On Wed, Dec 17, 2014 at 11:10 PM, Mandar Vaze mandarv...@gmail.com wrote:

 Can you share the entire pip freeze output ?
 Especially Astoid and logilab-common versions/details ?

 https://bitbucket.org/logilab/pylint says Pylint requires the astroid
 (the later the better; formerly known as logilab-astng) and logilab-common
 (version = 0.53) packages

 This may provide additional clues.

 -Mandar

 On Wednesday, December 17, 2014 8:32:23 PM UTC+5:30, Prasad Muley wrote:

 Hi Flagist,


  I've installed pylint-web2py plugin by downloading from
 flagist-pylint-web2py https://github.com/flagist0/pylint-web2py github.

 I've checked whether pylint-web2py plugin is successfully installed or
 not using following command:

 *$ pip freeze | grep pylint-web2py
  [20:22:13]*
 *pylint-web2py==0.1.2*

 I am getting following an error If I run following commands.

 *$ pylint -E --load-plugins pylint-web2py
 applications/asdf/scripts/asdf.py*

 Traceback (most recent call last):
   File /usr/local/bin/pylint, line 9, in module
 load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 line 23, in run_pylint
 Run(sys.argv[1:])
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 1193, in __init__
 linter.load_plugin_modules(self._plugins)
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 469, in load_plugin_modules
 module = load_module_from_name(modname)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 135, in load_module_from_name
 return load_module_from_modpath(dotted_name.split('.'), path,
 use_sys)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 177, in load_module_from_modpath
 mp_file, mp_filename, mp_desc = imp.find_module(part, path)
 *ImportError: No module named pylint-web2py*

 Or

 *$ pylint '--load-plugins=pylint-web2py'
 applications/asdf/scripts/asdf.py
   *
 Traceback (most recent call last):
   File /usr/local/bin/pylint, line 9, in module
 load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 line 23, in run_pylint
 Run(sys.argv[1:])
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 1193, in __init__
 linter.load_plugin_modules(self._plugins)
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 469, in load_plugin_modules
 module = load_module_from_name(modname)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 135, in load_module_from_name
 return load_module_from_modpath(dotted_name.split('.'), path,
 use_sys)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 177, in load_module_from_modpath
 mp_file, mp_filename, mp_desc = imp.find_module(part, path)
 *ImportError: No module named pylint-web2py*



 On Thursday, December 11, 2014 10:03:15 PM UTC+5:30, flagist0 wrote:



 On Wednesday, December 10, 2014 7:04:17 AM UTC+4, Massimo Di Pierro
 wrote:

 perhaps we should include this in script?

 Pylint expects the plugins to be installed system-wide, so it's better
 to use this plugin as a separate package.
 But I'll register my version of the plugin on PyPI so it can be
 installed without git.

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/db6NRkkMhGw/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p

Re: [web2py] Re: web2py and pylint

2014-12-17 Thread Prasad Muley
Hello Flagist,

   *pylint -E --load-plugins pylint_web2py
applications/asdf/scripts/asdf.py *command.
My bad to not recognize difference between *pylint-web2py* and
*pylint_web2py*

Thanks for quick reply.


On Thu, Dec 18, 2014 at 3:20 AM, flagist0 flagi...@gmail.com wrote:

 Hello Prasad!
 Yes, it is a strange naming convention bug inherited from original
 problem: repository is called pylint-web2py, but the plugin itself is
 called pylint_web2py (note the underscore).
 So you'll to call pylint like this: *pylint -E --load-plugins
 pylint_web2py applications/asdf/scripts/asdf.py*




 On Wednesday, December 17, 2014 7:02:23 PM UTC+4, Prasad Muley wrote:

 Hi Flagist,


  I've installed pylint-web2py plugin by downloading from
 flagist-pylint-web2py https://github.com/flagist0/pylint-web2py github.

 I've checked whether pylint-web2py plugin is successfully installed or
 not using following command:

 *$ pip freeze | grep pylint-web2py
  [20:22:13]*
 *pylint-web2py==0.1.2*

 I am getting following an error If I run following commands.

 *$ pylint -E --load-plugins pylint-web2py
 applications/asdf/scripts/asdf.py*

 Traceback (most recent call last):
   File /usr/local/bin/pylint, line 9, in module
 load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 line 23, in run_pylint
 Run(sys.argv[1:])
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 1193, in __init__
 linter.load_plugin_modules(self._plugins)
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 469, in load_plugin_modules
 module = load_module_from_name(modname)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 135, in load_module_from_name
 return load_module_from_modpath(dotted_name.split('.'), path,
 use_sys)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 177, in load_module_from_modpath
 mp_file, mp_filename, mp_desc = imp.find_module(part, path)
 *ImportError: No module named pylint-web2py*

 Or

 *$ pylint '--load-plugins=pylint-web2py'
 applications/asdf/scripts/asdf.py
   *
 Traceback (most recent call last):
   File /usr/local/bin/pylint, line 9, in module
 load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py,
 line 23, in run_pylint
 Run(sys.argv[1:])
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 1193, in __init__
 linter.load_plugin_modules(self._plugins)
   File 
 /usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py,
 line 469, in load_plugin_modules
 module = load_module_from_name(modname)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 135, in load_module_from_name
 return load_module_from_modpath(dotted_name.split('.'), path,
 use_sys)
   File /usr/local/lib/python2.7/dist-packages/astroid-1.3.2-
 py2.7.egg/astroid/modutils.py, line 177, in load_module_from_modpath
 mp_file, mp_filename, mp_desc = imp.find_module(part, path)
 *ImportError: No module named pylint-web2py*



 On Thursday, December 11, 2014 10:03:15 PM UTC+5:30, flagist0 wrote:



 On Wednesday, December 10, 2014 7:04:17 AM UTC+4, Massimo Di Pierro
 wrote:

 perhaps we should include this in script?

 Pylint expects the plugins to be installed system-wide, so it's better
 to use this plugin as a separate package.
 But I'll register my version of the plugin on PyPI so it can be
 installed without git.

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/db6NRkkMhGw/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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

[web2py] Unable to upload TIFF image files.

2014-12-02 Thread Prasad Muley
Hi All,

   I am trying to upload images for company table as below:

*models/db.py*

db.define_table('company',
 Field('name', 'text', notnull=True),
 Field('abbrev', 'string', length=32),
 Field('logo', 'upload', uploadfield=True,
  requires=IS_IMAGE(extensions=('png', 
',jpg', 'tiff', 'gif')),
 Field('timezone', 'string',
  requires=IS_IN_SET(all_timezones)),
 Field('url', 'string',
  requires=IS_URL()),
 format='%(name)s')

I got an error as *Invalid image *Whenever I tried to upload *tiff 
images.*

How can I upload tiff images?

-- 
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] Displaying blob image on login page

2014-12-01 Thread Prasad Muley
Hi All,

   I need to display logo according to url in login page. I tried to 
display the logo but it always shows *404 not found* error on login page.

My app settings are below:


*models/db.py*


db.define_table('company',
 Field('name', 'text', notnull=True),
 Field('abbrev', 'string', length=32),
 Field('logo', 'upload', uploadfield=True,
  requires=IS_IMAGE()),
 Field('timezone', 'string',
  requires=IS_IN_SET(all_timezones)),
 Field('url', 'string',
  requires=IS_URL()),
 format='%(name)s')


*controllers/default.py*

def user():

exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
http:///[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control

#set some default name
abbrev_name = 'ASDF'
company_rec = 
db(db.company.url.contains(request.env.http_host)).select().first()
if company_rec:
abbrev = company_rec['abbrev']
logo = IMG(_src = URL('default', 'show_logo', company_rec['logo']))
session.company_timezone = company_rec['timezone']
return dict(form=auth(), abbrev=abbrev, logo=logo)


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


*views/default/user.html:*

html
head  /head
body
   div class=logo style=display: inline-block;
   h2 {{=logo}} /h2
   h2{{=abbrev}}/h2
   /div

!-- some code for login / log_out / change_password --
/body
/head


It shows following error as: 

   1. Remote Address:
   127.0.0.1:8000
   2. Request URL:
   
   
https://127.0.0.1:8000/default/show_logo/investor.logo.91f2753b1fabaab6.736571756f69615f6361706974616c5f6c6f676f2e676966.gif
   3. Request Method:
   GET
   4. Status Code:
   404 NOT FOUND
   


Is there any way to display blob image ?

-- 
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] Re: Displaying blob image on login page

2014-12-01 Thread Prasad Muley
I've tried both solutions and it's not working here

   1) decode is giving me following error.

 27.0.0.1.2014-12-02.13-01-39.af379677-6327-4f4c-bc93-5ed1e5e02ed8
   class 'binascii.Error' Incorrect padding

  2) Second option is not working.

I've printed image path but it didn't display on login page.

  img
src=data:image/gif;base64,/default/show_logo/company.logo.91f2753b1fabaab6.736571756f69615f6361706974616c5f6c6f676f2e676966.gif
/



On Tue, Dec 2, 2014 at 12:44 PM, Mandar Vaze mandarv...@gmail.com wrote:


 http://stackoverflow.com/questions/16279856/converting-blob-stored-on-a-database-to-an-image-on-an-html-website

 On Tuesday, December 2, 2014 12:09:25 PM UTC+5:30, Prasad Muley wrote:

 Hi All,

I need to display logo according to url in login page. I tried to
 display the logo but it always shows *404 not found* error on login page.

 My app settings are below:


 *models/db.py*


 db.define_table('company',
  Field('name', 'text', notnull=True),
  Field('abbrev', 'string', length=32),
  Field('logo', 'upload', uploadfield=True,
   requires=IS_IMAGE()),
  Field('timezone', 'string',
   requires=IS_IN_SET(all_timezones)),
  Field('url', 'string',
   requires=IS_URL()),
  format='%(name)s')


 *controllers/default.py*

 def user():
 
 exposes:
 http:///[app]/default/user/login
 http:///[app]/default/user/logout
 http:///[app]/default/user/register
 http:///[app]/default/user/profile
 http:///[app]/default/user/retrieve_password
 http:///[app]/default/user/change_password
 http:///[app]/default/user/manage_users (requires membership in
 use @auth.requires_login()
 @auth.requires_membership('group name')
 @auth.requires_permission('read','table name',record_id)
 to decorate functions that need access control
 
 #set some default name
 abbrev_name = 'ASDF'
 company_rec = db(db.company.url.contains(request.env.http_host)).
 select().first()
 if company_rec:
 abbrev = company_rec['abbrev']
 logo = IMG(_src = URL('default', 'show_logo',
 company_rec['logo']))
 session.company_timezone = company_rec['timezone']
 return dict(form=auth(), abbrev=abbrev, logo=logo)


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


 *views/default/user.html:*

 html
 head  /head
 body
div class=logo style=display: inline-block;
h2 {{=logo}} /h2
h2{{=abbrev}}/h2
/div

 !-- some code for login / log_out / change_password --
 /body
 /head


 It shows following error as:

1. Remote Address:
127.0.0.1:8000
2. Request URL:
https://127.0.0.1:8000/default/show_logo/investor.
logo.91f2753b1fabaab6.736571756f69615f6361706974616c
5f6c6f676f2e676966.gif

 https://127.0.0.1:8000/default/show_logo/investor.logo.91f2753b1fabaab6.736571756f69615f6361706974616c5f6c6f676f2e676966.gif
3. Request Method:
GET
4. Status Code:
404 NOT FOUND



 Is there any way to display blob image ?

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/FndDA_sXQto/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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] Re: Displaying blob image on login page

2014-12-01 Thread Prasad Muley
Thanks Massimo,

It works :)

On Tue, Dec 2, 2014 at 1:13 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Here:
 logo = IMG(_src = URL('default', 'show_logo', company_rec['logo']))
 should be

 logo = IMG(_src = URL('default', 'show_logo',
 args=company_rec['logo']))


 On Tuesday, 2 December 2014 00:39:25 UTC-6, Prasad Muley wrote:

 Hi All,

I need to display logo according to url in login page. I tried to
 display the logo but it always shows *404 not found* error on login page.

 My app settings are below:


 *models/db.py*


 db.define_table('company',
  Field('name', 'text', notnull=True),
  Field('abbrev', 'string', length=32),
  Field('logo', 'upload', uploadfield=True,
   requires=IS_IMAGE()),
  Field('timezone', 'string',
   requires=IS_IN_SET(all_timezones)),
  Field('url', 'string',
   requires=IS_URL()),
  format='%(name)s')


 *controllers/default.py*

 def user():
 
 exposes:
 http:///[app]/default/user/login
 http:///[app]/default/user/logout
 http:///[app]/default/user/register
 http:///[app]/default/user/profile
 http:///[app]/default/user/retrieve_password
 http:///[app]/default/user/change_password
 http:///[app]/default/user/manage_users (requires membership in
 use @auth.requires_login()
 @auth.requires_membership('group name')
 @auth.requires_permission('read','table name',record_id)
 to decorate functions that need access control
 
 #set some default name
 abbrev_name = 'ASDF'
 company_rec = db(db.company.url.contains(request.env.http_host)).
 select().first()
 if company_rec:
 abbrev = company_rec['abbrev']
 logo = IMG(_src = URL('default', 'show_logo',
 company_rec['logo']))
 session.company_timezone = company_rec['timezone']
 return dict(form=auth(), abbrev=abbrev, logo=logo)


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


 *views/default/user.html:*

 html
 head  /head
 body
div class=logo style=display: inline-block;
h2 {{=logo}} /h2
h2{{=abbrev}}/h2
/div

 !-- some code for login / log_out / change_password --
 /body
 /head


 It shows following error as:

1. Remote Address:
127.0.0.1:8000
2. Request URL:
https://127.0.0.1:8000/default/show_logo/investor.
logo.91f2753b1fabaab6.736571756f69615f6361706974616c
5f6c6f676f2e676966.gif

 https://127.0.0.1:8000/default/show_logo/investor.logo.91f2753b1fabaab6.736571756f69615f6361706974616c5f6c6f676f2e676966.gif
3. Request Method:
GET
4. Status Code:
404 NOT FOUND



 Is there any way to display blob image ?

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/FndDA_sXQto/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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] Query difference in SQLFORM.GRID

2014-11-19 Thread Prasad Muley
Hi All,
 
 I want to support multiple keywords search as well as web2py's 
built-in-search.

 I've written one module which will check if in_built_search is called 
or not.

* If in_built_search isn't called then search keywords in custom_module*

*def built_in_search(keywords):*
*This module will return True if opertor*
*   in built_in_search is used in keywords*
*search_operators = ['=', '!=', '', '', '=', '=',*
*'starts with', 'contains', 'in', 'not in']*
*return any(operator in keywords for operator in search_operators)*



 Code of SQLFORM.GRID in *controllers/default.py*


 keywords = request.vars.keywords

 if keywords and not built_in_search(keywords):

new_query, usr_company_exist = _custom_search_query(keywords, 
field_dicts)

   #field_dicts contains field_name and table attribute.



 grid = SQLFORM.grid(query, create=allow_create,
orderby=~db.table_name.created_on,
showbuttontext=False, csv=False, 
deletable=False,
maxtextlengths=textlengths, 
searchable=True)


Here  I am building query according to *request.vars.keywords*

I've written a custom module to search keywords on *selected attributes* as 
:
It also searches on reference key (company_name) 



*def _custom_search_query(keywords, field_dicts):*
*This module will build search each keyword in keywords*
*   in predefined table attributes*

*keys = keywords.strip()*
*user_company_exist = False*
*import time*
*start_time = time.time()*
*filters = []*
*print \n Keywords, keys*
*words = keys.split(' ')*

*for field_name, db_table_attr in field_dicts.iteritems():*

*#check for company name*
*if field_name == 'company_name':*
*company = db(db.company.name.contains(keys)).select().first()*
*if company is not None:*
*filters.append(db_table_attr == company.id)*
*continue*
*all_words_filter = []*

*for word in words:*
*all_words_filter.append(db_table_attr.contains(word))*
*filters.append(reduce(lambda a, b: (a  b), all_words_filter))*

*return reduce(lambda a, b: a | b, filters)*



If I tried to search '*XYZ'* (First_name_of_company) in search box, then *it 
gives me* *incorrect records.*
Actually It shows only 3 records.

*I've printed count of query in pdb.*


*(Pdb) db(query).count()139L*
*It is showing exact count as in database.*


If I tried to search '*XYZ Private' *(first and middle name of company) in 
search box, then *It gives me correct records.*

*I've also printed query count in pdb.(Pdb) db(query).count()139L*
It also shows exact count as in database.

Does any one know why is it giving different results?


-- 
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] Re: Query difference in SQLFORM.GRID

2014-11-19 Thread Prasad Muley
Hi Anthony,

 Sorry for pasting insufficient code.

Following is code from controllers/xyz.py

def built_in_search(keywords):
This module will return True if opertor
   in built_in_search is used in keywords
search_operators = ['=', '!=', '', '', '=', '=',
'starts with', 'contains', 'in', 'not in']
return any(operator in keywords for operator in search_operators)


def _custom_search_query(user_company_locs, keywords, field_dicts):
This module will build search each keyword in keywords
   in predefined table attributes
keys = keywords.strip()
user_company_exist = False
import time
start_time = time.time()
filters = []
print \n Keywords, keys
words = keys.split(' ')
for field_name, db_table_attr in field_dicts.iteritems():
#check for company name
if field_name == 'company_name':
company = db(db.company.name.contains(keys)).select().first()
if company is not None and company.id in user_company_locs:
filters.append(db_table_attr == company.id)
user_company_exist = True
continue
all_words_filter = []
for word in words:
all_words_filter.append(db_table_attr.contains(word))
filters.append(reduce(lambda a, b: (a  b), all_words_filter))
print Time required custom build query, time.time() - start_time
return reduce(lambda a, b: a | b, filters), user_company_exist


def controller_name():

  #following variable contains a list of all company ids
  user_company_locs = get_user_company_ids()

 query = (db.company.id.belongs(user_company_locs))

status_query = valid_status_query #can't disclose it.

#following dict it contains
# { id:db.company.id,
# name: db.company.name }

field_dicts = { 'valid_table_attr_name' : valid_table_attr,
.
.
   }

   keywords = request.vars.keywords

   if keywords and not built_in_search(keywords):
new_query, usr_company_exist = _custom_search_query(
user_company_locs, keywords, field_dicts)

#entered company_name exist in user_company_locs list then
#display only single record only single.
if usr_company_exist:
query  = new_query  status_query
else:
query = status_query  new_query


 grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.valid_table_name.created_on,
 showbuttontext=False, csv=False, deletable=False,
 maxtextlengths=textlengths, searchable=True)



I've printed query object in pdb.

IF I search XYZ keyword then it shows correct count in pdb -
db(query).count()

*But grid shows only 3 records*

IF I search XYZ Private or XYZ P or any valid word after XYZ
*then it also shows correct count in pdb as well as on grid*.

Why is grid showing different records (count)?
It is showing same record (count) on DAL or PDB.


On Wed, Nov 19, 2014 at 7:47 PM, Anthony abasta...@gmail.com wrote:

 Is this the exact code? I notice that the output of the call to
 _custom_search_query gets assigned to the tuple (new_query,
 user_company_exist), but (a) that function does not return a tuple, and (b)
 you don't use new_query when calling the grid.

 Anthony


 On Wednesday, November 19, 2014 6:16:19 AM UTC-5, Prasad Muley wrote:

 Hi All,

  I want to support multiple keywords search as well as web2py's
 built-in-search.

  I've written one module which will check if in_built_search is
 called or not.

 * If in_built_search isn't called then search keywords in
 custom_module*

 *def built_in_search(keywords):*
 *This module will return True if opertor*
 *   in built_in_search is used in keywords*
 *search_operators = ['=', '!=', '', '', '=', '=',*
 *'starts with', 'contains', 'in', 'not in']*
 *return any(operator in keywords for operator in search_operators)*



  Code of SQLFORM.GRID in *controllers/default.py*


  keywords = request.vars.keywords

  if keywords and not built_in_search(keywords):

 new_query, usr_company_exist = _custom_search_query(keywords,
 field_dicts)

#field_dicts contains field_name and table attribute.



  grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.table_name.created_on,
 showbuttontext=False, csv=False,
 deletable=False,
 maxtextlengths=textlengths,
 searchable=True)


 Here  I am building query according to *request.vars.keywords*

 I've written a custom module to search keywords on *selected attributes*
 as :
 It also searches on reference key (company_name)



 *def _custom_search_query(keywords, field_dicts):*
 *This module will build search each keyword in keywords*
 *   in predefined table

Re: [web2py] SQLFORM.grid custom search where is the error?

2014-11-18 Thread Prasad Muley

This problem still exist in web2py 2.9.6.

I've tried to use custom grid search But It is showing me invalid query 
near grid.


On Thursday, February 21, 2013 10:09:33 PM UTC+5:30, Mandar Vaze wrote:

 I'm using Version 2.3.2 (2012-12-17 15:03:30) stable and the problem 
 still persists. i.e. I'm still getting Invalid Query error.

 I'm using Alex's workaround which seems to be working. Thanks Alex.

 -Mandar

 On Friday, September 28, 2012 6:07:13 PM UTC+5:30, Massimo Di Pierro wrote:

 Clearly something is wrong I will try this today. Before I do, could you 
 check the latest trunk?

 On Friday, 28 September 2012 04:36:26 UTC-5, alex wrote:

 Thank you Johann, of course I did already,

 The query itself gets translated correctly. 
 I think that something very subtle is happening when I pass 
 search_widget=search_form, and I cannot catch it

 I uploaded here 
 https://www.dropbox.com/s/d5t13fejdqlr7r4/web2py.app.test.w2p the 
 packed version maybe it is easier to understand what happens.
 Thank you anyway.
 Alex


 On Friday, September 28, 2012 3:45:25 PM UTC+9, Johann Spies wrote:

 On 28 September 2012 07:15, alex a22...@gmail.com wrote:


 What am I doing wrong?


 A good way to learn this query syntax is to build the query from the 
 dropdownbox which you get when you click in the search box.   

 Regards
 Johann

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63: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] Re: SAML2 Service Provider app in web2py?

2014-10-27 Thread Prasad Muley
Hi Massimo,

   In which provider log should I look into? (service provider [web2py
app] or idp provider [okta / onelogin]).
Could you share your web2py app's (service provider) setting and idp
provider settings?.
   I've followed same instructions but getting that error.


On Sat, Oct 25, 2014 at 9:01 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I do not know what to say. It works with the provide I was using. Look
 into the provider log. perhaps there is an error message there.


 On Friday, 24 October 2014 19:30:24 UTC-5, Prasad Muley wrote:

 Yes. I've printed it. It shows empty dict
 On Oct 23, 2014 7:33 PM, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:

 Yes it works for me. Can you help debug? Can you print d['response'] and
 try figure out where the response attributes are?

 On Friday, 17 October 2014 00:42:29 UTC-5, Prasad Muley wrote:

 Hi Wel,
Did you test SAML2 app? there is an experimental saml2 app in
 web2py_2.9.6

I need to use saml2(web2py app) as service provider with onelogin
 (which is idp)

 I am getting an error (Screen shot is attached PFA).


 here is my config settings
 1) *private/sp_conf.py*

 # Make sure the same port number appear in service_conf.py
 BASE = http://localhost:8000;
 APPNAME = saml2
 PATH = /home/prasad/Prasad/web2py_2.9.6_beta/applications/saml2/pr
 ivate/
 CONFIG = {
 entityid: %s/saml2/static/sp.xml % BASE,
 'entity_category': [COC],
 accepted_time_diff: 5, # very important
 description: Example SP,
 service: {
 sp: {
 endpoints: {
 assertion_consumer_service: [
 (%s/%s/default/user/login % (BASE, APPNAME),
 BINDING_HTTP_REDIRECT),
 ],
 }
 },
 },
 key_file: %s/pki/mykey.pem % PATH,
 cert_file: %s/pki/mycert.pem % PATH,
 xmlsec_binary: xmlsec_path,
 metadata: {local: [PATH+idp.xml]},
 name_form: NAME_FORMAT_URI,
 }

 Here I've copied *assertion_consumer_service url *(
 http://localhost:8000/saml2/default/login ) in onelogin's app's SAML
 consumer url

 2) I've downloaded a meta data file from onelogin app.
   copy  it to

 *saml/private/*3) Created a *static/sp.xml file *as
 make_metadata.py sp_conf  ../static/sp.xml

 4) Ran web2py server

 * (python webpy.py)*5) Selected SAML2 app through administrator
 interface,

 6) Clicked on login tab and
It is redirecting to onelogin app's login window.

 7) Entered username and password in onelogin app
 It it redirecting me to http://localhost:8000/saml2/default/login
 (which is a assertion consumer url)

 and I am getting an internal error .

 type 'exceptions.AttributeError' 'dict' object has no attribute
 'assertion'
 Let me know If there are wrong settings in my app.

 Could you share your app settings (including web2py app and idp
 settings)


 On Thursday, August 21, 2014 7:35:29 PM UTC+5:30, Wei Wang wrote:

 I have the need to use a SAML2 identity provider (specifically, a
 NetIQ product) for authentication and authorization in some web2py apps.

 I searched in this group, also googled web2py and SAML, but did not
 find anything that seems readily available.

 My thoughts on building a Service Provider (in SAML2 terminology)
 app in web2py alongside other apps:

- The SAML2 service provider would be /saml2sp:
   - The saml2sp app communicates to the SAML2 Id provider for
   authentication and authorization;
   - A web2py app is configured to use cas_auth, with
localhost/saml2sp as the CAS server base URL;

 Does something like this exist? Does that sound reasonable?

 Thanks for any pointers, comments, thoughts.

 Wei

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit https://groups.google.com/d/
 topic/web2py/zn1OvErE6Wc/unsubscribe.
 To unsubscribe from this group and all its topics, 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/zn1OvErE6Wc/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses

Re: [web2py] Re: SAML2 Service Provider app in web2py?

2014-10-24 Thread Prasad Muley
Yes. I've printed it. It shows empty dict
On Oct 23, 2014 7:33 PM, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

 Yes it works for me. Can you help debug? Can you print d['response'] and
 try figure out where the response attributes are?

 On Friday, 17 October 2014 00:42:29 UTC-5, Prasad Muley wrote:

 Hi Wel,
Did you test SAML2 app? there is an experimental saml2 app in
 web2py_2.9.6

I need to use saml2(web2py app) as service provider with onelogin
 (which is idp)

 I am getting an error (Screen shot is attached PFA).


 here is my config settings
 1) *private/sp_conf.py*

 # Make sure the same port number appear in service_conf.py
 BASE = http://localhost:8000;
 APPNAME = saml2
 PATH = /home/prasad/Prasad/web2py_2.9.6_beta/applications/saml2/
 private/
 CONFIG = {
 entityid: %s/saml2/static/sp.xml % BASE,
 'entity_category': [COC],
 accepted_time_diff: 5, # very important
 description: Example SP,
 service: {
 sp: {
 endpoints: {
 assertion_consumer_service: [
 (%s/%s/default/user/login % (BASE, APPNAME),
 BINDING_HTTP_REDIRECT),
 ],
 }
 },
 },
 key_file: %s/pki/mykey.pem % PATH,
 cert_file: %s/pki/mycert.pem % PATH,
 xmlsec_binary: xmlsec_path,
 metadata: {local: [PATH+idp.xml]},
 name_form: NAME_FORMAT_URI,
 }

 Here I've copied *assertion_consumer_service url *(
 http://localhost:8000/saml2/default/login ) in onelogin's app's SAML
 consumer url

 2) I've downloaded a meta data file from onelogin app.
   copy  it to

 *saml/private/*3) Created a *static/sp.xml file *as
 make_metadata.py sp_conf  ../static/sp.xml

 4) Ran web2py server

 * (python webpy.py)*5) Selected SAML2 app through administrator
 interface,

 6) Clicked on login tab and
It is redirecting to onelogin app's login window.

 7) Entered username and password in onelogin app
 It it redirecting me to http://localhost:8000/saml2/default/login (which
 is a assertion consumer url)

 and I am getting an internal error .

 type 'exceptions.AttributeError' 'dict' object has no attribute
 'assertion'
 Let me know If there are wrong settings in my app.

 Could you share your app settings (including web2py app and idp settings)


 On Thursday, August 21, 2014 7:35:29 PM UTC+5:30, Wei Wang wrote:

 I have the need to use a SAML2 identity provider (specifically, a NetIQ
 product) for authentication and authorization in some web2py apps.

 I searched in this group, also googled web2py and SAML, but did not
 find anything that seems readily available.

 My thoughts on building a Service Provider (in SAML2 terminology) app
 in web2py alongside other apps:

- The SAML2 service provider would be /saml2sp:
   - The saml2sp app communicates to the SAML2 Id provider for
   authentication and authorization;
   - A web2py app is configured to use cas_auth, with
localhost/saml2sp as the CAS server base URL;

 Does something like this exist? Does that sound reasonable?

 Thanks for any pointers, comments, thoughts.

 Wei

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/zn1OvErE6Wc/unsubscribe.
 To unsubscribe from this group and all its topics, 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: SAML2 Service Provider app in web2py?

2014-10-20 Thread Prasad Muley
Hi Massimo,
   Could you reply on my query?


On Friday, August 22, 2014 7:26:31 AM UTC+5:30, Massimo Di Pierro wrote:

 Incidentally, I just committed an experimental SAML2 login method for 
 Web2py. Please contact me privately and perhaps you can help me test it.

 Massimo

 On Thursday, 21 August 2014 09:05:29 UTC-5, Wei Wang wrote:

 I have the need to use a SAML2 identity provider (specifically, a NetIQ 
 product) for authentication and authorization in some web2py apps.

 I searched in this group, also googled web2py and SAML, but did not 
 find anything that seems readily available.

 My thoughts on building a Service Provider (in SAML2 terminology) app 
 in web2py alongside other apps:

- The SAML2 service provider would be /saml2sp:
   - The saml2sp app communicates to the SAML2 Id provider for 
   authentication and authorization;
   - A web2py app is configured to use cas_auth, with 
localhost/saml2sp as the CAS server base URL;

 Does something like this exist? Does that sound reasonable?

 Thanks for any pointers, comments, thoughts.

 Wei



-- 
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] error in sample saml app in web2py.2.9.6

2014-10-16 Thread Prasad Muley
Hi All,
  I am getting an error when I try to login in sample *saml2 app* ( 
http://127.0.0.1:8000/saml2/default/user/login?_next=/saml2/default/index)
type 'exceptions.IOError' [Errno 2] No such file or directory: 
u'pki/mycert.pem'

Did anybody use sample saml2?


-- 
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] error in sample saml app in web2py.2.9.6

2014-10-16 Thread Prasad Muley
I've solved this error.
I've made change in private/sp_conf.py

changed CONFIG settings as


- key_file: pki/mykey.pem,
- cert_file: pki/mycert.pem% PATH,

+ key_file: %s/pki/mykey.pem % PATH,
+ cert_file: %s/pki/mycert.pem% PATH,

It successfully check whether I am login in idp or not (in my case onelogin
is idp)
If I am not login then it'll open idp login page and redirect to
*http://127.0.0.1:8000/saml2/default/user/index
http://127.0.0.1:8000/saml2/default/user/index *page.


On Thu, Oct 16, 2014 at 12:49 PM, Prasad Muley pmmu...@gmail.com wrote:

 Hi All,
   I am getting an error when I try to login in sample *saml2 app* (
 http://127.0.0.1:8000/saml2/default/user/login?_next=/saml2/default/index)
 type 'exceptions.IOError' [Errno 2] No such file or directory:
 u'pki/mycert.pem'

 Did anybody use sample saml2?


  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/FbS7j7dsNqo/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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: web2py 2.9.6 is out!

2014-10-16 Thread Prasad Muley
Hi Massimo,
   I have had followed your instructions and got following error.
type 'exceptions.IOError' [Errno 2] No such file or directory: 
u'pki/mycert.pem'

I think, there is a wrong path assigned in 
*applications/saml2/private/sp_config.py* for these keys
I've resolved this error by changing two lines in CONFIG setting as below

- key_file: pki/mykey.pem,
- cert_file: pki/mycert.pem% PATH,

+ key_file: %s/pki/mykey.pem % PATH,
+ cert_file: %s/pki/mycert.pem% PATH,

I hope you'll update it in this pdf file.

On Saturday, September 13, 2014 8:36:54 AM UTC+5:30, Massimo Di Pierro 
wrote:

 Not published yet:

 https://dl.dropboxusercontent.com/u/18065445/Tmp/saml2.pdf

 On Thursday, 11 September 2014 10:50:29 UTC-5, Copper Lark wrote:

 support for SAML2 (with pysaml2)


 in docs not found ( 



-- 
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: SAML2 Service Provider app in web2py?

2014-10-16 Thread Prasad Muley
Hi Wel,
   Did you test SAML2 app? there is an experimental saml2 app in 
web2py_2.9.6
 
   I need to use saml2(web2py app) as service provider with onelogin (which 
is idp) 

I am getting an error (Screen shot is attached PFA).


here is my config settings
1) *private/sp_conf.py*

# Make sure the same port number appear in service_conf.py
BASE = http://localhost:8000;
APPNAME = saml2
PATH = /home/prasad/Prasad/web2py_2.9.6_beta/applications/saml2/private/
CONFIG = {
entityid: %s/saml2/static/sp.xml % BASE,
'entity_category': [COC],
accepted_time_diff: 5, # very important
description: Example SP,
service: {
sp: {
endpoints: {
assertion_consumer_service: [
(%s/%s/default/user/login % (BASE, APPNAME), 
BINDING_HTTP_REDIRECT),
],
}
},
},
key_file: %s/pki/mykey.pem % PATH,
cert_file: %s/pki/mycert.pem % PATH,
xmlsec_binary: xmlsec_path,
metadata: {local: [PATH+idp.xml]},
name_form: NAME_FORMAT_URI,
}
 
Here I've copied *assertion_consumer_service url 
*(http://localhost:8000/saml2/default/login 
) in onelogin's app's SAML consumer url

2) I've downloaded a meta data file from onelogin app.
  copy  it to 

*saml/private/*3) Created a *static/sp.xml file *as 
make_metadata.py sp_conf  ../static/sp.xml

4) Ran web2py server

* (python webpy.py)*5) Selected SAML2 app through administrator interface,

6) Clicked on login tab and
   It is redirecting to onelogin app's login window.

7) Entered username and password in onelogin app
It it redirecting me to http://localhost:8000/saml2/default/login (which is 
a assertion consumer url)

and I am getting an internal error .

type 'exceptions.AttributeError' 'dict' object has no attribute 
'assertion'
Let me know If there are wrong settings in my app.

Could you share your app settings (including web2py app and idp settings)


On Thursday, August 21, 2014 7:35:29 PM UTC+5:30, Wei Wang wrote:

 I have the need to use a SAML2 identity provider (specifically, a NetIQ 
 product) for authentication and authorization in some web2py apps.

 I searched in this group, also googled web2py and SAML, but did not find 
 anything that seems readily available.

 My thoughts on building a Service Provider (in SAML2 terminology) app in 
 web2py alongside other apps:

- The SAML2 service provider would be /saml2sp:
   - The saml2sp app communicates to the SAML2 Id provider for 
   authentication and authorization;
   - A web2py app is configured to use cas_auth, with 
localhost/saml2sp as the CAS server base URL;

 Does something like this exist? Does that sound reasonable?

 Thanks for any pointers, comments, thoughts.

 Wei


-- 
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] pysaml for web2py2.9.5

2014-10-14 Thread Prasad Muley
Hi All,
  I need to implement SSO using pysaml2 for a product. We've Okta as 
Identity provider.
Our product uses *web2py 2.9.5 _ stable* version. 
web2py_change_log http://www.web2py.com/init/default/changelog says that 
*web2py 
2.9.6-2.6.10* supports pysaml2. 
Should I upgrade my web2py version?
Where can I get web2py pysaml2 documentation?

-- 
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] Re: pysaml for web2py2.9.5

2014-10-14 Thread Prasad Muley
Thanks for Mandar.

On Tue, Oct 14, 2014 at 10:59 PM, Mandar Vaze mandarv...@gmail.com wrote:


 https://dl.dropboxusercontent.com/u/18065445/Tmp/saml2.pdf - Link found
 here :
 https://groups.google.com/forum/#!searchin/web2py/SAML2/web2py/8DgzUksCmSo/f-jlU5wV20UJ


 On Tuesday, October 14, 2014 10:33:03 PM UTC+5:30, Mandar Vaze wrote:

 Does this help ?
 https://github.com/web2py/web2py/blob/447493c754da06b9e455643f6ce2d1
 80add60391/gluon/contrib/login_methods/saml2_auth.py

 On Tuesday, October 14, 2014 12:53:43 PM UTC+5:30, Prasad Muley wrote:

 Hi All,
   I need to implement SSO using pysaml2 for a product. We've Okta as
 Identity provider.
 Our product uses *web2py 2.9.5 _ stable* version.
 web2py_change_log http://www.web2py.com/init/default/changelog says
 that *web2py 2.9.6-2.6.10* supports pysaml2.
 Should I upgrade my web2py version?
 Where can I get web2py pysaml2 documentation?

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/Y7-fq3K4BxQ/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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] Re: Scheduler error

2014-08-28 Thread Prasad Muley
Hi Niphlod,
  I need to get current task's id. I saw your sample scheduler example
on niphlod_w2p_scheduler_tests
https://github.com/niphlod/w2p_scheduler_tests/blob/master/models/scheduler.py
I did it in same way but got error.



*#models/scheduler.py*
def send_mail(to, subject, message, cc=None, bcc=None,
  attachments=None):

This module is called by scheduler.
mail is queued by scheduler.

if cc is None:
cc = []
if bcc is None:
bcc = []
if attachments is None:
attachments = []
#sending mail
print W2P_TASK
result= mail.send(to=to, cc=cc, bcc=bcc,
  subject=subject, message=message,
  attachments=attachments)

#if not result:
#   print FAILED: Task [%d] % W2P_TASK.id
### update tasks' status


from gluon.scheduler import Scheduler
mail_scheduler = Scheduler(db, migrate=False)


I got following error

DEBUG:web2py.scheduler:new task report: FAILED
DEBUG:web2py.scheduler:   traceback: Traceback (most recent call last):
  File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 229, in
executor
result = dumps(_function(*args, **vars))
  File applications/lcm/models/scheduler.py, line 16, in send_mail
print W2P_TASK
NameError: global name 'W2P_TASK' is not defined



if mail.send() fails due to some issue [for eg wrong password, port etc]
Still web2py scheduler mark current task as COMPLETED.

That's why I want to check mail.send's result.
If result is False then I've to update current task's status as Failed.
How do I get id of current task?

Thanks in advance.


On Tue, Aug 26, 2014 at 3:46 PM, Niphlod niph...@gmail.com wrote:

 I'd strongly advise you to read the section on the book about migrations
 and fixing broke migrations.
 If you're starting now with the scheduler, please do the following:
 - delete all databases/*_scheduler_*.table files
 - delete scheduler_worker, scheduler_tasks, scheduler_run table from your
 backend MANUALLY
 - use Scheduler(db, , migrate=True)
 - open appadmin
 - reset Scheduler(db, , migrate=False)


 On Tuesday, August 26, 2014 11:18:25 AM UTC+2, Prasad Muley wrote:

 Hi,
I tried to access db.scheduler_run table but it is giving me following
 error in web2py shell and app admin UI.

 *OperationalError: (1054, Unknown column 'scheduler_run.scheduler_task'
 in 'field list')*


 On Tue, Aug 26, 2014 at 1:04 PM, Niphlod nip...@gmail.com wrote:

 there's yet a scheduler_task table in the database. Fix migrations in
 the usual way, or set Scheduler(db,,migrate=False) to avoid the
 error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12:07:02]
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.3.2 (2012-12-17 15:03:30) stable
 Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
 MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
 MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
 starting single-scheduler for send_mail_app...
 Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line 212,
 in restricted
 exec ccode in environment
   File applications/send_mail_app/models/scheduler.py, line 2, in
 module
 mail_scheduler = Scheduler(db)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 449,
 in __init__
 self.define_tables(db, migrate=migrate)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 501,
 in define_tables
 migrate=migrate, format='%(task_name)s')
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7186, in
 define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7222, in
 lazy_define_table
 polymodel=polymodel)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 935, in
 create_table
 self.create_sequence_and_triggers(query,table)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1694, in
 create_sequence_and_triggers
 self.execute(query)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1709, in
 execute
 return self.log_execute(*a, **b)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1703, in
 log_execute
 ret = self.cursor.execute(*a, **b)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py,
 line 201, in execute
 self.errorhandler(self, exc, value)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py,
 line 36, in defaulterrorhandler
 raise errorclass, errorvalue
 OperationalError: (1050, Table 'scheduler_task' already exists)

 I've followed following instructions.

 *1) Created a file models/scheduler.py*

 #code from scheduler.py file
 from gluon.scheduler import Scheduler

Re: [web2py] Re: Scheduler error

2014-08-28 Thread Prasad Muley
Okay.
I am using 2.3 . I can't upgrade it because Company decided to use 2.3
only.
Is there anyway to access current task id in 2.3?



On Thu, Aug 28, 2014 at 1:47 PM, Niphlod niph...@gmail.com wrote:

 what version are you using ?! W2P_TASK is available from 2.4.1.


 On Thursday, August 28, 2014 9:30:28 AM UTC+2, Prasad Muley wrote:

 Hi Niphlod,
   I need to get current task's id. I saw your sample scheduler
 example on niphlod_w2p_scheduler_tests
 https://github.com/niphlod/w2p_scheduler_tests/blob/master/models/scheduler.py
 I did it in same way but got error.



 *#models/scheduler.py*
 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 mail is queued by scheduler.
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 print W2P_TASK
 result= mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 #if not result:
 #   print FAILED: Task [%d] % W2P_TASK.id
 ### update tasks' status


 from gluon.scheduler import Scheduler
 mail_scheduler = Scheduler(db, migrate=False)


 I got following error

 DEBUG:web2py.scheduler:new task report: FAILED
 DEBUG:web2py.scheduler:   traceback: Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 229, in
 executor
 result = dumps(_function(*args, **vars))
   File applications/lcm/models/scheduler.py, line 16, in send_mail
 print W2P_TASK
 NameError: global name 'W2P_TASK' is not defined



 if mail.send() fails due to some issue [for eg wrong password, port etc]
 Still web2py scheduler mark current task as COMPLETED.

 That's why I want to check mail.send's result.
 If result is False then I've to update current task's status as Failed.
 How do I get id of current task?

 Thanks in advance.


 On Tue, Aug 26, 2014 at 3:46 PM, Niphlod nip...@gmail.com wrote:

 I'd strongly advise you to read the section on the book about migrations
 and fixing broke migrations.
 If you're starting now with the scheduler, please do the following:
 - delete all databases/*_scheduler_*.table files
 - delete scheduler_worker, scheduler_tasks, scheduler_run table from
 your backend MANUALLY
 - use Scheduler(db, , migrate=True)
 - open appadmin
 - reset Scheduler(db, , migrate=False)


 On Tuesday, August 26, 2014 11:18:25 AM UTC+2, Prasad Muley wrote:

 Hi,
I tried to access db.scheduler_run table but it is giving me
 following error in web2py shell and app admin UI.

 *OperationalError: (1054, Unknown column
 'scheduler_run.scheduler_task' in 'field list')*


 On Tue, Aug 26, 2014 at 1:04 PM, Niphlod nip...@gmail.com wrote:

  there's yet a scheduler_task table in the database. Fix migrations
 in the usual way, or set Scheduler(db,,migrate=False) to avoid
 the error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail
 sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12:07:02]
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.3.2 (2012-12-17 15:03:30) stable
 Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
 MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
 MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
 starting single-scheduler for send_mail_app...
 Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line
 212, in restricted
 exec ccode in environment
   File applications/send_mail_app/models/scheduler.py, line 2, in
 module
 mail_scheduler = Scheduler(db)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 449,
 in __init__
 self.define_tables(db, migrate=migrate)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 501,
 in define_tables
 migrate=migrate, format='%(task_name)s')
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7186, in
 define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7222, in
 lazy_define_table
 polymodel=polymodel)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 935, in
 create_table
 self.create_sequence_and_triggers(query,table)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1694, in
 create_sequence_and_triggers
 self.execute(query)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1709, in
 execute
 return self.log_execute(*a, **b)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1703, in
 log_execute
 ret = self.cursor.execute(*a, **b)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py,
 line 201, in execute

Re: [web2py] Re: Scheduler error

2014-08-28 Thread Prasad Muley
NP. I got another way to catch failed mail/task.



*#models/scheduler.py*
def send_mail(to, subject, message, cc=None, bcc=None,
  attachments=None):

This module is called by scheduler.
mail is queued by scheduler.

if cc is None:
cc = []
if bcc is None:
bcc = []
if attachments is None:
attachments = []
#sending mail
print W2P_TASK
result= mail.send(to=to, cc=cc, bcc=bcc,
  subject=subject, message=message,
  attachments=attachments)

if not result:
raise Exception(Mail sent failed)


This is working for me. It will change current task status to FAILED.
I can easily find which mails sent failed due to mail.send errors



On Thu, Aug 28, 2014 at 3:52 PM, Niphlod niph...@gmail.com wrote:

 no.


 On Thursday, August 28, 2014 10:26:42 AM UTC+2, Prasad Muley wrote:

 Okay.
 I am using 2.3 . I can't upgrade it because Company decided to use 2.3
 only.
 Is there anyway to access current task id in 2.3?



 On Thu, Aug 28, 2014 at 1:47 PM, Niphlod nip...@gmail.com wrote:

 what version are you using ?! W2P_TASK is available from 2.4.1.


 On Thursday, August 28, 2014 9:30:28 AM UTC+2, Prasad Muley wrote:

 Hi Niphlod,
   I need to get current task's id. I saw your sample scheduler
 example on niphlod_w2p_scheduler_tests
 https://github.com/niphlod/w2p_scheduler_tests/blob/master/models/scheduler.py
 I did it in same way but got error.



 *#models/scheduler.py*
 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 mail is queued by scheduler.
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 print W2P_TASK
 result= mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 #if not result:
 #   print FAILED: Task [%d] % W2P_TASK.id
 ### update tasks' status


 from gluon.scheduler import Scheduler
 mail_scheduler = Scheduler(db, migrate=False)


 I got following error

 DEBUG:web2py.scheduler:new task report: FAILED
 DEBUG:web2py.scheduler:   traceback: Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 229,
 in executor
 result = dumps(_function(*args, **vars))
   File applications/lcm/models/scheduler.py, line 16, in send_mail
 print W2P_TASK
 NameError: global name 'W2P_TASK' is not defined



 if mail.send() fails due to some issue [for eg wrong password, port
 etc]
 Still web2py scheduler mark current task as COMPLETED.

 That's why I want to check mail.send's result.
 If result is False then I've to update current task's status as Failed.
 How do I get id of current task?

 Thanks in advance.


 On Tue, Aug 26, 2014 at 3:46 PM, Niphlod nip...@gmail.com wrote:

 I'd strongly advise you to read the section on the book about
 migrations and fixing broke migrations.
 If you're starting now with the scheduler, please do the following:
 - delete all databases/*_scheduler_*.table files
 - delete scheduler_worker, scheduler_tasks, scheduler_run table from
 your backend MANUALLY
 - use Scheduler(db, , migrate=True)
 - open appadmin
 - reset Scheduler(db, , migrate=False)


 On Tuesday, August 26, 2014 11:18:25 AM UTC+2, Prasad Muley wrote:

 Hi,
I tried to access db.scheduler_run table but it is giving me
 following error in web2py shell and app admin UI.

 *OperationalError: (1054, Unknown column
 'scheduler_run.scheduler_task' in 'field list')*


 On Tue, Aug 26, 2014 at 1:04 PM, Niphlod nip...@gmail.com wrote:

  there's yet a scheduler_task table in the database. Fix migrations
 in the usual way, or set Scheduler(db,,migrate=False) to avoid
 the error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail
 sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12:07:02]
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.3.2 (2012-12-17 15:03:30) stable
 Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
 MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), 
 PostgreSQL(pg8000),
 MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
 starting single-scheduler for send_mail_app...
 Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line
 212, in restricted
 exec ccode in environment
   File applications/send_mail_app/models/scheduler.py, line 2,
 in module
 mail_scheduler = Scheduler(db)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line
 449, in __init__
 self.define_tables(db, migrate=migrate)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line
 501

Re: [web2py] Re: Scheduler error

2014-08-28 Thread Prasad Muley
Pardon me earlier messaeg.
I copied wrong code.



*#models/scheduler.py*
def send_mail(to, subject, message, cc=None, bcc=None,
  attachments=None):

This module is called by scheduler.
mail is queued by scheduler.

if cc is None:
cc = []
if bcc is None:
bcc = []
if attachments is None:
attachments = []
#sending mail
result= mail.send(to=to, cc=cc, bcc=bcc,
  subject=subject, message=message,
  attachments=attachments)

if not result:
raise Exception(Mail sent failed)

This is working for me. It will change current task status to FAILED.
I can easily find which mails sent failed due to mail.send errors


On Thu, Aug 28, 2014 at 4:03 PM, Prasad Muley pmmu...@gmail.com wrote:

 NP. I got another way to catch failed mail/task.




 *#models/scheduler.py*
 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 mail is queued by scheduler.
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 print W2P_TASK
 result= mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 if not result:
 raise Exception(Mail sent failed)


 This is working for me. It will change current task status to FAILED.
 I can easily find which mails sent failed due to mail.send errors



 On Thu, Aug 28, 2014 at 3:52 PM, Niphlod niph...@gmail.com wrote:

 no.


 On Thursday, August 28, 2014 10:26:42 AM UTC+2, Prasad Muley wrote:

 Okay.
 I am using 2.3 . I can't upgrade it because Company decided to use 2.3
 only.
 Is there anyway to access current task id in 2.3?



 On Thu, Aug 28, 2014 at 1:47 PM, Niphlod nip...@gmail.com wrote:

 what version are you using ?! W2P_TASK is available from 2.4.1.


 On Thursday, August 28, 2014 9:30:28 AM UTC+2, Prasad Muley wrote:

 Hi Niphlod,
   I need to get current task's id. I saw your sample scheduler
 example on niphlod_w2p_scheduler_tests
 https://github.com/niphlod/w2p_scheduler_tests/blob/master/models/scheduler.py
 I did it in same way but got error.



 *#models/scheduler.py*
 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 mail is queued by scheduler.
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 print W2P_TASK
 result= mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 #if not result:
 #   print FAILED: Task [%d] % W2P_TASK.id
 ### update tasks' status


 from gluon.scheduler import Scheduler
 mail_scheduler = Scheduler(db, migrate=False)


 I got following error

 DEBUG:web2py.scheduler:new task report: FAILED
 DEBUG:web2py.scheduler:   traceback: Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 229,
 in executor
 result = dumps(_function(*args, **vars))
   File applications/lcm/models/scheduler.py, line 16, in send_mail
 print W2P_TASK
 NameError: global name 'W2P_TASK' is not defined



 if mail.send() fails due to some issue [for eg wrong password, port
 etc]
 Still web2py scheduler mark current task as COMPLETED.

 That's why I want to check mail.send's result.
 If result is False then I've to update current task's status as Failed.
 How do I get id of current task?

 Thanks in advance.


 On Tue, Aug 26, 2014 at 3:46 PM, Niphlod nip...@gmail.com wrote:

 I'd strongly advise you to read the section on the book about
 migrations and fixing broke migrations.
 If you're starting now with the scheduler, please do the following:
 - delete all databases/*_scheduler_*.table files
 - delete scheduler_worker, scheduler_tasks, scheduler_run table from
 your backend MANUALLY
 - use Scheduler(db, , migrate=True)
 - open appadmin
 - reset Scheduler(db, , migrate=False)


 On Tuesday, August 26, 2014 11:18:25 AM UTC+2, Prasad Muley wrote:

 Hi,
I tried to access db.scheduler_run table but it is giving me
 following error in web2py shell and app admin UI.

 *OperationalError: (1054, Unknown column
 'scheduler_run.scheduler_task' in 'field list')*


 On Tue, Aug 26, 2014 at 1:04 PM, Niphlod nip...@gmail.com wrote:

  there's yet a scheduler_task table in the database. Fix
 migrations in the usual way, or set Scheduler(db,,migrate=False)
 to avoid the error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail
 sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12

[web2py] Scheduler error

2014-08-26 Thread Prasad Muley
Hi,
 I've web2py 2.3 version. I tried to use scheduler for mail sending.
I got this error while creating a worker for scheduler

$ python web2py.py -K send_mail_app 

 
[12:07:02]
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.3.2 (2012-12-17 15:03:30) stable
Database drivers available: SQLite(sqlite2), SQLite(sqlite3), 
MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000), 
MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
starting single-scheduler for send_mail_app...
Traceback (most recent call last):
  File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line 212, in 
restricted
exec ccode in environment
  File applications/send_mail_app/models/scheduler.py, line 2, in module
mail_scheduler = Scheduler(db)
  File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 449, in 
__init__
self.define_tables(db, migrate=migrate)
  File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 501, in 
define_tables
migrate=migrate, format='%(task_name)s')
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7186, in 
define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7222, in 
lazy_define_table
polymodel=polymodel)
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 935, in 
create_table
self.create_sequence_and_triggers(query,table)
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1694, in 
create_sequence_and_triggers
self.execute(query)
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1709, in execute
return self.log_execute(*a, **b)
  File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1703, in 
log_execute
ret = self.cursor.execute(*a, **b)
  File /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py, line 
201, in execute
self.errorhandler(self, exc, value)
  File /usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py, 
line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1050, Table 'scheduler_task' already exists)

I've followed following instructions.

*1) Created a file models/scheduler.py*

#code from scheduler.py file
from gluon.scheduler import Scheduler
mail_scheduler = Scheduler(db)


def send_mail(to, subject, message, cc=None, bcc=None,
  attachments=None):

This module is called by scheduler.
You can check scheduler_task table and scheduler.task_status table

if cc is None:
cc = []
if bcc is None:
bcc = []
if attachments is None:
attachments = []
#sending mail
mail.send(to=to, cc=cc, bcc=bcc,
  subject=subject, message=message,
  attachments=attachments)

*2) Called send_mail module in an external script.*
(scripts/send_mails.py)

#extra code here
task = mail_scheduler.queue_task('send_mail',
 pvars={'to': email,
'subject': subject,
'message': html_email},
 
start_time=datetime.datetime.now())
print task


*3) Created a worker and got above error*


Am I missing some steps?

-- 
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] Re: Scheduler error

2014-08-26 Thread Prasad Muley
Thanks.
It works.


On Tue, Aug 26, 2014 at 1:04 PM, Niphlod niph...@gmail.com wrote:

 there's yet a scheduler_task table in the database. Fix migrations in the
 usual way, or set Scheduler(db,,migrate=False) to avoid the error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12:07:02]
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.3.2 (2012-12-17 15:03:30) stable
 Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
 MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
 MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
 starting single-scheduler for send_mail_app...
 Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line 212, in
 restricted
 exec ccode in environment
   File applications/send_mail_app/models/scheduler.py, line 2, in
 module
 mail_scheduler = Scheduler(db)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 449, in
 __init__
 self.define_tables(db, migrate=migrate)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 501, in
 define_tables
 migrate=migrate, format='%(task_name)s')
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7186, in
 define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7222, in
 lazy_define_table
 polymodel=polymodel)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 935, in
 create_table
 self.create_sequence_and_triggers(query,table)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1694, in
 create_sequence_and_triggers
 self.execute(query)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1709, in
 execute
 return self.log_execute(*a, **b)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1703, in
 log_execute
 ret = self.cursor.execute(*a, **b)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py, line
 201, in execute
 self.errorhandler(self, exc, value)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py,
 line 36, in defaulterrorhandler
 raise errorclass, errorvalue
 OperationalError: (1050, Table 'scheduler_task' already exists)

 I've followed following instructions.

 *1) Created a file models/scheduler.py*

 #code from scheduler.py file
 from gluon.scheduler import Scheduler
 mail_scheduler = Scheduler(db)


 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 You can check scheduler_task table and scheduler.task_status table
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 *2) Called send_mail module in an external script.*
 (scripts/send_mails.py)

 #extra code here
 task = mail_scheduler.queue_task('send_mail',
  pvars={'to': email,
 'subject': subject,
 'message':
 html_email},

 start_time=datetime.datetime.now())
 print task


 *3) Created a worker and got above error*


 Am I missing some steps?

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/gx5o0vAGXQQ/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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] Re: Scheduler error

2014-08-26 Thread Prasad Muley
Hi,
   I tried to access db.scheduler_run table but it is giving me following
error in web2py shell and app admin UI.

*OperationalError: (1054, Unknown column 'scheduler_run.scheduler_task' in
'field list')*


On Tue, Aug 26, 2014 at 1:04 PM, Niphlod niph...@gmail.com wrote:

 there's yet a scheduler_task table in the database. Fix migrations in the
 usual way, or set Scheduler(db,,migrate=False) to avoid the error.


 On Tuesday, August 26, 2014 8:58:06 AM UTC+2, Prasad Muley wrote:

 Hi,
  I've web2py 2.3 version. I tried to use scheduler for mail sending.
 I got this error while creating a worker for scheduler

 $ python web2py.py -K send_mail_app

 [12:07:02]
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.3.2 (2012-12-17 15:03:30) stable
 Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
 MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
 MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
 starting single-scheduler for send_mail_app...
 Traceback (most recent call last):
   File /home/prasad/Rootpy/web2py 2.3/gluon/restricted.py, line 212, in
 restricted
 exec ccode in environment
   File applications/send_mail_app/models/scheduler.py, line 2, in
 module
 mail_scheduler = Scheduler(db)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 449, in
 __init__
 self.define_tables(db, migrate=migrate)
   File /home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py, line 501, in
 define_tables
 migrate=migrate, format='%(task_name)s')
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7186, in
 define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 7222, in
 lazy_define_table
 polymodel=polymodel)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 935, in
 create_table
 self.create_sequence_and_triggers(query,table)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1694, in
 create_sequence_and_triggers
 self.execute(query)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1709, in
 execute
 return self.log_execute(*a, **b)
   File /home/prasad/Rootpy/web2py 2.3/gluon/dal.py, line 1703, in
 log_execute
 ret = self.cursor.execute(*a, **b)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py, line
 201, in execute
 self.errorhandler(self, exc, value)
   File /usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py,
 line 36, in defaulterrorhandler
 raise errorclass, errorvalue
 OperationalError: (1050, Table 'scheduler_task' already exists)

 I've followed following instructions.

 *1) Created a file models/scheduler.py*

 #code from scheduler.py file
 from gluon.scheduler import Scheduler
 mail_scheduler = Scheduler(db)


 def send_mail(to, subject, message, cc=None, bcc=None,
   attachments=None):
 
 This module is called by scheduler.
 You can check scheduler_task table and scheduler.task_status table
 
 if cc is None:
 cc = []
 if bcc is None:
 bcc = []
 if attachments is None:
 attachments = []
 #sending mail
 mail.send(to=to, cc=cc, bcc=bcc,
   subject=subject, message=message,
   attachments=attachments)

 *2) Called send_mail module in an external script.*
 (scripts/send_mails.py)

 #extra code here
 task = mail_scheduler.queue_task('send_mail',
  pvars={'to': email,
 'subject': subject,
 'message':
 html_email},

 start_time=datetime.datetime.now())
 print task


 *3) Created a worker and got above error*


 Am I missing some steps?

  --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/gx5o0vAGXQQ/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie
   *http://www.cs.bell-labs.com/who/dmr/*
http://www.cs.bell-labs.com/who/dmr/

-- 
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

[web2py] Use of mail.send in Scheduler

2014-08-13 Thread Prasad Muley
Hi,
   I want to use mail.send in Scheduler. Is there any way to use it in 
scheduler?
AFAIK task which queued in scheduler.queue_task must be present in 
models/scheduler.py 
So how can I override mail.send() in models/scheduler.py
 

-- 
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] Re: Appending div class=error for validation using jQuery.

2013-07-25 Thread Prasad Muley
has anybody got my question?


On Thu, Jul 25, 2013 at 2:30 PM, Prasad Muley pmmu...@gmail.com wrote:

 Hello Joe,
   I made a mistake while pasting. // working isn't there in
 updated code.
 actual code is
 {{extend 'layout.html'}}
 {{=form}}
 script
 jQuery(document).ready( function(){
 var flag=0
 jQuery('.web2py_form').submit(function(){
 //Getting value from tracker status
 var get_data=jQuery(this).html();
 var get_name=jQuery('#taxpayer_name').val()
 if(get_name ==) {
   if(flag==0) {
   //Following are working
 //alert(Please Enter valid Name);
 // jQuery(div class='error'Please Enter Valid
 Name/div).appendTo(#taxpayer_name__label)
 //jQuery(div class='error'Please Enter Valid
 Name/div).appendTo(.w2p_fw)
   jQuery(div class='error'Please Enter
 Name/div/div).appendTo(#taxpayer_name);
   flag=1
 }
 return false
 }
 });
 });
 /script

 As per your advice I opened firebug and found no errors ( I've attached
 screen shot)
 But When I opened Web console It shows me one error as Empty string passed
 to getElementById().
 If it works on other fields then why it should work in field also.


 On Thu, Jul 25, 2013 at 1:25 PM, Joe Barnhart joe.barnh...@gmail.comwrote:

 It's probably just a typo, but shouldn't there be a semi-colon after the
 line that is // WORKING as a comment?  You need to separate javascript
 lines with semi-colons, except for the last statement in a function.  (But
 even there it doesn't hurt anything if you put one in.)

 Get Firebug on Firefox and open the console pane.  It shows you if you
 have any javascript errors.

 -- Joe B.


 On Wednesday, July 24, 2013 10:05:52 PM UTC-7, Prasad Muley wrote:

 Hello All,
 I am newbie web2py programmer. I tried to do custom
 validation  using jQuery but not gettng expected result. Code is as
 followed:

 *Model-db.py*

 db.define_table('taxpayer',
 Field('name'),
 Field('married','boolean'),
 Field('spouse_name')
 )
 # I don't want use IS_NOT_EMPTY() in this table

 *Controller-default.py*

 def taxer():
 grid=SQLFORM.grid(db.taxpayer,**user_signature=False)
 if request.args(0) in ['edit']:
 form=grid.update_form
 if form.process().accepted:
 response.flash=form.vars
 return dict(grid=grid)

 *
 *
 *View- default/taxer.html*

 {{extend 'layout.html'}}
 {{=grid}}
 script
 jQuery(document).ready( function(){
 var flag=0
 jQuery('.web2py_form').submit(**function(){
 //Getting value from tracker status
 var get_name=jQuery('#taxpayer_**name').val()
 if(get_name ==) {
 if(flag==0) {
//alert(Please Enter valid Name);
  WORKING
jQuery(div class='error'Please Enter
 Valid Name/div).appendTo(#**taxpayer_name__label)  // WORKING
jQuery(div class='error'Please Enter
 Valid Name/div).appendTo(#**taxpayer_name) // NOT WORKING
   flag=1
 }
 return false
 }
 });
 });
 /script

 Please help me for this.
 I want to display error message for 'name' field as IS_NOT_EMPTY() does.
 It successfully does for taxpayer_name__label even as well as
 taxpayer_name__row but isn't working for taxpayer_name id.

  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/orFuJ3h2JxY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 Thanks and Regards
 Prasad M. Muley
 Programmer at One Delta Synergies Pvt Ltd. [ Themis Group ] | PICT 2013

 “Pretty much everything on the web uses those two things: *C* and *UNIX*,”
 - Dennis Ritchie

 *http://www.cs.bell-labs.com/who/dmr/*http://www.cs.bell-labs.com/who/dmr/




-- 
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. [ Themis Group ] | PICT 2013

“Pretty much everything on the web uses those two things: *C* and *UNIX*,”
- Dennis Ritchie

*http://www.cs.bell-labs.com/who/dmr/*http://www.cs.bell-labs.com/who/dmr/

-- 

--- 
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

Re: [web2py] Re: Appending div class=error for validation using jQuery.

2013-07-25 Thread Prasad Muley
Now it's Working.
Thank you for quick response.


On Thu, Jul 25, 2013 at 7:26 PM, Paolo Caruccio
paolo.carucci...@gmail.comwrote:

 Please try;

 jQuery(div class='error'Please Enter Name/div/div).appendTo(jQuery
 (#taxpayer_name).parent());

 or

 jQuery(div class='error'Please Enter Name/div/div).insertAfter(
 #taxpayer_name);

 Your code fails because the div.error is created inside the input element

 Il giorno giovedì 25 luglio 2013 13:39:34 UTC+2, Prasad Muley ha scritto:

 has anybody got my question?


 On Thu, Jul 25, 2013 at 2:30 PM, Prasad Muley pmm...@gmail.com wrote:

 Hello Joe,
   I made a mistake while pasting. // working isn't there in
 updated code.
 actual code is
 {{extend 'layout.html'}}
 {{=form}}
 script
 jQuery(document).ready( function(){
 var flag=0
 jQuery('.web2py_form').submit(**function(){
 //Getting value from tracker status
 var get_data=jQuery(this).html();
 var get_name=jQuery('#taxpayer_**name').val()
 if(get_name ==) {
   if(flag==0) {
   //Following are working
 //alert(Please Enter valid Name);
 // jQuery(div class='error'Please Enter Valid
 Name/div).appendTo(#**taxpayer_name__label)
 //jQuery(div class='error'Please Enter Valid
 Name/div).appendTo(.w2p_**fw)
   jQuery(div class='error'Please Enter
 Name/div/div).appendTo(#**taxpayer_name);
flag=1
 }
 return false
 }
 });
 });
 /script

 As per your advice I opened firebug and found no errors ( I've attached
 screen shot)
 But When I opened Web console It shows me one error as Empty string
 passed to getElementById().
 If it works on other fields then why it should work in field also.


 On Thu, Jul 25, 2013 at 1:25 PM, Joe Barnhart joe.ba...@gmail.comwrote:

 It's probably just a typo, but shouldn't there be a semi-colon after
 the line that is // WORKING as a comment?  You need to separate
 javascript lines with semi-colons, except for the last statement in a
 function.  (But even there it doesn't hurt anything if you put one in.)

 Get Firebug on Firefox and open the console pane.  It shows you if
 you have any javascript errors.

 -- Joe B.


 On Wednesday, July 24, 2013 10:05:52 PM UTC-7, Prasad Muley wrote:

 Hello All,
 I am newbie web2py programmer. I tried to do custom
 validation  using jQuery but not gettng expected result. Code is as
 followed:

 *Model-db.py*

 db.define_table('taxpayer',
 Field('name'),
 Field('married','boolean'),
 Field('spouse_name')
 )
 # I don't want use IS_NOT_EMPTY() in this table

 *Controller-default.py*

  def taxer():
 grid=SQLFORM.grid(db.taxpayer,user_signature=False)
 if request.args(0) in ['edit']:
 form=grid.update_form
 if form.process().accepted:
 response.flash=form.vars
 return dict(grid=grid)

 *
 *
 *View- default/taxer.html*

 {{extend 'layout.html'}}
 {{=grid}}
 script
 jQuery(document).ready( function(){
 var flag=0
 jQuery('.web2py_form').submit(function(){
 //Getting value from tracker status
 var get_name=jQuery('#taxpayer_**nam**e').val()
 if(get_name ==) {
 if(flag==0) {
//alert(Please Enter valid Name);
  WORKING
jQuery(div class='error'Please Enter
 Valid Name/div).appendTo(#**taxpay**er_name__label)  // WORKING
jQuery(div class='error'Please Enter
 Valid Name/div).appendTo(#**taxpay**er_name) // NOT WORKING
   flag=1
 }
 return false
 }
 });
 });
 /script

 Please help me for this.
 I want to display error message for 'name' field as IS_NOT_EMPTY()
 does.
 It successfully does for taxpayer_name__label even as well as
 taxpayer_name__row but isn't working for taxpayer_name id.

  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit https://groups.google.com/d/**
 topic/web2py/orFuJ3h2JxY/**unsubscribehttps://groups.google.com/d/topic/web2py/orFuJ3h2JxY/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 web2py+un...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .






 --
 Thanks and Regards
 Prasad M. Muley
 Programmer at One Delta Synergies Pvt Ltd. [ Themis Group ] | PICT 2013

 “Pretty much everything on the web uses those two things: *C* and *UNIX*,”
 - Dennis Ritchie

 *http://www.cs.bell

[web2py] Appending div class=error for validation using jQuery.

2013-07-24 Thread Prasad Muley
Hello All,
I am newbie web2py programmer. I tried to do custom validation 
 using jQuery but not gettng expected result. Code is as followed:

*Model-db.py*

db.define_table('taxpayer',
Field('name'),
Field('married','boolean'),
Field('spouse_name')
)
# I don't want use IS_NOT_EMPTY() in this table

*Controller-default.py*

def taxer():
grid=SQLFORM.grid(db.taxpayer,user_signature=False)
if request.args(0) in ['edit']:
form=grid.update_form
if form.process(hiderrors=False).accepted:
response.flash=form.vars
return dict(grid=grid)

*
*
*View- default/taxer.html*

{{extend 'layout.html'}}
{{=grid}}
script
jQuery(document).ready( function(){
var flag=0
jQuery('.web2py_form').submit(function(){
//Getting value from tracker status
var get_name=jQuery('#taxpayer_name').val()
if(get_name ==) {
if(flag==0) {
   //alert(Please Enter valid Name);  WORKING
   jQuery(div class='error'Please Enter 
Valid Name/div).appendTo(#taxpayer_name__label)  // WORKING
   jQuery(div class='error'Please Enter 
Valid Name/div).appendTo(#taxpayer_name) // NOT WORKING
  flag=1
}
return false
}
});  
});
/script

Please help me for this.
I want to display error message for 'name' field as IS_NOT_EMPTY() does.
It successfully does for taxpayer_name__label even as well as 
taxpayer_name__row but isn't working for taxpayer_name id.

-- 

--- 
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] Error when Inserting data into table.

2013-07-10 Thread Prasad Muley
Hello All,
 I am newbie to web2py framework. I have created one database 
connection string to 'Mysql' as

prankester@Altocumulus: ~ master ⚡
$ bash cmdweb2py.sh  
[17:21:35]
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.6.0-development+timestamp.2013.07.03.01.52.44
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
MySQL(MySQLdb), PostgreSQL(pg8000), IMAP(imaplib)
WARNING:web2py:import IPython error; use default python shell
Python 2.7.3 (default, Apr 10 2013, 05:46:21) 
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
(InteractiveConsole)

db=DAL(mysql://root:root@localhost/test)
*#Creating a Table*

 db.define_table('User_info',
... Field('username',unique=True),
... Field('password',notnull=True),
... format='%(name)s',
... migrate=False)
Table User_info (id,username,password)

 db.User_info.insert(username='facebook',password='twitter')
*Traceback (most recent call last):
  File console, line 1, in module
  File /home/prankester/web2py-master/gluon/dal.py, line 8579, in insert
ret =  self._db._adapter.insert(self, self._listify(fields))
  File /home/prankester/web2py-master/gluon/dal.py, line 1209, in insert
raise e
ProgrammingError: (1146, Table 'test.User_info' doesn't exist)*

I don't know what happened wrong
Please help me.

And I also want to know difference between

db=DAL((mysql://root:root@localhost/test,*migrate_enabled=True*)
and db.define_table('person',Field('name'), *migrate=True*)

-- 

--- 
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] Failed to Insert into Mysql Database

2013-07-10 Thread Prasad Muley
Hello all,
   I have created one table called 'Programmer'. Table creation 
is done successfully but whenever I tried to insert data it shows me errors 
'test.Programmer' doesn't exist. I have done in following way.

prankester@Altocumulus: ~ master ⚡
$ bash cmdweb2py.sh   [12:37:21]
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.6.0-development+timestamp.2013.07.03.01.52.44
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
MySQL(MySQLdb), PostgreSQL(pg8000), IMAP(imaplib)
WARNING:web2py:import IPython error; use default python shell
Python 2.7.3 (default, Apr 10 2013, 05:46:21) 
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
(InteractiveConsole)
 db=DAL(mysql://root:root@localhost/test)
 db.define_table('Programmer',
... Field('username',type='string',length=100,unique=True),
... Field('password',type='password',notnull=True),
... Field('level',notnull=True),
... format='%(username)s',
... migrate=False)
Table Programmer (id,username,password,level)
 db.Programmer.username #table created successfully
gluon.dal.Field object at 0x8c17fac
 
db.Programmer.insert(username=Prasad,password=web2py,level=Beginner)
Traceback (most recent call last):
  File console, line 1, in module
  File /home/prankester/web2py-master/gluon/dal.py, line 8579, in insert
ret =  self._db._adapter.insert(self, self._listify(fields))
  File /home/prankester/web2py-master/gluon/dal.py, line 1209, in insert
raise e
ProgrammingError: (1146, Table 'test.Programmer' doesn't exist)
#what's going on wrong

-- 

--- 
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.