[Zope-dev] Re: Unit testing, ZUnit
--- In [EMAIL PROTECTED], Lalo Martins [EMAIL PROTECTED] wrote: snip We first conceived it as a kind of Zope-based version of unittestgui.py - you create a "TestRunner" object giving it the package, module and name of a TestSuite object generator (see the PyUnit documentation) and inside it you may click on some widget to run the tests and produce a "TestResult" object which you can inspect later. Does this sound like a good design? Then I figured in the long run a Product isn't the best sollution; instead, fiddling with App/Product* sounds more like it, to allow developers to register tests just like they register classes, ZClass superclasses, _misc and help. Of course, just like the current registerHelp and others, it wouldn't be mandatory and not using it wouldn't break anything. Then, in the Product's page in the Control Panel, there would be a tab "Test", where you'd be allowed to run the unit tests. What do people think of this? What does DC think of this? Can I go ahead and develop it in this direction? Kewl. ;^) please do! I've been test-infected ever since I started using JUnit about 8 months ago so I know the value of building a unittest framework for Zope. I even started playing around with PyUnit and integrating it with Zope... I got to the point where I had a ZPublisher-based framework that allowed me to have something like a function that had a relative url as its argument and it would return the rendered HTML... I then stored the string into a file and it would allow me easily build tests that compared the string output to the one stored in the file... I was planning to do more (e.g. get to the point where I have a function with a relative url as its argument which would return me the actual object -- this would then allow me to run its methods and check its properties, check assertions, etc., etc... but then, my "real" work interfered and I had to put my plans in the backburner for a while...(I might get back to this in a month or so, so I'm very interested in your project...keep us posted) I had envisioned it as something that ran on the commandline (not as a TTW thing) and the context in which I was using it for was that I would be developing a lot of python code and that running my test suite on the commandline would return the familiar "" output that the commandline versions of Junit and PyUnit provide... it would also allow me to run the GUI version without changing any of my unittests... My intention was that most of the testing would be the testing of the application, so I didnt intend to test the ZServer part of Zope (I assumed that ZServer would be passing the right URL to the ZPublisher) -- instead, everything would be run locally and single-threaded...(of course, this framework is limited and can't do the testing of ZServer-related stuff -- e.g. virtual hosting stuff like ZServer -- but since I was more focused on the 'application', this wasn't such a big deal compared to the benefit of being able to run my tests locally and with the flexibility of running them either thru the commandline or thru a GUI... So I do have some questions about how you intend the ZUnit to be used... e.g. -- lets say I'm developing a Zope Application... I begin by writing the Python code interface, then I start writing the PyUnit test... in the the Setup section, I put in the code that hooks me into the Zope ZODB, installs the product, sets the properties, etc.; in the test section, I can get to the object, test my assertions, etc... and in the TearDown -- I back out my changes, etc... Then I add this test to my Test suite...etc., etc...Then to run this test, I...do...what? Also one coding caveat: when I started building my ZPublisher-based framework, I encountered a bug I couldn't easily solve: I could run my PyUnit tests fine using the commandline but when I tried to run them via the PyUnit GUI they failed : as far as I could tell, the GUI version of PyUnit did something esoteric with the "import" function (which would allow automatic reloading whenever you started it -- allowing you to leave the GUI up all the time and you could modify your python code and it would reload correctly (this is equivalent to JUnit's LoadingTestRunner) -- unfortunately, it reacted badly with Zope's 'esoteric' use of the "import" function as well ;^)... HTH. Butch Landingin [EMAIL PROTECTED] http://squishdot.org PS. Sorry for the rambling, its been a while since I last posted to the list and I wanted to get a lot of things off my chest ;^) __ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/ ___ 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
[Zope-dev] Security requires Acquisition?!
Toby Dickenson and Brian Lloyd wrote: list.append(DisplayClass(name,self)) list.append(DisplayClass(name,self).__of__(self)) class DisplayClass(Globals.Persistent): class DisplayClass(Globals.Persistent, Acquisition.Implicit): Okay, this did the trick, but I'm not very happy with the result :-( I don't want the DisplayClass to be acquiring and I don't really see (from a moral standpoint ;-) why I should need to mix in an Acquisiton class to make security work :-S That said, I think Shane said that Zope security is predicated a lot on Acquisition. Now, can I get the solution I'm looking for by mixing in Aquisition.Explicit, still have the security stuff work and not have the DisplayClass acquiring attributes I don't want it do? cheers, Chris ___ 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] Unit testing, ZUnit
What do people think of this? What does DC think of this? Can I go ahead and develop it in this direction? For our XP endeavors, we've developed a testing framework we call SimpleTest, which tests our systems using HTTP requests. Tests are written in XML, along the lines of: ?xml version="1.0" ? !DOCTYPE testrun SYSTEM "../multiple_test.dtd" testrun description="Tests for read-only form" test descriptionThis is a very simple tests/description target_urlhttp://my.server.name/somewhere/target_url input field name="field1"magicroundabout/field field name="field2"1/field /input output ... various condition blocks to test if the returned HTML contains or doesn't contain stuff, or the return code was xxx /output /test test ... you can have lots of tests in a test run /test /testrun You can set authentication for a test run, and (crudely) pass variables from one test to another. Tests are stored as XML files and we use CVS to control them. Our feeling is we will probably need to use PyUnit at some point, but for the moment this is serving our needs OK. Using this we have been able to unit test most of the bits of the Zope applications we write, including where those applications link into other web-accessible systems. The framework is written in Python and we've been adding bits to it as needed. Simon -- - My opinions are my own, NIP's opinions are theirs -- Simon J. Coles Email: [EMAIL PROTECTED] New Information Paradigms Work Phone: +44 1344 753703 http://www.nipltd.com/ Work Fax: +44 1344 753742 === Life is too precious to take seriously === ___ 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] WriteLocking RiskFactors updated
The WriteLocking RiskFactors artifact has had some new work done on it and I'm interested in some editorial comments and review before work begins on Architecture and UseCases. http://dev.zope.org/Wikis/DevSite/Projects/WriteLocking/RiskFactors Make any comments you have at: http://dev.zope.org/Wikis/DevSite/Projects/WriteLocking/ProjectDiscussion -- Jeffrey P Shell, [EMAIL PROTECTED] http://www.zope.org/ | http://www.digicool.com/ ___ 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] extending objectValues() and objectIds() or ?
I have developed a flock of Python products that have attributes 'first_date', 'last_date', and 'ok_to_publish' with the intention that these attributes will be set by the content managers. Each product also has an 'isPublishable' method that returns true if 'ok_to_publish' is true _and_ today = 'first_date' _and_ today = 'last_date'. This all works fine but I find myself writing DTML in many places to retrieve a list of objects with objectValues() and then looping over them making yet another list of only the objects that are publishable. What I would really like is an objectValues() and an objectIds() that return only publishable objects/ids. It looks like this could be easily accomplished by {tremble} adding an additional parameter to those two routines, say chkPub=None so that I could do a call such as objectValues('Poll',1) when I wanted just the publishable Poll items returned. However... 1. modifying ObjectManager.py doesn't seem like the best move I've ever thought of 2. I'm confused about the ObjectManager internals - can I call my isPublishable methods on objects that ObjectManager keeps in its lists? How? I guess a better question, rather than asking about this one possible solution, would be: How can I extend Zope to give me a list of objects qualified by more than just the meta_type? Guidance gleefully gathered. Thanks! -- Dennis Nichols [EMAIL PROTECTED] ___ 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] Unit testing, ZUnit
Lalo Martins [EMAIL PROTECTED] writes: Then I figured in the long run a Product isn't the best sollution; instead, fiddling with App/Product* sounds more like it, to allow developers to register tests just like they register classes, ZClass superclasses, _misc and help. Of course, just like the current registerHelp and others, it wouldn't be mandatory and not using it wouldn't break anything. Then, in the Product's page in the Control Panel, there would be a tab "Test", where you'd be allowed to run the unit tests. I like the idea a lot, but would like to suggest that unit tests ala PyUnit really have three parts that call for separate treatment. 1. Test environment setup: construct the data structure(s) a test needs to run against. This wants to be separate because different tests can frequently share the same data structures and data structure setup can be non-trivial in systems like Zope. Since Zope is a persistent object space, there would also need to be code to tear down a test environment. Let's just lump that in here since it will be automagically invoked by the unit test facility. 2. Test definition and execution: pretty obvious :-) 3. Test results reporting: a small number (1?) of standard reporters plus the ability to define and register new reporters. Given the above, the task of writing most tests would consist of: 1. Select test environment. 2. Select default reporter. Optionally list which other reporters can be selected at test execution time? 3. Write and test the test. 4. Register the test so that it appears on the Test page. Dan Pierson ___ 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] Using LoginManager with users stored in several Specialists
In article a05001900b61b0b6ac87c@[10.0.1.2], Itai Tavor [EMAIL PROTECTED] wrote: - I'm not sure how to customize a UserSource to access the propertysheets on the Customer and Reseller classes. The easiest way seems to be to define userExists, userRoles and userAuthenticate methods in a GenericUserSource, but I don't think it's a good idea - I still wouldn't know how to make changes to the propertysheet from the LoginManager (for example, changePassword should be a method of acl_users, not of the user classes, because it does the same thing for all user types), and there is no caching. Should I write my own UserSource? Or can I do it with Data Plug-ins? I'd like to keep the solution simple, but I do want it to be efficient (fast and cached). Generic User Source is basically for people who are familar with GUF and want some degree of backward compatability. There was also a time where it was the only choice :-) Now there is "User Source", which is to LoginManager what Rack is to Specialist. It's completely general, defaulting to storing things persistently, but overrideable with SkinScript and the "load from existence of attribute blah" to do anything you want. It's much more Generic than Generic User Source, actually :) Have a look at the SkinScript reference for the "Object Remapping" example (last one under WITH ... COMPUTE ...) of how to make a Rack that retrieves proxyies for objects from a different Specialist. You can direcly apply this same technique to have a User Source provide users based on objects in other Specialists. ___ 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] Migrating from ZClasses to Python Products
And now the big question... How do you migrate and existing application from ZClasses to Python products? I've got about 50,000 objects. Can it be done or am I stuck with ZClasses? Hopefully, Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. ___ 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] extending objectValues() and objectIds() or ?
Write a Python Method (install the PythonMethods product first) called say, publishableObjectValues that does that: paramself/param # functions that returns publishable objects result = [] for o in self.objectValues(): if o.isPublishable(): result.append(o) return result -- Itamar S.T. [EMAIL PROTECTED] Fingerprint = D365 7BE8 B81E 2B18 6534 025E D0E7 92DB E441 411C ___ 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] Unique and Contant object IDs
Ty Sarna wrote: Unfortunately there are a lot of things that Zope just can't do because there is no way to get a persistent "ticket" for an object that can be handed out to some external system, and then later redeemed for the (properly wrapped) object. Pathnames are not useful, because they don't last for the object's lifetime. Hmmm ... what you describe sounds a lot like an ILU "string binding handle" -- see http://www-db.stanford.edu/~testbed/ilu/ilu20doc/manual_1.html#SEC10 ILU does have a Python binding, and I've been thinking that ILU and Zope might have a lot of potential if used together ... it could make Zope "multi-lingual" :^) Has anyone thought of doing anything with the two together? Cheers, -- Steve. oo _\o \/\ \ / oo _ "Sometime you're the windshield; sometime you're the bug." - Knopfler Stephen C. Waterbury Component Technologies Code 562, NASA/GSFC and Radiation Effects Branch Greenbelt, MD 20771 Engineering Web/Database Specialist Tel: 301-286-7557 FAX: 301-286-1695 WWW: http://misspiggy.gsfc.nasa.gov/people/waterbug.html _ ___ 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] Migrating from ZClasses to Python Products
Andy McKay writes: Cool Project... That means I'm screwed. :) And now the big question... How do you migrate and existing application from ZClasses to Python products? I've got about 50,000 objects. Can it be done or am I stuck with ZClasses? Well the number of objects doesnt really matter, but migrating it from ZClass to Python - Ive never heard of that happening. It would be a cool project though. Hopefully, Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. ___ 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 ) Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. ___ 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] DataSkinAddons 0-0-2 released
DataSkinAddons 0-0-2 http://www.zope.org/Members/stevea/DataSkinAddons Changes: DataSkinAddons 0-0-2, 24 October 2000 DataSkinAddons 0-0-2 works with ZPatterns-0-4-3b1 and Zope 2.2 only Various changes to CatalogTrigger to bring it in line with the new Expressions module from ZPatters 0-4-3b1, and to tidy up some cruft. Thanks to John Eikenberry for contributing to this. Note that CatalogTrigger does not cause a ZPatterns transaction to abort, but instead logs an error, if an object cannot be catalogued or uncatalogued. In some cases, this may be wrong behaviour. Some checkboxes might appear for this in the next release of DataSkinAddons. Until then, use SkinScript if you want to abort the transaction if there is a problem cataloguing or uncataloguing. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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] Getting all objects matching a given meta_type and more
Morten W. Petersen wrote: I've managed using the ZCatalog now. However, I have a small problem: When I instansiate a ZCatalog at the root of a tree, and search for all objects matching a given meta-type, all the objects in the entire tree are returned. Is there a way to instruct the ZCatalog instance that it should only return objects from within a certin part of the tree, without instansiating a new ZCatalog instance in the given subtree? Yes. Create a keyword index in your catalog called "path_kw_for_catalog". Create an external method called "path_kw_for_catalog" that, for an object, returns a list of strings that uniquely represent the physical path to that object, and to each of its parents by containment. Create an external method "path_kw" that, for an object, returns a string that uniquely represents the physical path to that object. Then, query your catalog using that keyword index, and the results path_kw for the path you want results from under. As an example, path_kw_for_catalog might return ['foo_bar_baz', 'foo_bar', 'foo'] for an object at http://your.server.net/foo/bar/baz In the same example, path_kw would return 'foo_bar' for the object at http://your.server.net/foo/bar I don't know whether you can use the results of string.join(getPhysicalPath(), '/') as a keyword in a KeywordIndex in a ZCatalog. In the following methods, I'm assuming that you can't. They can be simplified if it turns out you can. I'm also assuming that space characters are bad in keyword indexes. Again, I might be completely wrong. I guess I should check. Anyhow, these methods should give you the general idea: from string import join, replace def kw_path_for_catalog(self): keywords=[] pp=self.getPhysicalPath() for p in range(2, len(pp)+1): keywords=keywords+[join(map(fix_bad_chars, pp[1:p]), '_')] return keywords def kw_path(self): return join(map(fix_bad_chars, self.getPhysicalPath()[1:]), '_') def fix_bad_chars(s): return replace(s, ' ', 'x') -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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] RE: Security requires Acquisition?!
Okay, this did the trick, but I'm not very happy with the result :-( I don't want the DisplayClass to be acquiring and I don't really see (from a moral standpoint ;-) why I should need to mix in an Acquisiton class to make security work :-S I suspect that was a rhetorical question, but ill answer anyway. Zope security is context based: Users can be defined in a subfolder and only have access under that folder, they can also be given local roles for a given folder. The role:permission mapping is set per-folder. Any security aware object needs to know its context. That said, I think Shane said that Zope security is predicated a lot on Acquisition. Now, can I get the solution I'm looking for by mixing in Aquisition.Explicit, still have the security stuff work and not have the DisplayClass acquiring attributes I don't want it do? Yes, you will need to set Acquisition.Acquired for the necessary attributes. Alternatively there may be other ways of avoiding an object using some specific acquired attributes: I often define an index_html=None to avoid a class using its container's default view. Wanting to make an object non-acquiring may be a danger-sign of some other problems. If the correctness of your program depends on the absence of certain attributes (acquired or otherwise) then you need to take extra care over PropertyManager-like features, which might allow a user to add the critical attribute. hth, ___ 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] Unique and Contant object IDs
On 24 Oct 2000 15:14:24 GMT, [EMAIL PROTECTED] (Ty Sarna) wrote: Unfortunately there are a lot of things that Zope just can't do because there is no way to get a persistent "ticket" for an object that can be handed out to some external system, and then later redeemed for the (properly wrapped) object. Pathnames are not useful, because they don't last for the object's lifetime. How come? because you want the identity to remain unchanged even after the object is moved? or duplicated? Toby Dickenson [EMAIL PROTECTED] ___ 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] Re: [Zope] The Great Python (and Perl) Method Renaming Poll
Michel Pelletier wrote: We will be conducting a community poll to decide what to call Python (Perl, insert your language here) Methods. [snip] So, before the poll, we are calling for nominiations from the community. Please send me an email containing one or more candidate names. These names will be added to the list. No pre-screening will be done, so please exercise some discretion if your favorite name is more tounge-in-cheek than practical (you never know what the masses will decide though!). Later this week, I will create a web poll where you can vote for your favorite. I would like to suggest that instead of a plurality vote, we use a 'Borda count', also known as an 'preferential' or 'single-transferable' ballot. Those of you who followed the recent ICANN election should be familiar with it. It works like this: All votes consist of ranking the availble choices according to desireability (if there are six choices, you would number them 1-6, each choice must be uniquely ranked, not all choices must be ranked). All voters first choices are tallied. If, at this point, one choice has achieved over 50% of the vote, the vote is over. If no choice has achieved 50%, the choice with the fewest votes is removed, and the voters who voted for that choice have their second choice counted and distributed. If at this point one of the choices acheives 50%...etc. Lather, Rinse, Repeat. This method has the advantage of better representing peoples true choice, since no one is tempted to vote for a choice that they simply disapprove of less, because 'otherwise they're throwing away their vote'. In a five-way race for example, a plurality may consist of 25% of the vote, thereby ensuring that 75% of the voters will be pissed off. With a Borda count though, the winner could be everyone's second-favorite choice, thus better representing what people want. There's a few other wrinkles to this, such as situatuions where not all choices have been ranked. If a voter has only ranked four choices and a fifth runoff phase is neccessary, their ballot is discarded, and the 50% mark is recalculated for that phase to account for the reduced number of ballots. Cheers, Michael Bernstein. ___ 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 )