def create(self, user, values): # Delete the gid which sets the default group when creating a # new user. The default group when creating a new user is always # the usergroup which gets automatically created on user # creation. So this value can (and must) be ignored. # Not removing the "gid" will otherwise cause an # IntegrityError while flushing the new user to the DB as the # usergroup with the given id is not persistent in the DB. if "gid" in values: del values["gid"] # Delete the sid which sets the default settings for the same # reasons than deleting the "gid" attribute. if "sid" in values: del values["sid"] new_user = BaseFactory.create(self, user, values) # Now create a a new Profile profile_property = get_prop_from_instance(new_user, "profile", include_relations=True) profile_class = profile_property.mapper.class_ profile_factory = BaseFactory(profile_class) profile = profile_factory.create(user, {}) new_user.profile.append(profile) # Create settings settings_factory = BaseFactory(UserSetting) settings = settings_factory.create(user, {}) new_user.settings = settings # A usergroup usergroup_property = get_prop_from_instance(new_user, "usergroup", include_relations=True) usergroup_class = usergroup_property.mapper.class_ usergroup_factory = BaseFactory(usergroup_class) usergroup = usergroup_factory.create(None, {}) usergroup.name = new_user.login usergroup.members.append(new_user) # If no default group is set, then set the users group as # default group new_user.usergroup = values.get("usergroup") or usergroup return new_user
def create(self, user=None, values=None): # Hack! We have a not null constraint on the datafild. But the # value will be actually set in a savedata callback. if values is None: values = {} if "data" not in values: values["data"] = 'EMPTY' new_item = BaseFactory.create(self, user, values) return new_item
def create(self, user, values): new_item = BaseFactory.create(self, user, values) return new_item
def create(self, user=None): new_item = BaseFactory.create(self, user) return new_item
def create(self, user=None, request=None): new_item = BaseFactory.create(self, user, request) return new_item