150
I Use This!
Activity Not Available

News

Analyzed about 1 month ago. based on code collected about 1 month ago.
Posted about 14 years ago by Lennart Regebro: Python, Plone, Web
Since quite some time the so called “rich comparison methods”, ie __lt__, __le__, __eq__, __ge__, __gt__ and __ne__, has been around in Python and preferred to the old __cmp__, and in Python 3 __cmp__ is gone, so you must use the rich methods. That’s ... [More] six methods instead of one, so most people try to avoid doing that, and use some mixin or other technique to only implement one. But that is surprisingly tricky, and is in fact so tricky that the official Python documentation points to a recipe that is incorrect. Even worse, this incorrect recipe has been included into Python 2.7! (If I knew this was planned, I would have written this post earlier). The recipe in question is the “Total Ordering” recipe, in Python 2.7 included as functools.total_ordering. And the fault it makes is that it flips the comparison around. If the class you implement doesn’t implement the greater than method, __gt__ it will add a method to your class that asks the other object to do a less than comparison. In practice it does this: __gt__ = lambda self, other: other < self That sounds extremely reasonable. The problem is that your comparison methods can indicate that they don’t know how to compare self to the other object. They do this by returning NotImplemented. Python will then ask the other object. In other words,  Python will do exactly this “reversal” of comparisons all by itself. What happens then if you use the total_ordering deocrator, and then compare self to an object that doesn’t know how to compare itself to you? You ask a if it is less than b. The total_ordering methods will ask b if it is greater than a. b will return NotImplemented, hence telling Python that is does not know how to compare itself to a. Python will then ask a if it is less than b. And you got infinite recursion! Here is code that will demonstrate this in Python 2.7: >>> class MinimalOrdering(object): ...     ...     def __init__(self, value): ...         self._value = value ...         ...     def __lt__(self, other): ...         try: ...             return self._value < other._value ...         except AttributeError: ...             # I don't know how to compare to other ...             return NotImplemented ... >>> from functools import total_ordering >>> @total_ordering ... class TotalOrder(object): ...     ...     def __init__(self, value): ...         self.value = value ...         ...     def __lt__(self, other): ...         self.value < other.value ... >>> total = TotalOrder(1) >>> mini = MinimalOrdering(2) >>> total > mini Traceback (most recent call last): File "", line 1, in File "/opt/python27/lib/python2.7/functools.py", line 56, in '__lt__': [('__gt__', lambda self, other: other < self), ....waaaaaayyyyyyy later.... File "/opt/python27/lib/python2.7/functools.py", line 56, in '__lt__': [('__gt__', lambda self, other: other < self), RuntimeError: maximum recursion depth exceeded In short: never, ever in your rich comparison methods, ask the other object to do the comparison. Here is the recipe I use instead. (Or well, I don’t, I used something more complicated, but a comment from Martin von Löwis started a process in my head that ended up in this, much simplified version. So this is the recipe I *will* use, in the future). It’s a mixin. If you are allergic to multiple inheritance you can make it into a class decorator instead, but I like mixins. class ComparableMixin(object): def _compare(self, other, method): try: return method(self._cmpkey(), other._cmpkey()) except (AttributeError, TypeError): # _cmpkey not implemented, or return different type, # so I can't compare with "other". return NotImplemented def __lt__(self, other): return self._compare(other, lambda s,o: s < o) def __le__(self, other): return self._compare(other, lambda s,o: s <= o)  def __eq__(self, other):  return self._compare(other, lambda s,o: s == o)  def __ge__(self, other):  return self._compare(other, lambda s,o: s >= o) def __gt__(self, other): return self._compare(other, lambda s,o: s > o) def __ne__(self, other): return self._compare(other, lambda s,o: s != o) Not so difficult. Note how instead of delegating to the other object, I delegate to a _cmpkey() method (that was Martins brilliant idea) and if the other object does not have a _cmpkey() method, or returns a different type from what your class does, it will return NotImplemented, and Python will then delegate to the other object. This is how it’s designed to work. You use this by subclassing from the mixin and implementing the _cmpkey() method: class Comparable(ComparableMixin): def __init__(self, value): self.value = value def _cmpkey(self): return self.value Which is simple enough. You don’t even need to implement one comparison method, you just return a key that can be compared. Suddenly all need to think when implementing comparison is gone. Feedback on this is welcome! Filed under: plone, python, python3 Tagged: comparison, total ordering [Less]
Posted about 14 years ago by Weblog
I had problems at a client site using Plone 3.3 and quintagroup.plonecomments 4.1.2. I do not think the problem is in that last package, but that is the spot where strange behaviour surfaced. The client reported that on some pages the comments were ... [More] visible but the buttons to Remove or Edit them was not visible, not even for a Manager. The comments and their buttons were shown by the plone.comments viewlet, which is customized by quintagroup.plonecomments. The Remove button was guarded by a permission 'Moderate Discussion'. The page template claimed that as Manager I did not have this permission. A simple Script Python added in the ZMI showed that this was non-sense: I did have that permission: return context.portal_membership.checkPermission( 'Moderate Discussion', context) In the end, what turned out to be the problem was that the object was owned by a user that no longer existed. Somehow that seems to have tricked Plone/Zope into thinking (at least in the template of this viewlet) that no one had the Moderate Discussion permission anymore. Other permissions seemed unaffected; for example you could still view the comments and reply to them. Giving someone the local role Owner in the ZMI, or changing the Creator in the Ownership tab of the edit form did not have any effect. I had to add 'ownership_form' at the end of the url of the object to give ownership of this item (and its subobjects) to someone else. This fixed it, even when I myself was not the new owner. So it looks like somewhere some code path was triggered that did not like the fact that the current owner did not exist anymore. Now, maybe something weird was happening because the plone.comments viewlet was customized in the portal_view_customizations, but this worked without problems on a local older copy of the Data.fs. I still do not understand what the difference is between the live site and my local copy where I could remove comments everywhere just fine, even though the owner was gone there as well. Well, stranger things have happened in this particular Data.fs and I have come up with stranger solutions to tackle them. This one was quite clean. :-) [Less]
Posted about 14 years ago by Zea Partners News
A new Plone product release from a ZEA Partners member is so common an event that it does not deserve a news. In this case, RedTurtle released three in a very short time lapse.
Posted about 14 years ago by Zea Partners News
A new Plone product release form a ZEA Partners member is so common an event that it does not deserve a news. In this case, RedTurtle released three in a very short time lapse.
Posted about 14 years ago by Zea Partners News
Naple's TIGEM will host on 26 November the second event in the "Plone for University and Research" series, promoted by two members of ZEA Partners, RedTurtle Technology and Abstract Open Solutions, and by BioDec.
Posted about 14 years ago by Zea Partners News
On 3 November 2010, some PloneGov Italia Members meet for a technical discussion about the solutions adopted by each Public Organizations. The workshop has a very operational tone and aims at sharing the choices made at local level, and presenting products that are useful for reuse.
Posted about 14 years ago by Mock It!
Although still a little rough around the edges with regards to supporting less trivial fields such as rich text, Plone's new settings registry framework works really well. It basically lets you point to a Zope schema interface and have the contained ... [More] fields presented as a control panel form.I recently wanted to code up a control panel form modelled as a series of fieldsets (displayed with a tabbed interface in Plone). Each of the fieldsets corresponded in my case to its own interface declaration, but potentially I wanted to allow for any sort of nesting.This proved to be somewhat out of the ordinary for plone.registry. It includes a records proxy class which neatly does the mapping between the interface and the registry. The following gist includes two points of interest in particular: an abstract records proxy class that takes care of this mapping for any type of schema and it also demonstrates the syntax for rendering your interfaces in different form groups – which will ultimately display as form tabs. http://gist.github.com/738156.There currently seems to be the issue that error messages that appear inside a tab aren't immediately visible when you post back the form. The user will for the moment have to interpret the generic error message as "please look under each tab to find the concrete error". [Less]
Posted about 14 years ago by Plone News
Are you a Plone Help Channel Superstar? Have you been helped by one? The Plone Foundation is pleased to announce the 2010 Plone Help Channel Superstar Awards, where we recognize outstanding community members who provide volunteer tech support in ... [More] the #plone IRC support channel.The #plone IRC support channel is the Plone community's free, volunteer-powered, 24-hour-a-day live helpline. Unlike many other open-source IRC channels, #plone is incredibly active, newbie-friendly and it's the number one way to get immediate help with both simple and complicated Plone questions.None of this would be possible without the many Plone community members who volunteer their time and expertise to field questions. Their passion, experience and wisdom is vital to "smoothing the on-ramp" to Plone for new users. We're proud to honor and recognize them through this award process. The Rules It's simple. If you spot someone in the act of being a "Help Channel Superstar," nominate them using this handy form. Nominations open now, and close December 20th, 2010 We'll then open a (very) quick round of Plone community-wide voting during the week of December the 22nd to the 27th to narrow the field of nominees down to the top 5. An all-star panel of judges will then choose the winners by December 29th, just in time for the New Year! How Do I Recognize a Plone Help Channel Superstar? The characteristics of Plone Help Channel Superstars could include (but are not limited to): Extreme helpfulness to new Plone users. Conspicuous persistence in tackling unusual or complicated questions. Creating a welcoming environment for everyone. For tips on learning how to be an IRC superstar, see How to Be a Plone Help Channel Superstar. Prizes Grand prize One supremely helpful grand prize winner will receive free admission to Plone Conference 2011 in a location to be announced and a USD$1000 travel stipend to get them there (Total value: around USD$1250). Second prizeFree entry in to Plone conference 2011 courtesy of the Plone foundation. Honorable mentionThe thrill of being acknowledged as one of the Help channel superstars alongside the possibility of lots of free beer at the next conference! Thanks to our sponsors The Plone Foundation wishes to thank Devaus Oy for sponsoring the 2010 PHC Superstar awards. Meet the Judges Steve McMahon (stevem) is most famous as the author and maintainer of several stellar add-on products, most noticeably PloneFormGen. He is a principal at Reid-McMahon. Steve has served on the Plone Foundation board for the past two terms, and currently serves as Board Secretary. Jon Stahl (jonstahl) is a Senior Strategist at Groundwire, which provides technology and communications strategy assistance to environmental nonprofits. Jon organized the 2006 Seattle Plone Conference and the 2008 Plone Strategic Planning Summit. He is currently serving his third term on the Plone Foundation board of directors. Matthew Wilkes (matthewwilkes) is a prolific developer in the Plone project, with significant code in core Plone and add-ons. He helped mentor during Google Code-In and the Google Summer of Code. Matthew works for Jarn AS in Germany and serves on the Plone 4 framework team. David Glick (davisagli) some say David is the re-incarnation of G. W. von Leibniz, others that he is an android from the lost city of Atlantis, we just know he’s a frigging genius and a key Plone core developer, David was last year’s PHC superstar award winner and works for Groundwire. Virginia Choy Is a Business Development Manager and long term community member, she advocates at the grass roots level for open source and Plone and founded the rocking PretaWeb Plone company in 2004. Wyn Williams (asigottech) is a senior systems consultant at Devaus and Plone foundation member. Wyn's networking and sysadmin experience help to keep the Plone community connected and working efficiently. The Fine Print Anyone can nominate anyone. Individuals can nominate themselves. Individuals can nominate several people, once per form entry. Current Plone Foundation board members and 2010 Help Channel Superstar Contest judges are not eligible. The purpose of the community vote is to help the judges narrow the candidates down to a set of finalists. The decision of the judges is final. Prizes cannot be redeemed for cash or beer. [Less]
Posted about 14 years ago by Plone News
Are you a Plone Help Channel Superstar? Have you been helped by one? The Plone Foundation is pleased to announce the 2010 Plone Help Channel Superstar Awards, where we recognize outstanding community members who provide volunteer tech support in ... [More] the #plone IRC support channel.The #plone IRC support channel is the Plone community's free, volunteer-powered, 24-hour-a-day live helpline. Unlike many other open-source IRC channels, #plone is incredibly active, newbie-friendly and it's the number one way to get immediate help with both simple and complicated Plone questions.None of this would be possible without the many Plone community members who volunteer their time and expertise to field questions. Their passion, experience and wisdom is vital to "smoothing the on-ramp" to Plone for new users. We're proud to honor and recognize them through this award process. The Rules It's simple. If you spot someone in the act of being a "Help Channel Superstar," nominate them using this handy form. Nominations open now, and close December 20th, 2010 We'll then open a (very) quick round of Plone community-wide voting during the week of December the 22nd to the 27th to narrow the field of nominees down to the top 5. An all-star panel of judges will then choose the winners by December 29th, just in time for the New Year! How Do I Recognize a Plone Help Channel Superstar? The characteristics of Plone Help Channel Superstars could include (but are not limited to): Extreme helpfulness to new Plone users. Conspicuous persistence in tackling unusual or complicated questions. Creating a welcoming environment for everyone. For tips on learning how to be an IRC superstar, see How to Be a Plone Help Channel Superstar. Prizes Grand prize One supremely helpful grand prize winner will receive free admission to Plone Conference 2011 in a location to be announced and a USD$1000 travel stipend to get them there (Total value: around USD$1250). Second prizeFree entry in to Plone conference 2011 courtesy of the Plone foundation. Honorable mentionThe thrill of being acknowledged as one of the Help channel superstars alongside the possibility of lots of free beer at the next conference! Thanks to our sponsors The Plone Foundation wishes to thank Devaus Oy for sponsoring the 2010 PHC Superstar awards. Meet the Judges Steve McMahon (stevem) is most famous as the author and maintainer of several stellar add-on products, most noticeably PloneFormGen. He is a principal at Reid-McMahon. Steve has served on the Plone Foundation board for the past two terms, and currently serves as Board Secretary. Jon Stahl (jonstahl) is a Senior Strategist at Groundwire, which provides technology and communications strategy assistance to environmental nonprofits. Jon organized the 2006 Seattle Plone Conference and the 2008 Plone Strategic Planning Summit. He is currently serving his third term on the Plone Foundation board of directors. Matthew Wilkes (matthewwilkes) is a prolific developer in the Plone project, with significant code in core Plone and add-ons. He helped mentor during Google Code-In and the Google Summer of Code. Matthew works for Jarn AS in Germany and serves on the Plone 4 framework team. David Glick (davisagli) some say David is the re-incarnation of G. W. von Leibniz, others that he is an android from the lost city of Atlantis, we just know he’s a frigging genius and a key Plone core developer, David was last year’s PHC superstar award winner and works for Groundwire. Virginia Choy Is a Business Development Manager and long term community member, she advocates at the grass roots level for open source and Plone and founded the rocking PretaWeb Plone company in 2004. Wyn Williams (asigottech) is a senior systems consultant at Devaus and Plone foundation member. Wyn's networking and sysadmin experience help to keep the Plone community connected and working efficiently. The Fine Print Anyone can nominate anyone. Individuals can nominate themselves. Individuals can nominate several people, once per form entry. Current Plone Foundation board members and 2010 Help Channel Superstar Contest judges are not eligible. The purpose of the community vote is to help the judges narrow the candidates down to a set of finalists. The decision of the judges is final. Prizes cannot be redeemed for cash or beer. [Less]
Posted about 14 years ago by Planet Nuxeo
The recent Nuxeo World Global Customer & Partner Conference was a perfect occasion to get in contact with long-time Nuxeo contributor Jean Marc Orliaguet, of the University of Chalmers, Sweden. He was unable to attend the conference, but ... [More] took the time to create a professional-quality video that we showcased during the closing keynote. Jean Marc has contributed a UI component for Nuxeo software called Nuxeo Themes. His blog documents the progress of Nuxeo Themes. I was keen to find out what motivates such an avid contributor to an open source project, and how contributors help shape the Nuxeo community. The Interview Tell me about yourself. What is your role at the University of Chalmers? I have been a software developer at the University of Chalmers for about 10 years. I have always used open source software, because I think it's easier to write applications with. You have source code, contact with the developers, and there's no need for licenses, which means no need for a procurement process. This is an important factor – being able to test the software without going through an administrative process beforehand. How are you using Nuxeo software? Before the Nuxeo platform was released, we were using the Zope platform with CPS (Collaborative Portal Server, an earlier version). We are still using it; it works like clockwork. Our department is now focusing more on applications that are not bought off the shelf. For example, we are currently developing a payment solution. It's a database-driven application that requires a short development time (about 1 month). Starting next year, students at the University of Chalmers will pay tuition fees through an online payment provider. The system we are developing will track the payment status of the students. This solution cannot be be bought, because it doesn't exist on the market. We are using the Nuxeo platform as a backend database for the payment solution. In general, we use Nuxeo as a backend that allows us to develop applications rapidly. What is Nuxeo Themes? I started working on this when Nuxeo made a switch to Java. I had already contributed to the CPS project. This project has been a good way of learning Java technologies. I noticed that in most applications, the user interface is very monolithic. I'm trying to make the UI more modular and reusable. The idea is to be able to reuse parts of the application, especially the visual parts. The UI is a very important part of an application, but it sometimes gets overlooked. When people look at an application, they are very influenced by what it looks like visually. Nuxeo Themes is packaged with the Nuxeo application; I have contributed the source code. It is written in java with java script for the user interface. It has evolved with the Nuxeo application. At first, it was only for Nuxeo DM, now it's available for Nuxeo DAM also. I have also adapted Nuxeo Themes so that a theme can be re-used across multiple Nuxeo applications. What components are in a theme? There are two separate components - the theme editor and web widgets - working together. In the theme editor, the components of a theme - styles, images, fragments, and layout - can be modified by a designer. The web widgets component allows end-users to move fragments around like in iGoogle and Netvibes. This is done on the client side in javascript, for performance reasons. The two components work together. One part is static (the themes rendered on the server) and the other part is dynamic (web widgets, in javascript on the client side). For future developments, I plan to see if it's possible to re-use Wordpress themes. I'm also working with Damien (Metzler, another Nuxeo contributor) to integrate web widgets and OpenSocial. The idea is to reuse OpenSocial widgets. Do you have any comments about contributing to open source? The Nuxeo Community is a very good community to contribute code to, due to the high quality of the software development. It is different from other open source projects, where everyone contributes. Nuxeo's QA process guarantees that the code has been tested. Nuxeo is an interesting mixture of a commercial company creating open source software. -- @JaneZupan       [Less]