本文整理汇总了Python中publica.core.portal.Portal._readFile方法的典型用法代码示例。如果您正苦于以下问题:Python Portal._readFile方法的具体用法?Python Portal._readFile怎么用?Python Portal._readFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类publica.core.portal.Portal
的用法示例。
在下文中一共展示了Portal._readFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _action
# 需要导入模块: from publica.core.portal import Portal [as 别名]
# 或者: from publica.core.portal.Portal import _readFile [as 别名]
def _action(self, id_treeapp, schema, id_conteudo, link,
add=None, edit=None, delete=None, dados={}):
"""
"""
if not link:
return
portal = Portal(id_site=self.id_site,
request=self.request)
link = "/".join( link.split("/")[:-1] )
src = portal._readFile(path="htmls/%s/index.xml" % link)
if src:
fd = open("%s%s,%s,%s.xml" % (self.dados["path"],
schema,
self.id_site,
id_conteudo), "w")
soup = BeautifulSoup(src,
fromEncoding=settings.GLOBAL_ENCODING)
for item in soup.findAll("rdf:description"):
if add:
site = getDadosSite(id_site=self.id_site,
request=self.request)
base = site["base_html"]
tit = portal._getConteudoSite(env_site=self.id_site,
id_conteudo=id_conteudo,
schema=schema)['url']
item.__setitem__("rdf:about", base+tit)
## push para alertar usuário de uma notícia importante
## Neste metodo sempre envia false
tag = Tag(soup, "dc:push", [])
tag['rdf:enviar'] = 'false'
item.insert(0, tag)
if add:
status = "added"
elif edit:
status = "edited"
elif delete:
status = "deleted"
else:
status = "added"
tag = Tag(soup, "dc:status", [])
tag.insert(0, status)
item.insert(0, tag)
dadosite = getDadosSite(self.id_site)
veiculo = dadosite["titulo"]
tag = Tag(soup, "dc:veiculo", [])
tag.insert(0, veiculo)
item.insert(0, tag)
base_img = dadosite["base_app"]
tag = Tag(soup, "dc:base_img", [])
tag.insert(0, base_img)
item.insert(0, tag)
src = unicode(soup)
src = src.replace("<?xml version='1.0' encoding='utf-8'?>",
"<?xml version='1.0' encoding='latin1'?>")
fd.write(src.encode(settings.GLOBAL_ENCODING))
fd.close()