title: Python2 (with six) metaclass and Fields with parameters
body: <p>I am working on creating a metaclass that should work with fields. </p>
  
  <p>Based on sources on the internet, and here on StackOverflow I have come this far:</p>
  
  <h3>Metaclass</h3>
  
  <pre><code>def getmethod(attrname):
      def _getmethod(self):
          return getattr(self, "__"+attrname).get()
      return _getmethod
  
  
  def setmethod(attrname):
      def _setmethod(self, value):
          return getattr(self, "__"+attrname).set(value)
      return _setmethod
  
  
  class Metaclass(type):
      def __new__(cls, name, based, attrs):
          ndict = {}
          for attr in attrs:
              if isinstance(attrs[attr], Field):
                  ndict['__'+attr] = attrs[attr]
                  ndict[attr] = property(getmethod(attr), setmethod(attr))
          return super(Metaclass, cls).__new__(cls, name, based, ndict)
  </code></pre>
  
  <h3>model</h3>
  
  <pre><code>class Model(six.with_metaclass(Metaclass)):
      foo = CharField()
  
      def __init__(self, *args, **kwargs):
          pass
  </code></pre>
  
  <h3>Field</h3>
  
  <pre><code>class Field(object):
      def __init__(self, required=False, *args, **kwargs):
          self.required = required
          self.name = None
  
      def set(self, value):
          self.value = value
  
      def get(self):
          return self.value
  
      def set_name(self, name):
          self.name = name
  </code></pre>
  
  <h3>CharField</h3>
  
  <pre><code>class CharField(Field):
      def __init__(self, required=False, max_length=0, min_length=0, *args, **kwargs):
          self.max_length = max_length
          self.min_length = min_length
          super(CharField, self).__init__(required, args, kwargs)
  </code></pre>
  
  <p>Now when I create a subclass of <code>Model</code></p>
  
  <pre><code>class Product(Model):
      name = CharField()
  </code></pre>
  
  <p>and create an instance of <code>Product</code></p>
  
  <pre><code>if __name__ == '__main__':
      p = Product()
  </code></pre>
  
  <p>This works just fine. </p>
  
  <p>I can even add or change the product name</p>
  
  <pre><code>if __name__ == '__main__':
      p = Product()
      p.name = "Another beautiful product"
  </code></pre>
  
  <p>However, when I would like to use <code>name</code> as a parameter:</p>
  
  <pre><code>if __name__ == '__main__':
      p = Product(name="Another beautiful product")
  </code></pre>
  
  <p>An error is raised: <code>TypeError: object() takes no parameters</code></p>
  
  <p>When debugging I can see that the instance of the Metaclass is created but the error is raised when the line <code>return super(Metaclass, cls).__new__(cls, name, based, ndict)</code> is reached.</p>
  
  <p>Could someone help me out here?</p>