本文整理汇总了Python中tg.override_template函数的典型用法代码示例。如果您正苦于以下问题:Python override_template函数的具体用法?Python override_template怎么用?Python override_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了override_template函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ajax_view_chead
def ajax_view_chead(self, ** kw):
print '*' * 80
print 'ajax_view_chead: %s' % kw
print '*' * 80
try:
collections = []
chead = CHead.get(kw['id'])
sql = '''select tnh.NOTE_NO,tnh.NOTE_TYPE,tnh.STATUS,tnc.LINE_NO,tnc.CHG_DISCOUNT_CODE,tnc.TOTAL,tnh.NOTE_DATE,tnh.REMARK
From t_cust_note_charges tnc,t_cust_note_hdr tnh
where tnh.COMPANY_CODE='RPACSZ' and tnh.SC_NO is null and
tnh.INVOICE_NO is null and tnh.CUSTOMER='%s' and tnh.NOTE_NO=tnc.NOTE_NO''' % (chead.customer_code)
other_charges_from_erp = []
t_head_id = DBSession.execute('''SELECT t_head_id FROM "public"."vat_c_head" WHERE id='%s' ''' %(kw['id'])).fetchone()[0]
other_charges_from_vat = Charge.find_Other_Charges_From_vat(t_head_id, const.ERP_HEAD_TYPE_CHEAD, kw['id'])
if chead.head_type == const.ERP_HEAD_TYPE_SI:
override_template(self.ajax_view_chead, 'mako:vatsystem.templates.ar.view_chead_si')
else:
relation_si = chead.relation_si.split(',') if chead.relation_si else []
for invoice_no in relation_si:
si_details = SID.find(** {'invoice_no':invoice_no})
if len(si_detail[0]) > 0:
for si_detail in si_details[0]: collections.append(si_detail)
override_template(self.ajax_view_chead, 'mako:vatsystem.templates.ar.view_chead_so')
return dict(flag = 0, cHead = chead, collections = collections, other_charges_from_erps = other_charges_from_erp, other_charges_from_vat = other_charges_from_vat, ** kw)
except:
flash("Error!")
traceback.print_exc()
return dict(flag=1, ** kw)
示例2: _default
def _default(self, page=None, *args, **kw):
page_slug = dict(slug=page)
hooks.notify('flatpages.before_override_template', args=(page_slug, self))
page = model.FlatPage.by_slug(page_slug['slug'])
if page is None:
abort(404, 'Page not found')
permission = page.required_permission
if permission and permission != 'public':
if permission == 'not_anonymous':
predicate = predicates.not_anonymous()
else:
predicate = predicates.has_permission(permission)
if not predicate.is_met(request.environ):
abort(403, 'Forbidden')
try:
userid = request.identity['user'].user_id
except:
userid = None
override_template(RootController._default, page.template)
hooks.notify('flatpages.after_override_template', (page, self))
return dict(page=page,
tg_cache={'expire': self.CACHE_EXPIRE,
'key': '%s-%s-%s' % (page.slug, page.updated_at, userid)})
示例3: new
def new(self, parent_id=None, workspace_id=None):
""" Show the add form """
tg.override_template(self.new, self.TEMPLATE_NEW)
workspace_id = tg.request.GET['workspace_id']
parent_id = tg.request.GET['parent_id'] if 'parent_id' in tg.request.GET else None
return DictLikeClass(result=self._struct_new_serialized(workspace_id, parent_id))
示例4: index
def index(self):
"""Handle the front-page."""
if config.get('single_user', False):
override_template(self.index, 'genshi:hiringpond.templates.resume')
user = get_user_or_default_user()
else:
user = None
return {'user': user, 'tags': ''}
示例5: summary
def summary(self, id):
movie = DBSession.query(Movie).filter_by(id=id).first()
if movie is None:
override_template(self.summary, 'genshi:cotufa.templates.movie-imdb')
# emulate 'Movie' object with basic info
movie = Movie.lightweight_instance_for(IMDb(), id)
return {'movie': movie}
示例6: index
def index(self, **kw):
override_template(self.index, "mako:"+self.template)
if not kw:
result=[]
else:
result=self.searchMaster(kw)
return {
"searchWidget" : self.searchWidget,
"result" : result,
"funcURL" :self.url,
"values" : kw,
}
示例7: ajax_view_ohead
def ajax_view_ohead(self, ** kw):
print '*' * 80
print 'ajax_view_ohead: %s' % kw
print '*' * 80
try:
ohead = OHead.get(kw['id'])
override_template(self.ajax_view_ohead, 'mako:vatsystem.templates.cost.view_ohead')
return dict(flag = 0, oHead = ohead, ** kw)
except:
flash("Error!")
traceback.print_exc()
return dict(flag = 1, ** kw)
示例8: ajax_view_phead
def ajax_view_phead(self, ** kw):
print '*' * 80
print 'ajax_view_phead: %s' % kw
print '*' * 80
try:
phead = PHead.get(kw['id'])
Other_Charges_From_vat = PCharge.find_other_charges_from_vat(kw['id'], [const.CHARGE_TYPE_P_MAN, const.CHARGE_TYPE_P_ERP], 'p_head_id')
override_template(self.ajax_view_phead, 'mako:vatsystem.templates.ap.view_thead_si')
return dict(flag = 0, pHead = phead, Other_Charges_From_vats = Other_Charges_From_vat, ** kw)
except:
flash("Error!")
traceback.print_exc()
return dict(flag=1, ** kw)
示例9: index
def index( self, **kw ):
if self.template:
override_template( self.index, ''.join( ["mako:", self.template] ) )
if not kw:
result = []
else:
result = self.searchMaster( kw )
return {"searchWidget" : self.searchWidget,
"result" : result['result'] if result else result,
"regions": result['regions'] if result else result,
"funcURL" :self.url,
"values" : kw,
}
示例10: edit
def edit(self, id, revid=None):
file = DBSession.query(File).filter_by(id=id).one()
if request.is_xhr:
override_template(self.edit, "genshi:vertex.templates.editor.edit-comparing")
revision = None
if revid is not None:
revision = DBSession.query(FileRevision).filter_by(id=revid, file_id=id).one()
if file.is_binary:
tmpl_context.update_file_form = update_file_form
return {"file": file, "revision": revision}
示例11: ajax_view_nhead
def ajax_view_nhead(self, ** kw):
print '*' * 80
print 'ajax_view_nhead: %s' % kw
print '*' * 80
try:
nhead = NHead.get(kw['id'])
override_template(self.ajax_view_nhead, 'mako:vatsystem.templates.cost.view_nhead')
return dict(flag = 0,
nHead = nhead,
Other_Charges_From_Erps = [],
Other_Charges_From_vats = [],
** kw
)
except:
flash("Error!")
traceback.print_exc()
return dict(flag = 1, ** kw)
示例12: _default
def _default(self, *args, **kwargs):
"""Catch requests for "/<category>" or "/<category>/<article>" and
serve them through the article controller, otherwise rise a "Not Found"
error"""
num_args = len(args)
if num_args > 0:
categoryid = args[0]
category = DBSession.query(Category).get(categoryid.decode())
else:
category = None
if num_args > 1:
articleid = args[1]
article = DBSession.query(Article).get(articleid.decode())
else:
article = None
if num_args > 2:
languageid = args[2]
else:
languageid = None
tag = kwargs.get('tag', None)
mode = kwargs.get('mode', 'all')
settings = dict([(s.id, s.value) for s in DBSession.query(Setting)])
max_results = int(kwargs.get('max_results',
settings.get('max_results', 0)))
if article:
override_template(self._default,
'mako:tagger.templates.article.get_one')
result = self.article.get_one(article.id, languageid)
result.update(path=(category.id, ''))
return result
elif category:
override_template(self._default,
'mako:tagger.templates.article.get_all')
result = self.article.get_all(categoryid=category.id, tag=tag,
max_results=max_results, mode=mode)
result.update(path=(category.id, ''))
return result
else:
raise HTTPNotFound
示例13: index
def index(self, ** kw):
viewPager, cust, display, collections = 1, 0, 0, [[], 1, 1]
if kw.get("viewPager"):viewPager = kw.get("viewPager")
if kw.get("supplier_name") or kw.get("supplier"):
cust = 1
if kw.get('type') == const.SEARCH_TYPE_PI:
collections = PI.find( ** kw)
override_template(self.index, 'mako:vatsystem.templates.ap.list_si')
if kw.get('type') == const.SEARCH_TYPE_PSIPSO:
cust = 0
collections = PHead.find(** kw)
override_template(self.index, 'mako:vatsystem.templates.ap.list_thead')
if kw.get('type') == const.SEARCH_TYPE_MSN:
cust = 0
collections = SHead.find(** kw)
override_template(self.index, 'mako:vatsystem.templates.ap.list_chead')
if kw.get("type") == const.SEARCH_TYPE_EXCEL:
cust = 0
collections = STHead.find(** kw)
override_template(self.index, 'mako:vatsystem.templates.ap.list_statement')
if kw.get("type") == const.SEARCH_TYPE_MF:
cust = 0
collections = MHead.find(** kw)
override_template(self.index, 'mako:vatsystem.templates.ap.list_mf')
if cust ==0:display = 1
else:
if viewPager == 1:display = 1
results = dict(
collections = collections[0],
pi_search_form = pi_search_form,
po_search_form = po_search_form,
phead_search_form = phead_search_form,
shead_search_form = shead_search_form,
mhead_search_form = mhead_search_form,
excel_search_form = excel_search_form,
kw = kw,
cust = cust,
display = display,
limit = collections[2],
offset = collections[1]
)
return results
示例14: edit
def edit(self, item_id):
"""
Show the edit form (do not really edit the data)
:param item_id:
:return:
"""
# the follwing line allow to define the template to use in child classes.
tg.override_template(self.edit, self.TEMPLATE_EDIT)
item_id = int(item_id)
user = tmpl_context.current_user
workspace = tmpl_context.workspace
content_api = ContentApi(user)
item = content_api.get_one(item_id, self._item_type, workspace)
dictified_item = Context(self._get_one_context).toDict(item, 'item')
return DictLikeClass(result = dictified_item)
示例15: document
def document(self, *args, **kwargs):
"""Render the error document"""
resp = request.environ.get('tg.original_response')
default_message = ('<p>We\'re sorry but we weren\'t able to process '
' this request.</p>')
values = DictLikeClass(
prefix=request.environ.get('SCRIPT_NAME', ''),
code=request.params.get('code', resp.status_int),
message=request.params.get('message', default_message))
if request.identity:
override_template(ErrorController.document, 'mako:tracim.templates.error_authenticated')
TIMRestPathContextSetup.current_user()
user = tmpl_context.current_user
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
fake_api = Context(CTX.CURRENT_USER).toDict({'current_user': current_user_content})
values['fake_api'] = fake_api
return values