예제 #1
0
 def __init__(self, context, request):
     super(ContainerJSONBrowserView, self).__init__(context, request)
     self.domain_model = proxy.removeSecurityProxy(
         self.context).domain_model
     self.domain_interface = model.queryModelInterface(self.domain_model)
     self.domain_annotation = model.queryModelDescriptor(
         self.domain_interface)
     self.fields = tuple(
         container.getFields(self.context, self.domain_interface,
                             self.domain_annotation))
     # table keys
     self.table = orm.class_mapper(self.domain_model).mapped_table
     self.utk = dict([(self.table.columns[k].key, k)
                      for k in self.table.columns.keys()])
     # sort_on defaults: [str]
     self.defaults_sort_on = getattr(self.domain_model, "sort_on", None)
     # sort_on parameter name: str
     # pick off request, if necessary setting it from the first name
     # defined in defaults_sort_on
     if not self.request.get("sort") and self.defaults_sort_on:
         self.request.form["sort"] = u"sort_%s" % (self.defaults_sort_on[0])
     self.sort_on = request.get("sort")
     # sort_dir: "desc" | "asc"
     # pick off request, if necessary setting it from default in
     # domain model, else "desc"
     if not self.request.get("dir"):
         self.request.form["dir"] = unicode(
             getattr(self.domain_model, "sort_dir", "desc"))
     self.sort_dir = self.request.get("dir")
예제 #2
0
    def __init__(self, context, request):
        super(ContainerJSONBrowserView, self).__init__(context, request)
        self.domain_model = proxy.removeSecurityProxy(
            self.context).domain_model
        ti = capi.get_type_info(self.domain_model)
        derived_table_schema = ti.derived_table_schema
        self.domain_annotation = ti.descriptor_model
        self.fields = tuple(
            container.getFields(self.context, derived_table_schema,
                                self.domain_annotation))
        # table keys
        self.table = orm.class_mapper(self.domain_model).mapped_table
        self.utk = dict([(column.key, column)
                         for column in self.table.columns])

        # sort_on defaults: [str]
        self.defaults_sort_on = getattr(self.domain_annotation, "sort_on",
                                        None)
        # sort_on parameter name: str
        # pick off request, if necessary setting it from the first name
        # defined in defaults_sort_on
        if not self.request.get("sort") and self.defaults_sort_on:
            self.request.form["sort"] = u"sort_%s" % (self.defaults_sort_on[0])
        self.sort_on = request.get("sort")
        # sort_dir: "desc" | "asc"
        # pick off request, if necessary setting it from default in
        # domain model, else "desc"
        if not self.request.get("dir"):
            self.request.form["dir"] = unicode(
                getattr(self.domain_annotation, "sort_dir", "desc"))
        self.sort_dir = self.request.get("dir")
        _sort_dir_funcs = dict(asc=sql.asc, desc=sql.desc)
        self.sort_dir_func = _sort_dir_funcs.get(self.sort_dir, sql.desc)
예제 #3
0
 def __init__(self, context, request):
     super(ContainerJSONBrowserView, self).__init__(context, request)
     self.domain_model = proxy.removeSecurityProxy(
         self.context).domain_model
     self.domain_interface = model.queryModelInterface(self.domain_model)
     self.domain_annotation = model.queryModelDescriptor(
         self.domain_interface)
     self.fields = tuple(container.getFields(
         self.context, self.domain_interface, self.domain_annotation))
     # table keys
     self.table = orm.class_mapper(self.domain_model).mapped_table
     self.utk = dict(
         [ (column.key, column) for column in self.table.columns ])
     
     # sort_on defaults: [str]
     self.defaults_sort_on = getattr(self.domain_model, "sort_on", None)
     # sort_on parameter name: str
     # pick off request, if necessary setting it from the first name
     # defined in defaults_sort_on
     if not self.request.get("sort") and self.defaults_sort_on:
         self.request.form["sort"] = u"sort_%s" % (self.defaults_sort_on[0])
     self.sort_on = request.get("sort")
     # sort_dir: "desc" | "asc"
     # pick off request, if necessary setting it from default in
     # domain model, else "desc"
     if not self.request.get("dir"):
         self.request.form["dir"] = unicode(
             getattr(self.domain_model, "sort_dir", "desc"))
     self.sort_dir = self.request.get("dir")
예제 #4
0
 def __init__(self, context, request):
     super(ContainerJSONBrowserView, self).__init__(context, request)
     self.domain_model = proxy.removeSecurityProxy(
         self.context).domain_model
     ti = capi.get_type_info(self.domain_model)
     derived_table_schema = ti.derived_table_schema
     self.domain_annotation = ti.descriptor_model
     self.fields = tuple(container.getFields(
         self.context, derived_table_schema, self.domain_annotation))
     # table keys
     self.table = orm.class_mapper(self.domain_model).mapped_table
     self.utk = dict(
         [ (column.key, column) for column in self.table.columns ])
     
     # sort_on defaults: [str]
     self.defaults_sort_on = getattr(self.domain_annotation, "sort_on", None)
     # sort_on parameter name: str
     # pick off request, if necessary setting it from the first name
     # defined in defaults_sort_on
     if not self.request.get("sort") and self.defaults_sort_on:
         self.request.form["sort"] = u"sort_%s" % (self.defaults_sort_on[0])
     self.sort_on = request.get("sort")
     # sort_dir: "desc" | "asc"
     # pick off request, if necessary setting it from default in
     # domain model, else "desc"
     if not self.request.get("dir"):
         self.request.form["dir"] = unicode(
             getattr(self.domain_annotation, "sort_dir", "desc"))
     self.sort_dir = self.request.get("dir")
     _sort_dir_funcs = dict(asc=sql.asc, desc=sql.desc)
     self.sort_dir_func = _sort_dir_funcs.get(self.sort_dir, sql.desc)