Changeset 2f6820c


Ignore:
Timestamp:
May 28, 2010 3:40:47 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
2c1fd21
Parents:
5bf359d
Message:

Explicit access attributes in the format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/access.py

    r5bf359d r2f6820c  
    129129        """
    130130        Read an access DB with filename config  of the form:
    131             (id, id, id) -> something
    132         where the ids can be fedids, strings, or <any> or <none> and somthing
    133         is any set of charcters.  The hash self.access is populated with
    134         mappings from those triples to the results of access_obj being called
    135         on the remainder of the line.  If access_obj is not given, the string
    136         itself is entered in the hash.  Additionally, a triple with <any> and
    137         <none> mapped to None is entered in self.auth with the attribute
    138         "access".
     131            (id, id, id) -> attribute, something
     132        where the ids can be fedids, strings, or <any> or <none>, attribute is
     133        the attribute to assign , and something is any set of charcters.  The
     134        hash self.access is populated with mappings from those triples to the
     135        results of access_obj being called on the remainder of the line (if
     136        present).  If access_obj is not given, the string itself is entered in
     137        the hash.  Additionally, a triple with <any> and <none> mapped to None
     138        is entered in self.auth with the attribute given.
    139139
    140140        Parsing errors result in a self.parse_error exception being raised.
     
    146146        key_name = "(<ANY>|<NONE>|"+fedid_expr + "|"+ name_expr + ")"
    147147        access_re = re.compile('\('+key_name+'\s*,\s*'+key_name+'\s*,\s*'+
    148                 key_name+'\s*\)\s*->\s*(.*)', re.IGNORECASE)
     148                key_name+'\s*\)\s*->\s*([^,]+)\s*(.*)', re.IGNORECASE)
    149149
    150150        def parse_name(n):
     
    158158            else:
    159159                return n
     160        def strip_comma(s):
     161            s = s.strip()
     162            if s.startswith(','):
     163                s = s[1:].strip()
     164            return s
    160165
    161166        if access_obj is None:
     
    175180                    access_key = tuple([ parse_name(x) \
    176181                            for x in m.group(1,2,3)])
     182                    attribute = m.group(4)
    177183                    auth_key = tuple([ auth_name(x) for x in access_key])
    178                     access_val = access_obj(m.group(4))
    179 
    180                     self.access[access_key] = access_val
    181                     self.auth.set_attribute(auth_key, "access")
     184                    self.auth.set_attribute(auth_key, attribute)
     185                    if len(m.group(5)) > 0:
     186                        access_val = access_obj(strip_comma(m.group(5)))
     187                        self.access[access_key] = access_val
    182188                    continue
    183189
Note: See TracChangeset for help on using the changeset viewer.