Changeset 280


Ignore:
Timestamp:
Dec 4, 2009, 3:01:25 PM (11 years ago)
Author:
jjbot
Message:

Fixed small bug, renamed some vars to constants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • web/IbidasAtomicServices2.py

    r279 r280  
    6565        """Adds the set and type constaints to items."""
    6666        self.logger.debug("__addItemConstraints")
    67         if(args.has_key(SETS) & (len(args[SETS]) > 0)):
     67        if(args.has_key(self.SETS) & (len(args[self.SETS]) > 0)):
    6868            self.logger.debug("Adding item set contraint")
    69             set_ids = [int(x) for x in args[SETS]]
     69            set_ids = [int(x) for x in args[self.SETS]]
    7070            query = query[_.source_id.within(*set_ids)]
    7171            self.logger.debug(
    7272                    "Nr of items left after item set constraint: "
    7373                    + str(len(query)))
    74         if(args.has_key(ITEMTYPES) & (len(args[ITEMTYPES]) > 0)):
     74        if(args.has_key(self.ITEMTYPES) & (len(args[self.ITEMTYPES]) > 0)):
    7575            self.logger.debug("Adding item type contraint")
    76             item_type_ids = [int(x) for x in args[ITEMTYPES]]
     76            item_type_ids = [int(x) for x in args[self.ITEMTYPES]]
    7777            query = query[_.type_id.within(*item_type_ids)]
    7878        query = query[:, IbidasSimpleMessage.ITEM_FN]
     
    8383        """Adds the set and type constraints to itemlinks."""
    8484        self.logger.debug("__addItemlinkConstraints")
    85         if(args.has_key(SETS) & (len(args[SETS]) > 0)):
     85        if(args.has_key(self.SETS) & (len(args[self.SETS]) > 0)):
    8686            self.logger.debug("Adding link set constraint")
    8787            print query.fields.name
    8888            self.logger.debug("Nr of links before link set constraint: "
    8989                    + str(len(query)))
    90             set_ids = [int(x) for x in args[SETS]]
     90            set_ids = [int(x) for x in args[self.SETS]]
    9191            query = query[_.source_id.within(*set_ids)]
    9292        self.logger.debug("Nr of links after link set constraint: "
     
    105105        self.logger.debug("Called getItemChildren")
    106106        self.logger.debug("Provided arguments: " + str(args.keys()))
    107         assert args.has_key(ITEMS), \
     107        assert args.has_key(self.ITEMS), \
    108108                'No item_ids provided to search children with.'
    109109        msg = IbidasSimpleMessage()
    110110       
    111         item_ids = [int(x) for x in args[ITEMS]]
     111        item_ids = [int(x) for x in args[self.ITEMS]]
    112112        parents = self.cd.item[_.item_id.within(*item_ids)]
    113113        self.logger.debug("Number of matched parent items: " +
     
    137137                'No item_ids provided to search parents with.'
    138138        msg = IbidasSimpleMessage()
    139         item_ids = [int(x) for x in args[ITEMS]]
     139        item_ids = [int(x) for x in args[self.ITEMS]]
    140140        children = self.cd.item[_.item_id.within(*item_ids)]
    141141        self.logger.debug("Nr of matched child items: " +
     
    161161        self.logger.debug("getItemNeighbours")
    162162        self.logger.debug("Provided arguments: " + str(args.keys()))
    163         items = args[ITEMS]
     163        items = args[self.ITEMS]
    164164        msg = IbidasSimpleMessage()
    165165        ids = [int(x) for x in items]
     
    186186        self.logger.debug("Provided arguments: " + str(args.keys()))
    187187        msg = IbidasSimpleMessage()
    188         assert args.has_key(ITEMS), \
     188        assert args.has_key(self.ITEMS), \
    189189                "No items provided to get links for."
    190         item_ids = [int(x) for x in args[ITEMS]]
     190        item_ids = [int(x) for x in args[self.ITEMS]]
    191191        items = self.cd.item[_.item_id.within(*item_ids)]
    192192        links = self.cd.item_child_link.join(items, 'parent_id', 'item_id').up()
     
    202202        self.logger.debug("Provided arguments: " + str(args.keys()))
    203203        msg = IbidasSimpleMessage()
    204         assert args.has_key(ITEMS), \
     204        assert args.has_key(self.ITEMS), \
    205205                "No item_ids provided to fetch."
    206         item_ids = [int(x) for x in args[ITEMS]]
     206        item_ids = [int(x) for x in args[self.ITEMS]]
    207207        items = self.cd.item[_.item_id.within(*item_ids)]
    208208        msg.addItems(items)
     
    211211    def getItemsByName(self, args):
    212212        """Returns items based on the names provided in the input map."""
    213         assert args.has_key(ITEMNAMES), \
     213        assert args.has_key(self.ITEMNAMES), \
    214214                "No itemnames provided to match against."
    215215        msg = IbidasSimpleMessage()
    216         names = args[ITEMNAMES]
     216        names = args[self.ITEMNAMES]
    217217        accessions = self.cd.item_prop_accession[_.value.within(*names)]
    218218        items = self.cd.item.join(accessions, 'item_id', 'item_id').up()
     
    247247        """Returns all the items and links associated with the
    248248        provided set_id."""
    249         assert args.has_key(SETS), \
     249        assert args.has_key(self.SETS), \
    250250                "No sets provided to fetch content from."
    251         source_ids = [int(x) for x in args[SETS]]
     251        source_ids = [int(x) for x in args[self.SETS]]
    252252        self.logger.debug("Called getSetContentBySourceID")
    253253        self.logger.debug("source_ids: " + str(source_ids))
     
    280280        """Finds all accessions belonging to a list of items."""
    281281        self.logger.debug("Called getItemAccessions")
    282         assert args.has_key(ITEMS), \
     282        assert args.has_key(self.ITEMS), \
    283283                "No items provided to get accessions for."
    284284        msg = IbidasSimpleMessage()
    285         item_ids = [int(x) for x in args[ITEMS]]
     285        item_ids = [int(x) for x in args[self.ITEMS]]
    286286        self.logger.debug("item_ids: " + str(item_ids))
    287287        items = self.cd.item[_.item_id.within(*item_ids)]
Note: See TracChangeset for help on using the changeset viewer.