Exemplo n.º 1
0
 def _processExtFile(self, mid, ctype):
     """ Apply media converters to self subobject with given id (mid) which
     is stored outside Data.fs, with original content-type ctype.
     """
     from OFS.ObjectManager import ObjectManager
     media = ObjectManager._getOb(self, mid)
     launch_job(media2flv, self.aq_parent, ofs_path(media))
Exemplo n.º 2
0
    def test_thread(self):
        from time import sleep
        from threading import Semaphore
        from naaya.core.zope2util import ofs_path, launch_job
        import transaction

        job_done = Semaphore(0)

        def threaded_job(context):
            context.hello = "world"
            transaction.commit()
            job_done.release()

        folder = self.portal['info']
        launch_job(threaded_job, folder, ofs_path(folder))
        transaction.commit()

        for c in range(100):
            if job_done.acquire(blocking=False):
                break
            sleep(0.1)
        else:
            self.fail("Waited 10 seconds and the job did not finish yet")

        transaction.abort()
        self.assertEqual(folder.hello, "world")
Exemplo n.º 3
0
 def _processExtFile(self, mid, ctype):
     """ Apply media converters to self subobject with given id (mid) which
     is stored outside Data.fs, with original content-type ctype.
     """
     from OFS.ObjectManager import ObjectManager
     media = ObjectManager._getOb(self, mid)
     launch_job(media2flv, self.aq_parent, ofs_path(media))
Exemplo n.º 4
0
    def test_thread(self):
        from time import sleep
        from threading import Semaphore
        from naaya.core.zope2util import ofs_path, launch_job
        import transaction

        job_done = Semaphore(0)

        def threaded_job(context):
            context.hello = "world"
            transaction.commit()
            job_done.release()

        folder = self.portal['info']
        launch_job(threaded_job, folder, ofs_path(folder))
        transaction.commit()

        for c in range(100):
            if job_done.acquire(blocking=False):
                break
            sleep(0.1)
        else:
            self.fail("Waited 10 seconds and the job did not finish yet")

        transaction.abort()
        self.assertEqual(folder.hello, "world")