def __init__(self, validHtml=__undefinedC__, indexed=False, languages=None, maxLength=200000, *args, **kwargs): baseBone.__init__(self, *args, **kwargs) if indexed: raise NotImplementedError( "indexed=True is not supported on textBones") if self.multiple: raise NotImplementedError( "multiple=True is not supported on textBones") if validHtml == textBone.__undefinedC__: global _defaultTags validHtml = _defaultTags if not (languages is None or (isinstance(languages, list) and len(languages) > 0 and all([isinstance(x, basestring) for x in languages]))): raise ValueError("languages must be None or a list of strings ") self.languages = languages self.validHtml = validHtml self.maxLength = maxLength if self.languages: self.defaultValue = LanguageWrapper(self.languages)
def __init__(self, boundsLat, boundsLng, gridDimensions, indexed=True, *args, **kwargs): """ Initializes a new spatialBone. :param boundsLat: Outer bounds (Latitude) of the region we will search in. :type boundsLat: (int, int) :param boundsLng: Outer bounds (Latitude) of the region we will search in. :type boundsLng: (int, int) :param gridDimensions: Number of sub-regions the map will be divided in :type gridDimensions: (int, int) """ baseBone.__init__(self, *args, indexed=indexed, **kwargs) assert indexed, "spatialBone must be indexed! You want to search using it - don't you?" assert isinstance(boundsLat, tuple) and len( boundsLat) == 2, "boundsLat must be a tuple of (int, int)" assert isinstance(boundsLng, tuple) and len( boundsLng) == 2, "boundsLng must be a tuple of (int, int)" assert isinstance(gridDimensions, tuple) and len( gridDimensions ) == 2, "gridDimensions must be a tuple of (int, int)" self.boundsLat = boundsLat self.boundsLng = boundsLng self.gridDimensions = gridDimensions
def __init__(self, kind=None, module=None, refKeys=None, parentKeys=None, multiple=False, format="$(dest.name)", using=None, *args, **kwargs): """ Initialize a new relationalBone. :param kind: KindName of the referenced property. :type kind: String :param module: Name of the modul which should be used to select entities of kind "type". If not set, the value of "type" will be used (the kindName must match the moduleName) :type type: String :param refKeys: A list of properties to include from the referenced property. These properties will be avaiable in the template without having to fetch the referenced property. Filtering is also only possible by properties named here! :type refKeys: List of Strings :param parentKeys: A list of properties from the current skeleton to include. If mixing filtering by relational properties and properties of the class itself, these must be named here. :type parentKeys: List of Strings :param multiple: If True, allow referencing multiple Elements of the given class. (Eg. n:n-relation. otherwise its n:1 ) :type multiple: False :param format: Hint for the admin how to display such an relation. See admin/utils.py:formatString for more information :type format: String """ baseBone.__init__(self, *args, **kwargs) self.multiple = multiple self.format = format #self._dbValue = None #Store the original result fetched from the db here so we have that information in case a referenced entity has been deleted if kind: self.kind = kind if module: self.module = module elif self.kind: self.module = self.kind if self.kind is None or self.module is None: raise NotImplementedError( "Type and Module of relationalbone's must not be None") if refKeys: if not "key" in refKeys: raise AttributeError("'key' must be included in refKeys!") self.refKeys = refKeys if parentKeys: if not "key" in parentKeys: raise AttributeError("'key' must be included in parentKeys!") self.parentKeys = parentKeys self.using = using
def __init__( self, creationMagic=False, updateMagic=False, date=True, time=True, localize=False, *args, **kwargs ): """ Initializes a new dateBone. :param creationMagic: Use the current time as value when creating an entity; ignoring this bone if the entity gets updated. :type creationMagic: bool :param updateMagic: Use the current time whenever this entity is saved. :type updateMagic: bool :param date: Should this bone contain a date-information? :type date: bool :param time: Should this bone contain time information? :type time: bool :param localize: Automatically convert this time into the users timezone? Only valid if this bone contains date and time-information! :type localize: bool """ baseBone.__init__( self, *args, **kwargs ) if creationMagic or updateMagic: self.readonly = True self.visible = False self.creationMagic = creationMagic self.updateMagic = updateMagic if not( date or time ): raise ValueError("Attempt to create an empty datebone! Set date or time to True!") if localize and not ( date and time ): raise ValueError("Localization is only possible with date and time!") self.date=date self.time=time self.localize = localize
def __init__(self, indexed=True, visible=False, readOnly=True, slices=2, sliceSize=0.5, *args, **kwargs ): """ Initializes a new randomSliceBone. """ if not indexed or visible or not readOnly: raise NotImplemented("A RandomSliceBone must be indexed, not visible and readonly!") baseBone.__init__( self, indexed=True, visible=False, readOnly=True, *args, **kwargs ) self.slices = slices self.sliceSize = sliceSize
def __init__(self, precision=0, min=-int(pow(2, 30)), max=int(pow(2, 30)), *args, **kwargs): """ Initializes a new NumericBone. :param precision: How may decimal places should be saved. Zero casts the value to int instead of float. :type precision: int :param min: Minimum accepted value (including). :type min: float :param max: Maximum accepted value (including). :type max: float """ baseBone.__init__(self, *args, **kwargs) self.precision = precision if not self.precision and "mode" in kwargs and kwargs[ "mode"] == "float": #Fallback for old API self.precision = 8 self.min = min self.max = max
def __init__(self, mode="rgb", *args, **kwargs): #mode rgb/rgba baseBone.__init__(self, *args, **kwargs) assert mode in ["rgb", "rgba"] self.mode = mode
def __init__(self, kind=None, module=None, refKeys=None, parentKeys=None, multiple=False, format="$(dest.name)", using=None, updateLevel=0, *args, **kwargs): """ Initialize a new relationalBone. :param kind: KindName of the referenced property. :type kind: str :param module: Name of the module which should be used to select entities of kind "type". If not set, the value of "type" will be used (the kindName must match the moduleName) :type type: str :param refKeys: A list of properties to include from the referenced property. These properties will be available in the template without having to fetch the referenced property. Filtering is also only possible by properties named here! :type refKeys: list of str :param parentKeys: A list of properties from the current skeleton to include. If mixing filtering by relational properties and properties of the class itself, these must be named here. :type parentKeys: list of str :param multiple: If True, allow referencing multiple Elements of the given class. (Eg. n:n-relation. otherwise its n:1 ) :type multiple: False :param format: Hint for the admin how to display such an relation. See admin/utils.py:formatString for more information :type format: str :type format: String :param updateLevel: level 0==always update refkeys (old behavior), 1==update refKeys only on rebuildSearchIndex, 2==update only if explicitly set :type updateLevel: int """ baseBone.__init__(self, *args, **kwargs) self.multiple = multiple self.format = format #self._dbValue = None #Store the original result fetched from the db here so we have that information in case a referenced entity has been deleted if kind: self.kind = kind if module: self.module = module elif self.kind: self.module = self.kind if self.kind is None or self.module is None: raise NotImplementedError( "Type and Module of relationalbone's must not be None") if refKeys: if not "key" in refKeys: raise AttributeError("'key' must be included in refKeys!") self.refKeys = refKeys if parentKeys: if not "key" in parentKeys: raise AttributeError("'key' must be included in parentKeys!") self.parentKeys = parentKeys self.using = using self.updateLevel = updateLevel if getSystemInitialized(): from server.skeleton import RefSkel, skeletonByKind self._refSkelCache = RefSkel.fromSkel(skeletonByKind(self.kind), *self.refKeys) self._usingSkelCache = using() if using else None else: self._refSkelCache = None self._usingSkelCache = None