Commit d24785f9 authored by Taddeus Kroes's avatar Taddeus Kroes

Static values of the form array(array('relation')) are now rewritten to 'relation'.

parent 908f5a80
......@@ -140,15 +140,39 @@ class Model(object):
self.belongs_to.append((singular, self.relopts(other_model)))
other_model.add_has_relation(self)
def strip_array(self, attr):
array = getattr(self, attr)
if len(array) == 1:
relation, opts = array[0]
if not len(opts):
return php_static_var(attr, php_value(relation))
def php_has_many(self):
stripped = self.strip_array('has_many')
if stripped:
return stripped
if self.has_many:
return php_static_array('has_many', self.has_many)
def php_has_one(self):
stripped = self.strip_array('has_one')
if stripped:
return stripped
if self.has_one:
return php_static_array('has_one', self.has_one)
def php_belongs_to(self):
stripped = self.strip_array('belongs_to')
if stripped:
return stripped
if self.belongs_to:
return php_static_array('belongs_to', self.belongs_to)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment