Esempio n. 1
0
 def __setitem__(self, key, value):
     if not _is_schema_element(self.struct._schema[key]):
         raise TypeError(
             "Property '%s.%s' of type %s cannot be referenced with an URL"
             % (type(self.struct).__name__, key,
                self.struct._schema[key].__name__))
     setattr(self.struct, key, value)
def _single_element( seq ):
	if seq is None or schema._is_schema_element( type(seq) ):	return seq
	first = True
	for elt in seq:
		if not first: raise ValueError( "Sequence contains more than one element" )
		first = False
	if first: raise ValueError( "Sequence contains no elements" )
	return elt
Esempio n. 3
0
def _single_element(seq):
    if seq is None or schema._is_schema_element(type(seq)): return seq
    first = True
    for elt in seq:
        if not first:
            raise ValueError("Sequence contains more than one element")
        first = False
    if first: raise ValueError("Sequence contains no elements")
    return elt
	def __setitem__( self, key, value ):
		if not _is_schema_element( self.struct._schema[key] ):
			raise TypeError( "Property '%s.%s' of type %s cannot be referenced with an URL" % ( type(self.struct).__name__, key, self.struct._schema[key].__name__ ) )
		setattr( self.struct, key, value )