code: def to_objectid(objid):
      
      if objid is None:
          return objid
  
      try:
          objid = ObjectId(objid)
      except:
          util_log.error('%s is invalid objectid' % objid)
          return None
  
      return objid
docs: 字符对象转换成objectid