code: def by_name(cls, session, name):
          
          # XXX the field "name" should be created with a
          # case insensitive collation.
          pkg = cls.first(session, where=(cls.name.like(name),))
          if not pkg:
              name = name.replace(u'-', u'_').upper()
              pkg = cls.first(session,
                              where=(cls.name.like(name),))
              # XXX _ is a like operator
              if pkg and pkg.name.upper().replace(u'-', u'_') != name:
                  pkg = None
          return pkg
docs: Get a package from a given name.
  
          :param session: SQLAlchemy session
          :type session: :class:`sqlalchemy.Session`
  
          :param name: name of the package
          :type name: `unicode
  
          :return: package instance
          :rtype: :class:`pyshop.models.Package`