コード例 #1
0
    def create(cls, session, endpoint=None, **attrs):
        queue = cls(**attrs)
        if endpoint:
            queue.endpoint = Endpoint.polymorphic_create(endpoint)

        session.add(queue)
        return queue
コード例 #2
0
 def create(cls, session, endpoints=None, **attrs):
     executor = cls(**attrs)
     if endpoints:
         for subject, endpoint in endpoints.iteritems():
             executor.endpoints[subject] = Endpoint.polymorphic_create(endpoint)
     
     session.add(executor)
     return executor
コード例 #3
0
    def update(self, session, **attrs):
        if 'endpoint' in attrs:
            endpoint = attrs.pop('endpoint')
            if endpoint:
                if self.endpoint:
                    self.endpoint.update_with_mapping(endpoint)
                else:
                    self.endpoint = Endpoint.polymorphic_create(endpoint)
            else:
                self.endpoint = None

        self.update_with_mapping(attrs)
コード例 #4
0
 def update(self, session, endpoints=None, **attrs):
     if attrs:
         self.update_with_mapping(attrs, ignore='id')
     if endpoints is not None:
         collection = self.endpoints
         for subject, endpoint in endpoints.iteritems():
             if subject in collection:
                 collection[subject].update_with_mapping(endpoint)
             else:
                 collection[subject] = Endpoint.polymorphic_create(endpoint)
         for subject in collection.keys():
             if subject not in endpoints:
                 del collection[subject]