[Zope-dev] Zope Tests: 4 OK, 1 Failed
Summary of messages to the zope-tests list. Period Sun Jan 6 12:00:00 2008 UTC to Mon Jan 7 12:00:00 2008 UTC. There were 5 messages: 5 from Zope Unit Tests. Test failures - Subject: FAILED (failures=1) : Zope-trunk Python-2.4.4 : Linux From: Zope Unit Tests Date: Sun Jan 6 21:02:33 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-January/008915.html Tests passed OK --- Subject: OK : Zope-2.7 Python-2.3.6 : Linux From: Zope Unit Tests Date: Sun Jan 6 20:56:30 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-January/008911.html Subject: OK : Zope-2.8 Python-2.3.6 : Linux From: Zope Unit Tests Date: Sun Jan 6 20:58:00 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-January/008912.html Subject: OK : Zope-2.9 Python-2.4.4 : Linux From: Zope Unit Tests Date: Sun Jan 6 20:59:31 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-January/008913.html Subject: OK : Zope-2.10 Python-2.4.4 : Linux From: Zope Unit Tests Date: Sun Jan 6 21:01:02 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-January/008914.html ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] zope.interface confuses Python
Yesterday, I released dm.zdoc and today I find problems. The analysis revealed: The class webdav.EtagSupport.EtagSupport has initially no attributes __provides__ and __providedBy__. For still unknown reasons, it suddenly gets these attributes. __provides__ is a zope.interface.declarations.ClassProvides. Therefore, I expect that Zope 3 or five is responsible for these additions. EtagSupport is in the mro of ManagableIndex. But nevertheless, ManagableIndex.__provides__ results in an AttributeError. Here is a transscript reproducing the problem: import App.FindHomes from webdav.EtagSupport import EtagSupport EtagSupport.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: class EtagSupport has no attribute '__provides__' from Products.ManagableIndex.ManagableIndex import ManagableIndex /usr/local/lib/python24.zip/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module DeprecationWarning) EtagSupport.__provides__ zope.interface.declarations.ClassProvides object at 0x40b5566c ManagableIndex.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: __provides__ from inspect import getmro EtagSupport in getmro(ManagableIndex) True Any ideas? -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[zope.interface bug] Re: [Zope-dev] zope.interface confuses Python
Dieter Maurer wrote at 2008-1-7 17:55 +0100: Yesterday, I released dm.zdoc and today I find problems. The analysis revealed: The class webdav.EtagSupport.EtagSupport has initially no attributes __provides__ and __providedBy__. For still unknown reasons, it suddenly gets these attributes. __provides__ is a zope.interface.declarations.ClassProvides. Therefore, I expect that Zope 3 or five is responsible for these additions. EtagSupport is in the mro of ManagableIndex. But nevertheless, ManagableIndex.__provides__ results in an AttributeError. Here is a transscript reproducing the problem: import App.FindHomes from webdav.EtagSupport import EtagSupport EtagSupport.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: class EtagSupport has no attribute '__provides__' from Products.ManagableIndex.ManagableIndex import ManagableIndex /usr/local/lib/python24.zip/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module DeprecationWarning) EtagSupport.__provides__ zope.interface.declarations.ClassProvides object at 0x40b5566c ManagableIndex.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: __provides__ from inspect import getmro EtagSupport in getmro(ManagableIndex) True Any ideas? I think I understand the behavior -- and I think it is a zope.interface bug. Under some circumstances zope.interface adds a __provides__ descriptor to a class. The descriptor is implemented in zope/interface/_zope_interface_coptimizations.c and called CPB_descr_get. While __implements__ is inherited by derived classes, the inherited __provides__ refuses to work for a derived class and raises AttributeError: __provides__ instead, the AttriuteError, I observe I will try to make my failure independent of ManagableIndex and then file a bug report. -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [zope.interface bug] Re: [Zope-dev] zope.interface confuses Python
On Jan 7, 2008, at 2:35 PM, Dieter Maurer wrote: Dieter Maurer wrote at 2008-1-7 17:55 +0100: Yesterday, I released dm.zdoc and today I find problems. The analysis revealed: The class webdav.EtagSupport.EtagSupport has initially no attributes __provides__ and __providedBy__. For still unknown reasons, it suddenly gets these attributes. __provides__ is a zope.interface.declarations.ClassProvides. Therefore, I expect that Zope 3 or five is responsible for these additions. EtagSupport is in the mro of ManagableIndex. But nevertheless, ManagableIndex.__provides__ results in an AttributeError. Here is a transscript reproducing the problem: import App.FindHomes from webdav.EtagSupport import EtagSupport EtagSupport.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: class EtagSupport has no attribute '__provides__' from Products.ManagableIndex.ManagableIndex import ManagableIndex /usr/local/lib/python24.zip/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module DeprecationWarning) EtagSupport.__provides__ zope.interface.declarations.ClassProvides object at 0x40b5566c ManagableIndex.__provides__ Traceback (most recent call last): File stdin, line 1, in ? AttributeError: __provides__ from inspect import getmro EtagSupport in getmro(ManagableIndex) True Any ideas? I think I understand the behavior -- and I think it is a zope.interface bug. No, it is intended behavior. Under some circumstances zope.interface adds a __provides__ descriptor to a class. The descriptor is implemented in zope/interface/_zope_interface_coptimizations.c and called CPB_descr_get. While __implements__ is inherited by derived classes, the inherited __provides__ refuses to work for a derived class and raises AttributeError: __provides__ instead, the AttriuteError, I observe That is intentional. I will try to make my failure independent of ManagableIndex and then file a bug report. I'm unclear why this caused a problem for you. You never said, afaict, what actually broke for you. What expectation did you have that is unsatisfied? My main gripe with the way this works is that classes get mutated. If I ever redo this someday, I'd use a data structure external to the classes. Modifying the classes was a mistake. Jim -- Jim Fulton Zope Corporation ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [zope.interface bug] Re: [Zope-dev] zope.interface confuses Python
Hello Jim, Jim Fulton wrote at 2008-1-7 15:15 -0500: I think I understand the behavior -- and I think it is a zope.interface bug. No, it is intended behavior. Why? ... Under some circumstances zope.interface adds a __provides__ descriptor to a class. The descriptor is implemented in zope/interface/_zope_interface_coptimizations.c and called CPB_descr_get. While __implements__ is inherited by derived classes, the inherited __provides__ refuses to work for a derived class and raises AttributeError: __provides__ instead, the AttriuteError, I observe That is intentional. If __implements__ is inherited, why is __provides__ not inherited? I will try to make my failure independent of ManagableIndex and then file a bug report. I'm unclear why this caused a problem for you. You never said, afaict, what actually broke for you. What expectation did you have that is unsatisfied? inspect does no longer work reliably. inspect.getmembers and inspect.classify_class_attrs require that for each name in dir(cls) getattr(cls, name) does not raise an exception. This fails for classes magically stuffed with a __provides__ descriptor. As a consequence, pydoc (which sits on top of inspect) fails -- and therefore dm.zdoc. My main gripe with the way this works is that classes get mutated. If I ever redo this someday, I'd use a data structure external to the classes. Modifying the classes was a mistake. Yes. That, too, would have avoided the bug. -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [zope.interface bug] Re: [Zope-dev] zope.interface confuses Python
On Jan 7, 2008, at 3:54 PM, Dieter Maurer wrote: ... Under some circumstances zope.interface adds a __provides__ descriptor to a class. The descriptor is implemented in zope/interface/_zope_interface_coptimizations.c and called CPB_descr_get. While __implements__ is inherited by derived classes, the inherited __provides__ refuses to work for a derived class and raises AttributeError: __provides__ instead, the AttriuteError, I observe That is intentional. If __implements__ is inherited, why is __provides__ not inherited? __provides__ (in this context) is a class attribute. I don't support (and don't want to support) inheritance between class objects. I will try to make my failure independent of ManagableIndex and then file a bug report. I'm unclear why this caused a problem for you. You never said, afaict, what actually broke for you. What expectation did you have that is unsatisfied? inspect does no longer work reliably. I expected as much. inspect is broken. inspect.getmembers and inspect.classify_class_attrs require that for each name in dir(cls) getattr(cls, name) does not raise an exception. This fails for classes magically stuffed with a __provides__ descriptor. It also fails for any descriptor that sometimes raises attribute errors. Someone should report this as an inspect bug. This would be so easy to fix. As a consequence, pydoc (which sits on top of inspect) fails -- and therefore dm.zdoc. That's what you get for building on a broken foundation. I suggest monkey-fixing inspect.getmembers. This is a small function that should be easy to replace with a non-broken version. My main gripe with the way this works is that classes get mutated. If I ever redo this someday, I'd use a data structure external to the classes. Modifying the classes was a mistake. Yes. That, too, would have avoided the bug. Yes, it would have avoided the inspect bug. IMO, it would also have been cleaner. If someone wants to volunteer to change it, I'll try to provide some oversight. Unfortunately, it's not a small task, which is why I'm not volunteering to do it. Jim -- Jim Fulton Zope Corporation ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope] Intercept request
Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Cheers, David ___ 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] Intercept request
--On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. -aj pgpvK0Zz0ecuC.pgp Description: PGP signature ___ 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] Intercept request
On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. So I need to access the originating IP address and filter appropriately. I've written a few custom zope products before, but I've not done anything that really modifies zope's behaviour on every request - just on requests for the specific objects I'm publishing. So I'm familiar with the request object, but I don't know how to intercept *every* request. Are there any global request life-cycle hooks? If you can point me to those that would be a great help. Cheers, David ___ 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] Intercept request
On Jan 7, 2008, at 9:00 AM, David Chelimsky wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Cheers, David swap out theipaddress with the actual IP. dtml-if REMOTE_ADDR == 'theipaddress' true dtml-elif HTTP_X_FORWARDED_FOR == 'theipaddress' true dtml-else false /dtml-if Tom ___ 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] Intercept request
--On 7. Januar 2008 08:18:14 -0600 David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. You have a firewall for this purpose or you use apache rewrite rules for performing URL rewriting. -aj pgpZ4UZxAVLPR.pgp Description: PGP signature ___ 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] Intercept request
On Jan 7, 2008, at 9:18 AM, David Chelimsky wrote: On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. So I need to access the originating IP address and filter appropriately. I've written a few custom zope products before, but I've not done anything that really modifies zope's behaviour on every request - just on requests for the specific objects I'm publishing. So I'm familiar with the request object, but I don't know how to intercept *every* request. Are there any global request life-cycle hooks? If you can point me to those that would be a great help. Cheers, David If you just need to redirect traffic from an IP range, and not do anything fancy, it may be better to do it in Apache rather than Zope. http://wiki.zope.org/zope2/ZopeAndApache Tom ___ 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] Intercept request
On Jan 7, 2008 8:23 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:18:14 -0600 David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. You have a firewall for this purpose or you use apache rewrite rules for performing URL rewriting. Our host uses nginx, not apache. We can still do this w/ nginx configuration, but it means maintaining a configuration file rather than application code (which in my experience is more flexible/maintainable). Right now I'm just exploring options, so I'd still like to know how I can do this with Zope. Thanks, David -aj ___ 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] Intercept request
--On 7. Januar 2008 08:35:50 -0600 David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:23 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:18:14 -0600 David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. You have a firewall for this purpose or you use apache rewrite rules for performing URL rewriting. Our host uses nginx, not apache. We can still do this w/ nginx configuration, but it means maintaining a configuration file rather than application code (which in my experience is more flexible/maintainable). This issue is a configuration and not an application issue. So it basically does not belong into Zope. -aj pgpR36ROmZscS.pgp Description: PGP signature ___ 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] Intercept request
+---[ Andreas Jung ]-- | | This issue is a configuration and not an application issue. So it basically | does not belong into Zope. That's a pretty narrow view in my opinion. We nearly all already display different content to different classes of user, I fail to see how grouping those users by IP address is really any different. -- Andrew Milton [EMAIL PROTECTED] ___ 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] Intercept request
--On 8. Januar 2008 01:49:21 +1100 Andrew Milton [EMAIL PROTECTED] wrote: +---[ Andreas Jung ]-- | | This issue is a configuration and not an application issue. So it | basically does not belong into Zope. That's a pretty narrow view in my opinion. We nearly all already display different content to different classes of user, I fail to see how grouping those users by IP address is really any different. Narrow or not..it does not belong into directly in Zope in my opinion. If you were using Plone for example as CMS, you could create your PAS plugin providing dedicated roles for different IP ranges (or something similar) and control the visibility of content through the standard Zope security by granting View permission (and others) to the related roles. -aj pgp9nrM3fwgbd.pgp Description: PGP signature ___ 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] Re: Intercept request
BTW - I'm using ZPT, not DTML. I'm guessing I can do this with a simple script that I include on every page, yes? That could work, but seems a bit error prone - that's why I'm looking for some sort of request hook. But maybe that's my best option within Zope. Thoughts? I guess if you want to do this easily inside zope, then a script is the way to go. Somebody already posted a dtml solution; however, I think it is better you put it in a python script that will be called from your standard_header file, which can be either a dtml method or a page template. A request hook will require you to patch zope, write a monkey patch, or some kind of UserFolder based on ip addresses, which means to directly modify zope's code or create an external product. The invested time on doing this isn't worth, when you can do it easier and in less time, with either a script or by modifying your proxy's configuration. I think it would be better to let your proxy do this. This isn't really hard with nginx: http://wiki.codemongers.com/NginxHttpAccessModule Anyway, if you don't have access to the maschine hosting your zope, then you should try the script solution. Best regards Josef ___ 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] Re: Intercept request
David Chelimsky wrote: [..] BTW - I'm using ZPT, not DTML. I'm guessing I can do this with a simple script that I include on every page, yes? That could work, but seems a bit error prone - that's why I'm looking for some sort of request hook. But maybe that's my best option within Zope. Thoughts? Are you saying you want an access rule? http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZopeServices.stx Raphael ___ 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] Intercept request
On Jan 7, 2008 8:35 AM, David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:23 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:18:14 -0600 David Chelimsky [EMAIL PROTECTED] wrote: On Jan 7, 2008 8:06 AM, Andreas Jung [EMAIL PROTECTED] wrote: --On 7. Januar 2008 08:00:27 -0600 David Chelimsky [EMAIL PROTECTED] wrote: Hi, I want to show different things to different viewers based on their IP addresses. How can I do this? Basically you look at the clients ip address (from the REQUEST object) and perform any action you need (redirections, conditions within scripts, templates)...but no idea what the sense of this usecase is. If you have different audiences, setup sites with different content or something similar. In addition: using Zope behind proxy will lead in request coming from the IP address of your reverse proxy. Additional configuration/programming is necessary to get hold of the original IP. Thanks for the reply. The use case is that my client wants to block a range of IP addresses from being able to view their site. You have a firewall for this purpose or you use apache rewrite rules for performing URL rewriting. Our host uses nginx, not apache. We can still do this w/ nginx configuration, but it means maintaining a configuration file rather than application code (which in my experience is more flexible/maintainable). Right now I'm just exploring options, so I'd still like to know how I can do this with Zope. BTW - I'm using ZPT, not DTML. I'm guessing I can do this with a simple script that I include on every page, yes? That could work, but seems a bit error prone - that's why I'm looking for some sort of request hook. But maybe that's my best option within Zope. Thoughts? Thanks, David -aj ___ 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] Re: Intercept request
Raphael Ritz schrieb: David Chelimsky wrote: [..] BTW - I'm using ZPT, not DTML. I'm guessing I can do this with a simple script that I include on every page, yes? That could work, but seems a bit error prone - that's why I'm looking for some sort of request hook. But maybe that's my best option within Zope. Thoughts? Are you saying you want an access rule? http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZopeServices.stx Well, I guess that would be much easier than the script solution I mentioned before. You can put your access rule, which is also a script, on the folder you want to restrict. You have to be careful with this rules since you can block your access to the site; however, this can be easily undone. ___ 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] can't pickle instancemethod objects in testcase
My code works fine in normal running zope but not when run as a testcase (I'm not using bin/zopectl test if that matters) I get the following error. I feel guilty since I've got this line in my code: transaction.get().commit() (Expense.py#4458) I remember having come across this error before but can't remember what the solution was. -- Traceback (most recent call last): File /home/peterbe/zope/zope285/lib/python/Testing/ZopeTestCase/profiler.py, line 98, in __call__ testMethod() File testExpenses2.py, line 81, in test_uploadPhotos eids = context.uploadExpenseFiles(files) File /home/peterbe/zope/zope285/Products/MExpenses/Expense.py, line 4458, in uploadExpenseFiles transaction.get().commit() File lib/python/transaction/_transaction.py, line 381, in commit File lib/python/transaction/_transaction.py, line 379, in commit File lib/python/transaction/_transaction.py, line 424, in _commitResources File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 462, in commit self._commit(transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 503, in _commit self._store_objects(ObjectWriter(obj), transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 525, in _store_objects p = writer.serialize(obj) # This calls __getstate__ of obj File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 330, in serialize return self._dump(meta, obj.__getstate__()) File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 339, in _dump self._p.dump(state) File copy_reg.py, line 69, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle instancemethod objects -- -- 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] can't pickle instancemethod objects in testcase
--On 7. Januar 2008 18:29:50 + Peter Bengtsson [EMAIL PROTECTED] wrote: My code works fine in normal running zope but not when run as a testcase (I'm not using bin/zopectl test if that matters) I get the following error. I feel guilty since I've got this line in my code: transaction.get().commit() (Expense.py#4458) I remember having come across this error before but can't remember what the solution was. -- Traceback (most recent call last): File /home/peterbe/zope/zope285/lib/python/Testing/ZopeTestCase/profiler.py, line 98, in __call__ testMethod() File testExpenses2.py, line 81, in test_uploadPhotos eids = context.uploadExpenseFiles(files) File /home/peterbe/zope/zope285/Products/MExpenses/Expense.py, line 4458, in uploadExpenseFiles transaction.get().commit() File lib/python/transaction/_transaction.py, line 381, in commit File lib/python/transaction/_transaction.py, line 379, in commit File lib/python/transaction/_transaction.py, line 424, in _commitResources File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 462, in commit self._commit(transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 503, in _commit self._store_objects(ObjectWriter(obj), transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 525, in _store_objects p = writer.serialize(obj) # This calls __getstate__ of obj File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 330, in serialize return self._dump(meta, obj.__getstate__()) File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 339, in _dump self._p.dump(state) File copy_reg.py, line 69, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle instancemethod objects Well, this error is self-speaking :-) The standard solution for figuring out the related property/attr keeping the instancemethod is: pdb. Look at the object or its __dict__ and check what is inside or think about your code where you might be assigning a method somewhere. -aj pgpV74RHTM3KV.pgp Description: PGP signature ___ 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] can't pickle instancemethod objects in testcase
Andreas Jung wrote: --On 7. Januar 2008 18:29:50 + Peter Bengtsson [EMAIL PROTECTED] wrote: My code works fine in normal running zope but not when run as a testcase (I'm not using bin/zopectl test if that matters) I get the following error. I feel guilty since I've got this line in my code: transaction.get().commit() (Expense.py#4458) I remember having come across this error before but can't remember what the solution was. -- Traceback (most recent call last): File /home/peterbe/zope/zope285/lib/python/Testing/ZopeTestCase/profiler.py, line 98, in __call__ testMethod() File testExpenses2.py, line 81, in test_uploadPhotos eids = context.uploadExpenseFiles(files) File /home/peterbe/zope/zope285/Products/MExpenses/Expense.py, line 4458, in uploadExpenseFiles transaction.get().commit() File lib/python/transaction/_transaction.py, line 381, in commit File lib/python/transaction/_transaction.py, line 379, in commit File lib/python/transaction/_transaction.py, line 424, in _commitResources File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 462, in commit self._commit(transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 503, in _commit self._store_objects(ObjectWriter(obj), transaction) File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 525, in _store_objects p = writer.serialize(obj) # This calls __getstate__ of obj File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 330, in serialize return self._dump(meta, obj.__getstate__()) File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 339, in _dump self._p.dump(state) File copy_reg.py, line 69, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle instancemethod objects Well, this error is self-speaking :-) The standard solution for figuring out the related property/attr keeping the instancemethod is: pdb. Look at the object or its __dict__ and check what is inside or think about your code where you might be assigning a method somewhere. Damn it! Not the answer I was hoping for. I was hoping for something simpler and more obvious :) What object do you suggest I inspect in the debugger then? I don't know how the ZODB figures out what it needs to save. -- 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] Intercept request
Andreas Jung wrote at 2008-1-7 16:04 +0100: Narrow or not..it does not belong into directly in Zope in my opinion. If you were using Plone for example as CMS, you could create your PAS plugin providing dedicated roles for different IP ranges (or something similar) and control the visibility of content through the standard Zope security by granting View permission (and others) to the related roles. And this solution is possible in Zope, too (after PluggableAuthService) has been installed). And of course, this solution is in Zope (and not the web server or the firewall). -- 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] Re: Intercept request
Raphael Ritz wrote at 2008-1-7 16:16 +0100: David Chelimsky wrote: [..] BTW - I'm using ZPT, not DTML. I'm guessing I can do this with a simple script that I include on every page, yes? That could work, but seems a bit error prone - that's why I'm looking for some sort of request hook. But maybe that's my best option within Zope. Thoughts? Are you saying you want an access rule? http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZopeServices.stx When SiteAccess AccessRules are used for security critical demands then one has to keep in mind that they can be disabled via special segments in the url. In such a case, I would remove the code that makes this possible. -- 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] can't pickle instancemethod objects in testcase
--On 7. Januar 2008 19:17:06 + Peter Bengtsson [EMAIL PROTECTED] wrote: Damn it! Not the answer I was hoping for. I was hoping for something simpler and more obvious :) What object do you suggest I inspect in the debugger then? I don't know how the ZODB figures out what it needs to save. That's trivial start your debugger in ZODB.serialize._dump() and check the 'state' parameter (should be a dict). Using pprint.pprint(state) will make the output less painful...just check the output for something with instancemethod or something similar smelly. -aj pgpG0vLQvlsQk.pgp Description: PGP signature ___ 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] Using md5 with allow_module
Hi, I have a need to generate an md5 hash for an XML fragment generated by TTW Zope code. I thought I could do this with allow_module - I have a pseudo-product with an __init_,py that contains: - # Global module assertions for Python scripts from Products.PythonScripts.Utility import allow_module allow_module(md5) In my TTW python script, I have: - import md5 hash=md5.new() hash=hash.update('test') ...but when I execute the script I get: - Error Type: Unauthorized Error Value: The container has no security assertions. Access to 'update' of (md5.md5 object at 0xb98ab00) denied. I'm basing this on: - http://www.zope.org/Documentation/Books/ZDG/current/Security.stx ...specifically the section entitled Utility Functions For Allowing Import of Modules By Through The Web Code. I thought I understood this, and have used it with other Python modules, but based on what is happening with the md5 module, I obvioulsy don't! Can someone clue me in, or point me towards more recent or explicit documentation, please? -- Cheers, Philip ___ 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] Using md5 with allow_module
--On 7. Januar 2008 21:10:32 + Running Clam [EMAIL PROTECTED] wrote: Hi, I have a need to generate an md5 hash for an XML fragment generated by TTW Zope code. Error Type: Unauthorized Error Value: The container has no security assertions. Access to 'update' of (md5.md5 object at 0xb98ab00) denied. I'm basing this on: - http://www.zope.org/Documentation/Books/ZDG/current/Security.stx ...specifically the section entitled Utility Functions For Allowing Import of Modules By Through The Web Code. I thought I understood this, and have used it with other Python modules, but based on what is happening with the md5 module, I obvioulsy don't! FAQ! allow_module() does not work with all and everything. Use an external method or a browser view instead or move your code into your zope product code (if you have one). -aj pgp83PV2ymWMR.pgp Description: PGP signature ___ 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] Using md5 with allow_module
Hi All, Sorry Andreas - I hit reply instead of reply-all, and sent my response only to you. Thanks for your reply. On 1/8/08, Andreas Jung [EMAIL PROTECTED] wrote: FAQ! Yes, there have been a good few questions about this - I spent a lot of time googling yesterday, and found a couple of threads where the questioner seems to have given up at this point. The problem seems to be that it works some of the time - I have another case where it works (pywintypes, FWIW). allow_module() does not work with all and everything. Use an external method or a browser view instead or move your code into your zope product code (if you have one). In this case, how could I know that allow_module() will not work with md5? IOW, how could I tell the difference between a module not being a candidate for allow_module() and an error in my own code? I understand that an external method or a product are my other choices, but I'm really uncomfortable about not understanding how I can tell when I can and when I cannot use allow_module() - at the moment, this feels horribly like trial and error coding! Enough people have struggled with this that I'd like to understand it well enough to add something to the wiki for the next person who has the problem... -- Cheers, Philip ___ 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] Using md5 with allow_module
--On 8. Januar 2008 06:47:37 + Running Clam [EMAIL PROTECTED] wrote: I understand that an external method or a product are my other choices, but I'm really uncomfortable about not understanding how I can tell when I can and when I cannot use allow_module() - at the moment, this feels horribly like trial and error coding! Enough people have struggled with this that I'd like to understand it well enough to add something to the wiki for the next person who has the problem... There is an intriguing comment at the end of the page: http://wiki.zope.org/zope2/HowToAddModulesToRestrictedCode Andreas pgpci4wS9oRuE.pgp Description: PGP signature ___ 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 )