model

ASP.NET MVC 2 LINQ-to-SQL generated classes and Model Validation

Hi, I just want to make sure I understand correctly the best practices for ASP.NET MVC2 with LINQ-TO-SQL. Please correct me if I am wrong at any of the following points: LINQ TO SQL generates classes for you, based on your tables The generated classes are Models Those are the models we are supposed to use in the Views If we want to a...

How to import models in other projects in Django

Is it possible to import models from apps in different Django projects? I hope to move some common models in a base projects from which every child projects can share the same data in these common models. Edit I have to place from baseproject.appname.models import basemodel before os.environ['DJANGO_SETTINGS_MODULE'] = 'childproje...

"Value" member field can be one of four different types - best design?

I have a class called "DataModel" or something, which is basically a unit of data which can be either a string or a number or a date or a boolean with various (identical) attributes. What is the best way to write this model? Have the value be of type Object interface DataModel { Object getValue(); // cast to whatever is needed ...

Where does input validation belong in an MVC application?

I have a MVC application that receives an input from a form. This is a login form so the only validation that is necessary is to check whether the input is non-empty. Right now before I pass it to the model I validate it in the controller. Is this a best practice or not? Does it belong to the model? ...

Access models in other project in a Django view cause "table doesn't exist" error

Base project structure baseproject baseapp models.py class BaseModel(models.Model) ... Other project structure: project app views.py urls.py project.app.views.py import os os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' from django.conf import settings from baseproj...

ASP.NET MVC Is it possible to use ascx files across multiple views with different Models

Hi All, I am wondering if it is possible to wrap up an ascx file so that it can be used in different views, without having to type it to a specific Model. This would mean you could use one ascx file for many pages, as long as the relevant model data was passed in. Currently I'm duplicating my ascx files for different parts of the site...

ASP.NET MVC 2 AJAX dilemma: Lose Models concept or create unmanageable JavaScript

Hi, Ok, let's assume we are working with ASP.NET MVC 2 (latest and greatest preview) and we want to create AJAX user interface with jQuery. So what are our real options here? Option 1 - Pass Json from the Controller to the view, and then the view submits Json back to the controller. This means (in the order given): User opens some Vi...

Model binding in ASP.NET MVC when editing an entity

Hi, i am kind of stuck with this code: [AcceptVerbs(HttpVerbs.Post), Authorize] public ActionResult Edit(FormCollection collection, [Bind(Exclude="Id,Latitude,Longitude")]Store bindStore, string Latitude, string Longitude) { Store st = storeModel.GetStore(Session["user_id"].ToString()); bool modelUpdate = Tr...

Best solution for managing navigation (and marking currently active item) in CakePHP

So I have been looking around for a couple hours for a solid solution to handling site navigation in CakePHP. Over the course of a dozen projects, I have rigged together something that works for each one, but what I'm looking for is ideally a CakePHP plugin that handles the following: Navigation Model Component for handing off to the ...

Best database design (model) for user tables

I'm developping a web application using google appengine and django, but I think my problem is more general. The users have the possibility to create tables, look: tables are not represented as TABLES in the database. I give you an example: First form: Name of the the table: __________ First column name: __________ Second column na...

CakePHP External API aggregation - A Model, Datasource & Behaviour Design Question - Best Practice

Hi, I have a project that requires me to integrate with 2 REST APIs and then aggregate the results. I am building this project in CakePHP My basic approach is: Product (model) Products (controller) API1 (datasource) API2 (datasource) Aggregation (behaviour) The basic flow is: 1. User enters a product name into a search form /products...

Specifying the foreign key in a has_many :through relationship

I have the following three models: User, Project, and Assignment. A User has_many Projects through an assignment. However, Assignment actually has two foreign keys that relate to a User: user_id (representing the user who was assigned the project) and completer_id (representing the user who completed the project). Often, user_id and co...

Routes and primary keys in rails

I am a rails rookie and fear that my question is woefully ignorant - please be gentle. I am building an app that will catalog and monitor other websites, and need to synchronize with an external data source (thus overiding primary key). I have the model below, but i cannot figure out the routing for accessing individual records (tho li...

In an MVC approach, should I separate my model functions, or combine then as much as possible?

Should you separate model functions, even if they retrieve the fields of data? Lets say I have an Articles Model that gets Articles from the database. I have a function, getUserArticles($id), that gets the users articles. I have a function, getAllArticles($offset, $limit), that gets a list of articles. Should I leave the two functio...

Are there patterns for model / entity classes

What is the best approach to take when you are pulling model objects from multiple datasources? For example I have an application has has some data stored in a mySQL database using hibernate. What If I wanted to store some other objects in EC2 or Google App Engine? I understand that DAO's abstract the implementation of working with ...

django - 3-model set all, with joining?

I have these models: class A(Model): pass class B(Model): the_a = ForeignKey(A) class C(Model): the_b = ForeignKey(B) somewhere in code, I have an A instance. I know how to get all of the B's associated with A; A.b_set.all() - but is there a way to get all of the C's associated with all the B's associated with my A, without...

CakePHP: Layout, variables and question

Howdy! I got layout, nothing special, three columns, just to learn CakePHP. In documentation I found nothing about this case. I got some statistics in sidebars, si I send them to layout file (default.ctp) cause they are displayed on every page. I build (thanks to one user here) a component: class SidebarComponent extends object { ...

Asp.net MVC exception not being caught in try catch block

Hi, Could anyone tell me why a problem in the noun model would not be caught by this try catch? I have tried this on two different controller methods now, and both times, even if the linq2sql doesn't allow the data to be saved, the code never jumps into the catch block. I've watched the noun object in the middle of the trace, and the ...

Do any software developers know what the General Systems Model or an Organizational Model is?

Apparently the General Systems Model and Organizational Model are part of requirements phase of a software development project using the waterfall model (according to my professor), but we did not learn about this in my software engineering course, neither of my two software engineering books mention them, and Google doesn't seem to know...

[Rails] How to associate a new model with existing models using has_and_belongs_to_many

I have two models with a many to many relationship using has_and_belongs_to_many. Like so: class Competition < ActiveRecord::Base has_and_belongs_to_many :teams accepts_nested_attributes_for :teams end class Team < ActiveRecord::Base has_and_belongs_to_many :competitions accepts_nested_attributes_for :competitions end If we a...