Hello, i am working on a profile import/export module.
The user suplies a serialized profile configuration in a edit-box , or a profile is received by a com chat message, and the addon creates a new profile with the suplied configuration data. That is the import/profile switch code, appears to work well:
local function ImportProfile(data, Hex)
local profileName= CalculateNewProfileName(Hex and strsub(data,1,64) or nil )
local Success, data= UnserializeProfile(data,Hex)
if not Success then
print("Profile unserialize failed: ", data)
local prev_Hook= Grid2.ProfileChanged
for key,section in pairs(data) do
if key=="Grid2" then
db= self:GetModule(key) and self.db:GetNamespace(key,true) or nil
if db then
for k,v in pairs(section) do
1. Is it posible to inject a new profile directly in AceDB config ? without activating a new profile first with SetProfile ? And avoiding using internal structures that can be changed in future AcedDB versions.
2. Currently the code iterate throught profile tables and assign the keys one by one. If AceDB dont keep some reference to module.db.profile tables or has some metatable, i could make a simple asignement instead of iterate all keys: Is it safe to do: Module/Addon.db.profile= newprofiledata ?
3. My first intention was to register AceDB OnNewProfile event to avoid hooking Grid2:ProfileChanged function.
The AceDb documentation says: "Fires when a new profile is created, usually used to apply custom defaults that cannot be handled through AceDB." But it cant be done because OnNewProfile is fired AFTER OnProfileChanged. I can't see any utility to OnNewProfile Event if its not fired before ProfileChanged event. Is it working as intended ?