예제 #1
0
    def test_closest_content(self):
        """Test the closest content utility directly
        """
        # without any information the closest content is Plone Site
        self.assertEqual(self.portal, closest_content())

        # we can pass a parameter to closest_content that will be
        # used to find a content object
        folder = self._create_folder('folder-1')
        self.assertEqual(folder, closest_content(folder))
예제 #2
0
    def test_closest_content(self):
        """Test the closest content utility directly
        """
        # without any information the closest content is Plone Site
        self.assertEqual(self.portal, closest_content())

        # we can pass a parameter to closest_content that will be
        # used to find a content object
        folder = self._create_folder("folder-1")
        self.assertEqual(folder, closest_content(folder))
예제 #3
0
 def wrapped_context(self):
     """"We need to wrap the context to be able to acquire the root
         of the site to get tools, as done in plone.app.textfield"""
     context = self.context
     content = closest_content(context)
     if context.__class__ == dict:
         context = UserDict(self.context)
     return ImplicitAcquisitionWrapper(context, content)
예제 #4
0
 def wrapped_context(self):
     """"We need to wrap the context to be able to acquire the root
         of the site to get tools, as done in plone.app.textfield"""
     context = self.context
     content = closest_content(context)
     if context.__class__ == dict:
         context = UserDict(self.context)
     return ImplicitAcquisitionWrapper(context, content)
예제 #5
0
파일: widget.py 프로젝트: Vinsurya/Plone
 def wrapped_context(self):
     context = self.context
     content = closest_content(context)
     # We'll wrap context in the current site *if* it's not already
     # wrapped.  This allows the template to acquire tools with
     # ``context/portal_this`` if context is not wrapped already.
     # Any attempts to satisfy the Kupu template in a less idiotic
     # way failed. Also we turn dicts into UserDicts to avoid
     # short-circuiting path traversal. :-s
     if context.__class__ == dict:
         context = UserDict(self.context)
     return ImplicitAcquisitionWrapper(context, content)
예제 #6
0
 def wrapped_context(self):
     context = self.context
     content = closest_content(context)
     # We'll wrap context in the current site *if* it's not already
     # wrapped.  This allows the template to acquire tools with
     # ``context/portal_this`` if context is not wrapped already.
     # Any attempts to satisfy the Kupu template in a less idiotic
     # way failed. Also we turn dicts into UserDicts to avoid
     # short-circuiting path traversal. :-s
     if context.__class__ == dict:
         context = UserDict(self.context)
     return ImplicitAcquisitionWrapper(context, content)
def available_languages_provider(context):
    """
    Create a vocabulary with all available languages
    """
    # fail-safe context
    context = closest_content(context)

    ltool = api.portal.get_tool('portal_languages')
    supported_languages = ltool.getSupportedLanguages()
    tm = ITranslationManager(context)
    translated_languages = tm.get_translated_languages()

    items = [(l, info.get('name', l))
             for (l, info) in ltool.getAvailableLanguageInformation().items()
             if l in supported_languages and l not in translated_languages]
    items = [SimpleTerm(i[0], i[0], i[1]) for i in items]

    return SimpleVocabulary(items)
 def get_closest_content(self):
     """Return the closest persistent context to this form.
     The right context of this form is the object created by:
     z3c.form.object.registerFactoryAdapter
     """
     return closest_content(self.context)
예제 #9
0
 def get_closest_content(self):
     """Return the closest persistent context to this form.
     The right context of this form is the object created by:
     z3c.form.object.registerFactoryAdapter
     """
     return closest_content(self.context)