[web2py] Creating report from diffrent tables
Hi Web2py user I want to create report on Employee.I have three tables holiday list, login details and employe leave. I want to create report in such way so i can see employe name, total number of day in current month, total no of present, total number of holiday i current month and total number of leave emps have taken(vacation leave, medical and casual leave. can any one help me in this Model db.define_table('holiday_list', Field('holiday_date','date',requires=IS_NOT_EMPTY(error_message='Please enter the Holiday date')), Field('holiday_name',requires=IS_NOT_EMPTY(error_message='Please enter the Holiday Name')), Field('remarks','text')) db.define_table('employee_login_detail', Field('employee_code'), Field('employee_email'), Field('employee_name'), Field('employee_login_date','date'), Field('employee_login_time'), Field('ip_address')) db.define_table('employee_leave', Field('employee_code'), Field('email'), Field('taken_vacation_leave','integer'), Field('taken_medical_leave','integer'), Field('taken_casual_leave','integer'), Field('left_vacation_leave','integer'), Field('left_medical_leave','integer'), Field('left_casual_leave','integer')) controller part def admin_newholiday(): db.holiday_list.id.readable=False form=SQLFORM.grid(db.holiday_list, selectable = lambda ids: del_hlist(ids)) return dict(form=form) def admin_attendance(): db.employee_login_detail.id.readable=False form=SQLFORM.grid(db.employee_login_detail, selectable = lambda ids: del_att(ids)) return dict(form=form) def employee_leave(): db.employee_leave.id.readable=False grid = SQLFORM.grid(db.employee_leave, csv=False, deletable=False, editable=False, searchable=True, showbuttontext=False,create=False,paginate=15) return dict(form=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: Creating report from diffrent tables
Thanks Stifan can u give some example. i have gone trow that, but i am not getting result On Friday, 14 March 2014 17:31:33 UTC+5:30, 黄祥 wrote: > > for total number, i think you can achieve it with sum query in dal. > > ref : > > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len > > 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.
[web2py] problrm in smart sql grid
Hi Web2py User i am using smart sql grid. i am trying to take value from drop down. according to that i am fetching data in grid. my grid is working fine but when ever i click on edit view buttons. i will not work as it should to be bork. it refress the same page. plese my code below view part {{left_sidebar_enabled,right_sidebar_enabled=True,('message' in globals())}} {{extend 'layout.html'}} View By: Select View All Due This Month Due Today DueTomorrow {{=form}} controler part def a_search(): subject=request.vars.cars d_today = datetime.date.today() if subject == 'Due Today': query = ((db.mytable.due_date == d_today) & ( db.mytable.Compliance_Area == 'st')) session.grid = SQLFORM.smartgrid(db.mytable,linked_tables=['submit_detail'], csv=False , constraints = dict(mytable = query), paginate=15 , sorter_icons=(XML('↑'), XML('↓')) , deletable=False, create=False,showbuttontext=False) response.flash = T(" Due Today") elif subject == 'DueTomorrow': t_day = datetime.date.today() + datetime.timedelta(days=1) query = ((db.mytable.due_date == t_day) & ( db.mytable.Compliance_Area == 'st')) session.grid = SQLFORM.smartgrid(db.mytable,linked_tables=['submit_detail'], csv=False , constraints = dict(mytable = query), paginate=15 , sorter_icons=(XML('↑'), XML('↓')) , deletable=False, create=False,showbuttontext=False) response.flash = T(" Due Tomorrow") elif subject == 'Due This Month': date = datetime.date.today() start_date = datetime.datetime(date.year, date.month, 1) end_date = datetime.datetime(date.year, date.month, calendar.mdays[date.month]) query = (((db.mytable.due_date >= start_date) | (db.mytable.due_date >= end_date)) & ( db.mytable.Compliance_Area == 'st')) session.grid = SQLFORM.smartgrid(db.mytable,linked_tables=['submit_detail'], csv=False, constraints = dict(mytable = query), paginate=15 , sorter_icons=(XML('↑'), XML('↓')) , deletable=False, create=False,showbuttontext=False) response.flash = T(" Due This Month") elif subject == 'All': query = (( db.mytable.Compliance_Area == 'st')) session.grid = SQLFORM.smartgrid(db.mytable,linked_tables=['submit_detail'], csv=False , constraints = dict(mytable = query), paginate=15 , sorter_icons=(XML('↑'), XML('↓')) , deletable=False) response.flash = T(" All") return dict(form = session.grid) can any one help me to sole that issues -- 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] Uploading file through restful webservice
Hi, I am new to web2py and currently built a restful webservice that accepts data from my client (Android Application) and stores the data into the DB. But, due to business need I need to send a text file from the client and the server needs to store it in server file system. Can someone give me a pointer on how to implement file handling in web2py restful service? I did search through web2py docs and groups but couldn't find any relevant answer. kindly help me with a pointer. 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/groups/opt_out.
[web2py] Uploading file through restful webservice
Can someone give me a pointer.. I am waiting for the response.. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Uploading file through restful webservice
Hi Eduardo, Thanks for the response. Is it something like this, the file that I will be sending from client will come as a huge string and I need to handle it in the below mentioned way? I am confused about, who will convert the file into sting and send it. On Thursday, November 21, 2013 5:55:28 PM UTC+5:30, Eduardo Cruz wrote: > > Web2Py Book: > Uploads<http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads> > > You could do something like > > import StringIO > > myfile = StringIO.StringIO() > myfile.write(yourtextfile) > > being "yourtextfile" the text-file you sent from the client(which would > be actually a huge string) > then do something like > > db.mytable.insert(file=db.mytable.file.store(myfile, "filename")) > > > > > > On Thursday, November 21, 2013 12:43:22 AM UTC-4, Raj Chinna wrote: >> >> Can someone give me a pointer.. I am waiting for the response.. > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Detecting MYSQL running status
Hi, I have web2py application which talks with MYSQL and i have my db connection strings in db.py module. Sometime the web2py server is running without any issues, but mysql goes offline now and then. So, I am getting the ticket generated saying that *"Failure to connect, tried 5 times: Traceback (most recent call last): ".* All I wanted to do is to check if this error comes out (that's mysql is not running) I need to redirect the user to something like 404/database error page. Can someone tell me where and how can I detect this database connectivity failure and show some meaningful error message. Thanks, Raj Chinna -- 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/groups/opt_out.
[web2py] Re: Detecting MYSQL running status
Paolo, Thanks for the response. I just put 404 for as an example, I am may end up showing a page which asks the end user to contact the System Admin to fix the issue. What am doing is an webapp for a enterprise task. So, I may show few details about the issue. On Thursday, December 19, 2013 7:47:00 PM UTC+5:30, Paolo Valleri wrote: > > I've the same problem, I don't think DAL has this kind of ability but I > leave the word to others in such cases. > Are you interested in showing the 404 page for all tickets or only for > those the involve the db connection? > > Paolo > On Thursday, December 19, 2013 7:35:24 AM UTC+1, Raj Chinna wrote: >> >> Hi, >> >> I have web2py application which talks with MYSQL and i have my db >> connection strings in db.py module. Sometime the web2py server is running >> without any issues, but mysql goes offline now and then. So, I am getting >> the ticket generated saying that *"Failure to connect, tried 5 times: >> Traceback (most recent call last): ".* >> >> All I wanted to do is to check if this error comes out (that's mysql is >> not running) I need to redirect the user to something like 404/database >> error page. Can someone tell me where and how can I detect this database >> connectivity failure and show some meaningful error message. >> >> Thanks, >> Raj Chinna >> > -- 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/groups/opt_out.
[web2py] Re: Display "Loading' animated gif or js : How to
Hi Vineet, Could you share your successful implementation of the code? in my controller i have the following: def index(): msg="wait" form_main=FORM(INPUT(_type='submit', value="RUN"), INPUT(_name='text'), ) if form_main.accepts(request.vars,formname='form_main'): msg=wait(form_main.vars.text) return dict(msg=msg) def wait(some_text): import time time.sleep(10) msg=some_text return (msg) in my view: Type something and click RUN: {{=msg}} so basically i have a text box where user enters some text, then the controller simply takes the text and runs a wait function before returing the text to view. I am trying to implement the said loading.gif during the function wait is on-going. Could you please advice? I have very limited knowledge on Ajax. On Thursday, 13 October 2011 22:18:02 UTC+8, Vineet wrote: > > @juanduke, @Paolo, > > Thanks for sharing your time & ideas. > I successfully implemented your idea by juanduke. > The url -- http://www.ajaxload.info/ is excellent. > > Regarding Paolo's code, I need to re-structure my code somewhat (which > I will definitely do). > Then I will implement the idea. > In case of any query, I'll post it here. > > Thanks again. > ---Vineet > > On Oct 13, 12:05 am, Paolo Caruccio > wrote: > > Hi Vineet, > > > > as juanduke has suggested, I use the following jquery function (I put it > in > > web2py_ayax.js) instead of standard w2p ajax function to show a loading > > image: > > > > function web2py_polling(u,s,t){ > > $('#'+t).html(' > src="/static/images/loading.gif" alt="loading..." height="64" width="64" > > />'); > > ajax(u,s,t); > > > > } > > > > Of course you can set some css rules to custom > div#loading_gif_container. > > > > How to use: > > I insert at the bottom of the view : > > > > > > // > > > > > > ### controller ### > > > > def get_output(): > > the_output = "I'm the output" > > return the_output > > > > You could also use a standard ajax call to a function that returns > > web2py_polling function that, optionally, calls another action. > > > > For example: > > > > ### in the view ### > > > > > > // > > > > > > ### controller ### > > > > def get_output(): > > # make evaluation > > return "web2py_polling('another_action',[args],'output_target');" > > > > def another_action(): > > the_output = "I'm the output" > > return the_output > > > > Ciao. > > > > Paolo -- 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] ( parser stack overflow) when writing a row with 140 fields
Hi guys, I am trying to write a row with 140 fields into the database, with the following script: controller: *WCEL={item1:value1,item2:value2,...item140:value140}* *db.WCEL.update_or_insert(**(WCEL))* model: *db = DAL('sqlite://storage.sqlite1')* *db.define_table('WCEL',* *Field('item1'),* *Field('item2),* *..* *Field('item139'),* *Field('item140')* * )* but I am getting the following error: parser stack overflow File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 412, in execute rv = self.cursor.execute(command, *args[1:], **kwargs) OperationalError: parser stack overflow Function argument list (self=, *args=('SELECT "WCEL"."id", "WCEL."it.."."item140" = \'0\')) LIMIT 1 OFFSET 0;',), **kwargs={}) I tried the same set of 140 fields by importing from a csv, it was successful. *db.WCEL.import_from_csv_file(open('WCEL.csv', 'r'))* Is there a way to rectify this issue? I am actually extracting data from a xml and writing to the DB, if i have to write from xml to csv and import to dB, that is not efficient. Pls advise. Regards, Jaison -- 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] Correct way to put libraries in site-package folder?
Hi, I am trying to create a binary application (after compiling and packaging from windows). In my controller, i am importing a library :"import xml.etree.cElementTree as ET". I placed the files cElementTree.py and cElementTree.pyc in etree folder as follows: \web2py\site-packages\xml\etree. I am getting error: No module named cElementTree. How can i solver this error? Pls advice. Regards, Jaison -- 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: Correct way to put libraries in site-package folder?
Hi Anthony, Yes i have empty __init__.py files in each folders. I tried to use "import xml.etree.ElementTree as ET". (instead of cElementTree) it works. Now i am having problem importing another library: Plotly the trace back as follows; Traceback 1. 2. 3. 4. 5. 6. 7. 8. Traceback (most recent call last): File "D:\2. Projects\Web2Py\2_MULA_2_0\web2py\gluon\restricted.py", line 219, in restricted exec(ccode, environment) File "c:/web2py/applications/MULA_2_0\compiled\controllers.cell_reselection.index.py", line 3, in File "D:\2. Projects\Web2Py\2_MULA_2_0\web2py\gluon\custom_import.py", line 104, in custom_importer raise ImportError(e1, import_tb) # there an import error in the module ImportError: (ImportError(ImportError(ImportError('cannot import name exceptions',), ), ), ) I even copied everything from my C:\Python27\Lib\site-packages to. ... web2py\site-packages, still no luck. Is web2py binary limited to import certain type of libraries only? Please advise. Regards, Jaison On Friday, 16 March 2018 23:00:56 UTC+8, Anthony wrote: > > Do you have empty __init__.py files inside those two subfolders? > > On Friday, March 16, 2018 at 6:34:02 AM UTC-4, Jaison Raj wrote: >> >> Hi, >> I am trying to create a binary application (after compiling and packaging >> from windows). >> In my controller, i am importing a library :"import >> xml.etree.cElementTree as ET". >> I placed the files cElementTree.py and cElementTree.pyc in etree folder >> as follows: >> \web2py\site-packages\xml\etree. >> >> I am getting error: >> No module named cElementTree. >> >> How can i solver this error? >> Pls advice. >> >> >> Regards, >> Jaison >> > -- 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] swl smart grid
how to restrict user in sql smart grid for parent table to do not add record. but that same user can add record in child table. query = ( ( db.parentr.id >= 0)) grid = SQLFORM.smartgrid(db.parent,linked_tables=['child'], csv=False ,fields=fields, constraints = dict(tracker = query), paginate=15 , sorter_icons=(XML('↑'), XML('↓')) , editable=auth.has_membership('editor_group'), deletable=auth.has_membership('delete_group'), create=auth.has_membership('create'), showbuttontext=False) if i use create=auth.has_membership('create'), then user can add record in both tables. -- 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] smart_sql_grid
i am using sql smqrt grid.I have parent table and child table. i want to restrict user to add record for parent table but that same user can add records in child table. query = ( ( db.parent.id >= 0)) grid = SQLFORM.smartgrid(db.parent,linked_tables=['child'], constraints = dict(tracker = query), paginate=15 ) , editable=auth.has_membership('editor_group'), deletable=auth.has_membership('delete_group'), create=auth.has_membership('create'), showbuttontext=False) if i give create=auth_membership(' create') it will give both table permission to add record. is there any method to solve that problem. -- 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] web2py grid Serch and query
how to limit the list which come by clicking on the sqlgrid default search. I have 10 fields in table. i do not want to show all the fields on list of default search. Can it possible to customize the list of default search widget. this i can in html drop down, but that is very complex and increase line code. i want to use default search widget. can you help me in that. I do not want to hide fields by using db.tablename.fieldname.writeable=false.i want to show all fields but list of drop down of search should be customize and 2 query is in my table i have one status field and blob field to store img. i want to show image in grid according to the status. Suppose if i select status High, in blob fields red color image should update , if low green color img should update in blob field. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: SQLFORM - field_id - not work
i think you want to fetch data of particular row...Please use the following code for the same def myfunctionit_detail(): links = [lambda row: A('Upload',_href=URL("default","myfunction",args=[row.id] ))] query = ((db.tracker.id>=0 ) ) grid = SQLFORM.grid(query=query, links=links,maxtextlength=250, sortable=True,csv=False ,fields=fields, paginate=40 , sorter_icons=(XML('↑'), XML('↓')) , editable=auth.has_membership('editor_group'), deletable=auth.has_membership('delete_group'), create=auth.has_membership('create'), showbuttontext=False) return dict(form =grid) On Monday, August 25, 2014 12:30:47 PM UTC+5:30, Dmitry Ermolaev wrote: > > SQLFORM.grid(db.pets, > field_id = db.pets.url, > > -- 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] how to compare dates with dal
i am trying to compare date with database. i am not able to get record. nov_pending = c_pcdt= db( (db.tracker.client_owner==auth.user.email ) &(db.tracker.Compliance_Area == 1)& (db.tracker.periodicity_due_date >= '2014-11-01')& (db.tracker.periodicity_due_date <= '2014-11-30')&(db.tracker.Complience_Status ==4) ).count() is there any mistake in the query -- 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] date format of date picker
I have form with date field i have setup default format(dd/mm/). i am using web2py sqlform. when i select date from date picker. it used to take dd/mm/yy. i know its very silly question. i had tried in ajax.html file and check my db file also but i am not able to find the solution. can any one help me to solve. i set default value: dd/mm/. when i edit the date it change to dd/mm/yy my ajax file {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} -- 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.