Beispiel #1
0
    def __init__(self, content_id, data=None, **kwargs):

        if not data:
            data = {}

        Persistent.__init__(self)
        Base.__init__(self, content_id, data=data)
Beispiel #2
0
 def __init__(self, name,
              display_file, original_file=None, thumbnail_file=None,
              description=None,
              location=None,
              date=datetime.datetime.now(),
              original_size=(-1, -1),
              display_size=(-1, -1),
              thumbnail_size=(-1, -1),
              parent=None):
     Persistent.__init__(self)
     PersistentLocationAware.__init__(self)
     self.__name__ = name
     self.__parent__ = parent
     self.display_file = display_file
     self.original_file = original_file
     self.thumbnail_file = thumbnail_file
     self.description = description
     self.location = location
     self.date = date
     self.original_width = original_size[0]
     self.original_height = original_size[1]
     self.display_width = display_size[0]
     self.display_height = display_size[1]
     self.thumbnail_width = thumbnail_size[0]
     self.thumbnail_height = thumbnail_size[1]
    def __getattribute__(self, name):
        """Get an attribute value

        See the very important note in the comment below!
        """
        #################################################################
        # IMPORTANT! READ THIS! 8->
        #
        # We *always* give Persistent a chance first.
        # Persistent handles certain special attributes, like _p_
        # attributes. In particular, the base class handles __dict__
        # and __class__.
        #
        # We call _p_getattr. If it returns True, then we have to
        # use Persistent.__getattribute__ to get the value.
        #
        #################################################################
        if Persistent._p_getattr(self, name):
            return Persistent.__getattribute__(self, name)

        # Data should be in our secret dictionary:
        secret = self.__dict__['__secret__']
        if name in secret:
            return secret[name]

        # Maybe it's a method:
        meth = getattr(self.__class__, name, None)
        if meth is None:
            raise AttributeError(name)

        return meth.__get__(self, self.__class__)
Beispiel #4
0
 def __setattr__(self, name, value):
     """If name is __parent__, write value to _v_parent. This avoids
     _p_changed to be set set by Persitent.__setattr__. Using a read/write
     property for __parent__ won't work.
     """
     if name == '__parent__':
         name = '_v_parent'
     Persistent.__setattr__(self, name, value)
Beispiel #5
0
 def __init__(self, username, email, password):
     Persistent.__init__(self)
     UserMixin.__init__(self)
     self.username = username
     self.email = email
     self.password = password
     self._set_defaults()
     self.uid = db['player_uid'].get_next_id()
Beispiel #6
0
 def _p_accessed(self):
     # The superclass has issues changing the MRU
     # during initial serialization because we're not
     # yet in the picklecache
     try:
         Persistent._p_accessed(self)
     except KeyError:
         pass
Beispiel #7
0
    def __init__(self, crumb_name, owner, id):
        Persistent.__init__(self)
        self.owner = owner
        self.timestamp = datetime.now()
        self.id = id

        # Name used in breadcrumps
        self.crumb_name = crumb_name
Beispiel #8
0
 def __init__(self):
     Persistent.__init__(self)
     UserMixin.__init__(self)
     self.uid = WORLD_UID
     self.username = '******'
     self.email = ''
     self._password = ''
     self._set_defaults()
Beispiel #9
0
 def __init__(self, name, contacts):
     Persistent.__init__(self)
     self.key           = contacts.maxKey() + 1
     self.__parent__    = contacts
     self.__name__      = self.key
     for heading in contacts.Headings:
         self.__setattr__(heading, "")
     self.name          = name
     contacts[self.key] = self
Beispiel #10
0
 def __getattr__(self, key):
     """Maps values to attributes.
     Only called if there *isn't* an attribute with this name
     """
     if Persistent._p_getattr(self, key):
         return Persistent.__getattribute__(self, key) 
     try:
         return self.__getitem__(key)
     except KeyError:
         raise AttributeError(key)
Beispiel #11
0
 def __init__(self, id=None):
     Persistent.__init__(self)
     if id is not None:
         self.ID = id
     else:
         self.ID = uuid.uuid4()
     self.Name = ""
     self.Attributes = PersistentMapping()
     self.TitleAttr = None
     self.Graphics = None
Beispiel #12
0
	def __init__(self, id = None):
		Persistent.__init__(self)
		if id is not None:
			self.ID = id
		else:
			self.ID = uuid.uuid4()
		self.Name = ""
		self.Attributes = PersistentMapping()
		self.TitleAttr = None
		self.Graphics = None
Beispiel #13
0
	def __init__(self, id = None):
		Persistent.__init__(self)
		if id is not None:
			self.ID = id
		else:
			self.ID = uuid.uuid4()
		self.TemplateName = ""
		self.Attributes = PersistentMapping()
		self.TitleAttr = None
		self.Graphics = None
		self.IsReflection = False
		self.Tag = None
Beispiel #14
0
 def __init__(self, id=None):
     Persistent.__init__(self)
     if id is not None:
         self.ID = id
     else:
         self.ID = uuid.uuid4()
     self.TemplateName = ""
     self.Attributes = PersistentMapping()
     self.TitleAttr = None
     self.Graphics = None
     self.IsReflection = False
     self.Tag = None
Beispiel #15
0
 def __setattr__(self, name, value):
   #only run this if the name is within the current objects attributes
   if self._v_book and name not in Persistent.__dict__:
     # if the book exists AND
     # if the value has changed
     # and that attribute is an indexable attribute
     # OR we want it to be indexed, however it is not actually in the index (this condition will be caught 
     # in updateIndexedValue)
     if self._v_book and self.__dict__.get(name) != value and name in self.indexableAttrs:
       self._v_book.updateIndexedValue(self, name, value)
     # save changes
     self._v_book.commitTransaction()
   Persistent.__setattr__(self, name, value)
Beispiel #16
0
 def __init__(
     self,
     transition_function=None,
     initial_state=0,
     data=None, transition_table=None):
     """Initialize with transition rules for each state, and optionally
     include the initial state (default 0) or data (default None).
     """
     Persistent.__init__(self)
     if transition_function != None:
         self.transition_function = transition_function
     self.__transition_table = transition_table
     self.__data = data
     self.__state = initial_state
Beispiel #17
0
 def __init__( self, name, owner, conference, modificationDate=None, createdInLocalServer=True, showRoom=False ):
     Persistent.__init__(self)
     self._name = name
     self._owner = owner
     self._creationDate = nowutc()
     self._conferences = PersistentMapping()
     self._conferences[conference.getId()] = conference
     self._modificationDate = modificationDate
     self._createdInLocalServer = createdInLocalServer
     self._showRoom = showRoom
     #the id will be assigned just before being stored in the DB.
     #If we try to create a counter now it will fail if it's the first chatroom
     #in the conference, since no indexes have been created yet
     self._id = None
Beispiel #18
0
 def __delattr__(self, name):
     if name.startswith('_p_') or name in struct_attrs:
         return Persistent.__delattr__(self, name)
     # Set _p_changed before deleting the attribute. See
     # comment above, on __setattr__
     self._p_changed = 1
     delattr(self.__proxied__, name, v)
Beispiel #19
0
 def __new__(cls, obj):
     inst = Persistent.__new__(cls)
     inst._wrapped = obj
     inst.__parent__ = None
     inst.__name__ = None
     inst._Persistent__flags = None
     return inst
    def __init__(self):
        Persistent.__init__(self)
        # mapping of front end transaction identifiers to
        # backend transaction state machines
        #
        # perhaps this should be volitile?
        self.__front_end_to_back = {}

        # mapping of front end transaction identifiers to an input
        # for that transaction's state machine
        self.dirty_transaction_set = {}
        # set of front end transaction identified that are dirty, but
        # but are considered impossible to syncronize and are thus being
        # held instead of subjected to failed attempt after failed
        # attempt to syncrhonize
        self.held_transaction_set = set()
Beispiel #21
0
 def __setattr__(self, name, v):
     if name.startswith('_p_') or name in struct_attrs:
         return Persistent.__setattr__(self, name, v)
     # Set _p_changed before calling the mutator on the
     # proxied object, so we have the object marked
     # as dirty even if an exception takes place later.
     self._p_changed = 1
     setattr(self.__proxied__, name, v)
Beispiel #22
0
 def __getattribute__(self, name):
     """ see http://svn.zope.org/ZODB/trunk/src/persistent/tests/test_overriding_attrs.py?rev=38214&view=markup """
     #allow persistent to handle any special attributes it needs
     if Persistent._p_getattr(self, name):
         return Persistent.__getattribute__(self, name)
     #otherwise, we use this hook point to see if the user is allowed to perform the action:
     if name == 'privileges':
         return super(Auth, self).__getattribute__(name)
     elif name == 'has_privileges_on':
         return super(Auth, self).__getattribute__(name)
     elif name == '_v_current_user':
         return super(Auth, self).__getattribute__(name)
     elif Auth._v_current_user is None:#this is the case at startup, or if config.USE_AUTH is False
         return super(Auth, self).__getattribute__(name)
     elif Auth._v_current_user.has_privileges_on(self.__class__.__name__, name) is True:
         return super(Auth, self).__getattribute__(name)
     raise PermissionError(Auth._v_current_user, ' does not have permission to access ' , name)
Beispiel #23
0
 def test_index_doc_persistent_value_raises(self):
     from persistent import Persistent
     OTHER_FACETS = ['foo', 'foo:bar', 'foo:baz']
     class Dummy:
         pass
     index = self._makeOne('facets', OTHER_FACETS)
     dummy = Dummy()
     dummy.facets = Persistent()
     self.assertRaises(ValueError, index.index_doc, 1, dummy)
 def __new__(cls, *args, **kargs):
     '''
     @return: Division_Transporte
     @author: 
     '''
     if cls.instance is None:
         cls.instance = Persistent.__new__(cls, *args, **kargs)
         cls.instance.inicialize()
     return cls.instance
Beispiel #25
0
 def test_index_doc_persistent_value_raises(self):
     from persistent import Persistent
     index = self._makeIndex('abc')
     index._docids = set()
     class Dummy:
         pass
     dummy = Dummy()
     dummy.abc = Persistent()
     self.assertRaises(ValueError, index.index_doc, 1, dummy)
Beispiel #26
0
 def __reduce__(self):
     # Swap out the type constructor for the C version, if present.
     func, typ_gna, state = Persistent.__reduce__(self)
     # We ignore the returned type altogether in favor of
     # our calculated class (which allows subclasses but replaces our exact
     # type with the C equivalent)
     typ = self.__class__
     gna = typ_gna[1:]
     return (func, (typ,) + gna, state)
Beispiel #27
0
 def __init__(self, name, big_image_view, regular_image_view,
              small_image_view, description=None, location=None,
              date=datetime.datetime.now(), parent=None):
     Persistent.__init__(self)
     PersistentLocationAware.__init__(self, name, parent)
     if isinstance(big_image_view, GalleryImageFile):
         self.big_image_view = GalleryImageView(big_image_view)
     else:
         assert isinstance(big_image_view, GalleryImageView)
         self.big_image_view = big_image_view
     if isinstance(regular_image_view, GalleryImageFile):
         self.regular_image_view = GalleryImageView(regular_image_view)
     else:
         assert isinstance(regular_image_view, GalleryImageView)
         self.regular_image_view = regular_image_view
     if isinstance(small_image_view, GalleryImageFile):
         self.small_image_view = GalleryImageView(small_image_view)
     else:
         assert isinstance(small_image_view, GalleryImageView)
         self.small_image_view = small_image_view
     self.description = description
     self.location = location
     self.date = date
Beispiel #28
0
    def __init__(self, settings = {}, initialValuesGenerator = None):
        ''' Init. settings provide many means to customize the spatial tree.
            E.g. setting leaf_capacity and near_minimum_overlap_factor to "good"
            values can help to reduce the possibility of write conflict errors.
            
            Below is a list of the currently available properties. For more info
            about these and other properties see the rtree docs and/or code.
            
                writethrough
                buffering_capacity
                pagesize
                leaf_capacity
                near_minimum_overlap_factor
                type
                variant
                dimension
                index_capacity
                index_pool_capacity
                point_pool_capacity
                region_pool_capacity
                tight_mbr
                fill_factor
                split_distribution_factor
                tpr_horizon
                reinsert_factor
                
            If you supply an initialValuesGenerator you can build a spatial index
            from initial values. This is much faster than doing repeated insert()s.
        '''
        Persistent.__init__( self )
        self.family = settings.pop( 'family', self.default_family )
        self.settings = PersistentDict( settings )
        self.pageData = self.family.IO.BTree()             # here we save the actual rtree data in
        self.idToCoordinates = self.family.IO.BTree()      # we need to know the coordinates for each objectid to be able to delete it

        # this creates the tree and creates header and root pages
        self._getTree( initialValuesGenerator )
    def __setattr__(self, name, value):
        """Set an attribute value
        """
        #################################################################
        # IMPORTANT! READ THIS! 8->
        #
        # We *always* give Persistent a chance first.
        # Persistent handles certain special attributes, like _p_
        # attributes.
        #
        # We call _p_setattr. If it returns True, then we are done.
        # It has already set the attribute.
        #
        #################################################################
        if Persistent._p_setattr(self, name, value):
            return

        self.__dict__['__secret__'][name] = value

        if not name.startswith('tmp_'):
            self._p_changed = 1
Beispiel #30
0
 def __getattribute__(self, name):
     if name.startswith('_p_') or name in struct_attrs:
         v = Persistent.__getattribute__(self, name)
         # Handle descriptors here, eg: __Security_checker__
         # is a descriptor for Struct objects.
         if hasattr(v, '__get__'):
             return v.__get__(self, type(self))
         return v
     # TODO This is butt ugly. See the comment on SecurityDescriptor.
     if self._p_state == GHOST:
         self._p_activate()
     proxied = self.__proxied__
     v = getattr(proxied, name)
     # And also handle descriptors for the proxied object,
     # but using the proxied object on __get__ calls.
     if hasattr(v, '__get__'):
         # We should call it only if it came from the class,
         # otherwise its a descriptor being used as an instance
         # attribute, so just return it.
         if (hasattr(proxied, '__class__') and
             getattr(proxied.__class__, name) is v):
             return v.__get__(proxied, type(proxied))
     return v
Beispiel #31
0
 def __getstate__(self):
     if not hasattr(self, 'new_attribute'):
         self.new_attribute = 1 # pylint:disable=attribute-defined-outside-init
     return Persistent.__getstate__(self)
Beispiel #32
0
 def __init__(self, *args, **kw):
     Persistent.__init__(self)
     Schedule.__init__(self, *args, **kw)
     self.exceptions = PersistentDict()
Beispiel #33
0
 def __init__(self):
     Persistent.__init__(self)
     self._items = PersistentList()
Beispiel #34
0
 def __init__(self, email, message):
     Persistent.__init__(self)
     self.email = unicode(email)
     self.message = unicode(message)
Beispiel #35
0
	def __init__(self):
		Persistent.__init__(self)
		self.objects = PersistentMapping()
		self.templates = PersistentMapping()
		self.shapes = PersistentMapping()
		self.Tag = None