def available_language(node, value): """Checks that given language is available """ try: get_language_title(value) except UnknownLocaleError: raise Invalid(node, _(u"${lang} is not a valid language", mapping={'lang': value}))
def addable(self, context, request): """ In addition to the restrictions of :func:`kotti.resources.TypeInfo.addable`, a LanguageRoot must not be added within a parent that already has a language set. """ if hasattr(context, 'language') and context.language: return False return super(LanguageRootTypeInfo, self).addable(context, request) type_info = LanguageRootTypeInfo( name=u'LanguageRoot', title=_(u'Language root'), add_view=u'add_language_root', addable_to=Document.type_info.addable_to, edit_links=Document.type_info.edit_links, selectable_default_views=Document.type_info.selectable_default_views ) class LanguageRoot(Document): """ Root for a language specific subtree. """ implements(IDefaultWorkflow, INavigationRoot) id = Column( Integer(), ForeignKey('documents.id'),