'Helper method to prefix an unprefixed field selector
@param alias: the resource alias to use as prefix
@param selector: the field selector
@return: the prefixed selector'

def _prefix(self, selector):

    alias = self.alias
    items = selector.split('$', 0)
    head = items[0]
    if ('.' in head):
        if (alias not in (None, '~')):
            (prefix, key) = head.split('.', 1)
            if (prefix == '~'):
                prefix = alias
            elif (prefix != alias):
                prefix = ('%s.%s' % (alias, prefix))
            items[0] = ('%s.%s' % (prefix, key))
            selector = '$'.join(items)
    else:
        if (alias is None):
            alias = '~'
        selector = ('%s.%s' % (alias, selector))
    return selector
