Re: [Zope-dev] Puzzle re zope.pytest
Hi Uli, Thanks for your reply to clarify the history of zope.pytest. On 05/17/2012 07:22 AM, Uli Fouquet wrote: On Wed, 16 May 2012 03:40:17 -0500 Jeff Rush wrote: 5) the unit tests for zope.pytest itself are failing with: from zope.interface.interfaces import ComponentLookupError E ImportError: cannot import name ComponentLookupError You need at least zope.interface 3.8.0. Looks like you're using an older version. Yes, for backward compatibility with existing packages, we are using Zope 2.12.x which has an older zope.interface in its ZTK. I admit, though, that I am not too deep into py.test. If you're an experienced py.test user, we might could work out something together and make it more usable. I'd be happy to learn more about py.test from someone more experienced. No, I'm new to py.test. We had heard good things about it and, a post here on-list (from Jim Fulton) that zope.testrunner should be replaced with a more modern testrunner. I'm not the right one to enhance zope.pytest to better integrate with py.test though. If, however, you're after a quick, ready-to-use, comprehensive framework for testing Zope applications, you might be better off with other approaches like the regular Zope testrunner and related libs. Yes, we've been using zope.testrunner here, but some of the developers on the team who are less familiar with Zope don't care for the zope-specific coding in our tests. They had hoped to move us forward with a more general test framework but I guess it can't happen right now. I'm wondering if there is a way to run the improved test APIs of py.test while running it under the zope.testrunner. That way we'd get some of the benefit of py.test, to move away from the various self.assertEqual() calls and to the cleaner way of py.test. Initial investigation says not, that the API benefits of py.test are closely tied to its testrunner. I thought we could create a py.test-specific testsuite() and use the API internally. -Jeff ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Puzzle re zope.pytest
Are many folks using zope.pytest? We're looking into it but, for such a small amount of code, are finding it a bit odd and seemingly broken. Breaking down the basic creation of an application object, here is what the code does, with indentation to show what a method call performs: create_app() db = setup_db() storage = DemoStorage(name) db = DB(storage, database_name=name) db.setActivityMonitor( ZODB.ActivityMonitor.ActivityMonitor() ) notify( zope.processlifetime.DatabaseOpened(db) ) return db connection = setup_connection(db) return db.open() connection.root()[ZopePublication.root_name]['test'] = site_root My issues are: 1) the DatabaseOpened event is sent out _before_ the ZODB is actually opened, making it hard to use handlers to initialize a test layout in the ZODB. 2) there are no other events emitted, such as after root is initialized. 3) there is a key lookup of ZopePublication.root_name inside connection.root() before any code has _set_ such a key, raising a key lookup exception in my basic evaluation pgm. 4) there are no examples of tests that use the 'test' subscript, and I'm puzzled by the extra level of indirection instead of just using ZopePublication.root_name in test_XXX functions. 5) the unit tests for zope.pytest itself are failing with: from zope.interface.interfaces import ComponentLookupError E ImportError: cannot import name ComponentLookupError I've googled to find others using zope.pytest, to see examples of correct usage in a ZODB-based testing environment, without luck. -Jeff ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Sanity Check on zope.sessions and Zope 2.12.x
I'm chasing a problem when trying to use zope.sessions with Zope 2.12.x, and I'm beginning to think that they are an incompatible mix of Zope2 and Zope3 technologies. Can anyone confirm either way, so I know whether I'm wasting my time. What is happening is when I adapt the request I receive to IClientId, the CookieClientIdManager within zope.sessions code (logically) wants to invoke request.response.getCookie(). However the response object my view is receiving is a ZServerHTTPResponse, which lacks such a method. Considering that Zope 2.12.x runs ZServer, it makes sense I'm seeing ZServerHTTPRequest/ZServerHTTPResponse objects, but that means the ClientIdManager inside zope.session is just not compatible with ZServer. Am I missing something? Is there some magic someplace that fixes up the incompatibility in some way I'm missing? I'm guessing my only solution is to re-implement a ClientIdManager utility that restricts itself to the API provided by ZServerHTTPRequest/ZServerHTTPResponse. -Jeff ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope] Preferred non-Products Initialization Approach?
In my reading I can see there are two ways to initialize a Product that is not sitting in the Products directory: 1. use ZCML with the five:registerPackage directive 2. declare in setup.py a zope2.products entrypoint Which is the preferred way these days? Is there a subtle difference? In particular I'm having trouble with an Extensions/ subdirectory of the Product -not- being found in an import stmt when I moved it outside the Products directory. -Jeff ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Preferred non-Products Initialization Approach?
On 01/27/2011 06:34 AM, Jeff Rush wrote: In my reading I can see there are two ways to initialize a Product that is not sitting in the Products directory: 1. use ZCML with the five:registerPackage directive 2. declare in setup.py a zope2.products entrypoint Which is the preferred way these days? Is there a subtle difference? Hmm, there seems to be a third way that some packages use: 3. declare your egg to be a 'Products' namespace package, omit any entrypoint or registerPackage declarations and rely upon setuptools splicing you into the Products.__path__ list and being found the conventional way of scanning the (virtual) Products namespace. BTW, I'm working with Zope 2.12.10, and I'm not finding -any- code that searches for a zope2.initialize or zope2.products entrypoint - seems to be a NOP. -Jeff ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
[Zope-dev] Request Clarification of Five Support for Z3 Roles
I'm backporting a Zope3 app to Zope2 and hit the snag that I define the various possible roles in ZCML using the role id=... tag. Can anyone confirm that there is nothing in/around Five to support that tag and so all role definition has to be done the old Zope2 way? We have the permission id=... tag in Zope 2.12.* but I guess neither the role or grant tags, right? -Jeff ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope] extract page title
Andreas Jung wrote: --On 24. April 2007 15:25:24 +0100 Dean Hale [EMAIL PROTECTED] wrote: basically if i have some zpt pages with the title titleINTRODUCTION/title titleABOUT/title somehow within below the page title should be appended after 'websitename.' script language='JavaScript1.1' type='text/javascript' noscript img src=http://domain/xxx/xxx/s?websitename.INTRODUCTION; width=1 height=1 alt= /noscript /script script language='JavaScript1.1' type='text/javascript' noscript img src=http://domain/xxx/xxx/s?websitename.ABOUT; width=1 height=1 alt= /noscript /script does this make more sense? thanks again. no. a TITLE tag does not belong inside script tag. I don't see above him putting a title tag within the script tag. He wants to put the *value* of the title tag inside the script tag. It seems some form of a string: expression would do it, assuming the title is not literally in the zpt but rather expanded from a variable. script language='JavaScript1.1' type='text/javascript' noscript img tal:attributes=src http://domain/xxx/xxx/s?websitename.${title_or_id}; width=1 height=1 alt= / /noscript /script Apparently he has named his image files according to the title of the page on which they appear. Hopefully the names are not in need of URL-quoting, as I'm not sure how you do that within a string: expression. If the value of the title is *literally* in the zpt file above his img tag, then I know of no way for a zpt expression to extract literal text from neighboring text. -Jeff ___ 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] extract page title
Andreas Jung wrote: As far as I can recall: you can't use TALES within a SCRIPT block. That's why you must generate your stuff outside inside a script. Ah thanks I wasn't aware of that exclusion, never having tried it or found it documented. Then yes your approach is the only one left. -Jeff ___ 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] Reminder: Early Bird Registration for PyCon Ending Soon
Greetings. As the co-chair for the upcoming Python conference, being held in Dallas (Addison) Texas, I want to remind folk to register before early bird registration prices end. The event is the fifth international Python Conference, being held Feb 23-25, 2007 at the Marriott-Quorum in Addison Texas, with early-bird registration ending **Jan 15**. The conference draws approximately 400-500 attendees from diverse backgrounds such as scientists from national and medical labs, college/K-12 educators, web engineers and the myriad of IT developers and programming hobbyists. Those new to the Python language are welcome, and we're offering a half-day Python 101 tutorial on the day before the conference, Thursday Feb 22 to help you get up to speed and better enjoy the rest of the conference. We have a great selection of talks this year, some of which that are relevant to Zope are: - Web Frameworks Panel - Introduction to Zope 3 - The Component Architecture - Panel: State of Zope - WSGI: An Introduction - Using Python Eggs - Distributing your project with Python Eggs - Half-Day Tutorial: zc.buildout and the Zope Component Architecture - Half-Day Tutorial: How to Document a Python Open Source Project Being run by the Python community as a non-profit event, the conference strives to be inexpensive, with registration being only $260 (or $195 if you register prior to Jan 15th), with a further discount for students. On the day before the conference we are running a full day of classroom tutorials (extra charge per class) and then after the conference is a free four-days of sprints, which are informal gatherings of programmers to work together in coding on various projects. Sprints are excellent opportunities to do agile pair-programming side-by-side with experienced programmers and make new friends. Other activities are lightning talks, which are 5-minute presentations to show off a cool technology or spread the word about a project, open space talks, which are spontaneous gatherings around a topic and, new this year, a Python Lab where experienced and novice programmers will work together to solve challenging problems and then present their solutions. The conference is also running four keynote talks by leaders in the programming field, with a special focus on education this year: The Power of Dangerous Ideas: Python and One Laptop per Child by Ivan Krstic, senior member of the One Laptop per Child project Premise: eLearning does not Belong in Public Schools by Adele Goldberg, of SmallTalk fame Python 3000 by Guido van Rossum, creator of Python The Importance of Programming Literacy by Robert M. r0ml Lefkowitz, a frequent speaker at O'Reilly conferences I believe you will find the conference educational and enjoyable. More information about the conference along with the full schedule of presentations with abstracts, is available online: http://us.pycon.org/ Thanks for any help you can give in spreading the word, Jeff Rush Co-Chair PyCon 2007 ___ 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-Annce] Representation for Zope at PyCon 2007
PyCon 2007 will be held in Addison (Dallas) from Feb 23 to 25, and we're fast approaching the talk submission deadline of Oct 31. I'd like to encourage talks about Zope, particularly how to get started with Zope and also the new technologies coming out of Zope 3. Information on both of those topics has been in very short supply at PyCons. We're also approaching the deadline, Nov 15, for half-day tutorials taught on Feb 22. Attendees register separately for these and teachers can earn up to $1500 per half-day, depending upon the number of students. The tutorial format would be ideal for getting someone up to speed on either Zope 2 or Zope 3. Teach a basic intro in the morning and advanced material in the afternoon. And if you're nervous about such a commitment, tutorials are a great opportunity to partner with another teacher or class helper. As a longtime advocate of Zope (both 2 and 3) I'd very much like to see extensive coverage this year of getting started with Zope 3. Zope has a PR problem, partly from the immense power that comes with it, and the difficulty in getting your arms around it all. It evokes strong feelings and has a distinct philosophy and design tradeoff that you have to understand before you're productive. And with the recent formation of the Zope Foundation, putting forth your best image and getting new members into the community should be a priority. PyCon is a significant opportunity for the Zope community to evangelize. In the PyCon's I've attended one challenge is breaking Zope down into teaching chunks that can be taught in 30-40 minutes. It is very easy to leave the audience behind in the buzzwords and concepts of Zope. So please don't try to teach all of Zope + Plone in 30 minutes. ;-) ;-) One possible talk I think would fit, would help someone just getting into Zope 3 and I wish someone would tackle is the Zope 3 component architecture - nothing about the web or databases or security. Start with the abstract concept of interfaces and adapters, as exists in the zope/interface package, and then layer on it the idea of registries, as implemented in the zope/component package. And wrap up with the reasons why interfaces are better than abstract base classes and what kind of problems adapters are good at solving, including some _non-abstract_ examples. If you'd like to get involved, check out the following conference pages: http://us.pycon.org/TX2007/CallForProposals http://us.pycon.org/TX2007/CallForTutorials Django and TurboGears will be at PyCon in force; I hope Zope will be too. Jeff Rush PyCon 2007 Co-Chair ___ Zope-Announce maillist - Zope-Announce@zope.org http://mail.zope.org/mailman/listinfo/zope-announce Zope-Announce for Announcements only - no discussions (Related lists - Users: http://mail.zope.org/mailman/listinfo/zope Developers: http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope-dev] Representation for Zope at PyCon 2007
PyCon 2007 will be held in Addison (Dallas) from Feb 23 to 25, and we're fast approaching the talk submission deadline of Oct 31. I'd like to encourage talks about Zope, particularly how to get started with Zope and also the new technologies coming out of Zope 3. Information on both of those topics has been in very short supply at PyCons. We're also approaching the deadline, Nov 15, for half-day tutorials taught on Feb 22. Attendees register separately for these and teachers can earn up to $1500 per half-day, depending upon the number of students. The tutorial format would be ideal for getting someone up to speed on either Zope 2 or Zope 3. Teach a basic intro in the morning and advanced material in the afternoon. And if you're nervous about such a commitment, tutorials are a great opportunity to partner with another teacher or class helper. As a longtime advocate of Zope (both 2 and 3) I'd very much like to see extensive coverage this year of getting started with Zope 3. Zope has a PR problem, partly from the immense power that comes with it, and the difficulty in getting your arms around it all. It evokes strong feelings and has a distinct philosophy and design tradeoff that you have to understand before you're productive. And with the recent formation of the Zope Foundation, putting forth your best image and getting new members into the community should be a priority. PyCon is a significant opportunity for the Zope community to evangelize. In the PyCon's I've attended one challenge is breaking Zope down into teaching chunks that can be taught in 30-40 minutes. It is very easy to leave the audience behind in the buzzwords and concepts of Zope. So please don't try to teach all of Zope + Plone in 30 minutes. ;-) ;-) One possible talk I think would fit, would help someone just getting into Zope 3 and I wish someone would tackle is the Zope 3 component architecture - nothing about the web or databases or security. Start with the abstract concept of interfaces and adapters, as exists in the zope/interface package, and then layer on it the idea of registries, as implemented in the zope/component package. And wrap up with the reasons why interfaces are better than abstract base classes and what kind of problems adapters are good at solving, including some _non-abstract_ examples. If you'd like to get involved, check out the following conference pages: http://us.pycon.org/TX2007/CallForProposals http://us.pycon.org/TX2007/CallForTutorials Django and TurboGears will be at PyCon in force; I hope Zope will be too. Jeff Rush PyCon 2007 Co-Chair ___ 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] Representation for Zope at PyCon 2007
PyCon 2007 will be held in Addison (Dallas) from Feb 23 to 25, and we're fast approaching the talk submission deadline of Oct 31. I'd like to encourage talks about Zope, particularly how to get started with Zope and also the new technologies coming out of Zope 3. Information on both of those topics has been in very short supply at PyCons. We're also approaching the deadline, Nov 15, for half-day tutorials taught on Feb 22. Attendees register separately for these and teachers can earn up to $1500 per half-day, depending upon the number of students. The tutorial format would be ideal for getting someone up to speed on either Zope 2 or Zope 3. Teach a basic intro in the morning and advanced material in the afternoon. And if you're nervous about such a commitment, tutorials are a great opportunity to partner with another teacher or class helper. As a longtime advocate of Zope (both 2 and 3) I'd very much like to see extensive coverage this year of getting started with Zope 3. Zope has a PR problem, partly from the immense power that comes with it, and the difficulty in getting your arms around it all. It evokes strong feelings and has a distinct philosophy and design tradeoff that you have to understand before you're productive. And with the recent formation of the Zope Foundation, putting forth your best image and getting new members into the community should be a priority. PyCon is a significant opportunity for the Zope community to evangelize. In the PyCon's I've attended one challenge is breaking Zope down into teaching chunks that can be taught in 30-40 minutes. It is very easy to leave the audience behind in the buzzwords and concepts of Zope. So please don't try to teach all of Zope + Plone in 30 minutes. ;-) ;-) One possible talk I think would fit, would help someone just getting into Zope 3 and I wish someone would tackle is the Zope 3 component architecture - nothing about the web or databases or security. Start with the abstract concept of interfaces and adapters, as exists in the zope/interface package, and then layer on it the idea of registries, as implemented in the zope/component package. And wrap up with the reasons why interfaces are better than abstract base classes and what kind of problems adapters are good at solving, including some _non-abstract_ examples. If you'd like to get involved, check out the following conference pages: http://us.pycon.org/TX2007/CallForProposals http://us.pycon.org/TX2007/CallForTutorials Django and TurboGears will be at PyCon in force; I hope Zope will be too. Jeff Rush PyCon 2007 Co-Chair ___ 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-dev] Re: [Zope] PCGI?
Having only ever used Zope-behind-PCGI myself, if we drop it, what would be the prevailing approach for running Zope behind Apache? Has everyone switched to FastCGI (or Quixote's SCGI) but me? Be aware that there are Zope-specific patches (some of which I provided) in the version of PCGI that Zope ships with, so you can't refer everyone to the non-Zope version of PCGI available elsewhere on the web. The patches relate to error handling and meaningful reporting, not core functionality. -Jeff Dieter Maurer wrote: Jim Fulton wrote at 2003-2-13 11:30 -0500: I'm wondering how PCGI should be supported in Zope moving forward. Do we still need it? I would prefer to drop it (to reduce complexity). ___ Zope-Dev maillist - [EMAIL PROTECTED] 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-dev] Re: [Zope] PCGI?
I had thought (obviously incorrectly) that mod_proxy was hard to configure correctly to pass all headers, particularly in complex virtual hosting scenarios. But I'm no Apache expert. And I thought that mod_redirect added overhead to every request, doing the redirect cycle via the browser. It also exposed the port 8000-based Zope to direct access, which some admin's might not want. But mostly I thought PCGI (and FastCGI) was the preferred way, since it is covered in detail in Zope's doc/WEBSERVER.TXT and neither mod_proxy nor mod_redirect are mentioned in there. ;-) I just figured PCGI was cleaner and let me delegate responsibility to each hosting client, to manage their own CGI-BIN stuff w/o access to Apache's config files.. So if we drop PCGI, we'll need an action item to rework that file and perhaps ZopeBook et. al. -Jeff Tim Hoffman wrote: I have always run Zope behind Apache utilising mod_proxy. I have to admit I never tried or really even evaluated pcgi, and don't build it when I install Zope. Is there a benefit of pcgi over using mod_proxy ? Guido van Rossum wrote: AFAIK most people use Apache's mod_redirect to a Zope HTTP server running at (e.g.) port 8000. No additional software needed. On Fri, 2003-02-14 at 09:16, Jeff Rush wrote: Having only ever used Zope-behind-PCGI myself, if we drop it, what would be the prevailing approach for running Zope behind Apache? Has everyone switched to FastCGI (or Quixote's SCGI) but me? ___ Zope-Dev maillist - [EMAIL PROTECTED] 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-dev] Creating a variable in a DTML method that may be modified
Other than explictly passing arguments, the shareable namespace, _, is the logical place to exchange such variables btw DTML and Script(Python). However, the namespace object, a TemplateDict, only allows you to PUSH/POP spaces, not set/change variables, so you have to find or provide something in the namespace that is mutable. You found REQUEST, and there is also SESSION. And you can provide your own mutable namespace as a dictionary: - cut here - DTML Method dtml-let myvars={ 'somevar': 5 } !-- Create My Own Namespace -- dtml-with myvars mapping !-- and Push onto the Search Stack -- Before: dtml-var somevar dtml-call mypython After: dtml-var somevar /dtml-with /dtml-let - cut here - Script(Python) Method ## Script (Python) mypython ##bind container=container ##bind context=context ##bind namespace=_ ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## _['myvars']['somevar'] = 7 When the DTML Method is invoked, this will print: Before: 5 After: 7 When the end of the DTML-WITH is reached, the namespace will be popped/discarded, so it won't be permanent, as you wish to avoid. Hope this helps, Jeff Rush Asad Habib wrote: Hello. Does anyone know how to create a variable in a DTML method which may be updated by a Python script? I am currently using the set method of the REQUEST object to create a variable. However, creating a variable in this fashion renders it permanent. Any help would be appreciated. Thanks. ___ Zope-Dev maillist - [EMAIL PROTECTED] 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-dev] Can't return / publish object of a dictionary?
Yeah, the new property type in Python 2.2 is pretty cool, but out of range for use under Zope at the moment. The ExtensionClass requirement for persistence eliminates using it with new style Python classes. Plus... the Lars, the original poster, said he was a Python newbie and he certainly doesn't need to get lost wandering around in bleeding edge versions. I think Zope 2.7 or 3.0 is supposed to support new style classes and persistence. But not today... -Jeff Leonardo Rochael Almeida wrote: On Sat, 2003-01-18 at 17:44, Seb Bacon wrote: Jeff Rush wrote: I use a form of the following to compute dynamic titles for Zope objects, where the 'title' attribute is the result of a method call. Modifying it slightly for your case... from ComputedAttribute import ComputedAttribute Class B(A): def getMyObjects(self): ... myObjects = ComputedAttribute(lambda self: self.getMyObjects()) In Python 2.2 (which is unfortunately not yet an option unless you are using a bleeding edge Zope) you can also use the new property type: I might be wrong but I believe class properties only work with new-style classes, and I don't know if Zope ExtensionClass-based objects qualify... Cheers, Leo ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Can't return / publish object of a dictionary?
Lars Heber wrote: I've got two other questions: 1. Say we have a Class A with an attribute myObjects which is just a list. Now, I'd like to write my own Class B(A) - it extends A. But, in Class B, myObjects has to be a method because it has to be rebuild everytime it is called. So, how can I do something like: myObjects = getMyObjects() ? I tried to do this in the class itself, didn't work. Also tried self.myObjects = self.getMyObjects() - result wasn't what I wanted, myObjects got (of course) the resulting list of getMyObjects(), but I need myObjects to be a reference to getMyObjects() I use a form of the following to compute dynamic titles for Zope objects, where the 'title' attribute is the result of a method call. Modifying it slightly for your case... from ComputedAttribute import ComputedAttribute Class B(A): def getMyObjects(self): ... myObjects = ComputedAttribute(lambda self: self.getMyObjects()) 2. Class A has another attribute, say data, which I want to control in Class B(A), i. e. everytime data is accessed (reading or writing), I want to intercept those actions. If it was just reading, I could use the strategy from 1., but I also want to control made changes to that attribute. Do I absolutely have to rewrite all the methods which access the wanted attribute, or is there another possibility with some kind of references, perhaps similar to software interrupts in DOS? I'm not sure about this one, but I suspect an override of the __getattr__() method will let you intercept the lookup of the 'data' attribute, do any pre/post actions you wish, then return the real 'data'. You might try a ComputedAttribute arrangement instead and see if it works for your case since that would be easier. __getattr__ overrides can get into infinite loops w/o careful designs. Jeff Rush ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Can I run 2 zope servers on one machine?
Yes, I do it all the time, as a Zope-hosting ISP. 1. You can forgo FTP (-f -) and just run HTTP, on different ports. 2. You can use the -f option to Z2.py and run FTP on a different IP address or port. 3. You can run HTTP only via some flavor of CGI, and then use Apache to map portions of the URL space to different servers, Zope or non-Zope. This retains a single-webspace appearance to outside clients. 4. You can also do (3) using the proxy features of Apache. The weak spot is always FTP, which doesn't support virtual hosting or URL/filesystem space splicing, whereas Apache does do both. -Jeff Tena Sakai wrote: Folks, Can I run 2 zope servers on one machine? I have a machine that runs zope 2.5.1. I want to run zope 2.6 on the same machine without taking 2.5.1 down. Is this possible? 2.5.1 runs on port 7117 and I chose 7118 for 2.6. port. What I got was: 2003-01-13T14:39:44 PANIC(300) z2 Startup exception Traceback (innermost last): Module __main__, line 726, in ? Module ZServer.FTPServer, line 602, in __init__ Module ZServer.medusa.ftp_server, line 727, in __init__ Module ZServer.medusa.asyncore, line 306, in bind error: (125, 'Address already in use') Would it be possible to run 2.6 on port 7118 and specify that ftp for this zope server to use a specific ftp port? [I'm just mumbling... In the file ZServer/medusa.ftp_server there is a definition of port=21 (line 701). What happens if I hack this and put some big number like 9221 instead?] Regards, Tena Sakai ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Proper Use of __init__ inside Zope Products?
Can a Zope-internals guru provide some enlightenment regarding the mysteries of __init__? I'm writing some zproducts that subclass the existing Folder class, and then are themselves subclassed. What I've got works, but I'm not sure its _correct_. As I'm writing a Zope Best Practices document, I'd like to get it right. As I understand it, the use of __init__ should be avoided when possible, since it isn't invoked (necessarily) when persistent objects are reloaded from disk. Therefore Zope tends to do instance init within manage_addMYPRODUCT global-to-Zope functions, although this doesn't seem to be fully consistent throughout the Zope community contributions. The scenario is something like the following: def manage_addFolder(self, id, title='', ...): instance = Folder() instance.id = str(id) instance.title = title self._setObject(id, instance) class Folder(...): # no __init__ method def manage_addLargeFolder(self, id, title='', ...): instance = LargeFolder() instance.id = str(id) instance.title = title self._setObject(id, instance) class LargeFolder(Folder): def __init__(self): # parent class has no __init__ so don't call it! #Folder.__init__() self._tree = OOBTree() def manage_addSpecialLargeFolder(self, id, title='', ...): instance = SpecialLargeFolder() instance.id = str(id) instance.title = title self._setObject(id, instance) class SpecialLargeFolder(LargeFolder): def __init__(self): # parent class DOES have an __init__ so call it LargeFolder.__init__() self._other = OOBTree() (A) I reluctantly found it necessary to add an __init__ to my LargeFolder class because if I init'd self._tree in manage_addLargeFolder(), then it won't get init'd when manage_addSpecialLargeFolder() is used to create instances. manage_addLargeFolder doesn't get invoked in that case. (B) Currently the Folder class lacks an __init__ so I cannot call it from LargeFolder.__init__, but if someday ZC decides to add one, my code will fail to init Folder and break. Is this correct? I wish Python auto-provided a default no-nothing __init__ for this case so I could always call it. So the Guiding Rule seems to be initialize those attributes that are common to all Zope objects, e.g. id and title, within the factory functions, but init any attributes you introduce using an __init__ method. Correct? -Jeff Rush ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Contents of Initial Data.fs in Zope Distribution?
Working on updating my ZOPE and ZEO RPMs I got to wondering... What's in the default data.fs that ships with Zope? I mean, ZEO (actually ZODB) auto-creates a data.fs when one isn't found, so why does Zope come with one? Or if there -is- something Zope-specific in data.fs, then shouldn't there be a warning in the ZEO notes that when ZEO is used _underneath_ Zope, be sure to copy the data.fs that comes with it? My experience has always been with ZEO and StandaloneZODB, not ZEO+Zope so I'm puzzled. -Jeff ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Contents of Initial Data.fs in Zope Distribution?
I don't quite understand -- so there *are* root level elements specific to Zope that need to be copied into a Zope-over-ZEO environment? (hm, how do those elements get into a non-FileStorage Zope-over-ZEO environment?) And do those elements interfere even a little in a non-Zope-just-ZEO environment? The only way I can imagine, other than simplistic name clashes would be if a full iteration of such a ZODB would cause unghosting of objects lacking Zope .pyc and raise unnecessary exceptions. I ask because I'm trying to decide whether two ZEO RPMs are needed re ZEO-wo-Zope-2.0-1.i386.rpm and ZEO-w-Zope-2.0-1.i386.rpm, or just one. Somewhat similar to how the Zope RPMs have separate ZServer and PCGI flavor packages. -Jeff Rush Casey Duncan wrote: It is only there due to lack of time to take it out. We had planned to take it out for 2.6, but time was never made to replace it with code to bootstrap an empty storage with the proper root level elements still residing in Data.fs.in. -Casey On Wednesday 13 November 2002 02:22 pm, Jeff Rush wrote: Working on updating my ZOPE and ZEO RPMs I got to wondering... What's in the default data.fs that ships with Zope? I mean, ZEO (actually ZODB) auto-creates a data.fs when one isn't found, so why does Zope come with one? Or if there -is- something Zope-specific in data.fs, then shouldn't there be a warning in the ZEO notes that when ZEO is used _underneath_ Zope, be sure to copy the data.fs that comes with it? My experience has always been with ZEO and StandaloneZODB, not ZEO+Zope so I'm puzzled. -Jeff ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )