Tweak ORM relationship backrefs per SA 2.0 warnings

This commit is contained in:
Lance Edgar 2023-02-21 18:15:27 -06:00
parent 87477d7cbe
commit c03119acb2
2 changed files with 19 additions and 3 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -45,6 +45,11 @@ class MailChimpList(model.Base):
date_created = sa.Column(sa.DateTime(), nullable=True)
members = orm.relationship('MailChimpListMember',
back_populates='list',
# nb. this is to satisfy SA 2.0
cascade_backrefs=False)
def __str__(self):
return self.name or ""
@ -62,7 +67,8 @@ class MailChimpListMember(model.Base):
uuid = model.uuid_column()
list_uuid = sa.Column(sa.String(length=32), nullable=False)
list = orm.relationship(MailChimpList, backref='members')
list = orm.relationship(MailChimpList,
back_populates='members')
id = sa.Column(sa.String(length=32), nullable=True)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -130,10 +130,20 @@ class MailChimpListMemberImporter(FromMailChimp, mailchimp_importing.model.MailC
def get_all_members(self, list_id):
members = []
# cf. https://mailchimp.com/developer/marketing/api/list-members/list-members-info/
result = self.mailchimp.lists.members.all(list_id, get_all=True,
# TODO: maybe should try this instead of
# the default which seems to be 500
# count=1000
# TODO: this testing chunk left here for
# reference; it can be handy to filter
# results etc. for test runs
# count=500,
# # since_last_changed=datetime.date(2023, 1, 1),
# sort_field='last_changed',
# sort_dir='DESC',
)
members.extend(result['members'])
return members