コード例 #1
0
def build_adaptee(field, expand_collection=True):
    '''Build an adaptee vector for a field instance.
    
    This vector is to be used while trying to adapt on fields (for serialization,
    formatting, widgets etc.).
    '''

    # Load (if not already) the object-factory lookup function. 
    # Note it must be lazily loaded, as is not available at module's load time.
    from ckanext.publicamundi.lib.metadata import factory_for
    
    # Build adaptee vector

    adaptee = [field]
    
    if not expand_collection:
        return adaptee

    y = field
    while IContainerField.providedBy(y):
        adaptee.append(y.value_type)
        y = y.value_type
     
    if not (y is field) and IObjectField.providedBy(y):
        # Need a multiadapter for a (probably nested) container of objects:
        # replace field (instance of ObjectField) with a dummy object
        adaptee[-1] = factory_for(y.schema)()

    return adaptee
コード例 #2
0
def build_adaptee(field, expand_collection=True):
    '''Build an adaptee vector for a field instance.
    
    This vector is to be used while trying to adapt on fields (for serialization,
    formatting, widgets etc.).
    '''

    # Load (if not already) the object-factory lookup function.
    # Note it must be lazily loaded, as is not available at module's load time.
    from ckanext.publicamundi.lib.metadata import factory_for

    # Build adaptee vector

    adaptee = [field]

    if not expand_collection:
        return adaptee

    y = field
    while IContainerField.providedBy(y):
        adaptee.append(y.value_type)
        y = y.value_type

    if not (y is field) and IObjectField.providedBy(y):
        # Need a multiadapter for a (probably nested) container of objects:
        # replace field (instance of ObjectField) with a dummy object
        adaptee[-1] = factory_for(y.schema)()

    return adaptee
コード例 #3
0
ファイル: logic.py プロジェクト: avnik/method_repo
 def __getitem__(self, key):
     field = self.schema[key]
     if IContainer.providedBy(field):
         return VirtualList(self, key, self.context, field.value_type)
     elif IObject.providedBy(field):
         return VirtualSection(self, key, self.context, field.schema)
     raise KeyError(key)
コード例 #4
0
ファイル: logic.py プロジェクト: avnik/method_repo
def compound_field(field):
    return IContainer.providedBy(field) or IObject.providedBy(field)