def to_hash(self):
     """Convert the object to a hash."""
     obj = super(CitationProposal, self).to_hash()
     obj['_id'] = index_hash(int(self.citation.id), unicode_type(self.proposal.id))
     obj['citation_id'] = int(self.citation.id)
     obj['proposal_id'] = unicode_type(self.proposal.id)
     return obj
 def to_hash(self):
     """Convert the object to a hash."""
     obj = super(AToolProposal, self).to_hash()
     obj['_id'] = index_hash(unicode_type(self.proposal.id),
                             int(self.analytical_tool.id))
     obj['proposal_id'] = unicode_type(self.proposal.id)
     obj['analytical_tool_id'] = int(self.analytical_tool.id)
     return obj
 def to_hash(self):
     """Convert the object to a hash."""
     obj = super(ProposalInstrument, self).to_hash()
     obj['_id'] = index_hash(unicode_type(self.proposal.id),
                             int(self.instrument.id))
     obj['instrument_id'] = int(self.instrument.id)
     obj['proposal_id'] = unicode_type(self.proposal.id)
     return obj
 def to_hash(self, recursion_depth=1):
     """Convert the object to a hash."""
     obj = super(ProposalParticipant, self).to_hash(recursion_depth)
     obj['_id'] = index_hash(unicode_type(self.proposal.id),
                             int(self.person.id))
     obj['person_id'] = int(self.person.id)
     obj['proposal_id'] = unicode_type(self.proposal.id)
     return obj
Exemplo n.º 5
0
def index_hash(*args):
    """
    Generate a hash for all the arguments passed.

    This is used to combine multiple unique IDs into a single string.
    """
    arg_hash = md5()
    for arg in args:
        arg_hash.update(unicode_type(arg).encode('utf-8'))
    return arg_hash.hexdigest()
Exemplo n.º 6
0
def strip_chars(haystack, chars):
    return unicode_type(haystack).strip(chars)