def test_find_ploneroot(self):
        p1 = find_ploneroot(self.portal.newsite.subfolder)
        p2 = find_ploneroot(self.portal.subfolder2)
        self.assertEqual(p1, self.portal)
        self.assertEqual(p1, p2)

        self.assertEqual(find_ploneroot(self.portal.newsite.subfolder, as_url=True), "http://nohost/plone")
Example #2
0
    def test_find_ploneroot(self):
        p1 = find_ploneroot(self.portal.newsite.subfolder)
        p2 = find_ploneroot(self.portal.subfolder2)
        self.assertEqual(p1, self.portal)
        self.assertEqual(p1, p2)

        self.assertEqual(
            find_ploneroot(self.portal.newsite.subfolder, as_url=True),
            'http://nohost/plone')
Example #3
0
    def search_base_context(self):
        search_base_path = uuidToObject(self.data.search_base_uid)
        if search_base_path is not None:
            search_base_path = '/'.join(search_base_path.getPhysicalPath())

        if search_base_path:
            portal = find_ploneroot(self.context)
            search_base = '/'.join(search_base_path.split('/')[2:])
            return portal.unrestrictedTraverse(
                search_base.lstrip('/')
            )

        return find_site(self.context, as_url=False)
Example #4
0
def get_calendar_url(context, search_base):
    # search_base is always from the portal_root object. We won't include
    # the path from the portal root object, so we traverse to the calendar
    # object and call it's url then.
    calendar_url = None
    if search_base:
        portal = find_ploneroot(context)
        calendar_url = portal.unrestrictedTraverse(
            search_base.lstrip('/')  # start relative, first slash is omitted
        ).absolute_url()
    else:
        site_url = find_site(context, as_url=True)
        calendar_url = '%s/event_listing' % site_url

    return calendar_url
Example #5
0
def get_calendar_url(context, search_base):
    # search_base is always from the portal_root object. We won't include
    # the path from the portal root object, so we traverse to the calendar
    # object and call it's url then.
    calendar_url = None
    if search_base:
        portal = find_ploneroot(context)
        if six.PY2 and isinstance(search_base, six.text_type):
            search_base = search_base.encode('utf8')
        search_base = '/'.join(search_base.split('/')[2:])
        calendar_url = portal.unrestrictedTraverse(
            search_base.lstrip('/')  # start relative, first slash is omitted
        ).absolute_url()
    else:
        site_url = find_navroot(context, as_url=True)
        calendar_url = '%s/event_listing' % site_url

    return calendar_url