You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and then passed through to pending_registrations collection and then users collection on validate_registration().
What is the best way to add more user fields without hacking bottle-cork files?
Possibly (with pymongo):
Add fields to pending_registrations collection after register(), by assigning post_get('email_address') to variable email_addr and matching it in the pending_registrations collection and adding new fields with db.pending_registrations.update({"email_addr": email_addr},{"$set": {"new_key1":[],"new_key_2":"hello"}}). (I tried this, it works).
But then I need to ensure that the fields are added to users collection at validate_registration(), but these fields are "hard-coded" here:
# the user data is moved from pending_registrations to _users
self._store.users[username] = {
'role': data['role'],
'hash': data['hash'],
'email_addr': data['email_addr'],
'desc': data['desc'],
'creation_date': data['creation_date'],
'last_login': str(datetime.utcnow())
}
I ended up just having to hardcode changes in cork.py at validate_registration().
Just thinking out loud, I wonder if it is possible to iterate over data, get its key names and dynamically create the required key values to be added to users collection (so the custom fields are added as well). And perhaps pop off the unnecessary fields - pending registration number etc. Might have a look at doing that when I have a moment.
I can see user profile fields are created in:
register()
- https://github.com/FedericoCeratto/bottle-cork/blob/master/cork/cork.py#L387and then passed through to
pending_registrations
collection and thenusers
collection onvalidate_registration()
.What is the best way to add more user fields without hacking
bottle-cork
files?Possibly (with
pymongo
):Add fields to
pending_registrations
collection afterregister()
, by assigningpost_get('email_address')
to variableemail_addr
and matching it in thepending_registrations
collection and adding new fields withdb.pending_registrations.update({"email_addr": email_addr},{"$set": {"new_key1":[],"new_key_2":"hello"}})
. (I tried this, it works).But then I need to ensure that the fields are added to
users
collection atvalidate_registration()
, but these fields are "hard-coded" here:https://github.com/FedericoCeratto/bottle-cork/blob/master/cork/cork.py#L467
The text was updated successfully, but these errors were encountered: