def upload(type): if context.user is None: raise HttpForbiddenError() # get photo service: provider = shared.get_setting('storage', 'photo_provider', '') if not provider: return __upload_result( 403, '', '', 'You do not configure a photo provider. Go to "Setting", "Storage" to configure a photo provider.' ) settings = shared.get_settings('storage') prefix = provider[:-len('PhotoProvider')].replace('.', '_') kw = {} for key in settings: if key.startswith(prefix): k = key[len(prefix):] v = settings[key] if isinstance(k, unicode): k = k.encode('utf8') if isinstance(v, unicode): v = v.encode('utf8') kw[k] = v try: module_name = provider[:-len('.PhotoProvider')] mod = __import__(module_name, globals(), locals(), ['PhotoProvider']) payload = context.request.get('NewFile') url = mod.PhotoProvider.upload(payload, 'title', 'upload from ExpressMe', **kw) if 'photo_proxied' in settings and settings['photo_proxied'] == 'True': import util url = util.make_proxy(url) __upload_result(0, url, 'filename', '') except Exception, e: __upload_result(1, '', 'filename', 'Upload failed: %s' % str(e))
def upload(type): if context.user is None: raise HttpForbiddenError() # get photo service: provider = shared.get_setting('storage', 'photo_provider', '') if not provider: return __upload_result(403, '', '', 'You do not configure a photo provider. Go to "Setting", "Storage" to configure a photo provider.') settings = shared.get_settings('storage') prefix = provider[:-len('PhotoProvider')].replace('.', '_') kw = {} for key in settings: if key.startswith(prefix): k = key[len(prefix):] v = settings[key] if isinstance(k, unicode): k = k.encode('utf8') if isinstance(v, unicode): v = v.encode('utf8') kw[k] = v try: module_name = provider[:-len('.PhotoProvider')] mod = __import__(module_name, globals(), locals(), ['PhotoProvider']) payload = context.request.get('NewFile') url = mod.PhotoProvider.upload(payload, 'title', 'upload from ExpressMe', **kw) if 'photo_proxied' in settings and settings['photo_proxied']=='True': import util url = util.make_proxy(url) __upload_result(0, url, 'filename', '') except Exception, e: __upload_result(1, '', 'filename', 'Upload failed: %s' % str(e))
def __handle_get_theme(): ''' Display all themes under dir '/theme' ''' themes = manage.get_themes() selected = shared.get_setting('theme', 'selected', '') if not selected in themes: selected = themes[0] return {'template': 'theme.html', 'themes': themes, 'selected': selected}
def __handle_get_settings(): ''' show form of settings of wiki ''' return { 'template' : 'setting.html', 'entry' : shared.get_setting('wiki', 'entry', 'Main Page'), 'edit_level' : '', 'approve_level' : '' }
def __handle_get_settings(): ''' show form of settings of wiki ''' return { 'template': 'setting.html', 'entry': shared.get_setting('wiki', 'entry', 'Main Page'), 'edit_level': '', 'approve_level': '' }
def __handle_get_theme(): ''' Display all themes under dir '/theme' ''' themes = manage.get_themes() selected = shared.get_setting('theme', 'selected', '') if not selected in themes: selected = themes[0] return { 'template' : 'theme.html', 'themes' : themes, 'selected' : selected }
def update_model(rootpath, appname, model): # set current theme = 'simple': theme = shared.get_setting('theme', 'selected', '') if not theme: themes = manage.get_themes() theme = themes[0] shared.save_setting('theme', 'selected', theme) model['theme'] = theme # add widgets: instances = widget.get_widget_instances() all_settings = widget.get_all_instances_settings() widget.bind_instance_model(instances, all_settings) import logging model['widgets'] = instances model['show_widget__raw__'] = show_widget logging.warning('loaded ' + str(instances))