def field_names(*args, **kwargs): prepend = '' if 'prepend' in kwargs: prepend = kwargs['prepend']+'.' fieldNames = exclude(settings.EXCLUDE_FIELDS,TCountry._meta.get_all_field_names()) #return map(lambda x: prepend+x,fieldNames) return map(lambda x: prepend+x,fieldNames)
def field_names(*args, **kwargs): prepend = '' if 'prepend' in kwargs: prepend = kwargs['prepend']+'.' fieldNames = exclude(settings.EXCLUDE_FIELDS,TArtist._meta.get_all_field_names()) fieldNames.extend(TCountry.field_names(**{'prepend':'citizenship'})) fieldNames.extend(TResource.field_names(**{'prepend':'resourceid'})) return map(lambda x: prepend+x,fieldNames)
def add_element(parent, tagname, attrs={}, children={}, text=None): """Returns an ElementTree.Element object which is guaranteed to be unique, based on the given arguments.""" forbiddenvalues = [None, ''] attrs = exclude(attrs, values=forbiddenvalues) children = exclude(children, values=forbiddenvalues) el = ET.SubElement(parent, tagname, **attrs) if text and not attrs and not children: el.text = text for childname, value in children.items(): if is_xml_fragment(value) and not value.startswith('<%s' % childname): # create a valid xml fragment value = '<%s>%s</%s>' % (childname, value, childname) child = ET.fromstring(value) el.append(child) else: ET.SubElement(el, childname).text = value return el
def update(self, data): columns = dict(Listing.__table__.columns) columns = utils.exclude(["user_id", "id"], columns) self.__dict__.update(utils.pick(columns, data))