Coder Social home page Coder Social logo

Comments (4)

joernhees avatar joernhees commented on July 25, 2024

yes, i think that's intentional as the method is a skeleton meant to be filled with merging logic depending on the final app. see discussion in #62

from gae-init.

lipis avatar lipis commented on July 25, 2024

yep it's intentional.. as some people might want to do something extra after the merge to the given user_db..

from gae-init.

joernhees avatar joernhees commented on July 25, 2024

maybe we could update the comment so it's a bit clearer that this is not a left TODO for us but for the developer using gae-init?
# TODO: if you want to handle user data for merged users, do it here!

from gae-init.

gmist avatar gmist commented on July 25, 2024

it is not obvious... maybe something like this

def merge_user_dbs(deprecated_keys, user_db=None, post_func=lambda u: u):
  deprecated_dbs = ndb.get_multi(deprecated_keys)
  for deprecated_db in deprecated_dbs:
    deprecated_db.auth_ids = []
    deprecated_db.active = False
    if not deprecated_db.username.startswith('_'):
      deprecated_db.username = '_%s' % deprecated_db.username
  ndb.put_multi(deprecated_dbs)
  post_func(user_db)

usage by default

deprecated_keys = [key for key in user_db_keys if key != merged_user_db.key]
merge_user_dbs(deprecated_keys)

with extra something

deprecated_keys = [key for key in user_db_keys if key != merged_user_db.key]
merge_user_dbs(deprecated_keys, merged_user_db, lambda u: u.key.delete())

or

def something(user):
  user.key.delete()
deprecated_keys = [key for key in user_db_keys if key != merged_user_db.key]
merge_user_dbs(deprecated_keys, merged_user_db, something)

from gae-init.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.