Changes between Version 11 and Version 12 of ContribAuthImprovements


Ignore:
Timestamp:
03/23/2012 06:21:09 AM (3 years ago)
Author:
bhuztez
Comment:

add solution 2b AUTH_USER_MODEL_MIXINS setting

Legend:

Unmodified
Added
Removed
Modified
  • ContribAuthImprovements

    v11 v12  
    138138 * As with Solution 2, prone to unpredictable problems if `USER_MODEL` is modified after the initial syncdb.
    139139
     140== Solution 2b: `AUTH_USER_MODEL_MIXINS` setting ==
     141
     142This is similar to solution 2 and 2a, but is quite the opposite to solution 3.
     143
     144Making every model pluggable. So that auth.User could be defined like this.
     145
     146{{{#!python
     147class User(models.Model):
     148    __mixins__ = settings.AUTH_USER_MODEL_MIXINS
     149}}}
     150
     151=== Implementation ===
     152
     153 * Change bases before creating user-defined Model class in !ModelBase.
     154     {{{#!python
     155     mixins = attrs.get('__mixins__', ())
     156     bases = load_available_model_mixins(mixins) + bases
     157     }}}
     158 * separate fields out as mixins like solution 2a
     159
     160=== Advantages ===
     161
     162 * do not have unpredictable problems in solution 2/2a.
     163 * Existing projects require no migration. the same as solution 2/2a.
     164 * Unlike solution 2a, change is not required for existing apps.
     165 * Unrelated and third-party apps can indicate that they depend on various orthogonal mixins. the same as solution 2.
     166
     167=== Problems ===
     168
     169 * built-in schema migration tools is required.
     170 * Doesn't address the !EmailField length problem. (can be solved by schema migration tools?)
     171 * !ModelForm must be more restrictive, otherwise, django will suffer security issues, just as the register_globals of PHP or the mass-assignment of Rails.
     172
    140173== Solution 3: Leverage App Refactor ==
    141174
Back to Top