Пример #1
0
 def _setUpWidgets(self):
     adapted = self.schema(self.context)
     if adapted is not self.context:
         if not ILocation.providedBy(adapted):
             adapted = LocationProxy(adapted)
         adapted.__parent__ = self.context
     self.adapted = adapted
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)
Пример #2
0
 def _setUpWidgets(self):
     adapted = self.schema(self.context)
     if adapted is not self.context:
         if not ILocation.providedBy(adapted):
             adapted = LocationProxy(adapted)
         adapted.__parent__ = self.context
     self.adapted = adapted
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)
Пример #3
0
def assertLocation(adapter, parent):
    """Assert locatable adapters.

    This function asserts that the adapter get location-proxied unless it does
    not provide ILocation itself. Further more the returned locatable adapter
    get its parent set unless its __parent__ attribute is not None.

    see adapter.txt
    """
    # handle none-locatable adapters (A)
    if not ILocation.providedBy(adapter):
        locatable = LocationProxy(adapter)
        locatable.__parent__ = parent
        return locatable

    # handle locatable, parentless adapters (B)
    if adapter.__parent__ is None:
        adapter.__parent__ = parent
        return adapter

    # handle locatable, parentful adapters (C)
    else:
        return adapter