コード例 #1
0
ファイル: acl.py プロジェクト: unn/fileconveyor
class Policy:
    def __init__(self, parent=None):
        self.parent = parent
        self.acl = None

    def startElement(self, name, attrs, connection):
        if name == 'Owner':
            self.owner = User(self)
            return self.owner
        elif name == 'AccessControlList':
            self.acl = ACL(self)
            return self.acl
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'Owner':
            pass
        elif name == 'AccessControlList':
            pass
        else:
            setattr(self, name, value)

    def to_xml(self):
        s = '<AccessControlPolicy>'
        s += self.owner.to_xml()
        s += self.acl.to_xml()
        s += '</AccessControlPolicy>'
        return s
コード例 #2
0
ファイル: acl.py プロジェクト: jspring11/boto
class Policy:

    def __init__(self, parent=None):
        self.parent = parent
        self.acl = None

    def startElement(self, name, attrs, connection):
        if name == 'Owner':
            self.owner = User(self)
            return self.owner
        elif name == 'AccessControlList':
            self.acl = ACL(self)
            return self.acl
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'Owner':
            pass
        elif name == 'AccessControlList':
            pass
        else:
            setattr(self, name, value)

    def to_xml(self):
        s = '<AccessControlPolicy>'
        s += self.owner.to_xml()
        s += self.acl.to_xml()
        s += '</AccessControlPolicy>'
        return s
コード例 #3
0
class Policy(object):

    def __init__(self, parent=None):
        self.parent = parent
        self.namespace = None
        self.acl = None

    def __repr__(self):
        grants = []
        for g in self.acl.grants:
            if g.id == self.owner.id:
                grants.append("%s (owner) = %s" % (g.display_name, g.permission))
            else:
                if g.type == 'CanonicalUser':
                    u = g.display_name
                elif g.type == 'Group':
                    u = g.uri
                else:
                    u = g.email_address
                grants.append("%s = %s" % (u, g.permission))
        return "<Policy: %s>" % ", ".join(grants)

    def startElement(self, name, attrs, connection):
        if name == 'AccessControlPolicy':
            self.namespace = attrs.get('xmlns', None)
            return None      
        if name == 'Owner':
            self.owner = User(self)
            return self.owner
        elif name == 'AccessControlList':
            self.acl = ACL(self)
            return self.acl
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'Owner':
            pass
        elif name == 'AccessControlList':
            pass
        else:
            setattr(self, name, value)

    def to_xml(self):
        if self.namespace is not None:
            s = '<AccessControlPolicy xmlns="{0}">'.format(self.namespace)
        else:
            s = '<AccessControlPolicy>'     
        s += self.owner.to_xml()
        s += self.acl.to_xml()
        s += '</AccessControlPolicy>'
        return s
コード例 #4
0
ファイル: acl.py プロジェクト: raggiskula/boto
class Policy:

    NameSpace = 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/"'

    def __init__(self, parent=None):
        self.parent = parent
        self.acl = None

    def __repr__(self):
        grants = []
        for g in self.acl.grants:
            if g.id == self.owner.id:
                grants.append("%s (owner) = %s" % (g.display_name, g.permission))
            else:
                if g.type == 'CanonicalUser':
                    u = g.display_name
                elif g.type == 'Group':
                    u = g.uri
                else:
                    u = g.email
                grants.append("%s = %s" % (u, g.permission))
        return "<Policy: %s>" % ", ".join(grants)

    def startElement(self, name, attrs, connection):
        if name == 'Owner':
            self.owner = User(self)
            return self.owner
        elif name == 'AccessControlList':
            self.acl = ACL(self)
            return self.acl
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'Owner':
            pass
        elif name == 'AccessControlList':
            pass
        else:
            setattr(self, name, value)

    def to_xml(self):
        s = '<AccessControlPolicy %s>' % self.NameSpace
        s += self.owner.to_xml()
        s += self.acl.to_xml()
        s += '</AccessControlPolicy>'
        return s
コード例 #5
0
ファイル: acl.py プロジェクト: dquangsinh/fb2pdf
class Policy:
    def __init__(self, parent=None):
        self.parent = parent
        self.acl = None

    def __repr__(self):
        grants = []
        for g in self.acl.grants:
            if g.id == self.owner.id:
                grants.append("%s (owner) = %s" % (g.display_name, g.permission))
            else:
                if g.type == "CanonicalUser":
                    u = g.display_name
                elif g.type == "Group":
                    u = g.uri
                else:
                    u = g.email
                grants.append("%s = %s" % (u, g.permission))
        return "<Policy: %s>" % ", ".join(grants)

    def startElement(self, name, attrs, connection):
        if name == "Owner":
            self.owner = User(self)
            return self.owner
        elif name == "AccessControlList":
            self.acl = ACL(self)
            return self.acl
        else:
            return None

    def endElement(self, name, value, connection):
        if name == "Owner":
            pass
        elif name == "AccessControlList":
            pass
        else:
            setattr(self, name, value)

    def to_xml(self):
        s = "<AccessControlPolicy>"
        s += self.owner.to_xml()
        s += self.acl.to_xml()
        s += "</AccessControlPolicy>"
        return s