Esempio n. 1
0
	def func(fn):
		@wraps(fn)
		def call(*cargs, **ckw):
			request = ckw.get('request') or cargs[0]
			if not has_access(request.user, 'portal_%s'%fn.__name__):
				raise Http403
			return fn(*cargs, **ckw)
		kw['name'] = fn.__name__
		kw['function'] = call
		register_action(**kw)
		check_permission('portal_%s'%kw['name'], kw.get('verbose_name', kw['name']))
		return call
Esempio n. 2
0
def register_type(cls, base=None, user=True, verbose_name=u''):
	if not verbose_name:
		verbose_name = getattr(cls._meta, 'verbose_name', u'')
		actions = {}
	for member_name in dir(cls):
		try:
			member = getattr(cls, member_name)
			if inspect.ismethod(member) and getattr(member, 'is_objectaction', False):
				actions[member_name] = {'verbose_name': member.verbose_name,
										'name': member_name,
										'category': member.category}
				check_permission(member_name, member.verbose_name, cls)
		except: pass
	REGISTRUM['types'][cls.__name__] = {'cls':cls, 'verbose_name':verbose_name,
			'user':user, 'base':base, 'actions': actions}
	logging.info('REGISTER TYPE %s'%cls.__name__)