@staticmethod
    def formlist():
        """
            Retrieve a list of available XForms

            @return: a list of tuples (url, title) of available XForms
        """

        resources = current.deployment_settings.get_xforms_resources()

        xforms = []
        if resources:
            s3db = current.s3db
            for item in resources:

                # Parse item options
                options = {}
                if isinstance(item, (tuple, list)):
                    if len(item) == 2:
                        title, tablename = item
                        if isinstance(tablename, dict):
                            tablename, options = title, tablename
                            title = None
                    elif len(item) == 3:
                        title, tablename, options = item
                    else:
                        continue
                else:
                    title, tablename = None, item

                # Get the resource
                try:
                    resource = s3db.resource(tablename)
                except AttributeError:
                    current.log.warning("XForms: non-existent resource %s" % tablename)
                    continue

                if title is None:
                    title = " ".join(w.capitalize() for w in resource.name.split("_"))

                # Options can override target controller/function and URL vars
                c = options.get("c", "xforms")
                f = options.get("f", "forms")
                url_vars = options.get("vars", {})

                config = resource.get_config("xform")
                if config:
                    if isinstance(config, dict):
                        # Template-based XForm
                        collection = config.get("collection")
                        if not collection:
                            continue
                        table = resource.table
                        DELETED = current.xml.DELETED
                        if DELETED in table:
                            query = table[DELETED] != True
                        else:
                            query = table.id > 0
                        public = options.get("check", "public")
                        if public in table:
                            query &= table[public] == True
                        title_field = options.get("title", "name")
                        # @todo: audit
                        rows = current.db(query).select(table._id,
                                                        table[title_field],
                                                        )
                        native = c == "xforms"
                        for row in rows:
                            if native:
                                args = [tablename, row[table._id]]
                            else:
                                args = [row[table._id], "xform.xhtml"]
                            url = URL(c = c,
                                      f = f,
                                      args = args,
                                      vars = url_vars,
                                      host = True,
                                      extension = "",
                                      )
                            xforms.append((url, row[title_field]))
                    else:
                        # Custom XForm => not supported yet, skip
                        continue
                else:
                    # Introspective XForm
                    if c == "xforms":
                        args = [tablename]
                    else:
                        args = ["xform.xhtml"]
                    url = URL(c = c,
                              f = f,
                              args = args,
                              vars = url_vars,
                              host = True,
                              extension = "",
                              )
                    xforms.append((url, title))

        return xforms

# =============================================================================
dataset/ETHPy150Open sahana/eden/modules/s3/s3xforms.py/S3XForms.formlist/original