def by_name(cls, session, name):
        """
        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`
        """
        # 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
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`