from wcs.qommon.storage import StorableObject

class Link(StorableObject):
    _names = 'links'

    title = None
    url = None
    position = None

    def sort_by_position(cls, links):
        def cmp_position(x, y):
            if x.position == y.position:
                return 0
            if x.position is None:
                return 1
            if y.position is None:
                return -1
            return cmp(x.position, y.position)
        links.sort(cmp_position)
    sort_by_position = classmethod(sort_by_position)

