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


Python Tiddler.title方法代码示例

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


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

示例1: submit

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import title [as 别名]
def submit(environ, start_response):
    """
    Take POSTed input, put it in a Tiddler and save
    it into the store, and redirect back to the user
    page.
    """
    user = environ['tiddlyweb.usersign']['name']
    if user == 'GUEST':
        raise UserRequiredError, 'real user required to twote'

    recent_recipe = _check_recipe('recent', environ, user)
    all_recipe = _check_recipe('all', environ, user)

    tiddler = _make_tiddler(environ, user)

    bag = control.determine_bag_for_tiddler(all_recipe, tiddler)
    tiddler.bag = bag.name

    store = environ['tiddlyweb.store']

    original_title = tiddler.title
    tester_tiddler = Tiddler(original_title, bag=bag.name)
    addendum = 2
    while 1:
        try:
            tester_tiddler = store.get(tester_tiddler)
            new_title = '%s-%s' % (original_title, addendum)
            tiddler.title = new_title
            tester_tiddler.title = new_title
            addendum += 1
        except NoTiddlerError:
            store.put(tiddler)
            break

    raise HTTP302, '%s/twoter/%s' % (server_base_url(environ), urllib.quote(user))
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:37,代码来源:twoter.py

示例2: _get_links_in_parent

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import title [as 别名]
 def _get_links_in_parent(self, tiddler, value):
     """
     Try to get parent from store, and make a list of the tiddlylinks it contains. 
     """
     temp_tiddler = Tiddler("temp")
     temp_tiddler.title = value
     temp_tiddler.bag = tiddler.bag
     
     try:
         self.parent = tiddler.store.get(temp_tiddler)
         self._parse_tiddlylinks()
     except NoTiddlerError:
         pass
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:15,代码来源:tiddlylinkfilter.py

示例3: getPlugins

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import title [as 别名]
	def getPlugins(self, dir, recursive = False):
		"""
		retrieve .js files from directory

		if there is a whitelist file, only those items will be retrieved
		if there is a blacklist file, those items will be excluded
		whitelist and blacklist files contain one file or directory name per line
		whitelist takes precedence over blacklist

		@param dir (str): directory (relative path)
		@param recursive (bool): process subdirectories
		@return (list): plugin tiddlers
		"""
		plugins = []
		uri = posixpath.join(self.host, dir)
		content = self._get(uri)
		soup = BeautifulSoup(content)
		list = soup.find("ul")
		try:
			items = list.findChildren("li")
		except AttributeError: # means 404 -- XXX: ugly hack; check for HTTP status code directly
			raise IOError("404 Not Found") # XXX: IOError not appropriate
		uris = [item.findChild("a")["href"] for item in items]
		if self.whitelist in uris: # whitelisting
			uri = posixpath.join(self.host, dir, self.whitelist)
			patterns = self._get(uri).split("\n")
			meta = [uri.strip() for uri in uris if uri.endswith(".meta")]
			uris = [uri.strip() for uri in uris if matchPatterns(uri, patterns)]
			uris.extend(meta)
		elif self.blacklist in uris: # blacklisting
			uri = posixpath.join(self.host, dir, self.blacklist)
			patterns = self._get(uri).split("\n")
			patterns.append(self.blacklist)
			uris = [uri.strip() for uri in uris if not matchPatterns(uri, patterns)]
		for uri in uris:
			if uri == "../":
				continue
			if uri.endswith(".js"): # plugin -- XXX: also excludes whitelisted items missing .js extension
				plugin = Tiddler()
				plugin.title = posixpath.basename(uri[:-3])
				plugin.tags = ["systemConfig"]
				fullURI = posixpath.join(self.host, dir, uri)
				plugin.text = self._get(fullURI)
				if uri + ".meta" in uris: # retrieve metadata
					metaURI = posixpath.join(self.host, dir, uri + ".meta")
					self.retrieveMetadata(plugin, metaURI)
				plugins.append(plugin)
			elif uri.endswith("/") and recursive: # directory -- XXX: potential for infinite loop?
				subDir = posixpath.join(dir, uri)
				plugins.extend(self.getPlugins(subDir, recursive))
		return plugins
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:53,代码来源:dirScraper.py


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