Mercurial > p > roundup > code
comparison roundup/admin.py @ 2493:164b704c8f98 maint-0.7
fixed roundup-admin "find" to use better value parsing
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 23 Jun 2004 22:59:17 +0000 |
| parents | ce7cfd3ac27b |
| children | 4d112730e02f |
comparison
equal
deleted
inserted
replaced
| 2491:e84f07f00fea | 2493:164b704c8f98 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 19 # $Id: admin.py,v 1.68.2.1 2004-06-13 00:40:55 richard Exp $ | 19 # $Id: admin.py,v 1.68.2.2 2004-06-23 22:59:17 richard Exp $ |
| 20 | 20 |
| 21 '''Administration commands for maintaining Roundup trackers. | 21 '''Administration commands for maintaining Roundup trackers. |
| 22 ''' | 22 ''' |
| 23 __docformat__ = 'restructuredtext' | 23 __docformat__ = 'restructuredtext' |
| 24 | 24 |
| 610 cl = self.get_class(classname) | 610 cl = self.get_class(classname) |
| 611 | 611 |
| 612 # handle the propname=value argument | 612 # handle the propname=value argument |
| 613 props = self.props_from_args(args[1:]) | 613 props = self.props_from_args(args[1:]) |
| 614 | 614 |
| 615 # if the value isn't a number, look up the linked class to get the | 615 # convert the user-input value to a value used for find() |
| 616 # number | |
| 617 for propname, value in props.items(): | 616 for propname, value in props.items(): |
| 618 num_re = re.compile('^\d+$') | 617 if ',' in value: |
| 619 if value == '-1': | 618 values = value.split(',') |
| 620 props[propname] = None | 619 else: |
| 621 elif not num_re.match(value): | 620 values = [] |
| 622 # get the property | 621 d = props[propname] = {} |
| 623 try: | 622 for value in values: |
| 624 property = cl.properties[propname] | 623 d[hyperdb.rawToHyperdb(self.db, cl, None, propname, value)] = 1 |
| 625 except KeyError: | |
| 626 raise UsageError, _('%(classname)s has no property ' | |
| 627 '"%(propname)s"')%locals() | |
| 628 | |
| 629 # make sure it's a link | |
| 630 if (not isinstance(property, hyperdb.Link) and not | |
| 631 isinstance(property, hyperdb.Multilink)): | |
| 632 raise UsageError, _('You may only "find" link properties') | |
| 633 | |
| 634 # get the linked-to class and look up the key property | |
| 635 link_class = self.db.getclass(property.classname) | |
| 636 try: | |
| 637 props[propname] = link_class.lookup(value) | |
| 638 except TypeError: | |
| 639 raise UsageError, _('%(classname)s has no key property"')%{ | |
| 640 'classname': link_class.classname} | |
| 641 | 624 |
| 642 # now do the find | 625 # now do the find |
| 643 try: | 626 try: |
| 644 id = [] | 627 id = [] |
| 645 designator = [] | 628 designator = [] |
