当前位置: 首页>>代码示例>>Python>>正文


Python data_linker.DataLinker类代码示例

本文整理汇总了Python中dNG.data.data_linker.DataLinker的典型用法代码示例。如果您正苦于以下问题:Python DataLinker类的具体用法?Python DataLinker怎么用?Python DataLinker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataLinker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_owner_root_directory

    def load_owner_root_directory(cls, owner_id):
        """
Load Entry instance of the root directory for the given owner ID.

:param cls: Expected encapsulating database instance class
:param owner_id: Owner ID

:return: (object) Entry instance on success
:since:  v0.1.00
        """

        if (owner_id is None): raise NothingMatchedException("Owner ID is invalid")

        with Connection.get_instance():
            db_instance = (DataLinker.get_db_class_query(cls)
                           .filter(_DbFileCenterEntry.vfs_type == Entry.VFS_TYPE_DIRECTORY,
                                   _DbFileCenterEntry.role_id == "owner_root",
                                   _DbFileCenterEntry.owner_type == "u",
                                   _DbFileCenterEntry.owner_id == owner_id
                                  )
                           .first()
                          )

            if (db_instance is None): raise NothingMatchedException("Owner ID '{0}' is invalid".format(owner_id))
            DataLinker._ensure_db_class(cls, db_instance)

            return Entry(db_instance)
开发者ID:dNG-git,项目名称:pas_file_center,代码行数:27,代码来源:entry.py

示例2: _insert

    def _insert(self):
        """
Insert the instance into the database.

:since: v0.1.00
        """

        # pylint: disable=maybe-no-member

        DataLinker._insert(self)

        is_acl_missing = (len(self.local.db_instance.rel_acl) == 0)
        is_data_missing = self.is_data_attribute_none("owner_type")
        is_directory_mimeclass = (self.local.db_instance.mimeclass == "directory")
        is_permission_missing = self.is_data_attribute_none("guest_permission", "user_permission")

        parent_object = (self.load_parent()
                         if (is_acl_missing or is_data_missing or is_directory_mimeclass or is_permission_missing) else
                         None
                        )

        if (is_data_missing and isinstance(parent_object, DataLinker)):
            parent_data = parent_object.get_data_attributes("id_site")
            if (self.local.db_instance.id_site is None and parent_data['id_site'] is not None): self.local.db_instance.id_site = parent_data['id_site']
        #

        if (is_directory_mimeclass and isinstance(parent_object, Entry)): self.local.db_instance.mimetype = parent_object.get_mimetype()

        if (isinstance(parent_object, OwnableInstance)):
            if (is_acl_missing): self._copy_acl_entries_from_instance(parent_object)
            if (is_permission_missing): self._copy_default_permission_settings_from_instance(parent_object)
开发者ID:dNG-git,项目名称:pas_file_center,代码行数:31,代码来源:entry.py

示例3: _insert

	def _insert(self):
	#
		"""
Insert the instance into the database.

:since: v0.1.00
		"""

		with self.local.connection.no_autoflush:
		#
			DataLinker._insert(self)

			if (self.local.db_instance.time_published is None): self.local.db_instance.time_published = int(time())

			is_acl_missing = (len(self.local.db_instance.rel_acl) == 0)
			is_data_missing = self.is_data_attribute_none("owner_type")
			is_permission_missing = self.is_data_attribute_none("guest_permission", "user_permission")

			parent_object = (self.load_parent() if (is_acl_missing or is_data_missing or is_permission_missing) else None)
			is_parent_topic = isinstance(parent_object, Topic)

			if (is_data_missing and (is_parent_topic or isinstance(parent_object, List))):
			#
				parent_data = parent_object.get_data_attributes("id_site")

				if (self.local.db_instance.id_site is None and parent_data['id_site'] is not None): self.local.db_instance.id_site = parent_data['id_site']
				if (is_parent_topic): self.local.db_instance.position = parent_object._get_db_instance().posts
			#

			if (isinstance(parent_object, OwnableInstance)):
			#
				if (is_acl_missing): self._copy_acl_entries_from_instance(parent_object)
				if (is_permission_missing): self._copy_default_permission_settings_from_instance(parent_object)
开发者ID:dNG-git,项目名称:pas_discuss,代码行数:33,代码来源:post.py

示例4: set_data_attributes

	def set_data_attributes(self, **kwargs):
	#
		"""
Sets values given as keyword arguments to this method.

:since: v0.1.00
		"""

		with self, self.local.connection.no_autoflush:
		#
			DataLinker.set_data_attributes(self, **kwargs)

			if ("owner_type" in kwargs): self.local.db_instance.owner_type = kwargs['owner_type']
			if ("author_id" in kwargs): self.local.db_instance.author_id = kwargs['author_id']
			if ("author_ip" in kwargs): self.local.db_instance.author_ip = kwargs['author_ip']
			if ("time_published" in kwargs): self.local.db_instance.time_published = int(kwargs['time_published'])
			if ("preserve_space" in kwargs): self.local.db_instance.preserve_space = kwargs['preserve_space']
			if ("locked" in kwargs): self.local.db_instance.locked = kwargs['locked']
			if ("guest_permission" in kwargs): self.local.db_instance.guest_permission = kwargs['guest_permission']
			if ("user_permission" in kwargs): self.local.db_instance.user_permission = kwargs['user_permission']

			if ("content" in kwargs):
			#
				if (self.local.db_instance.rel_text_entry is None):
				#
					self.local.db_instance.rel_text_entry = _DbTextEntry()
					self.local.db_instance.rel_text_entry.id = self.local.db_instance.id
					db_text_entry = self.local.db_instance.rel_text_entry
				#
				else: db_text_entry = self.local.db_instance.rel_text_entry

				db_text_entry.content = Binary.utf8(kwargs['content'])
开发者ID:dNG-git,项目名称:pas_discuss,代码行数:32,代码来源:post.py

示例5: _insert

    def _insert(self):
        """
Insert the instance into the database.

:since: v0.2.00
        """

        with self.local.connection.no_autoflush:
            DataLinker._insert(self)

            if (self.local.db_instance.time_published is None): self.local.db_instance.time_published = int(time())

            is_acl_missing = (len(self.local.db_instance.rel_acl) == 0)
            is_data_missing = self.is_data_attribute_none("owner_type", "entry_type")
            is_permission_missing = self.is_data_attribute_none("guest_permission", "user_permission")

            parent_object = (self.load_parent() if (is_acl_missing or is_data_missing or is_permission_missing) else None)

            if (is_data_missing and (isinstance(parent_object, Category) or isinstance(parent_object, Document))):
                parent_data = parent_object.get_data_attributes("id_site", "entry_type")

                if (self.local.db_instance.id_site is None and parent_data['id_site'] is not None): self.local.db_instance.id_site = parent_data['id_site']
                if (self.local.db_instance.entry_type is None): self.local.db_instance.entry_type = parent_data['entry_type']
            #

            if (isinstance(parent_object, OwnableInstance)):
                if (is_acl_missing): self._copy_acl_entries_from_instance(parent_object)
                if (is_permission_missing): self._copy_default_permission_settings_from_instance(parent_object)
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:28,代码来源:document.py

示例6: __init__

    def __init__(self, db_instance = None):
        """
Constructor __init__(Category)

:param db_instance: Encapsulated SQLAlchemy database instance

:since: v0.2.00
        """

        DataLinker.__init__(self, db_instance)
        LockableMixin.__init__(self)
        OwnableLockableWriteMixin.__init__(self)
        SubscribableMixin.__init__(self)
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:13,代码来源:category.py

示例7: delete

    def delete(self):
        """
Deletes this entry from the database.

:since: v0.2.00
        """

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.delete()- (#echo(__LINE__)#)", self, context = "pas_datalinker")

        with self:
            db_text_entry_instance = self.local.db_instance.rel_text_entry

            DataLinker.delete(self)
            if (db_text_entry_instance is not None): self.local.connection.delete(db_text_entry_instance)
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:14,代码来源:document.py

示例8: _analyze_structure

	def _analyze_structure(self, cache_id = None):
	#
		"""
Analyzes the entry structure, the number of total topics, values and
identifies the latest entry based on the main ID and list ID of this
instance.

:param cache_id: ID used for building the structure SQLAlchemy query and
                 cache its result.

:since: v0.1.00
		"""

		if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}._analyze_structure()- (#echo(__LINE__)#)", self, context = "pas_datalinker")

		with self:
		#
			if (cache_id is None): cache_id = "DiscussList:{0}".format(self.local.db_instance.id_main)
			permission_user_id = self.get_permission_user_id()

			DataLinker._analyze_structure(self, cache_id)

			self.latest_timestamp = -1
			self.total_topics = 0
			self.total_posts = 0

			for entry in self.structure_instance.get_structure_list(self.local.db_instance.id):
			#
				is_readable = True

				if (isinstance(entry, OwnableInstance)):
				#
					entry.set_permission_user_id(permission_user_id)
					is_readable = entry.is_readable()
				#

				if (is_readable and (not entry.is_data_attribute_none("topics", "posts"))):
				#
					entry_data = entry.get_data_attributes("time_sortable", "topics", "posts", "last_id_topic", "last_id_author", "last_preview")

					self.total_topics += entry_data['topics']
					self.total_posts += entry_data['posts']

					if (entry_data['last_id_topic'] is not None and entry_data['time_sortable'] > self.latest_timestamp):
					#
						self.latest_timestamp = entry_data['time_sortable']
						self.latest_topic_id = entry_data['last_id_topic']
						self.latest_author_id = entry_data['last_id_author']
						self.latest_preview = entry_data['last_preview']
开发者ID:dNG-git,项目名称:pas_discuss,代码行数:49,代码来源:list.py

示例9: set_data_attributes

    def set_data_attributes(self, **kwargs):
        """
Sets values given as keyword arguments to this method.

:since: v0.2.00
        """

        with self:
            DataLinker.set_data_attributes(self, **kwargs)

            if ("id_subscription" in kwargs): self.local.db_instance.id_subscription = Binary.utf8(kwargs['id_subscription'])
            if ("entry_type" in kwargs): self.local.db_instance.entry_type = kwargs['entry_type']
            if ("owner_type" in kwargs): self.local.db_instance.owner_type = kwargs['owner_type']
            if ("locked" in kwargs): self.local.db_instance.locked = kwargs['locked']
            if ("guest_permission" in kwargs): self.local.db_instance.guest_permission = kwargs['guest_permission']
            if ("user_permission" in kwargs): self.local.db_instance.user_permission = kwargs['user_permission']
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:16,代码来源:category.py

示例10: delete

    def delete(self):
        """
Deletes this entry from the database.

:since: v0.1.00
        """

        with self, TransactionContext():
            if (self.type & Entry.VFS_TYPE_DIRECTORY == Entry.VFS_TYPE_DIRECTORY):
                for entry in self.get_content_list(): entry.delete()
            #

            db_resource_metadata_instance = self.local.db_instance.rel_resource_metadata

            DataLinker.delete(self)
            if (db_resource_metadata_instance is not None): self.local.connection.delete(db_resource_metadata_instance)
开发者ID:dNG-git,项目名称:pas_file_center,代码行数:16,代码来源:entry.py

示例11: _get_subscription_handler

	def _get_subscription_handler(self, _id):
	#
		"""
Action for "subscribe"

:since: v0.1.00
		"""

		datalinker_object = None

		try: datalinker_object = DataLinker.load_id(_id)
		except NothingMatchedException: pass

		session = (self.request.get_session() if (self.request.is_supported("session")) else None)

		if (datalinker_object is None): raise TranslatableError("pas_http_datalinker_oid_invalid", 404)
		elif (isinstance(datalinker_object, OwnableInstance)
		      and (not datalinker_object.is_readable_for_session_user(session))
		     ): raise TranslatableError("core_access_denied", 403)

		return (datalinker_object.get_subscription_handler()
		        if (isinstance(datalinker_object, SubscribableInstance)) else
		        None
		       )
	#
#

##j## EOF
开发者ID:dNG-git,项目名称:pas_http_subscription,代码行数:28,代码来源:datalinker.py

示例12: __init__

    def __init__(self, db_instance = None):
        """
Constructor __init__(Document)

:param db_instance: Encapsulated SQLAlchemy database instance

:since: v0.2.00
        """

        DataLinker.__init__(self, db_instance)
        LockableMixin.__init__(self)
        OwnableLockableReadMixin.__init__(self)

        self.set_max_inherited_permissions(OwnableLockableReadMixin.READABLE,
                                           OwnableLockableReadMixin.READABLE
                                          )
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:16,代码来源:document.py

示例13: get_categories_count

    def get_categories_count(self):
        """
Returns the number of child categories of this instance.

:return: (int) Number of child categories
:since:  v0.2.00
        """

        return DataLinker.get_sub_entries_count(self, identity = "ContentorCategory")
开发者ID:dNG-git,项目名称:pas_contentor,代码行数:9,代码来源:category.py

示例14: get_sub_entries_count

	def get_sub_entries_count(self):
	#
		"""
Returns the number of child entries of this instance.

:return: (int) Number of child entries
:since:  v0.1.00
		"""

		return DataLinker.get_sub_entries_count(self, exclude_identity = "DiscussTopic")
开发者ID:dNG-git,项目名称:pas_discuss,代码行数:10,代码来源:list.py

示例15: get_reply_posts_count

	def get_reply_posts_count(self):
	#
		"""
Returns the number of reply posts of this instance.

:return: (int) Number of child posts
:since:  v0.1.00
		"""

		return DataLinker.get_sub_entries_count(self, identity = "DiscussPost")
开发者ID:dNG-git,项目名称:pas_discuss,代码行数:10,代码来源:post.py


注:本文中的dNG.data.data_linker.DataLinker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。