[Zope] Re: Hooking persistent.Persistent.__setstate__ was Re: [ZODB-Dev] Analyzing a ZODB.
Alan Runyan wrote: > > - Customer has software on a remote machine. They are seeing > unnecessary transaction commits. Just like the guy 'Analyzing a ZODB'. I'm that guy ;). BTW, we have related those unnecessary commits to CMFQuestions, an old plone product now superseded by PloneSurveys... We came to that not by inspecting the code, but by realizing there were too many conflicts related with CMFQuestionnaire. We removed it, and the commits vanished. Best regards, Manuel. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ExternalMethod - add new parameter
rishi pathak wrote at 2008-4-8 18:03 +0530: > I dont have a need to run all the external method as root, only >some of them. For this what I was thinking was to introduce a new control >apart from the regular ones. Apparently, my previous message has not been clear enough. Let's try again: The effect of changing the effective user (e.g. to "root") is not restricted to a single thread but affects all threads in the current process. If you do this in one of your ExternalMethod's, all Zope requests start to be executed with root as effective user -- even those not executing your ExternalMethod. If at the end of your ExternalMethod, you switch back to the former user, the complete Zope process switches back -- even (other) requests that are currently executing an ExternalMethod that should run as root -- and which is likely to fail therefore. I hope the description should show you that this is the wrong approach. Please read my previous message (and other messages in this thread) to learn about alternatives. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Problem with zopectl debug
Manuel Vazquez Acosta wrote at 2008-4-7 15:21 -0400: >Dieter Maurer wrote: >> That is very strange: >> >> "zopectl debug" uses almost exactly the same startup sequence >> as "zopectl fg" (at least until after the configuration). >> Thus, if your Zope starts at all, "zopectl debug" should start. > ... >zopectl fg starts. Would need to see the starting sequence? Really funny Unfortunately, this means that is will be quite difficult to find the cause of your problem. One approach would be to emulate in a pure Python interpreter what "zopectl debug" would do for us. You may try: bin/zopectl shell # will create a new shell process with the correct environment from Zope2.Startup.run import configure configure('etc/zope.conf') # this is likely to raise the exception you have earlier reported from pdb import pm pm() # analyse the exception context -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Help writing test where bobobase_modification_time changes
I'll try to explain as briefly as possible. I've got a working cache pattern that keeps a cached version of a Zope file's content and only when it changes (by > bobobase_modification_time) the cache is invalidated and recreated. Here's the gist of my test class Test(ZopeTestCase.FunctionalTestCase): def test_recreateCache(self): """ bla """ self.folder.manage_addFile('foo.js','FOO data') url = self.folder.mytool.cacheFile('foo.js') # pseudo code this time path = urlparse(url)[2] response = self.publish(path) self.assert... tests on response... _file = getattr(self.folder, 'foo.js') _file.manage_edit(_file.title, _file.content_type, filedata='new data') newurl = self.folder.mytool.cacheFile('foo.js') assert newurl != url, "url hasn't changed :(" The reason it fails on the last line is that the time difference between the first time and the second time is nil. Adding a time.sleep(1) won't change anything because the bobobase_modification_time() doesn't change. How can I solve this? Make one big transaction two without having to use transaction.get().commit() which I don't think I can use in unit tests as per Dieter's advice. Grateful for help. Peter -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ExternalMethod - add new parameter
Hi Rishi. Can you telll me where should I look in the source(Code segment where external methods are loaded and executed) External methods are not just 'called' or 'loaded', they are executed in a zope thread which belong to the zope user. Changing the effective user would be a complex and risky task to do and is probably not needed your your project. Can you explain what you're trying to do in those External methods? Maybe we can help you to find a more elegant, simple solution. Martijn. -- Martijn Jacobs Four Digits, Internet Solutions a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 09162137 | btw: 8161.22.234.B01 e-mail: [EMAIL PROTECTED] | web: http://www.fourdigits.nl tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ExternalMethod - add new parameter
Zope itself should not be running as root. The external method will run as whatever user zope is running as. If you insist on doing this kind of thing, which is a pretty bad idea, then use os.system(...) or one of the popen(...) commands to call another program that you have permitted root access by a somewhat controlled process, such as sudo. At least then, you will have a log of changes (unless you make a security mistake and the log can itself be altered). jim penny Chris Withers <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 04/08/2008 09:52 AM To rishi pathak <[EMAIL PROTECTED]> cc Dieter Maurer <[EMAIL PROTECTED]>, zope@zope.org Subject Re: [Zope] ExternalMethod - add new parameter rishi pathak wrote: > I dont have a need to run all the external method as root, only > some of them. You seem to be carefully ignoring the fact that Dieter is pointing out that this isn't possible ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ExternalMethod - add new parameter
rishi pathak wrote: I dont have a need to run all the external method as root, only some of them. You seem to be carefully ignoring the fact that Dieter is pointing out that this isn't possible ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ExternalMethod - add new parameter
Hi Dieter, I dont have a need to run all the external method as root, only some of them. For this what I was thinking was to introduce a new control apart from the regular ones. viz id , title , Module Name and Function Name by name of 'Run as root', it would probably be a checkbox.Then at the point when external method code is executed I would check for the said control and if checked would get it executed as root. Can you telll me where should I look in the source(Code segment where external methods are loaded and executed) On Tue, Apr 8, 2008 at 12:50 AM, Dieter Maurer <[EMAIL PROTECTED]> wrote: > rishi pathak wrote at 2008-4-7 17:46 +0530: > >There is a requirement for running some external methods as super user. > >For this I thought of adding a new parameter.If set the code would be > >executed with effective uid of root. > > This is extremely dangerous. > > To run code as super user, you need to change the effective user id. > Changing the effective user id affects the whole process -- not just > the thread executing your external method. > These things are very difficult to handle in a multi threaded environment, > in general. > Moreover, running internet driven code uncontrolled as super user > is likely to be a big security risk. > > > Let your application write some command to a queue and process > the queue asynchronously. The processing can be performed as > super user. > > If this is not possible, let your application communicate > with another process which runs as super user -- and pass on > synchronous commands from your application to this process. > > In both cases, it is ensured that only the restricted command > set can be used to run something as super user -- and > not some arbitrary code > > > > -- > Dieter > -- Regards-- Rishi Pathak National PARAM Supercomputing Facility Center for Development of Advanced Computing(C-DAC) Pune University Campus,Ganesh Khind Road Pune-Maharastra ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] default-zpublisher-encoding and zpt encoding
Hi Yuri. Strange, but using a different apache it has worked as expected, the encoding is sent now, FYI :) Just out of curiosity : which version of apache did you have and which do you use now? Martijn. -- Martijn Jacobs Four Digits, Internet Solutions a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 09162137 | btw: 8161.22.234.B01 e-mail: [EMAIL PROTECTED] | web: http://www.fourdigits.nl tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] default-zpublisher-encoding and zpt encoding
Yuri wrote: --On 2. April 2008 15:59:58 +0200 Yuri <[EMAIL PROTECTED]> wrote: default-zpublisher-encoding in zope.conf seems not to work in zope 2.7.9, the server response don't set any charset. While: works, and the characters are displayed ok. But I cannot modify all the templates around and I'm looking for a general solution. The problem is to replicate a 2.6 Zope (run with -L it_IT) with 2.7.9. Zope 2.6 returns: Content-Type: text/html; charset=iso-8859-1 while Zope 2.7.9 returns: Content-Type: text/html Here the zope.conf part (default-zpublisher-encoding is ok, default_zpublisher_encoding don't exists in zopeschema.xml): Strange, but using a different apache it has worked as expected, the encoding is sent now, FYI :) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )