@staticmethod
    def case_appointment_onaccept(form):

        # Read form data
        formvars = form.vars
        if "id" in formvars:
            record_id = formvars.id
        elif hasattr(form, "record_id"):
            record_id = form.record_id
        else:
            record_id = None
        if not record_id:
            return

        db = current.db
        s3db = current.s3db

        settings = current.deployment_settings

        person_id = formvars.get("person_id")
        case_id = formvars.get("case_id")

        if not person_id or not case_id:
            table = s3db.dvr_case_appointment
            row = db(table.id == record_id).select(table.case_id,
                                                   table.person_id,
                                                   limitby = (0, 1),
                                                   ).first()
            if row:
                person_id = row.person_id
                case_id = row.case_id

        if settings.get_dvr_appointments_update_last_seen_on() and person_id:
            # Update last_seen_on
            dvr_update_last_seen(person_id)

        # Update the case status if appointment is completed
        # NB appointment status "completed" must be set by this form
        if settings.get_dvr_appointments_update_case_status() and \
           s3_str(formvars.get("status")) == "4":

            # Get the case status to be set when appointment is completed today
            today = current.request.utcnow.date()
            ttable = s3db.dvr_case_appointment_type
            query = (table.id == record_id) & \
                    (table.deleted != True) & \
                    (ttable.id == table.type_id) & \
                    (ttable.status_id != None)
            row = db(query).select(table.date,
                                   ttable.status_id,
                                   limitby = (0, 1),
                                   ).first()
            if row:
                # Check whether there is a later appointment that
                # would have set a different case status (we don't
                # want to override this when closing appointments
                # restrospectively):
                date = row.dvr_case_appointment.date
                status_id = row.dvr_case_appointment_type.status_id
                query = (table.person_id == person_id)
                if case_id:
                    query &= (table.case_id == case_id)
                query &= (table.date != None) & \
                         (table.status == 4) & \
                         (table.date > date) & \
                         (table.deleted != True) & \
                         (ttable.id == table.type_id) & \
                         (ttable.status_id != None) & \
                         (ttable.status_id != status_id)
                later = db(query).select(table.id, limitby = (0, 1)).first()
                if later:
                    status_id = None
            else:
                status_id = None

            if status_id:
                # Update the corresponding case(s)
                # NB appointments without case_id update all cases for the person
                ctable = s3db.dvr_case
                stable = s3db.dvr_case_status
                query = (ctable.person_id == person_id) & \
                        (ctable.archived != True) & \
                        (ctable.deleted != True) & \
                        (stable.id == ctable.status_id) & \
                        (stable.is_closed != True)
                if case_id:
                    query &= (ctable.id == case_id)
                cases = db(query).select(ctable.id,
                                         ctable.person_id,
                                         ctable.archived,
                                         )
                has_permission = current.auth.s3_has_permission
                for case in cases:
                    if has_permission("update", ctable, record_id=case.id):
                        # Customise case resource
                        r = S3Request("dvr", "case",
                                      current.request,
                                      args = [],
                                      get_vars = {},
                                      )
                        r.customise_resource("dvr_case")
                        # Update case status + run onaccept
                        case.update_record(status_id = status_id)
                        s3db.onaccept(ctable, case, method="update")

    # -------------------------------------------------------------------------
Get some data from the TLS connection (socket emulation).
dataset/ETHPy150Open sahana/eden/modules/s3db/dvr.py/DVRCaseAppointmentModel.case_appointment_onaccept--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python3-alpha/python-libs/gdata/tlslite/TLSRecordLayer.py/TLSRecordLayer.recv