コード例 #1
0
    def test_OFS_ObjectManager__importObjectFromFile_xml(self):
        from OFS.DTMLMethod import DTMLMethod
        from OFS.Folder import Folder
        from OFS.XMLExportImport import exportXML

        connection, app = self._makeJarAndRoot()
        dm = DTMLMethod('test')
        dm._setId('test')
        dm.munge(_LONG_DTML)
        app._setObject('test', dm)
        sub = Folder('sub')
        app._setObject('sub', sub)
        transaction.savepoint(optimistic=True) # need an OID!
        oid = dm._p_oid
        sub = app._getOb('sub')

        handle, path = tempfile.mkstemp(suffix='.xml')
        try:
            ostream = os.fdopen(handle,'wb')
            data = exportXML(connection, oid, ostream)
            ostream.close()
            sub._importObjectFromFile(path, 0, 0)
        finally:
            # if this operaiton fails with a 'Permission Denied' error,
            # then comment it out as it's probably masking a failure in
            # the block above.
            os.remove(path)
コード例 #2
0
    def test_OFS_ObjectManager__importObjectFromFile_xml(self):
        from OFS.DTMLMethod import DTMLMethod
        from OFS.Folder import Folder
        from OFS.XMLExportImport import exportXML

        connection, app = self._makeJarAndRoot()
        dm = DTMLMethod('test')
        dm._setId('test')
        dm.munge(_LONG_DTML)
        app._setObject('test', dm)
        sub = Folder('sub')
        app._setObject('sub', sub)
        transaction.savepoint(optimistic=True) # need an OID!
        oid = dm._p_oid
        sub = app._getOb('sub')

        handle, path = tempfile.mkstemp(suffix='.xml')
        try:
            ostream = os.fdopen(handle,'wb')
            data = exportXML(connection, oid, ostream)
            ostream.close()
            sub._importObjectFromFile(path, 0, 0)
        finally:
            # if this operaiton fails with a 'Permission Denied' error,
            # then comment it out as it's probably masking a failure in
            # the block above.
            os.remove(path)
コード例 #3
0
ファイル: zope2testbase.py プロジェクト: goschtl/zope
    def test_dtml_method(self):
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            m = DTMLMethod()
            m._setId('m')
            method_body = '''All <dtml-var expr="'OK'">.'''
            m.manage_edit(method_body, 'test method')
            app._setObject(m.getId(), m, set_owner=0)
            transaction.commit()

            conn2 = self.db.open()
            try:
                app = conn2.root()['Application']
                m = app.m
                self.assertEqual(m.title, 'test method')
                res = m()
                self.assertEqual(res, 'All OK.')
            finally:
                conn2.close()

        finally:
            conn.close()
コード例 #4
0
ファイル: zope2testbase.py プロジェクト: bendavis78/zope
    def test_dtml_method(self):
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            m = DTMLMethod()
            m._setId('m')
            method_body = '''All <dtml-var expr="'OK'">.'''
            m.manage_edit(method_body, 'test method')
            app._setObject(m.getId(), m, set_owner=0)
            transaction.commit()

            conn2 = self.db.open()
            try:
                app = conn2.root()['Application']
                m = app.m
                self.assertEqual(m.title, 'test method')
                res = m()
                self.assertEqual(res, 'All OK.')
            finally:
                conn2.close()

        finally:
            conn.close()
コード例 #5
0
ファイル: test_CookieCrumbler.py プロジェクト: goschtl/zope
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        try:
            from OFS.userfolder import UserFolder
        except ImportError:
            # BBB for Zope < 2.13
            from AccessControl.User import UserFolder
        
        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous',)

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
        users._doAddUser('isaac', 'pass-w', ('Son',), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager',)
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
コード例 #6
0
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        try:
            from OFS.userfolder import UserFolder
        except ImportError:
            # BBB for Zope < 2.13
            from AccessControl.User import UserFolder

        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
コード例 #7
0
    def setUp(self):
        CookieCrumblerTests.setUp(self)
        root = Folder()
        self.root = root
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        users._doAddUser(
            'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
            'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
            ('Son', ), ())
        root._setObject(users.id, users)

        cc = CookieCrumbler()
        cc.id = 'cookie_authentication'
        root._setObject(cc.id, cc)
        self.cc = getattr(root, cc.id)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        self.responseOut = StringIO()
        self.req = makerequest(root, self.responseOut)

        self.credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').replace('\012', ''))
コード例 #8
0
    def _makeSite(self):
        from OFS.DTMLMethod import DTMLMethod
        from OFS.Folder import Folder
        from OFS.userfolder import UserFolder

        class TestFolder(Folder):
            def getPhysicalPath(self):
                return ()

        root = TestFolder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = quote(base64_encode(b'abraham:pass-w'))

        return root, cc, req, credentials
コード例 #9
0
    def _makeSite(self):
        from OFS.DTMLMethod import DTMLMethod
        from OFS.Folder import Folder
        from OFS.userfolder import UserFolder

        class TestFolder(Folder):
            def getPhysicalPath(self):
                return ()

        root = TestFolder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root._View_Permission = ('Anonymous',)

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
        users._doAddUser('isaac', 'pass-w', ('Son',), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager',)
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = quote(base64_encode(b'abraham:pass-w'))

        return root, cc, req, credentials
コード例 #10
0
ファイル: testCookieCrumbler.py プロジェクト: MarkTang/erp5
  def setUp(self):
    CookieCrumblerTests.setUp(self)
    root = Folder()
    self.root = root
    root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
    root.getPhysicalPath = lambda: ()  # hack
    root._View_Permission = ('Anonymous',)

    users = UserFolder()
    users._setId('acl_users')
    users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
    users._doAddUser('isaac', 'pass-w', ('Son',), ())
    users._doAddUser('abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
                     'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
                     ('Son',), ())
    root._setObject(users.id, users)
    
    cc = CookieCrumbler()
    cc.id = 'cookie_authentication'
    root._setObject(cc.id, cc)
    self.cc = getattr(root, cc.id)

    index = DTMLMethod()
    index.munge('This is the default view')
    index._setId('index_html')
    root._setObject(index.getId(), index)

    login = DTMLMethod()
    login.munge('Please log in first.')
    login._setId('login_form')
    root._setObject(login.getId(), login)

    protected = DTMLMethod()
    protected._View_Permission = ('Manager',)
    protected.munge('This is the protected view')
    protected._setId('protected')
    root._setObject(protected.getId(), protected)

    self.responseOut = StringIO()
    self.req = makerequest(root, self.responseOut)

    self.credentials = urllib.quote(
        base64.encodestring('abraham:pass-w').replace('\012', ''))