Example #1
0
    def test_add_person_column_later(self):
        new_type = self.new_temporary_type(
            behaviors=[IPerson.__identifier__],
            klass='seantis.people.types.base.PersonBase'
        )

        self.assertEqual(get_columns(new_type.lookupSchema()), [])

        with self.user('admin'):
            obj = api.content.create(
                id='123',
                type=new_type.id,
                container=self.new_temporary_folder(),
                foo='stop',
                bar='hammertime!'
            )

        # define the metadata after the obj has been created
        set_columns(new_type.lookupSchema(), [['foo']])

        # which leaves the attribute in a missing value state
        brain = tools.get_brain_by_object(obj, catalog_id)
        self.assertFalse(hasattr(brain, 'foo'))

        # until reindexing happens
        on_type_modified(new_type)
        brain = tools.get_brain_by_object(obj, catalog_id)
        self.assertEqual(brain.foo, 'stop')
 def test_load_column_schema(self):
     model = loadString(self.column_xml)
     self.assertEqual(
         get_columns(model.schema),
         [['first', 'second'], ['fourth']]
     )
     self.assertEqual(
         get_custom_column_titles(model.schema),
         [None, 'test']
     )
Example #3
0
def update_metadata(fti):
    compound_columns = get_compound_columns()

    for column in get_columns(fti.lookupSchema()):
        for field in column:
            tools.add_attribute_to_metadata(field, catalog_id)

            if field in compound_columns:
                tools.add_attribute_to_metadata(
                    compound_columns[field], catalog_id)
Example #4
0
def _get_schema_columns(schema, context, restricted):
    columns = []
    titles = get_custom_column_titles(schema)

    for ix, fields in enumerate(get_columns(schema)):
        if restricted:
            fields = [
                f for f in fields if has_read_access(schema, f, context)
            ]

        if fields:
            columns.append(SchemaColumn(schema, fields, titles[ix]))

    return columns