Re: Model Theory 101 - Video Sharing App
On Aug 26, 4:17 pm, thornomad <damont...@gmail.com> wrote:
>
> Caveats: I would like to keep the original "synced" data in its own
> field and the "approved" data (as edited) in separate field. I
> imagine that the data first gets brought into the "edit" field, admin
> may make changes and save, but the "originating" data will remain
> separate and continue to be updated (synced).
Create a copy of the data in a new record - don't duplicate the fields
Have a field on the model that designated whether its original or
edited
have a self relation based on URL that links the synced and edited
versions
>
> This means I need at least
>
> I am stuck, though, on the most appropriate/logical approach to this
> app. Some approaches I've considered.
>
> [1] My first thought is to create base model "Video" (with the main
> fields) and then create child models like YoutubeVideo and VimeoVideo
> and BlipVideo ... when the user submits a url, would do a regex on it
> in the view, and send it through the appropriate child class. I could
> then grab the base Video model in my views (not having to distinguish
> the type of video) and use a "leaf" technique (eg,http://www.djangosnippets.org/snippets/1031/) to run the child's
> "sync" or "update" command. CONS: seems tacky and not easy to build
> on. The leaf technique isn't working when I override the save()
> function in leaf models.
>
> [2] Perhaps create only a single model and then create separate
> classes/functions to handle the the syncing of data based on the
> URLField data ... so, perhaps when Video.update() is called, it would
> run the logic then to see what kind of url it has, and how to update
> it. CONS: I thought maybe I could just create a ForeignKey field to a
> non-model group of classes with common functions (update, sync,
> etc) ... but I am not sure how, or if, I can do that.
You don't need to have your syncing code be in django models - you can
just write a python module that given a URL, will return a dictionary
of data representing the common fields you are interested in. You
model would just use that. There is probably an undocumented dict
like behavior on models that would allow you to update() the model
given a dict - but I'm just speculating.
>
> [3] Outsourcing.
>
> Hope this makes sense and folks have some feedback about how they
> might approach this. I would like this to be easily expandable -- for
> example, add YouTube and Vimeo support to start, and easily add other
> sites without having to "hack" it.
What I'm proposing is you have one model, it calls one entry point in
a 'non-django' set of python code. This code either returns a valid
dictionary, or raises some exception like "URL not handled" You can
add to that python code as much as you like as you go without having
to change the model or django code.
-Preston
>
> I know this is a huge question, but am interested in your "Design
> Approach" thoughts ...
>
> Thanks,
> Damon
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home