本文整理汇总了Python中karl.views.api.TemplateAPI类的典型用法代码示例。如果您正苦于以下问题:Python TemplateAPI类的具体用法?Python TemplateAPI怎么用?Python TemplateAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
def __call__(self):
""" Folder contents for the INetworkEvents marker"""
context = self.context
request = self.request
page_title = context.title
api = TemplateAPI(context, request, page_title)
# Data for the filter bar, get the list of possible years and months
this_year = datetime.datetime.now().year
fb_years = [str(i) for i in range(2007, this_year + 1)]
fb_months = [
("1", "January"),
("2", "February"),
("3", "March"),
("4", "April"),
("5", "May"),
("6", "June"),
("7", "July"),
("8", "August"),
("9", "September"),
("10", "October"),
("11", "November"),
("12", "December"),
]
# Flatten the search results into ZPT data
try:
batch = self._get_batch()
except ParseError, e:
api.set_error_message("Error: %s" % e)
batch = {"entries": (), "batching_required": False}
示例2: __call__
def __call__(self):
api = TemplateAPI(self.context, self.request,
'Add Wiki Page')
api.karl_client_data['text'] = dict(
enable_wiki_plugin=True,
enable_imagedrawer_upload=True)
return {'api': api, 'actions': ()}
示例3: __call__
def __call__(self):
tapi = TemplateAPI(self.context, self.request, 'Trash')
if self.error is None:
self.fill_deleted()
else:
tapi.set_status_message(unicode(self.error))
return {'api': tapi, 'deleted': self.deleted}
示例4: __call__
def __call__(self):
api = TemplateAPI(self.context, self.request,
'Add Blog Entry')
api.karl_client_data['text'] = dict(
enable_imagedrawer_upload = True,
)
return {'api':api, 'actions':()}
示例5: __call__
def __call__(self):
page_title = 'Edit ' + self.context.title
api = TemplateAPI(self.context, self.request, page_title)
api.karl_client_data['text'] = dict(
enable_imagedrawer_upload = True,
)
return {'api':api, 'actions':()}
示例6: __call__
def __call__(self):
layout_provider = get_layout_provider(self.context, self.request)
layout = layout_provider('community')
api = TemplateAPI(self.context, self.request, 'Add Forum Topic')
api.karl_client_data['text'] = dict(
enable_imagedrawer_upload = True,
)
return {'api':api, 'actions':(), 'layout':layout}
示例7: reference_outline_view
def reference_outline_view(context, request):
# Look for moveUp or moveDown in QUERY_STRING, telling us to
# reorder something
status_message = None
subpath = request.params.get('subpath')
backto = {
'href': resource_url(context.__parent__, request),
'title': context.__parent__.title,
}
user_can_edit = False
actions = []
if has_permission('create', context, request):
addables = get_folder_addables(context, request)
if addables is not None:
actions.extend(addables())
if has_permission('edit', context, request):
user_can_edit = True
actions.append(('Edit', 'edit.html'))
if subpath:
direction = request.params['direction']
status_message = move_subpath(context, subpath, direction)
if has_permission('delete', context, request):
actions.append(('Delete', 'delete.html'))
if has_permission('administer', context, request):
actions.append(('Advanced', 'advanced.html'))
page_title = context.title
api = TemplateAPI(context, request, page_title)
# Get a layout
layout_provider = get_layout_provider(context, request)
layout = layout_provider()
# provide client data for rendering current tags in the tagbox
client_json_data = dict(
tagbox=get_tags_client_data(context, request),
)
previous, next = get_previous_next(context, request)
api.status_message = status_message
return render_to_response(
'templates/show_referencemanual.pt',
dict(api=api,
actions=actions,
user_can_edit=user_can_edit,
head_data=convert_to_script(client_json_data),
tree=getTree(context, request, api),
backto=backto,
layout=layout,
previous_entry=previous,
next_entry=next),
request=request,
)
示例8: __call__
def __call__(self):
layout_provider = get_layout_provider(self.context, self.request)
layout = layout_provider('community')
page_title = 'Edit %s' % self.context.title
api = TemplateAPI(self.context, self.request, page_title)
api.karl_client_data['text'] = dict(
enable_imagedrawer_upload=True)
return {
'api': api,
'layout': layout,
'actions': []}
示例9: __call__
def __call__(self):
page_title = 'Edit ' + self.context.title
api = TemplateAPI(self.context, self.request, page_title)
# ux1
api.karl_client_data['text'] = dict(
enable_imagedrawer_upload = True,
)
# ux2
layout = self.request.layout_manager.layout
layout.head_data['panel_data']['tinymce'] = api.karl_client_data['text']
return {'api':api, 'actions':()}
示例10: admin_contents_moveup_view
def admin_contents_moveup_view(context, request):
api = TemplateAPI(context, request, 'Contents')
name = request.GET['name']
order = context.order
n = order.index(name)
if n == 0:
api.status_message = 'Already at top of list'
else:
order[n], order[n-1] = order[n-1], order[n]
context.order = order
return HTTPFound(location=resource_url(context, request, 'admin.html'))
示例11: admin_contents_movedown_view
def admin_contents_movedown_view(context, request):
api = TemplateAPI(context, request, 'Contents')
name = request.GET['name']
order = list(context.order) # in case it is raw OOBTreeItems
n = order.index(name)
if n+1 == len(order):
api.status_message = 'Already at bottom of list'
else:
order[n], order[n+1] = order[n+1], order[n]
context.order = order
return HTTPFound(location=resource_url(context, request, 'admin.html'))
示例12: __call__
def __call__(self):
page_title = 'Edit %s' % self.context.title
api = TemplateAPI(self.context, self.request, page_title)
# prepare client data
api.karl_client_data['text'] = dict(
enable_wiki_plugin = True,
enable_imagedrawer_upload = True,
)
return {'api':api,
'actions':(),
}
示例13: admin_contents_movedown_view
def admin_contents_movedown_view(context, request):
peopledir = find_peopledirectory(context)
api = TemplateAPI(context, request, 'Contents')
name = request.GET['name']
order = context.order
n = order.index(name)
if n+1 == len(order):
api.status_message = 'Already at bottom of list'
else:
order[n], order[n+1] = order[n+1], order[n]
context.order = order
return HTTPFound(location=model_url(context, request, 'admin.html'))
示例14: __call__
def __call__(self):
if self.request.params.get('form.submitted', None) is not None:
resp = self.login()
if resp:
# if this returned with something, we deal with it
return resp
# Log in user seamlessly with kerberos if enabled
try_kerberos = self.request.GET.get('try_kerberos', None)
if try_kerberos:
try_kerberos = asbool(try_kerberos)
else:
try_kerberos = asbool(get_config_setting('kerberos', 'False'))
if try_kerberos:
from karl.security.kerberos_auth import get_kerberos_userid
userid = get_kerberos_userid(self.request)
if userid:
return remember_login(self.context, self.request, userid, None)
# Break infinite loop if kerberos authorization fails
if (self.request.authorization and
self.request.authorization[0] == 'Negotiate'):
try_kerberos = False
page_title = 'Login to %s' % get_setting(self.context, 'title')
api = TemplateAPI(self.context, self.request, page_title)
sso_providers = []
sso = self.settings.get('sso')
if sso:
# importing here rather than in global scope allows to only require
# velruse be installed for systems using it.
from velruse import login_url
for name in sso.split():
provider = self.settings.get('sso.%s.provider' % name)
title = self.settings.get('sso.%s.title' % name)
sso_providers.append({'title': title, 'name': name,
'url': login_url(self.request, provider)})
api.status_message = self.request.params.get('reason', None)
response = render_to_response(
'templates/login.pt',
dict(
api=api,
nothing='',
try_kerberos=try_kerberos,
sso_providers=sso_providers,
came_from=self.request.params.get('came_from', ''),
app_url=self.request.application_url),
request=self.request)
forget_headers = forget(self.request)
response.headers.extend(forget_headers)
return response
示例15: admin_contents_moveup_view
def admin_contents_moveup_view(context, request):
peopledir = find_peopledirectory(context)
api = TemplateAPI(context, request, "Contents")
name = request.GET["name"]
order = context.order
n = order.index(name)
if n == 0:
api.status_message = "Already at top of list"
else:
order[n], order[n - 1] = order[n - 1], order[n]
context.order = order
return HTTPFound(location=resource_url(context, request, "admin.html"))