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


Python User.get_current_user方法代码示例

本文整理汇总了Python中user.User.get_current_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_current_user方法的具体用法?Python User.get_current_user怎么用?Python User.get_current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.User的用法示例。


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

示例1: delete

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def delete(self):
		"""
		"""
		# Only owner can delete an instance
		if not self.own_by(User.get_current_user()):
			raise OwnerException("user '%s' try to update a namespace owns by '%s'."%(User.get_current_user().username, self.owner.username))
		return super(Tiddlywiki, self).delete()
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:9,代码来源:tiddlywiki.py

示例2: create_or_update

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def create_or_update(cls, name, owner, namespace, private_access, title='', subtitle='', tiddlers=''):
		# Only owner can update an instance
		t = Tiddlywiki(key_name= name, parent=owner, owner=owner.key(), name=name, namespace= namespace.key(), private_access=private_access, \
			title=title, subtitle=subtitle, tiddlers=tiddlers)
		if t and not t.own_by(User.get_current_user()):
			if User.get_current_user():
				username = User.get_current_user().username
			else:
				username = 'Anonymous'
			raise OwnerException("user '%s' try to update a tiddlywiki owns by '%s'."%(username, owner.username))
		t.put()
		return t		
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:14,代码来源:tiddlywiki.py

示例3: create_or_update

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def create_or_update(cls, name, owner, authors='',readers='',private_access=False):
		authors=[]
		readers=[]
		namespace = Namespace(key_name=name, parent=owner, name=name, owner=owner.key(), authors=authors, readers=readers, private_access=private_access)
		# Only owner can update an instance
		if namespace and not namespace.own_by(User.get_current_user()):
			if User.get_current_user():
				username = User.get_current_user().username
			else:
				username = 'Anonymous'
			raise OwnerException("user '%s' try to update a namespace owns by '%s'."%(username, owner.username))
		key = namespace.put()
		return namespace
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:15,代码来源:namespace.py

示例4: delete

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def delete(self):
		"""
		"""
		# Only owner can delete an instance
		if self.parent() and not self.parent().own_by(User.get_current_user()):
			raise OwnerException("user '%s' try to delete a tiddler in a namespace owns by '%s'."%(User.get_current_user().username, owner.username))		
		return super(Tiddler, self).delete()
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:9,代码来源:tiddler.py

示例5: create_or_update

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def create_or_update(cls, namespace, title, modifier, modified='', created='', tags='', text='', html='', newTitle=''):
		username = "Anonymous"
		if User.get_current_user():
			username = User.get_current_user().username
		if namespace and not namespace.own_by(User.get_current_user()):
			raise OwnerException("user '%s' try to update a tiddler in a namespace owns by '%s'."%(username, namespace.owner.username))		
		modified = datetime.utcnow()
		t = Tiddler.get_by_key_name(title, parent=namespace)
		if t:
			created = t.created
			if newTitle and (newTitle != title):
				t.delete()
		else:
			created = datetime.utcnow()			
		t = Tiddler(namespace_name=namespace.name, parent=namespace, key_name= newTitle, 
			title=newTitle, modifier=modifier, modified=modified, created=created, text=text, html=html, tags=tags)
		t.put()
		return t
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:20,代码来源:tiddler.py

示例6: delete

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def delete(self):
		"""
		"""
		# Only owner can delete an instance
		if not self.own_by(User.get_current_user()):
			if User.get_current_user():
				username = User.get_current_user().username
			else:
				username = 'Anonymous'
			raise OwnerException("user '%s' try to update a namespace owns by '%s'."%(username, self.owner.username))
		# first delete all tiddlers
		query = Tiddler.all().ancestor(self)
		tiddlers = query.fetch(999)
		for t in tiddlers:
				t.delete()
		# delete all tiddlywiki
		query = db.GqlQuery("SELECT * FROM Tiddlywiki " +
							" WHERE namespace = :1" , self )
		tiddlywikis = query.fetch(999)
		for t in tiddlywikis:
				t.delete()
		return super(Namespace, self).delete()
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:24,代码来源:namespace.py

示例7: display_in_html

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_current_user [as 别名]
	def display_in_html(self, out, url):
		#get template
		path = os.path.join(os.path.dirname(__file__), 'empty.html')
		f = open(path)
		try:
			data = f.read()
		finally:
			f.close()
		#Edit title and subtitle in html and shadow titlers
		data = self.__replace_chunk(data, "<title>", "</title>", self.title + ' - ' + self.subtitle)
		data = re.sub(r'SiteTitle: "My TiddlyWiki"', 'SiteTitle: "'+self.title+'"', data)
		data = re.sub(r'SiteSubtitle: "a reusable non-linear personal web notebook"', 'SiteSubtitle: "'+self.subtitle+'"', data )
		data = re.sub(r'SiteUrl: "http://www\.tiddlywiki\.com/"', 'SiteUrl: "'+url+'"', data )
		#Update markupBlock
		data = self.__update_markup_block(data, "PRE-HEAD","MarkupPreHead")
		data = self.__update_markup_block(data, "POST-HEAD","MarkupPostHead")
		data = self.__update_markup_block(data, "PRE-BODY","MarkupPreBody")
		data = self.__update_markup_block(data, "POST-SCRIPT","MarkupPostBody")
			
		#find storearea and insert tiddlers	
		match = re.match("^(.*?<div id=\"storeArea\">).*?(</div>.*?<!--POST-STOREAREA-->.*?)$", data, re.DOTALL)
		if match:
			begin = match.group(1)
			end = match.group(2)
			out.write(begin)
			tiddlers = {}
			for t in self.tiddlers:
				if t:
					tiddler = Tiddler.get(t)
					if tiddler:
						tiddlers[tiddler.title] = tiddler
			# add dynamic tiddlywiki
			if 'UploadTiddlerPlugin' not in tiddlers:
				tiddlers['UploadTiddlerPlugin'] = Namespace.get_tiddler('UploadTiddlerPlugin')
			tiddler = None
			if self.namespace.own_by(User.get_current_user()):
				tiddler = Tiddler.create_or_update(self.namespace, 'zzTiddlyHomeTweaks', self.owner.username, tags='systemConfig excludeLists excludeSearch', 
					newTitle='zzTiddlyHomeTweaks', 
					text= config.tweaks_tiddler%{'username': self.owner.username, 'filename': self.name, 'storeUrl': config.storeTiddler_url})
				tiddlers['zzTiddlyHomeTweaks'] = tiddler
				keys = tiddlers.keys()
				keys.sort()
			for ti in keys:
				if ti:
					out.write(tiddlers[ti].displayInStorearea(self.name))
			out.write(end)
			
			if tiddler:
				tiddler.delete()
		else:
			raise Error("Maformed empty.html file")
开发者ID:ParoTheParrot,项目名称:bidix,代码行数:53,代码来源:tiddlywiki.py


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