Search Results

Search found 1102 results on 45 pages for 'recurrence relation'.

Page 29/45 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Empty dict-like collection problem in SQLAlchemy

    - by maksymko
    I have a mapping in SQLAlchemy that looks like this: t_property_value = sa.Table('property_value', MetaData, autoload = True, autoload_with = engine) orm.mapper(PropertyValue, t_property_value) t_estate = sa.Table('estate', MetaData, autoload = True, autoload_with = engine) orm.mapper(Estate, t_estate, properties = dict( property_hash = orm.relation(PropertyValue, collection_class = column_mapped_collection(t_property_value.c.property_id)) )) Now, everything seems to be fine, when I load the Estate object and it has some relations to PropertyValue objects. However, when it does not, then property_hash attribute is None, instead of being something dict-like, so I can not add new relations like this: estate.property_hash[prop_id] = PropertyValue(...) because I get the "'NoneType' object does not support item assignment" error. So, is there any way to force SQLAlchemy to create proper empty collection?

    Read the article

  • sqlite - Foreign keys in VS2008 Designer

    - by rene marxis
    Hello I'm starting over to use strong typed datasets in VS 2008 with sqlite and running into a problem. I have some tables that have foreign keys allready defined in the database. I can see those in the Server-Explorer. Now i create a new strong typed Dataset with the designer and add only one table from that realtion to the dataset. Then i like to add the second one and i get an error message "Unexpected error ... Source: Microsoft.VSDesigner; ErrorCode:-1" No Additional Info. The error does not occure if i add both tables at the same time (say i drag them from the serverexplorer). Is there any way to add subsequent tables to an dataset that are in relation(s) to alreay added once? Many thanks _rene

    Read the article

  • django many to many validation when add()

    - by Julien
    Hi i have a Category model with parent/child self relation For primary category and sub categories : class Place(models.Model): name = models.CharField(_("name"), max_length=100) categories = models.ManyToManyField("Category", verbose_name=_("categories")) class Category(models.Model): name = models.CharField(_("name"), max_length=100) parent = models.ForeignKey('self', blank=True, null=True, related_name='child_set') i need to prevent orphans, to prevent this kind of errors (in admin web interface) c_parent = Category(name='Restaurant') c_parent.save() c_child = Category(name="Japanese restaurant", parent=c_parent) c_child.save() place1 = Place (name="Planet sushi") place1.save() place1.categories.add(c_parent) place1.categories.add(c_child) So now we have a new Place called "Planet sushi", it's a Restaurant (root category), and a Japanese Restaurant (sub category) but i want to prevent this kind of things : place2 = Place (name="Tokyofood") place2.save() place2.categories.add(c_child) because parent is not set, or is not the correct parent category where can i do form validation for the admin ? and other forms (because any user can add a new place and will have to choose correct categories for)

    Read the article

  • Android: Constructing a triangle based on Geographical information

    - by Aidan
    Hi Guys, I'm constructing a geolocation based application and I'm trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I've got the math figured, I just have the triangle to construct. Here's a further clarification of what I want to do.. I just want to know is there a way to get java to construct 2 other co-ordinates based on my orientation in relation to true north and my current co-ordinate? I'd like to construct a tri-angle, 45 degrees out each way of my current location (one of the points) and 1 kilometer in that direction. The problem is I don't know how to make Android/Java recognise that I want to find that point in the direction I'm currently facing.. Anyone got any ideas?

    Read the article

  • Multiple Foriegn Keys from One Table linking to single Primary Key in second Table

    - by croker10
    Hi all, I have a database with three tables, a household table, an adults table and a users table. The Household table contains two foreign keys, iAdult1ID and iAdult2ID. The Users table has a iUserID primary key and the Adult table has a corresponding iUserID foreign key. One of the columns in the Users table is strUsername, an e-mail address. I am trying to write a query that will allow me to search for an e-mail address for either adult that has a relation to the household. So I have two questions, assuming that all the values are not null, how can I do this? And two, in reality, iAdult2ID can be null, is it still possible to write a query to do this? Thanks for your help. Let me know if you need any more information.

    Read the article

  • Help me refactor this nasty Ruby if/else statement

    - by Suborx
    Hello, so I have this big method in my application for newsletter distribution. Method is for updating rayons and I need to assign a user to rayon. I have relation n:n through table colporteur_in_rayons which has attributes since_date and until_date. I am a junior programmer and I know this code is pretty dummy :) I appreciate every suggestion. def update rayon = Rayon.find(params[:id]) if rayon.update_attributes(params[:rayon]) if params[:user_id] != "" unless rayon.users.empty? unless rayon.users.last.id.eql?(params[:user_id]) rayon.colporteur_in_rayons.last.update_attributes(:until_date => Time.now) Rayon.assign_user(rayon.id,params[:user_id]) flash[:success] = "Rayon #{rayon.name} has been succesuly assigned to #{rayon.actual_user.name}." return redirect_to rayons_path end else Rayon.assign_user(rayon.id,params[:user_id]) flash[:success] = "Rayon #{rayon.name} has been successfully assigned to #{rayon.actual_user.name}." return redirect_to rayons_path end end flash[:success] = "Rayon has been successfully updated." return redirect_to rayons_path else flash[:error] = "Rayon has not been updated." return redirect_to :back end end

    Read the article

  • Is there a way to make this perl code capture stderr as well as stdout from a tcsh?

    - by mikelong
    open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests"|); while(<UNIT_TESTER>){ reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /core dumped/; reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /\[ FAILED \]/; writelog($tsttgt,$_); } close UNIT_TESTER; I have tried to redirect stderr to stdout using this syntax but it didn't work: open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests >& "|); I have also read the discussion on the perl FAQ but that was in relation to bash: http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q5.15.html

    Read the article

  • Inheritance in tables - structure problem

    - by Naor
    I have 3 types of users in my system. each type has different information I created the following tables: BaseUser(base_user_id, username, password, additional common data) base_user_id is PK and Identity UserType1(user_id, data related to type1 only) user_id is PK and FK to base_user_id UserType2(user_id, data related to type2 only) user_id is PK and FK to base_user_id UserType3(user_id, data related to type3 only) user_id is PK and FK to base_user_id Now I have relation from each type of user to warehouses table. Users from type1 and type2 should have only warehouse_id and users from type3 should have warehouse_id and customer_id. I thought about this structure: WarehouseOfUser(base_user_id,warehouse_id) base_user_id is FK to base_user_id in BaseUser WarehouseOfTyp3User(base_user_id,warehouse_id, customer_id) base_user_id is FK to base_user_id in BaseUser The problem is that such structure allows 2 things I want to prevent: 1. add to WarehouseOfTyp3User data of user from type2 or type1. 2. add to WarehouseOfUser data of user from type3. what is the best structure for such case?

    Read the article

  • Issues running python scripts in Command Prompt (Specifically with command line arguments)?

    - by dmanatunga
    I am trying to run my python scripts in DOS without calling python.exe first. I am specifically doing this in relation to running django-admin.py. I have C:\Python26 and C:\Python26\Scripts in my PATH. However, if I try running django-admin.py by doing: django-admin.py startproject helloworld I get the message: Type 'django-admin.py help' for usage. Now, after some experimentation, I realized the problem is that the secondary arguments to these scripts are not being passed for some reason, since I tried it with a some other python scripts I have. I know I could avoid this problem by simply doing: python C:\Python26\Scripts\django-admin.py startproject helloworld But I know it should be possible to run the first command only and get it to work, because I had it working before. I've looked everywhere, and not many places have been helpful so any idea would be useful for me at this point.

    Read the article

  • MYSQL Query with 2 columns in Table A related to 1 column in Table B

    - by CYREX
    I have 2 Tables, User and Mail. In User Table i have 2 columns that i will use, the ID column which makes the relation with the Mail Table and it is the Index of User Table and the Name column. In Mail Table i have Receiver Column and Sender Column. Both columns, Receiver and Sender have a number that relates to the ID Column in the User Table. In the User Table is where the name columns resides and i want to make a query that shows me the Receiver and Sender Columns but with the name of the user, not the ID. Up to this point i have this: SELECT name AS Send, name AS Receive FROM mail,user WHERE sender=guid; I know there is still a part of the query missing but i can not figure out what else to put to tell it to show in the SEND output column the name of the sender and in the RECEIVE output column the name of the receiver.

    Read the article

  • how to use multiple $_name using extends Zend_Db_Table_Abstract in zend frame work.

    - by karthik
    we tried to give our tables(users,messages) like this in two different abstract classes but it is not working. This is included in a file childconnect1.php ,is there any relation between the file name(childconnect1.php) and the class(Application_Model_childconnect1). class Application_Model_childconnect1 extends Zend_Db_Table_Abstract { protected $_name = 'users'; public function loginvalidation($username,$pwd) { $row = $this->fetchRow('UserName = \'' . $username . '\'and UserPW = \''. $pwd . '\''); if (!$row) { $msg="invalid"; return $msg; } else { return $row->toArray(); } } } class Application_Model_childconnect2 extends Zend_Db_Table_Abstract { protected $_name = 'messages'; public function replymessage($message) { $data=array( 'MessageText'=>$message ); $this->insert($data); } }

    Read the article

  • How to represent a Many-To-Many relationship in XML or other simple file format?

    - by CSharperWithJava
    I have a list management appliaction that stores its data in a many-to-many relationship database. I.E. A note can be in any number of lists, and a list can have any number of notes. I also can export this data to and XML file and import it in another instance of my app for sharing lists between users. However, this is based on a legacy system where the list to note relationship was one-to-many (ideal for XML). Now a note that is in multiple lists is esentially split into two identical rows in the DB and all relation between them is lost. Question: How can I represent this many-to-many relationship in a simple, standard file format? (Preferably XML to maintain backwards compatibility)

    Read the article

  • how to made one-to-one bidirectional relationships in grails?

    - by user369759
    I have two domain classes and want to have one-to-one BIDIRECTIONAL relation between them. I write: class Person { Book book; String name Integer age Date lastVisit static constraints = { book unique: true // "one-to-one". Without that = "Many-to-one". } } class Book { String title Date releaseDate String ISBN static belongsTo = [person:Person] // it makes relationship bi-directional regarding the grails-docs } So, i want to have bi-directional, i could NOT find link from Book to Person in generated SQL: CREATE TABLE `book` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `version` bigint(20) NOT NULL, `isbn` varchar(255) NOT NULL, `release_date` datetime NOT NULL, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 So then it means it is not bidirectional then? How to make bidirectional?

    Read the article

  • Zend Framework Handle One to Many

    - by user192344
    I have 2 tables "user", "contact", the relation between two tables is one user has many contact Table member m_id name ------------ Table Contact c_id c_m_id value in zend model class, i do it in this way /* Member.php */ class Default_Model_DbTable_Member extends Zend_Db_Table_Abstract { protected $_name = 'member'; protected $_dependentTables = array('Default_Model_DbTable_Contact'); } /* Contact.php */ class Default_Model_DbTable_Contact extends Zend_Db_Table_Abstract { protected $_name = 'contact'; protected $_referenceMap = array( 'Member' => array( 'columns'=> array('c_id'), 'refTableClass'=> 'Default_Model_DbTable_Member', 'refColumns'=> array('c_m_id') ) ); /* IndexController.php */ class IndexController extends Zend_Controller_Action { public function indexAction() { $m= new Default_Model_DbTable_Member(); $row = $m->find(1); $data = $row->current(); $data = $data->findDependentRowset('Default_Model_DbTable_Contact'); print_r($data->toArray()); } } But i just get Invalid parameter number: no parameters were bound , my goal is to search a member detail record, and it also contains a array which store all contact info (i can use join method to do that, but i just want to try zend feature)

    Read the article

  • Equivalence Classes LISP

    - by orcik
    I need to write a program for equivalence classes and get this outputs... (equiv '((a b) (a c) (d e) (e f) (c g) (g h))) => ((a b c g h) (d e f)) (equiv '((a b) (c d) (e f) (f g) (a e))) => ((a b e f g) (c d)) Basically, A set is a list in which the order doesn't matter, but elements don't appear more than once. The function should accept a list of pairs (elements which are related according to some equivalence relation), and return a set of equivalence classes without using iteration or assignment statements (e.g. do, set!, etc.). However, set utilities such as set-intersection, set-union and a function which eliminates duplicates in a list and built-in functions union, intersection, and remove-duplicates are allowed. Thanks a lot!

    Read the article

  • Hibernate inserting into join table

    - by Karl
    I got several entities. Two of them got a many-to-many relation. When I do a bigger operation on these entities it fails with this exception: org.hibernate.exception.ConstraintViolationException: could not insert collection rows: I execute the operation i a @Transactional context. I don't do any explicit flushing i my daos. The flush is triggered by a query. In the queue are 15 elements (all of the same structure). one of them always fails (but it's always a different one (I checked) and always at a different position). Does anybody have a hint for me for what I might do wrong? My Mapping: @ManyToMany(targetEntity = CategoryImpl.class) protected Set<Category> categories = new HashSet<Category>();

    Read the article

  • Finding relative libraries when using symlinks to ruby executables

    - by dgtized
    Imagine you have an executable foo.rb, with libraries bar.rb layed out in the following manner: <root>/bin/foo.rb <root>/lib/bar.rb In the header of foo.rb you place the following require to bring in functionality in bar.rb: require File.dirname(__FILE__)+"../lib/bar.rb" This works fine so long as all calls to foo.rb are direct. If you put as say $HOME/project, and symlink foo.rb into $HOME/usr/bin, then __FILE__ resolves to $HOME/usr/bin/foo.rb, and is thus unable to locate bar.rb in relation to the dirname for foo.rb. I realize that packaging systems such as rubygems fix this by creating a namespace to search for the library, and that it is also possible to adjust the load_path using $: to include $HOME/project/lib, but it seems as if a more simple solution should exist. Has anyone had experience with this problem and found a useful solution or recipe?

    Read the article

  • [app-engine-java-groovy] One-to-Many relationship. Select objects from datastore.

    - by Olexandr
    Hi. I've omitted some code(package declarations, imports, other fields) for shortness. I have here simple One-to-Many relation. It worked fine till this moment. @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") class Restaurant implements Serializable { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key id @Persistent(mappedBy = "restaurant") List<RestaurantAddress> addresses = new ArrayList<RestaurantAddress>() } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") class RestaurantAddress implements Serializable { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key id @Persistent Restaurant restaurant } Now i need to get(select) all the Restaurants from DB: def getRestaurantsToExport(final String dst, final int count) { String field = restaurantExportFields[dst] return transactionExecute() { PersistenceManager pm -> Query q = pm.newQuery(Restaurant.class) q.filter = "$field == null" q.setRange(0, count) return q.execute() } } But there are on problem - query gives me 12 restaurants(as in DB) but every Restaurant has 0 Address but in Datastore every Restaurant has minimum 2 addresses. Have anyone the same problem or knows the solution ?

    Read the article

  • PHP Get images from a UL list

    - by benjamin shrimpton
    I have a long UL list and each LI contains an image tag, dynamically generated from SLideshowPro Director. I need to get the widths of ALL the images inside the UL to use in a CSS width calculation. I have been able to get the image width for the first item, but not all. My PHP is pretty limited, but do I have to make this list into an ARRAY first to allow me to get all the widths? And how do i do that?? These images contain very long id's generated by the CMS, so reading through a directory is not possible, as the images in cache bare not relation to the file names that are output to the HTML page. It has to all be done from the content that's sent to the page. Or could I even use JQuery to do this??

    Read the article

  • What's the best way to implement one-dimensional collision detection?

    - by cyclotis04
    I'm writing a piece of simulation software, and need an efficient way to test for collisions along a line. The simulation is of a train crossing several switches on a track. When a wheel comes within N inches of the switch, the switch turns on, then turns off when the wheel leaves. Since all wheels are the same size, and all switches are the same size, I can represent them as a single coordinate X along the track. Switch distances and wheel distances don't change in relation to each other, once set. This is a fairly trivial problem when done through brute force by placing the X coordinates in lists, and traversing them, but I need a way to do so efficiently, because it needs to be extremely accurate, even when the train is moving at high speeds. There's a ton of tutorials on 2D collision detection, but I'm not sure the best way to go about this unique 1D scenario.

    Read the article

  • doubt in Exceptions

    - by Ajay Singh
    class MyException extends Exception { MyException() {} MyException(String msg) { super(msg);} } public class NewException { static void f() throws MyException { System.out.println("throwing exception from f()"); throw new ClassCastException(); } static void g() throws MyException { System.out.println("throwing exception from g()"); throw new MyException("parametrized "); } public static void main(String ...strings ) { try { f(); } catch(MyException e) { e.printStackTrace(System.out); } try { g(); } catch(MyException e) { e.printStackTrace(System.out); } } } In the function f() iam specifying that "MyException " exception will be thrown and actually iam throwing some other exception which has no relation with MyException but still the compiler does not report any complain.Why is it so??

    Read the article

  • Django - Static content display based on URL

    - by Steven Potter
    I'm working on a Django site with a basic three column design. Left column navigation, center column content and right column URL specific content blocks. My question is about the best method of controlling the URL specific content blocks in the right column. I am thinking of something along the lines of the Flatpages app that will make the content available to the template context if the URL matches a pre-determined pattern (perhaps regex?). Does anyone know if such an app already exists? If not, I am looking for some advice about the best way to implement it. Particularly in relation to the matching of patterns to the current URL. Is there any good way to re-use parts of the Django URL dispatcher for this use?

    Read the article

  • Referencing the current jQuery object in a chain?

    - by Lance McNearney
    At DevDays in SF last year (before jQuery 1.4 was released), I thought they mentioned an upcoming feature in 1.4 that would allow you to reference the current jQuery object while in a chain. I've read through all of the 1.4 improvements and wasn't able to find it. Does anyone know how this can be done? Example Being able to access the current jQuery object would be helpful when working with methods that are in relation to the current object like .next(): // Current way var items = $(this).closest('tr'); items = items.add(items.next(':not([id])')); // Magical 1.4 way? Is there a "chain"-like object? var items = $(this).closest('tr') .add(chain.next(':not([id])'));

    Read the article

  • Dowloading a bunch of files asynchronous wait till last finished

    - by Casper Broeren
    I'm trying to download a lot of files after downloading a sql statement must insert a record. I'm using System.Net.Client to download each file synchronously, still it could be done asynchronous. There's no relation or dependency between each download. At first I just tried to use WebClient.DownloadFileAsync but that shutted the program down and killed all the download processes/threads. Second I tried to create a wait routine something like this; while (processedFiles < totalFiles) Thread.Sleep(1000) This freezed everything. So could someone tell me which aproach to take to implement this Async?

    Read the article

  • what else to do to establish many-to-many associations in Ruby on Rails? thanks!

    - by john
    Hi, I have two classes and I want to establish a many-to-many assications, here is the code: class Category < ActiveRecord::Base has_and_belongs_to_many :events has_and_belongs_to_many :tips end class Tip < ActiveRecord::Base has_and_belongs_to_many :categories However, I kept getting the following errors and I would appreciate it if some one could educate me what is going wrong: PGError: ERROR: relation "categories_tips" does not exist : SELECT "categories".id FROM "categories" INNER JOIN "categories_tips" ON "categories".id = "categories_tips".category_id WHERE ("categories_tips".tip_id = NULL ) the viewer part: 4: <%= text_field :tip, :title %></label></p> 5: 6: <p><label>Categories<br/> 7: <%= select_tag('categories[]', options_for_select(Category.find(:all).collect {|c| [c.name, c.id] }, @tip.category_ids), :multiple => true ) %></label></p> 8: 9: <p><label>Location<br/> 10: <%= text_field_with_auto_complete :tip, :abstract %></label></p>

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >