Exemple #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")
 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")
Exemple #3
0
 def __init__(self, **kw):
     try:
         domain_schema = model.queryModelInterface(type(self))
         known_names = [ k for k, d in domain_schema.namesAndDescriptions(1) ]
     except Exception, e:
         log.error("Failed queryModelInterface(%s): %s: %s" % (
             type(self), type(e).__name__, e))
         known_names = None
    def __init__(self, **kw):
        try:
            domain_schema = model.queryModelInterface(self.__class__)
            known_names = [k for k, d in domain_schema.namesAndDescriptions(1)]
        except:
            known_names = None

        for k, v in kw.items():
            if known_names is None or k in known_names:
                setattr(self, k, v)
            else:
                log.error("Invalid attribute on %s %s" % (self.__class__.__name__, k))
Exemple #5
0
    def __init__(self, **kw):
        try:
            domain_schema = model.queryModelInterface(self.__class__)
            known_names = [k for k, d in domain_schema.namesAndDescriptions(1)]
        except:
            known_names = None

        for k, v in kw.items():
            if known_names is None or k in known_names:
                setattr(self, k, v)
            else:
                log.error("Invalid attribute on %s %s" %
                          (self.__class__.__name__, k))
def getFields(context, interface=None, annotation=None):
    """Generator of all fields that will be displayed in a containerlisting .
    
    Redefines alchemist.ui.container.getFields, making use of the 
    listing_columns declaration of the field's descriptor.
    """
    if interface is None: 
        domain_model = proxy.removeSecurityProxy(context.domain_model)
        interface = model.queryModelInterface(domain_model)
    if annotation is None:
        annotation = model.queryModelDescriptor(interface)
    for column in annotation.listing_columns:
        yield interface[column]
def getFields(context, interface=None, annotation=None):
    """Generator of all fields that will be displayed in a containerlisting .
    
    Redefines alchemist.ui.container.getFields, making use of the 
    listing_columns declaration of the field's descriptor.
    """
    if interface is None:
        domain_model = proxy.removeSecurityProxy(context.domain_model)
        interface = model.queryModelInterface(domain_model)
    if annotation is None:
        annotation = model.queryModelDescriptor(interface)
    for column in annotation.listing_columns:
        yield interface[column]
def getFields(context, interface=None, annotation=None):
    """Generator of all [zope.schema] fields that will be displayed in a 
    container listing.
    
    Redefines alchemist.ui.container.getFields, making use of the 
    @listing_columns property of the ModelDescriptor class.
    """
    if interface is None:
        domain_model = proxy.removeSecurityProxy(context.domain_model)
        interface = model.queryModelInterface(domain_model)
    if annotation is None:
        annotation = model.queryModelDescriptor(interface)
    for field_name in annotation.listing_columns:
        yield interface[field_name]
def getFields(context, interface=None, annotation=None):
    """Generator of all [zope.schema] fields that will be displayed in a 
    container listing.
    
    Redefines alchemist.ui.container.getFields, making use of the 
    @listing_columns property of the ModelDescriptor class.
    """
    if interface is None:
        domain_model = proxy.removeSecurityProxy(context.domain_model)
        interface = model.queryModelInterface(domain_model)
    if annotation is None:
        annotation = model.queryModelDescriptor(interface)
    for field_name in annotation.listing_columns:
        yield interface[field_name]
Exemple #10
0
 def defineIndexes(self, indexer):
     """
     define field indexes on the catalog at app server startup (note, xapian 
     doesn't allow for changing field definitions without reindexing) ... 
     see sync index script.
     """
     content_schema = model.queryModelInterface(self.domain_model)
     if interfaces.ENABLE_LOGGING: log.debug('generating indexing schema %r'%content_schema)
     for field in schema.getFields(content_schema).values():
         if field.__name__ in self.action_fields:
             continue
         if not isinstance(field, (schema.Text, schema.ASCII)):
             continue
         if interfaces.ENABLE_LOGGING: log.info(" indexing field %s"%field.__name__)
         indexer.add_field_action(
             field.__name__, xappy.FieldActions.INDEX_FREETEXT, language='en')
Exemple #11
0
 def __init__(self, context):
     self.context = context
     self.domain_model = removeSecurityProxy(self.context).domain_model
     self.domain_interface = model.queryModelInterface(self.domain_model)
     self.domain_annotation = model.queryModelDescriptor(
         self.domain_interface)
 def __init__(self, context):
     self.context = context
     self.domain_model = removeSecurityProxy(self.context).domain_model
     self.domain_interface = model.queryModelInterface(self.domain_model)
     self.domain_annotation = model.queryModelDescriptor(self.domain_interface)