Appointment Manager

236 views
Skip to first unread message

Tom Russell

unread,
Jun 26, 2013, 12:55:46 PM6/26/13
to web...@googlegroups.com
I am using the appointment manager from https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager.

I have tweaked it to my needs and works well so far but there is an issue trying to use SQLFORM.grid.

I get an error 

<type 'exceptions.TypeError'> <lambda>() takes exactly 1 argument (2 given)


by doing this:

def appointment_select():
    grid = SQLFORM.grid(db.t_appointment, deletable=True, editable=True, create=False, maxtextlength=64, paginate=25)

    return dict(grid=grid)

I cannot figure out why it is doing this.

Any ideas?

Richard Vézina

unread,
Jun 26, 2013, 1:21:57 PM6/26/13
to web2py-users
 Take care, I don't know if it has been solve, but I found a memory leak in this app caused by the way FullCalendar is integrated... I solve the issue for my own need by using the json feed feature of FullCalendar doing a simple json feed function returning a well formatted json object with simplejson dump.

Richard


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

Richard Vézina

unread,
Jun 26, 2013, 1:22:58 PM6/26/13
to web2py-users
Letting FullCalendar consume the json feed...

Tom Russell

unread,
Jun 26, 2013, 1:31:33 PM6/26/13
to web...@googlegroups.com
Well I updated to the latest fullcalendar and it seems to work good, but do not know if the memory leak still exists. By any chance could you share what you did? Also, any chance you added views for week/day in it?

You can see in the example here http://arshaw.com/fullcalendar/ that it has buttons for day and week also. I tried fiddling with some examples to get it to show but am not successful yet.

Thanks.

Richard Vézina

unread,
Jun 26, 2013, 1:51:03 PM6/26/13
to web2py-users
The memory leak was only perceptible with large dataset... Each time the calendar view is call there is a memory build up until saturation... So I gues that it could happen when web2py is not restarted during a certain periode and calendar view is call many many time with a smaller dataset...

You could use web2py feature to generate data and investigate if the leak is still there, or you can check the date of the app build... If it before january 2013, there surely still a memory leak...

I can provide a code sample for a json feed function, but you will need to adapt to suit your need...

Here an example :

# Controller
def calendar():
    a='' # empty view only to allow to create a callable view to initialize the FullCalendar plugin
    return dict(a=a)

def calendar_json_feed():
    rows=db(db.your_table.id>0).select(db.your_table.id, orderby=db.your_table.order_field_if_required, cache=(cache.ram, 86400)) # 1 day = 86400 sec
        # Order issue solve by order in FullCalendar. There is a specific order issue with chrome : https://code.google.com/p/fullcalendar/issues/detail?id=379
        # To workaround Chrome specific issue I could increment start time of event of 1 sec
    events = []
    for i,row in enumerate(rows):
        events.append({'title': id_represent[row.id],
            'allDay': False,
            'start': row.date.strftime('%Y-%m-%d 08:30:00'), # Leading zero is important for Firefox, comment 2 in answer : http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox
            'end': row.date.strftime('%Y-%m-%d 09:30:00'),
            'url': URL(c='your_controller', f='your_function', args=('your_table', row.id))})
    from gluon.contrib import simplejson
    return simplejson.dumps(events)


# View
{{response.files.append(URL(r=request,c='static',f='js/fullcalendar.min.js'))}}
{{response.files.append(URL(r=request,c='static',f='js/gcal.js'))}}
{{response.files.append(URL(r=request,c='static',f='css/fullcalendar.css'))}}
{{'''response.files.append(URL(r=request,c='static',f='css/fullcalendar.print.css'))'''}}

{{extend 'layout.html'}}

<h1>{{=T('Calendar')}}</h1>

<div id="calendar"></div>

<script type='text/javascript'>
  jQuery(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            editable: false,
            eventMouseover: function(calEvent, jsEvent, view) {
                                savBg = $(this).css("background-color");
                                savClr = $(this).css("color");
                                $(this).css( { color:'#fff', backgroundColor:"#006" } );
                        }, // To set the underline onMouseOver to be white
            eventSources: [
                // Ex.: Google calendar
                // className: 'gcal-event',
                // currentTimezone: 'America/Montreal'},
                {url: '/your_app_name/your_controller/calendar_json_feed', 'color': 'rgb(84, 132, 237)', cache: true},
                // you can insert here all the other json feed you want for the stuff you want to display, you can change color to make those differents groups of events distinctive
                ],
            // feed by simplejson function
            //[
            //    {
            //    title: "S-20120215-U219-2p",
            //    allDay: false,
            //    start: "2013-03-22 08:30:00", // Leading zero is important for Firefox, comment 2 in answer : http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox
            //    end: "2013-03-22 09:30:00",
            //    url: '/sgddms/lotns/read/lotns_sample/623'
            //    }
            //    ],
            header: {
                left:   'today prevYear,nextYear prev,next',
                center: 'title',
                right:  'month,basicWeek,basicDay'
            },
            {{if T.accepted_language.split('-')[0] == 'fr':}}
                timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
            {{pass}}
            monthNames: ["{{=T('January')}}",
                "{{=T('February')}}",
                "{{=T('March')}}",
                "{{=T('April')}}",
                "{{=T('May')}}",
                "{{=T('June')}}",
                "{{=T('July')}}",
                "{{=T('August')}}",
                "{{=T('September')}}",
                "{{=T('October')}}",
                "{{=T('November')}}",
                "{{=T('December')}}"],
            dayNames: ["{{=T('Sunday')}}",
                "{{=T('Monday')}}",
                "{{=T('Tuesday')}}",
                "{{=T('Wednesday')}}",
                "{{=T('Thursday')}}",
                "{{=T('Friday')}}",
                "{{=T('Saturday')}}"],
            dayNamesShort: ["{{=T('Sun')}}",
                "{{=T('Mon')}}",
                "{{=T('Tue')}}",
                "{{=T('Wed')}}",
                "{{=T('Thu')}}",
                "{{=T('Fri')}}",
                "{{=T('Sat')}}"],
            buttonText: {
                prev:     '&nbsp;&#9668;&nbsp;',  // left triangle
                next:     '&nbsp;&#9658;&nbsp;',  // right triangle
                prevYear: '&nbsp;&#9668;&#9668;&nbsp;', // <<
                nextYear: '&nbsp;&#9658;&#9658;&nbsp;', // >>
                today:    "{{=T('today')}}",
                month:    "{{=T('month')}}",
                week:     "{{=T('week')}}",
                day:      "{{=T('day')}}"
            }

        });

    });
</script>


Since I save you a lot of time you can consider to update the AppointmentManager app with this example to return to community :


Richard

Richard Vézina

unread,
Jun 26, 2013, 1:52:52 PM6/26/13
to web2py-users
I think I cover the week, day, month stuff in your last mail... But it just a matter of initialize the plugin has you want... Just read the plugin doc about that...

Richard

Tom Russell

unread,
Jun 26, 2013, 1:54:03 PM6/26/13
to web...@googlegroups.com
Ok thank you. I will update the code for everyone once I have it working.


Richard Vézina

unread,
Jun 26, 2013, 2:01:16 PM6/26/13
to web2py-users
:)
Reply all
Reply to author
Forward
0 new messages