def _update_sync(self, resource, filters, selected_repository_id, properties):

        db = current.db
        s3db = current.s3db
        auth = current.auth
        user_id = auth.user.id
        utcnow = current.request.utcnow

        if properties:
            old_repository_id = properties["repository_id"]
            if old_repository_id != selected_repository_id:
                # Update
                properties["repository_id"] = selected_repository_id
        else:
            # First Run
            properties = {"repository_id": selected_repository_id}
            old_repository_id = selected_repository_id

        # Sync Task
        sync_task_table = s3db.sync_task

        # Check if task already exists
        query = (sync_task_table.deleted != True) & \
                (sync_task_table.owned_by_user == user_id) & \
                (sync_task_table.repository_id == old_repository_id)

        row = db(query).select(sync_task_table.id,
                               sync_task_table.repository_id,
                               limitby=(0, 1)).first()
        if row:
            old_sync_id = properties["sync_task_id"]
            # Check if update?
            if row.repository_id != selected_repository_id:
                # Update
                db(sync_task_table.repository_id == old_repository_id).\
                                update(repository_id = selected_repository_id)
            sync_task_id = properties["sync_task_id"] = row.id
        else:
            # First Run
            sync_task_data = {"repository_id": selected_repository_id,
                              "resource_name": resource,
                              "mode": 2, #Push
                              "strategy": ["create"], # Alert updates are done
                                                      # as extra info elements
                              "representation": "cap",
                              "multiple_file": True,
                              "last_push": utcnow, # since used for notifications,
                                                   # so don't send old alerts
                              }
            sync_task_id = sync_task_table.insert(**sync_task_data)
            auth.s3_set_record_owner(sync_task_table, sync_task_id)
            old_sync_id = properties["sync_task_id"] = sync_task_id

        # Sync Resource Filter

        # Remove Old Filter and create new
        query = (FS("task_id") == old_sync_id)
        s3db.resource("sync_resource_filter", filter=query).delete()

        # Normally a filter looks like this
        # [["priority__belongs","24,3"],[u'location_id$L0__belongs', u'Nepal'],
        # [u'location_id$L1__belongs', u'Central']]
        # Get only those that have value and ignore null one
        filters = json.loads(filters)
        filters = [filter_ for filter_ in filters if filter_[1] is not None]

        sync_resource_filter_table = s3db.sync_resource_filter
        if len(filters) > 0:
            for filter_ in filters:
                # Get the prefix
                prefix = str(filter_[0]).strip("[]")
                # Get the value for prefix
                values = str(filter_[1])
                # Set the Components
                if prefix in ["event_type_id__belongs",
                              "priority__belongs",
                              "language__belongs"]:
                    component = "info"
                else:
                    component = "area_location"

                filter_string = "%s.%s=%s" % (component, prefix, values)
                resource_filter_data = {"task_id": sync_task_id,
                                        "tablename": resource,
                                        "filter_string": filter_string,
                                        "modified_on": utcnow,
                                        }
                resource_filter_id = sync_resource_filter_table. \
                                        insert(**resource_filter_data)
                row = db(sync_resource_filter_table.id == resource_filter_id).\
                                                select(limitby=(0, 1)).first()
                auth.s3_set_record_owner(sync_resource_filter_table,
                                         resource_filter_id)
                s3db.onaccept(sync_resource_filter_table, row)

        return properties

    # -------------------------------------------------------------------------
Get list of basic mayavi plugins that do not add any views or
dataset/ETHPy150Open sahana/eden/modules/templates/SAMBRO/controllers.py/subscriptions._update_sync--crossover with--dataset/ETHPy150Open enthought/mayavi/mayavi/plugins/app.py/get_non_gui_plugins