Re: [web2py] Read excel sheet in web2py

2012-04-28 Thread RAHUL PRIYADARSI
Dear All,
Thank you very much for your reply. I was getting this error because as
Anthony pointed out "That just means you didn't install or import the
module correctly. ".So I downloaded xlrd from this link:
http://pypi.python.org/packages/source/x/xlrd/xlrd-0.7.7.tar.gz#md5=ba46c586b4c1df977bf7bdcd711590bf,extracted
it in my application's modules folder and I imported it (without
local import). Whoosh it worked!!
Thank you very much.
Reply me for party anytime

On 29 April 2012 00:27, Anthony  wrote:

> That just means you didn't install or import the module correctly.  Both
>> are easy.
>>
>> Place the xlrd folder hierarchy in the modules folder of your app.
>>
>> Then import it with:
>> xlrd = local_import('xlrd')
>>
>
> Note, local_import has been deprecated. Even for modules in the
> application's /modules folder, you can now simply do:
>
> import xlrd
>
> Anthony
>


Re: [web2py] Re: File generation using web2py

2012-04-29 Thread RAHUL PRIYADARSI
Dear All,
Thanks for your answers.But what I was looking for was,putting into simple
words,implementing a use case similar to the following "The system
maintains the data related to each transaction.Each transaction includes
the list of items demanded per transaction with each item belonging to a
category.The system also generates an aggregated report per transaction as
well as an overall report of the total items belonging to each category
demanded.".Now "the report" here need not be in csv only.It may be txt
file.Since I am not sure as to whether is it possible to print formatted
strings(e.g. the string "report" printed right aligned in a total field of
15 characters,something likd printf(%15s)) in web2py,my question is that
how we do file IO in web2py. Can we generate a txt file in web2py. And can
we print formatted strings to it?
Since the controller runs on server and my application would be deployed in
an intranet lan and it needs to generate files to be used in local file
system of the system on which the user will access the app , where must
this file IO code be written, in controller or view.

On 30 April 2012 07:35, Brian M  wrote:

> Yep, I've got a processing app that spits out all sorts of csv files based
> on data gathered from multiple sources.
>
> Here's a little helper function I use
>
> def csv_export(records, column_names, fields, mode = 'dal'):
> """Export DAL result set, list of dicts or list of lists to CSV stream
> for returning to user
> Arguments:
> records = the data to be returned
> column_names (list)= the column names/headings for the first row in
> the CSV file
> Example ['First Name', 'Last Name', 'Email']
> fields (list) = the names of the fields (as they appear in records) in
> the order they
> should be in the CSV. Example ['f_name', 'l_name',
> 'email']
> or ['table_a.f_name', 'table_a.l_name',
> 'table_b.email']
> If mode = 'list' and your records are in the correct
> order then fields may be None
> otherwise use [1,3,0] if you list is in a different
> order
> mode (string) = what type of data is in records? 'dal' (Default),
> 'dict' or 'list'
> 'dal' if records came from a regular dal query
> (Default)
> 'dict' if records are a list of dicts (for example
> using db.executesql() with as_dict = True)
> 'list' if records are a list of lists/tuples (for
> example using db.executesql() with as_dict = False)
>
> """
>
> #create fake file object
> import cStringIO
> file = cStringIO.StringIO()
> #setup csv writer
> import csv
> csv_file = csv.writer(file)
> #write first row withspecified column headings/names
> csv_file.writerow(column_names)
> #which mode - dal or dict?
> if mode.lower() == 'dal' or mode.lower() == 'dict':
> for record in records:
> csv_file.writerow([record[field] for field in fields])
> elif mode.lower() == 'list':
> if fields == None:
> csv_file.writerows(records)
> else:
> for record in records:
> csv_file.writerow([record[field] for field in fields])
> return file
>
>
>
> Then in a controller you can have something like
>
> csv_stream = csv_export(processed_dataset, column_names, fields, mode
> = 'dict')
> response.headers['Content-Type']='application/vnd.ms-excel'
> response.headers['Content-Disposition']='attachment;
> filename=data_for_%s.csv' % date.today()
> return csv_stream.getvalue()
>
> which will cause browser to download the csv file with your chosen filename
>
> you could also turn around and save the datafile to the filesystem if you
> wanted.
>
> Hope this helps!
> Brian
>
>
> On Saturday, April 28, 2012 5:20:15 AM UTC-5, rahulserver wrote:
>>
>> I wish to generate a few reports in csv or txt or other file formats
>> based on some database data maintained through a crud application.
>> Previously, it was done through an asp.net application with vb as
>> scripting language.But as I explored the wonderful capabilities of web2py,
>> I have become a fan of this terrific framework.
>> Is it possible to do it in web2py. And if it is, then how and where
>> should the code be placed.In the view or model or controller?
>>
>


Re: [web2py] Re: File generation using web2py

2012-04-30 Thread RAHUL PRIYADARSI
Thanks Mr.Khalil!
I will surely give it a try!

On 30 April 2012 13:24, Khalil KHAMLICHI  wrote:

> Raul, when working with the web you always (most of the times) create the
> files server side and invite user to download it and save it to his file
> system, this sais you don't need to access the file system yourself, just
> invite the user to download your file and you are done.
> for csv versus txt files, they are both the same thing IF the user is not
> going to import them into some other software that needs only csv content,
> python has a module called StringIO, you can use it as a file and write to
> it mixed content : simple text and csv data.
>
> On Mon, Apr 30, 2012 at 6:03 AM, RAHUL PRIYADARSI 
> wrote:
>
>> Dear All,
>> Thanks for your answers.But what I was looking for was,putting into
>> simple words,implementing a use case similar to the following "The system
>> maintains the data related to each transaction.Each transaction includes
>> the list of items demanded per transaction with each item belonging to a
>> category.The system also generates an aggregated report per transaction as
>> well as an overall report of the total items belonging to each category
>> demanded.".Now "the report" here need not be in csv only.It may be txt
>> file.Since I am not sure as to whether is it possible to print formatted
>> strings(e.g. the string "report" printed right aligned in a total field of
>> 15 characters,something likd printf(%15s)) in web2py,my question is that
>> how we do file IO in web2py. Can we generate a txt file in web2py. And can
>> we print formatted strings to it?
>> Since the controller runs on server and my application would be deployed
>> in an intranet lan and it needs to generate files to be used in local file
>> system of the system on which the user will access the app , where must
>> this file IO code be written, in controller or view.
>>
>>
>> On 30 April 2012 07:35, Brian M  wrote:
>>
>>> Yep, I've got a processing app that spits out all sorts of csv files
>>> based on data gathered from multiple sources.
>>>
>>> Here's a little helper function I use
>>>
>>> def csv_export(records, column_names, fields, mode = 'dal'):
>>> """Export DAL result set, list of dicts or list of lists to CSV
>>> stream for returning to user
>>> Arguments:
>>> records = the data to be returned
>>> column_names (list)= the column names/headings for the first row in
>>> the CSV file
>>> Example ['First Name', 'Last Name', 'Email']
>>> fields (list) = the names of the fields (as they appear in records)
>>> in the order they
>>> should be in the CSV. Example ['f_name', 'l_name',
>>> 'email']
>>> or ['table_a.f_name', 'table_a.l_name',
>>> 'table_b.email']
>>> If mode = 'list' and your records are in the correct
>>> order then fields may be None
>>> otherwise use [1,3,0] if you list is in a different
>>> order
>>> mode (string) = what type of data is in records? 'dal' (Default),
>>> 'dict' or 'list'
>>> 'dal' if records came from a regular dal query
>>> (Default)
>>> 'dict' if records are a list of dicts (for example
>>> using db.executesql() with as_dict = True)
>>> 'list' if records are a list of lists/tuples (for
>>> example using db.executesql() with as_dict = False)
>>>
>>> """
>>>
>>> #create fake file object
>>> import cStringIO
>>> file = cStringIO.StringIO()
>>> #setup csv writer
>>> import csv
>>> csv_file = csv.writer(file)
>>> #write first row withspecified column headings/names
>>> csv_file.writerow(column_names)
>>> #which mode - dal or dict?
>>> if mode.lower() == 'dal' or mode.lower() == 'dict':
>>> for record in records:
>>> csv_file.writerow([record[field] for field in fields])
>>> elif mode.lower() == 'list':
>>> if fields == None:
>>> csv_file.writerows(records)
>>> else:
>>> for record in records:
>>>  

Re: [web2py] Re: File generation using web2py

2012-05-02 Thread RAHUL PRIYADARSI
Dear Mr.Brian,
Thank you very much for you reply.
" If you're worried about text alignment and other layout stuff, why not
just use HTML templates"

Well because I wish to get prints from them using dot matrix printer, which
prints only txt files!
But any way your response did help me very much.

With Regards,
rahulserver.

On 1 May 2012 02:30, Brian M  wrote:

> Yep, it is the web, you can't automatically write a file directly to the
> user's computer (Holy security issues Batman!) but you can provide them the
> prepared file as a download that they can then save to wherever they want.
> Doesn't matter if it is CSV or TXT or HTML or PDF or RTF whatever.
> Definitely note that reponse.header content-type and content-disposition
> portion of my sample code above, that is what will help you cause the
> user's browser to download the file with the correct name.  There is some
> StringIO stuff in there too which Khalil mentioned and you'd definitely
> want for generating the files.
>
> As far as the formatting of strings you bet python & web2py can do it. If
> you're worried about text alignment and other layout stuff, why not just
> use HTML templates, that's what web2py is for. If you look around on this
> list there is also some stuff on generating PDF reports - I think there is
> a markmin to PDF converter available too.   I believe that pyrtf is also in
> web2py's contrib so you could use that to do Rich Text Format files.
> Plenty of options out there for you.
>
>
> On Monday, April 30, 2012 2:54:28 AM UTC-5, Khalil KHAMLICHI wrote:
>
>> Raul, when working with the web you always (most of the times) create the
>> files server side and invite user to download it and save it to his file
>> system, this sais you don't need to access the file system yourself, just
>> invite the user to download your file and you are done.
>> for csv versus txt files, they are both the same thing IF the user is not
>> going to import them into some other software that needs only csv content,
>> python has a module called StringIO, you can use it as a file and write
>> to it mixed content : simple text and csv data.
>>
>> On Mon, Apr 30, 2012 at 6:03 AM, RAHUL PRIYADARSI <> wrote:
>>
>>> Dear All,
>>> Thanks for your answers.But what I was looking for was,putting into
>>> simple words,implementing a use case similar to the following "The system
>>> maintains the data related to each transaction.Each transaction includes
>>> the list of items demanded per transaction with each item belonging to a
>>> category.The system also generates an aggregated report per transaction as
>>> well as an overall report of the total items belonging to each category
>>> demanded.".Now "the report" here need not be in csv only.It may be txt
>>> file.Since I am not sure as to whether is it possible to print formatted
>>> strings(e.g. the string "report" printed right aligned in a total field of
>>> 15 characters,something likd printf(%15s)) in web2py,my question is that
>>> how we do file IO in web2py. Can we generate a txt file in web2py. And can
>>> we print formatted strings to it?
>>> Since the controller runs on server and my application would be deployed
>>> in an intranet lan and it needs to generate files to be used in local file
>>> system of the system on which the user will access the app , where must
>>> this file IO code be written, in controller or view.
>>>
>>>
>>> On 30 April 2012 07:35, Brian M <> wrote:
>>>
>>>> Yep, I've got a processing app that spits out all sorts of csv files
>>>> based on data gathered from multiple sources.
>>>>
>>>> Here's a little helper function I use
>>>>
>>>> def csv_export(records, column_names, fields, mode = 'dal'):
>>>> """Export DAL result set, list of dicts or list of lists to CSV
>>>> stream for returning to user
>>>> Arguments:
>>>> records = the data to be returned
>>>> column_names (list)= the column names/headings for the first row in
>>>> the CSV file
>>>> Example ['First Name', 'Last Name', 'Email']
>>>> fields (list) = the names of the fields (as they appear in records)
>>>> in the order they
>>>> should be in the CSV. Example ['f_name', 'l_name',
>>>> 'email']
>>>> or ['table_a

Re: [web2py] Re: Obtaining new names of more than one uploaded files in web2py

2012-05-04 Thread RAHUL PRIYADARSI
"I hope I understood your question.  ".Yes u did!
N thanks!
Silly question actually.But I feel that notations used in web2py official
book are a bit ambiguous(at least at some places).Hope it improves!
Regards,
:-)

On 5 May 2012 04:37, villas  wrote:

> Those fields would have different fieldnames...
>   form.vars.yourfield_1
>   form.vars.yourfield_2
>   form.vars.yourfield_3
>
> I hope I understood your question.
> Regards, D
>
>
> On Friday, 4 May 2012 23:26:26 UTC+1, rahulserver wrote:
>>
>> In the official book of web2py 
>> web2py.com/books/default/**chapter/29/7,
>> if a file is uploaded,its new file name can be obtained through
>> form.vars.fieldname.What if I wish to upload two or more files and obtain
>> their new names?
>>
>


Re: [web2py] Re: Exception not thrown for duplicate values.

2012-05-05 Thread RAHUL PRIYADARSI
Mr.Massimo,
Thank you for your response.And it is not only the case of unique=true
constraing, but also other constraints like is_not_empty. The db is not
enforcing these constraints if they are not declared at the first shot. But
what shall be done if i wish to enforce theses? shall i drop the table and
recreate them?
Kindly do reply because I need to add a few constraints after table
creation.

On 5 May 2012 09:33, Massimo Di Pierro  wrote:

> Validators are not applied to CSV import. The unique=True may be ignored
> if you are suing sqlite, unless you added it when you first defined the
> table. If you added unique=True later it is ignored.
>
>
> On Friday, 4 May 2012 22:40:12 UTC-5, rahulserver wrote:
>>
>> I am importing data from a csv file and the field declaration is
>> as:Field('Account',requires=**IS_NOT_EMPTY(),unique=True). But no
>> exception is thrown when duplicate values for the field is imported!  In
>> one of the posts, I have read that it is an sqllite specific issue which I
>> am using for backend How to get round it?
>>
>


Re: [web2py] Accessing extra sqlform elements from view

2012-06-08 Thread RAHUL PRIYADARSI
Hi All!,
Thanks to all for your reply!
Mr.Anthony's answer really helped as i tried out the first method using:-
{{=form.element(_name='agree')}}
As for Mr.Cornelius, your answer was also useful but i did not want to
access the value of the input field in the view.Rather I wanted to access
the field itself(to allow user to input values in it).But any way thanks
for it!

Yours Sincerely,
Rahul Priyadarsi.


On 6 June 2012 18:40, Cornelius Kölbel wrote:

>  Hello Rahul,
>
> I think you should be able to access it as
>
> form.vars.agree
>
> which would either be "on" or None.
>
> Kind regards
> Cornelius
>
> Am 06.06.2012 13:45, schrieb rahulserver:
>
> I added this extra element to my sqlform (as given in web2py book chapter
> forms and validators):
>
> form = SQLFORM(db.yourtable)my_extra_element = TR(LABEL('I agree to the terms 
> and conditions'), \
>   
> INPUT(_name='agree',value=True,_type='checkbox'))form[0].insert(-1,my_extra_element)
>
> But when i tried to access it in view as
> {{=form.custom.widget.my_extra_element}} (between form.custom.begin and
> form.custom.end) i am getting a none instead of a checkbox.
>
> {{=form}} does give the output as desired. But i wish to make a few
> customizations in the form so i am trying the custom form approachfo.So
> what is the way to access the extra sqlform elements from views?
>
>
>


Re: [web2py] Re: Unable to insert data into sqllite database

2012-06-09 Thread RAHUL PRIYADARSI
Dear Mr.Massimo!,
Thank you very much for your quick response.
I am presently using web2py version 1.99.7(download url:
http://www.web2py.com/examples/static/web2py_win.zip).
You are right that something else is causing the problem. Now i can not
perform any operations(insert,edit,delete or update) on any of the tables.
Something mysteriously has frozen the whole model. I tried dropping a few
fields from the table, they do get dropped.But no crud takes place on the
database. I suspect that i had deleted the files in the databases folder of
my application since sqllite does not issue alter command if i change a few
field definitions(like adding unique constraint). But they did get created
again when i changed the model.

I hope you can help me find a way out of this!

Yours Sincerely,
Rahul Priyadarsi.

On 9 June 2012 20:08, Massimo Di Pierro  wrote:

> I just tried this and it works fine with me. I only had to change the
> compute field:
>
>Field('Amt_Outstanding',compute=lambda r: (r.Net_Due or 0)-(r.Amt_Paid
> or 0))
>
> to avoid errors when Net_Due or Amt_Paid are blank.
>
> What web2py or python version do you use? I suspect something else is
> causing the problem.
>
> On Saturday, 9 June 2012 01:01:25 UTC-5, rahulserver wrote:
>>
>> Hi!
>> I have the following table in my model:
>> db.define_table('Transaction_**Master',Field('Account',db.**
>> Account_Master,requires=IS_IN_**DB(db,'Account_Master.id', '%(Account)s
>> %(State)s',zero=T('choose one'))),Field('Exam_Date','**
>> date'),Field('Entry_Date','**date',default=request.now),**
>> Field('C35Hindi','integer',**default=0),Field('C35Marathi',**
>> 'integer',default=0),Field('**C35Gujarati','integer',**
>> default=0),Field('C35English',**'integer',default=0),Field('**
>> C35Oriya','integer',default=0)**,Field('C35Telegu','integer',**
>> default=0),Field('C35Kannada',**'integer',default=0),Field('**
>> C35Punjabi','integer',default=**0),Field('C35Bengali','**
>> integer',default=0),Field('**C68Hindi','integer',default=0)**
>> ,Field('C68Marathi','integer',**default=0),Field('C68Gujarati'**
>> ,'integer',default=0),Field('**C68English','integer',default=**
>> 0),Field('C68Oriya','integer',**default=0),Field('C68Telegu','**
>> integer',default=0),Field('**C68Kannada','integer',default=**
>> 0),Field('C68Punjabi','**integer',default=0),Field('**
>> C68Bengali','integer',default=**0),Field('C912Hindi','integer'**
>> ,default=0),Field('**C912Marathi','integer',**default=0),Field('**
>> C912Gujarati','integer',**default=0),Field('C912English'**
>> ,'integer',default=0),Field('**C912Oriya','integer',default=**
>> 0),Field('C912Telegu','**integer',default=0),Field('**
>> C912Kannada','integer',**default=0),Field('C912Punjabi'**
>> ,'integer',default=0),Field('**C912Bengali','integer',**
>> default=0),Field('CSHindi','**integer',default=0),Field('**
>> CSMarathi','integer',default=**0),Field('CSGujarati','**
>> integer',default=0),Field('**CSEnglish','integer',default=**
>> 0),Field('CSOriya','integer',**default=0),Field('CSTelegu','**
>> integer',default=0),Field('**CSKannada','integer',default=**
>> 0),Field('CSPunjabi','integer'**,default=0),Field('CSBengali',**
>> 'integer',default=0),Field('**C35','integer',default=0),**
>> Field('C68','integer',default=**0),Field('C912','integer',**
>> default=0),Field('grad','**integer'),Field('Schoolwise_**
>> Form','upload'),Field('**Schoolwise_Form_Name'),Field('**
>> Hath_Ghari','integer'),Field('**Lekhan_Pad','integer'),Field('**
>> Geometry_Box','integer'),**Field('College_Bag','integer')**
>> ,Field('class3_5T','integer',**default=0),Field('class6_8T','**
>> integer',default=0),Field('**class9_12T','integer',default=**
>> 0),Field('gradT','integer',**default=0),Field('Amt_3_12','**
>> integer'),Field('Amt_grad','**integer'),Field('Pr1','**
>> integer'),Field('Pr2','**integer'),Field('Gross_Due','**
>> integer'),Field('Net_Due','**integer'),Field('Amt_Paid','**
>> integer',default=0),Field('**Amt_Outstanding',compute=**lambda r:
>> r['Net_Due']-r['Amt_Paid']),**format='%(Account)s %(Exam_Date)s')
>>
>> When i try to insert a value into it using either database
>> administration(admin interface) or thru sqlform, i am not able to insert
>> the data. When i flash the form.errors in sqlform, i get the following
>> :
>> What could be the reason?
>> Is there a limit to the maximum number of fields in a table in sqllite?
>> If so then what could be done apart from splitting the table?
>>
>


Re: [web2py] Re: Unable to insert data into sqllite database

2012-06-10 Thread RAHUL PRIYADARSI
Dear Mr.Massimo,
I have now resolved the issue. The problem was that the line 'db =
DAL('sqlite://storage.sqlite')' was missing from my model. I had initially
appended my model code to the default code that comes in db.py. Later on I
removed it and placed in a separate db.dpp.py. After this only problems
started appearing!

Thanks Again,

Yours Sincerely
rahulserver.
On 10 June 2012 11:58, RAHUL PRIYADARSI  wrote:

> Dear Mr.Massimo!,
> Thank you very much for your quick response.
> I am presently using web2py version 1.99.7(download url:
> http://www.web2py.com/examples/static/web2py_win.zip).
> You are right that something else is causing the problem. Now i can not
> perform any operations(insert,edit,delete or update) on any of the tables.
> Something mysteriously has frozen the whole model. I tried dropping a few
> fields from the table, they do get dropped.But no crud takes place on the
> database. I suspect that i had deleted the files in the databases folder of
> my application since sqllite does not issue alter command if i change a few
> field definitions(like adding unique constraint). But they did get created
> again when i changed the model.
>
> I hope you can help me find a way out of this!
>
> Yours Sincerely,
> Rahul Priyadarsi.
>
>
> On 9 June 2012 20:08, Massimo Di Pierro wrote:
>
>> I just tried this and it works fine with me. I only had to change the
>> compute field:
>>
>>Field('Amt_Outstanding',compute=lambda r: (r.Net_Due or 0)-(r.Amt_Paid
>> or 0))
>>
>> to avoid errors when Net_Due or Amt_Paid are blank.
>>
>> What web2py or python version do you use? I suspect something else is
>> causing the problem.
>>
>> On Saturday, 9 June 2012 01:01:25 UTC-5, rahulserver wrote:
>>>
>>> Hi!
>>> I have the following table in my model:
>>> db.define_table('Transaction_**Master',Field('Account',db.**
>>> Account_Master,requires=IS_IN_**DB(db,'Account_Master.id', '%(Account)s
>>> %(State)s',zero=T('choose one'))),Field('Exam_Date','**
>>> date'),Field('Entry_Date','**date',default=request.now),**
>>> Field('C35Hindi','integer',**default=0),Field('C35Marathi',**
>>> 'integer',default=0),Field('**C35Gujarati','integer',**
>>> default=0),Field('C35English',**'integer',default=0),Field('**
>>> C35Oriya','integer',default=0)**,Field('C35Telegu','integer',**
>>> default=0),Field('C35Kannada',**'integer',default=0),Field('**
>>> C35Punjabi','integer',default=**0),Field('C35Bengali','**
>>> integer',default=0),Field('**C68Hindi','integer',default=0)**
>>> ,Field('C68Marathi','integer',**default=0),Field('C68Gujarati'**
>>> ,'integer',default=0),Field('**C68English','integer',default=**
>>> 0),Field('C68Oriya','integer',**default=0),Field('C68Telegu','**
>>> integer',default=0),Field('**C68Kannada','integer',default=**
>>> 0),Field('C68Punjabi','**integer',default=0),Field('**
>>> C68Bengali','integer',default=**0),Field('C912Hindi','integer'**
>>> ,default=0),Field('**C912Marathi','integer',**default=0),Field('**
>>> C912Gujarati','integer',**default=0),Field('C912English'**
>>> ,'integer',default=0),Field('**C912Oriya','integer',default=**
>>> 0),Field('C912Telegu','**integer',default=0),Field('**
>>> C912Kannada','integer',**default=0),Field('C912Punjabi'**
>>> ,'integer',default=0),Field('**C912Bengali','integer',**
>>> default=0),Field('CSHindi','**integer',default=0),Field('**
>>> CSMarathi','integer',default=**0),Field('CSGujarati','**
>>> integer',default=0),Field('**CSEnglish','integer',default=**
>>> 0),Field('CSOriya','integer',**default=0),Field('CSTelegu','**
>>> integer',default=0),Field('**CSKannada','integer',default=**
>>> 0),Field('CSPunjabi','integer'**,default=0),Field('CSBengali',**
>>> 'integer',default=0),Field('**C35','integer',default=0),**
>>> Field('C68','integer',default=**0),Field('C912','integer',**
>>> default=0),Field('grad','**integer'),Field('Schoolwise_**
>>> Form','upload'),Field('**Schoolwise_Form_Name'),Field('**
>>> Hath_Ghari','integer'),Field('**Lekhan_Pad','integer'),Field('**
>>> Geometry_Box','integer'),**Field('College_Bag','integer')**
>>> ,Field('class3_5T','integer',**default=0),Field('class6_8T','**
>>> integer',default=0),Field('**class9_12T','integer',default=**
>>> 0),Field('gradT','integer',**default=0),Field('Amt_3_12','**
>>> integer'),Field('Amt_grad','**integer'),Field('Pr1','**
>>> integer'),Field('Pr2','**integer'),Field('Gross_Due','**
>>> integer'),Field('Net_Due','**integer'),Field('Amt_Paid','**
>>> integer',default=0),Field('**Amt_Outstanding',compute=**lambda r:
>>> r['Net_Due']-r['Amt_Paid']),**format='%(Account)s %(Exam_Date)s')
>>>
>>> When i try to insert a value into it using either database
>>> administration(admin interface) or thru sqlform, i am not able to insert
>>> the data. When i flash the form.errors in sqlform, i get the following
>>> :
>>> What could be the reason?
>>> Is there a limit to the maximum number of fields in a table in sqllite?
>>> If so then what could be done apart from splitting the table?
>>>
>>
>


Re: [web2py] Re: Unable to insert data into sqllite database

2012-06-10 Thread RAHUL PRIYADARSI
Dear Mr.Massimo,
Sorry to mail u again, but the problem was different one. This time again I
deleted the files in the databases forlder of the application(to clear all
the data in the database). But i did not delete the code in the model and
the tables froze again! So it seems that if we delete the files in the
database folder without clearing the model, the database freezes.

Thanking you once more!
With Regards.
rahulserver

On 10 June 2012 12:46, RAHUL PRIYADARSI  wrote:

> Dear Mr.Massimo,
> I have now resolved the issue. The problem was that the line 'db =
> DAL('sqlite://storage.sqlite')' was missing from my model. I had initially
> appended my model code to the default code that comes in db.py. Later on I
> removed it and placed in a separate db.dpp.py. After this only problems
> started appearing!
>
> Thanks Again,
>
> Yours Sincerely
> rahulserver.
>
> On 10 June 2012 11:58, RAHUL PRIYADARSI  wrote:
>
>> Dear Mr.Massimo!,
>> Thank you very much for your quick response.
>> I am presently using web2py version 1.99.7(download url:
>> http://www.web2py.com/examples/static/web2py_win.zip).
>> You are right that something else is causing the problem. Now i can not
>> perform any operations(insert,edit,delete or update) on any of the tables.
>> Something mysteriously has frozen the whole model. I tried dropping a few
>> fields from the table, they do get dropped.But no crud takes place on the
>> database. I suspect that i had deleted the files in the databases folder of
>> my application since sqllite does not issue alter command if i change a few
>> field definitions(like adding unique constraint). But they did get created
>> again when i changed the model.
>>
>> I hope you can help me find a way out of this!
>>
>> Yours Sincerely,
>> Rahul Priyadarsi.
>>
>>
>> On 9 June 2012 20:08, Massimo Di Pierro wrote:
>>
>>> I just tried this and it works fine with me. I only had to change the
>>> compute field:
>>>
>>>Field('Amt_Outstanding',compute=lambda r: (r.Net_Due or
>>> 0)-(r.Amt_Paid or 0))
>>>
>>> to avoid errors when Net_Due or Amt_Paid are blank.
>>>
>>> What web2py or python version do you use? I suspect something else is
>>> causing the problem.
>>>
>>> On Saturday, 9 June 2012 01:01:25 UTC-5, rahulserver wrote:
>>>>
>>>> Hi!
>>>> I have the following table in my model:
>>>> db.define_table('Transaction_**Master',Field('Account',db.**
>>>> Account_Master,requires=IS_IN_**DB(db,'Account_Master.id',
>>>> '%(Account)s %(State)s',zero=T('choose one'))),Field('Exam_Date','**
>>>> date'),Field('Entry_Date','**date',default=request.now),**
>>>> Field('C35Hindi','integer',**default=0),Field('C35Marathi',**
>>>> 'integer',default=0),Field('**C35Gujarati','integer',**
>>>> default=0),Field('C35English',**'integer',default=0),Field('**
>>>> C35Oriya','integer',default=0)**,Field('C35Telegu','integer',**
>>>> default=0),Field('C35Kannada',**'integer',default=0),Field('**
>>>> C35Punjabi','integer',default=**0),Field('C35Bengali','**
>>>> integer',default=0),Field('**C68Hindi','integer',default=0)**
>>>> ,Field('C68Marathi','integer',**default=0),Field('C68Gujarati'**
>>>> ,'integer',default=0),Field('**C68English','integer',default=**
>>>> 0),Field('C68Oriya','integer',**default=0),Field('C68Telegu','**
>>>> integer',default=0),Field('**C68Kannada','integer',default=**
>>>> 0),Field('C68Punjabi','**integer',default=0),Field('**
>>>> C68Bengali','integer',default=**0),Field('C912Hindi','integer'**
>>>> ,default=0),Field('**C912Marathi','integer',**default=0),Field('**
>>>> C912Gujarati','integer',**default=0),Field('C912English'**
>>>> ,'integer',default=0),Field('**C912Oriya','integer',default=**
>>>> 0),Field('C912Telegu','**integer',default=0),Field('**
>>>> C912Kannada','integer',**default=0),Field('C912Punjabi'*

Re: [web2py] Re: form with variable number of fields

2012-06-12 Thread RAHUL PRIYADARSI
Dear Mr.Massimo,
Thanks for your reply.
I tried the following way to get what I wanted to be done: I took a SQLFORM
and ran a for loop and inserted extra extra fields in it. The _name
attribute of those fields was like 'nm'+str(count) where count was the
looping variable. But when I tried accessing its using
form.vars.('nm'+str(count)) then it gives me invalid format error. So how
can we access form elements generated at runtime?

With Regards,
Rahul Priyadarsi.

On 12 June 2012 08:11, Massimo Di Pierro  wrote:

> This is best done in JS clientside. something like:
>
> jQuery(function(){
>jQuery('#table_field__row').hide();
>
>  
> jQuery('#table_otherfield').change(function(){if(jQuery('#table_otherfield').checked())
>  jQuery('#table_field__row').show();});
> });
>
>
> On Monday, 11 June 2012 01:08:44 UTC-5, rahulserver wrote:
>>
>> Is there a way to create a form from controller(or view) in web2py to
>> have variable number of fields depending on query?
>> To be more specific,I have following table in my model:
>>
>> db.define_table('Commitments',**Field('Account',requires=IS_**IN_DB(db,
>> db.Account_Master.id, '%(Account)s %(State)s')),Field('TID',db.**
>> Transaction_Master),Field('**Entry_Date','date',default=**
>> request.now),Field('pending','**boolean',default=True),Field('**
>> Due_Date','date'),Field('Mode'**,requires=IS_IN_SET(('DD','**
>> Direct_Banking','Cash','Other'**)),default='Other'),Field('**
>> Amount','integer',default=0),**Field('Remark'))
>>
>> The client wants to select a particular account and find all its entries
>> in a form wherein he may check or uncheck the value of field 'pending' and
>> accordingly the value of this field gets updated. So this needs a form with
>> variable number of rows. I do not want to use sqlform.grid for this and I
>> would prefer to have the code in the controller.
>>
>


[web2py] Invalid SQLFORM submit generates ticket instead of redirecting back to form with errors

2017-01-10 Thread Rahul Priyadarsi
Here is my db.py:

db.define_table('antenna_details',
Field('antenna_name',required=True),
Field('model_name',required=True),
Field('project_name',required=True),
Field('frequency_band',required=True),
Field('polarization',required=True),
Field('aperture_size',required=True),
Field('fixer_availability',required=True),
Field('weight',required=True),
Field('material',required=True),

Field('email_id',required=True,unique=True,requires=[IS_NOT_IN_DB]),
Field('subject',type='text',required=True),
Field('attached',type='upload', label="""
Antenna/feed Geometry
Electrical specification
Attach Simulated data in predicted form
""")
)

db.antenna_details.email_id.requires=[IS_EMAIL(),IS_NOT_EMPTY()]
db.antenna_details.attached.requires=IS_NOT_EMPTY()
db.antenna_details.subject.rquires=IS_NOT_EMPTY()
db.antenna_details.material.requires=IS_NOT_EMPTY()
db.antenna_details.weight.requires=IS_NOT_EMPTY()
db.antenna_details.fixer_availability.requires=IS_NOT_EMPTY()
db.antenna_details.aperture_size.requires=IS_NOT_EMPTY()
db.antenna_details.polarization.requires=IS_NOT_EMPTY()
db.antenna_details.frequency_band.requires=IS_NOT_EMPTY()
db.antenna_details.project_name.requires=IS_NOT_EMPTY()
db.antenna_details.model_name.requires=IS_NOT_EMPTY()


And I am using SQLFORM to create a form for it:

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()
"""
# response.flash = T("Hello World")
# return dict(message=T('Welcome to web2py!'))

form = SQLFORM(db.antenna_details).process()

if form.process().accepted:
response.flash = 'your data is posted'

return dict(form=form)

My problem is that when I submit a form with duplicate email id(that 
already exists in db), instead of redirecting back to form and showing the 
error, it generates a ticket like this:

 column email_id is not unique

While if I submit with empty fields, it simply redirects to the form and 
shows errors besides the respective input tags in red.
Why is it happening like this for email_id field only? And how do I disable 
this to show error messages in form itself?

-- 
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: Invalid SQLFORM submit generates ticket instead of redirecting back to form with errors

2017-01-11 Thread Rahul Priyadarsi
Thanks for the reply @Antony.
When I posted this question on this Forum, i did not see it appear so I 
thought something must be wrong with google groups itself. Hence I posted 
on stackoverflow.

 
On Wednesday, January 11, 2017 at 5:35:18 AM UTC+5:30, Anthony wrote:
>
> FYI, already answered on SO: http://stackoverflow.com/a/41554743/440323
>
> Anthony
>
> On Tuesday, January 10, 2017 at 6:07:17 PM UTC-5, Rahul Priyadarsi wrote:
>>
>> Here is my db.py:
>>
>> db.define_table('antenna_details',
>> Field('antenna_name',required=True),
>> Field('model_name',required=True),
>> Field('project_name',required=True),
>> Field('frequency_band',required=True),
>> Field('polarization',required=True),
>> Field('aperture_size',required=True),
>> Field('fixer_availability',required=True),
>> Field('weight',required=True),
>> Field('material',required=True),
>> 
>> Field('email_id',required=True,unique=True,requires=[IS_NOT_IN_DB]),
>> Field('subject',type='text',required=True),
>> Field('attached',type='upload', label="""
>> Antenna/feed Geometry
>> Electrical specification
>> Attach Simulated data in predicted form
>> """)
>> )
>>
>> db.antenna_details.email_id.requires=[IS_EMAIL(),IS_NOT_EMPTY()]
>> db.antenna_details.attached.requires=IS_NOT_EMPTY()
>> db.antenna_details.subject.rquires=IS_NOT_EMPTY()
>> db.antenna_details.material.requires=IS_NOT_EMPTY()
>> db.antenna_details.weight.requires=IS_NOT_EMPTY()
>> db.antenna_details.fixer_availability.requires=IS_NOT_EMPTY()
>> db.antenna_details.aperture_size.requires=IS_NOT_EMPTY()
>> db.antenna_details.polarization.requires=IS_NOT_EMPTY()
>> db.antenna_details.frequency_band.requires=IS_NOT_EMPTY()
>> db.antenna_details.project_name.requires=IS_NOT_EMPTY()
>> db.antenna_details.model_name.requires=IS_NOT_EMPTY()
>>
>>
>> And I am using SQLFORM to create a form for it:
>>
>> 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()
>> """
>> # response.flash = T("Hello World")
>> # return dict(message=T('Welcome to web2py!'))
>>
>> form = SQLFORM(db.antenna_details).process()
>>
>> if form.process().accepted:
>> response.flash = 'your data is posted'
>>
>> return dict(form=form)
>>
>> My problem is that when I submit a form with duplicate email id(that 
>> already exists in db), instead of redirecting back to form and showing the 
>> error, it generates a ticket like this:
>>
>>  column email_id is not unique
>>
>> While if I submit with empty fields, it simply redirects to the form and 
>> shows errors besides the respective input tags in red.
>> Why is it happening like this for email_id field only? And how do I 
>> disable this to show error messages in form itself?
>>
>

-- 
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] Order of form.vars not same as they appear in form

2017-01-12 Thread Rahul Priyadarsi
Currently I see that the order in which the fields appear in form is not 
same when i iterate through form.vars
I am using SQLFORM.

So how do I get the form.vars so that they appear in same order as they do 
on the form?

-- 
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: Order of form.vars not same as they appear in form

2017-01-13 Thread Rahul Priyadarsi
Yes form.fields works!
Thank you very much

On 13 January 2017 at 01:12, Anthony  wrote:

> form.vars is a dict-like object, so not guaranteed to return keys in any
> particular order. If the form is based on a db table, you can iterate
> through db.table._fields. The form object also includes the list of field
> names in form.fields.
>
> Anthony
>
>
> On Thursday, January 12, 2017 at 1:37:03 PM UTC-5, Rahul Priyadarsi wrote:
>>
>> Currently I see that the order in which the fields appear in form is not
>> same when i iterate through form.vars
>> I am using SQLFORM.
>>
>> So how do I get the form.vars so that they appear in same order as they
>> do on the form?
>>
> --
> 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/fZygOaWseek/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.
>



-- 
*Cheers,*
*RAHUL PRIYADARSI*

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