def _as_cfacet ( self, original_facet ): """ Returns the low-level C-based facet for this FacetValue. """ if self.default is not None: facet = CFacet( 0 ) facet.clone( original_facet ) if original_facet.__dict__ is not None: facet.__dict__ = original_facet.__dict__.copy() facet.default_value( 7, ( self.default, self.args, self.kw ) ) elif self.type is not None: type = self.type try: rc = issubclass( type, FacetType ) except: rc = False if rc: type = type( *self.args, **self.kw ) if not isinstance( type, FacetType ): raise FacetError( ("The 'type' attribute of a FacetValue instance must be a " "FacetType instance or subclass, but a value of %s was " "specified.") % self.facet ) self._cfacet = facet = type.as_cfacet() facet.value_allowed( True ) elif self.delegate is None: return None else: if self.name == '': raise FacetError( "You must specify a non-empty string value for the 'name' " "attribute when using the 'delegate' facet of a FacetValue " "instance." ) metadata = { 'type': 'property', '_facet_value': self, 'transient': True } getter = self._delegate_getter setter = self._delegate_setter validate = None self.add_facet( 'value', Event() ) self.delegate.on_facet_set( self._delegate_modified, self.name + '[]' ) facet = self._property_facet( getter, setter, validate, metadata ) return facet
def as_cfacet ( self, original_facet ): """ Returns the low-level C-based facet for this FacetValue. """ notifiers = original_facet._notifiers( 0 ) if self._cfacet is not None: if (notifiers is None) or (len( notifiers ) == 0): return self._cfacet facet = CFacet( 0 ) facet.clone( self._cfacet ) else: facet = self._as_cfacet( original_facet ) if ((facet is not None) and (notifiers is not None) and (len( notifiers ) > 0)): facet._notifiers( 1 ).extend( notifiers ) return facet