Daily Archives

Articles indexed Wednesday March 24 2010

Page 10/131 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Syncing data between devel/live databases in Django

    - by T. Stone
    With Django's new multi-db functionality in the development version, I've been trying to work on creating a management command that let's me synchronize the data from the live site down to a developer machine for extended testing. (Having actual data, particularly user-entered data, allows me to test a broader range of inputs.) Right now I've got a "mostly" working command. It can sync "simple" model data but the problem I'm having is that it ignores ManyToMany fields which I don't see any reason for it do so. Anyone have any ideas of either how to fix that or a better want to handle this? Should I be exporting that first query to a fixture first and then re-importing it? from django.core.management.base import LabelCommand from django.db.utils import IntegrityError from django.db import models from django.conf import settings LIVE_DATABASE_KEY = 'live' class Command(LabelCommand): help = ("Synchronizes the data between the local machine and the live server") args = "APP_NAME" label = 'application name' requires_model_validation = False can_import_settings = True def handle_label(self, label, **options): # Make sure we're running the command on a developer machine and that we've got the right settings db_settings = getattr(settings, 'DATABASES', {}) if not LIVE_DATABASE_KEY in db_settings: print 'Could not find "%s" in database settings.' % LIVE_DATABASE_KEY return if db_settings.get('default') == db_settings.get(LIVE_DATABASE_KEY): print 'Data cannot synchronize with self. This command must be run on a non-production server.' return # Fetch all models for the given app try: app = models.get_app(label) app_models = models.get_models(app) except: print "The app '%s' could not be found or models could not be loaded for it." % label for model in app_models: print 'Syncing %s.%s ...' % (model._meta.app_label, model._meta.object_name) # Query each model from the live site qs = model.objects.all().using(LIVE_DATABASE_KEY) # ...and save it to the local database for record in qs: try: record.save(using='default') except IntegrityError: # Skip as the record probably already exists pass

    Read the article

  • why attach to window

    - by Gutzofter
    I was looking over the code for qunit. My question is why would you want to attach the qunit object via property to window object. Here is the link to the file. Look at line 11. If I look at a unit test run using firebug you can see it is a property of window.

    Read the article

  • Convert array of hashes to array of structs?

    - by keruilin
    Let's say I have two objects: User and Race. User has two attributes: first_name, last_name. And Race has three attributes: course, start_time, end_time. Now let's say I create an array of hashes like this: user_races = races.map{ |race| {:user = race.user, :race = race} } How do I then convert user_races into an array of structs, keeping in mind that I want to be able to access the attributes of both user and race from the struct element?

    Read the article

  • viewDidLoad not being called by parent UITabBarController

    - by Adam Bishop
    Sample: I've created a minimal set of files that highlight the issue here: http://uploads.omega.org.uk/Foo3.zip If viewDidLoad/viewInitWithNibName are called, a message box is displayed. The message box is not displayed, therefore, the methods are not being called. Details: I have an application that is attempting to use a UITabBarController to switch between multiple views. The views are linked up to the UITabBarController using interface builder (select the tab page, open Attributes (Option-1), and fill in the NIB Name field), and so are displayed "automatically" with no extra code-behind to make them appear. Is it intended behaviour that views loaded like this do not have their viewDidLoad method executed? If not, how am I doing it wrong, and what do I need to change. If it is intended behaviour, I can think of a few work-arounds, but any suggestions are appreciated: Scrap the UITabBarController and implement the view switching myself (using initWithNibName and add/insert/push/Subview). Call each of the children's viewDidLoad method manually in the UITabBarController's own viewDidLoad method. Thank you in advance for any help you can offer.

    Read the article

  • How to use class_eval <<-"end_eval" in Ruby? Not parsing correctly

    - by viatropos
    I would like to define dynamic methods based on some options people give when instantiating it. So in their AR model, they'd do something like this: acts_as_something :class_name => "CustomClass" I'm trying to implement that like so: module MyModule def self.included(base) as = Config.class_name.underscore foreign_key = "#{as}_id" # 1 - class eval, throws these errors # ~/test-project/helpers/form.rb:45: syntax error, unexpected $undefined # @ ||= MyForm.new( # ^ # ~/test-project/helpers/form.rb:46: syntax error, unexpected ',' #~/test-project/helpers/form.rb:48: syntax error, unexpected ')', # expecting kEND from ~/test-project/helpers.rb:12:in `include' base.class_eval <<-"end_eval", __FILE__, __LINE__ attr_accessor :#{as} def #{as} @#{as} ||= MyForm.new( :id => self.#{foreign_key}, :title => self.title ) @#{as} end end_eval end end But it's throwing a bunch of errors I've printed in the comments. Am I using this incorrectly? What are some better ways I can define dynamic method names and dynamic names inside the method like this? I see people use this often instead of define_method (see these classes in resource_controller and couchrest toward the bottom). What I missing here? Thanks for the help

    Read the article

  • Best way to generate report using multiple databases

    - by Vinaaven
    Hi All, I am new to the reporting world. Wanted to know which is the right solution to about for generating a single report by querying for data from multiple databases. We are planning to use some reporting solution like Jasper Reports or BIRT. Generally the databases are going to be postgresql. Please do feel free to let me know about any other better solutions as well. Thanks.

    Read the article

  • Backup of folder + database - Python

    - by RadiantHex
    Hi there, I feel like this is quite delicate, I have various folders whith projects I would like to backup into a zip/tar file, but would like to avoid backing up files such as pyc files and temporary files. I also have a Postgres db I need to backup. Any tips for running this operation as a python script? Also, would there be anyway to stop the process from hogging resources in the process? Help would be very much appreciated.

    Read the article

  • How to send set of data for Ajax call from jquery with php at the serverside?

    - by Vinodtiru
    I basically have to do a update of a record. I have a set of controls like textbox, list box, radio button etc. Then i have a button on click of which i need to carry all the updated data into mysql database with a ajax request without page refresh. I am using the php with codeigniter as my serverside code. On client side i am able to send the ajax request like $(document).ready(function(){ $('#users_menu').click( function(){ $('#tempdiv').load('http://localhost//web1/index.php/c1',null); } ); }); In the above code the request is placed to a server side php page where i am not able to read the values of the control values (values of textbox, listbox etc). Now this means i should be sending the list with the request. But i am not aware of how to send this request. Please help me with some details of how to send the list of values or is it possible to read the vaules some how in the serverside php code. For your information i am using codeigniter with my php. Any kind of help is appreciated. Thanks and Regards VinodT.

    Read the article

  • Cannot display returned JSON from a JQUERY AJAX call in CodeIgniter

    - by Obay
    Im using JQUERY + CodeIgniter. I can't seem to get the returned data to display after an ajax call. Here is my JQUERY: $.post("<?= site_url('plan/get_conflict') ?>", { user_id : user_id, datetime_from : plan_datetime_start, datetime_to : plan_datetime_end, json : true }, function(data) { alert(data); }, "json"); Here is my CodeIgniter: function get_conflict() { ... log_message("debug","get_conflict(): $result"); return $result; } My logs show: get_conflict(): {"work_product_name":"Functional Design Document","datetime_start_plan":"2010-04-22 08:00:00","datetime_end_plan":"2010-04-22 09:00:00","overlap_seconds":3600} Meaning the JSON is being returned correctly. However, the alert(data) nor alert(data.work_product_name) are not displayed. Any ideas?

    Read the article

  • IIS7 authentication

    - by Kev
    To give our user's the ability to protect content on their IIS6 sites we used a tool called IISPassword which emulates .htaccess to provide Basic authentication. There isn't support for IISPassword on IIS7 at the moment. Is there an equivalent mechanism I can use built into IIS7 instead? I'm well aware of ASP.NET Forms Authentication, but I need a way for users deploying non-ASP.NET content (such as PHP, Perl, images etc) to be able to use Basic authentication but not have to write code to achieve this. Is this possible?

    Read the article

  • Function inside jquery returns undefined

    - by steamboy
    Hello Guys, The function I called inside jquery returns undefined. I checked the function and it returns correct data when I firebugged it. function addToPlaylist(component_type,add_to_pl_value,pl_list_no) { add_to_pl_value_split = add_to_pl_value.split(":"); $.ajax({ type: "POST", url: "ds/index.php/playlist/check_folder", data: "component_type="+component_type+"&value="+add_to_pl_value_split[1], success: function(msg) { if(msg == 'not_folder') { if(component_type == 'video') { rendered_item = render_list_item_video(add_to_pl_value_split[0],add_to_pl_value_split[1],pl_list_no) } else if(component_type == 'image') { rendered_item = render_list_item_image(add_to_pl_value_split[0],add_to_pl_value_split[1],pl_list_no) } } else { //List files from folder folder_name = add_to_pl_value_split[1].replace(' ','-'); var x = msg; // json eval('var file='+x); var rendered_item; for ( var i in file ) { //console.log(file[i]); if(component_type == 'video') { rendered_item = render_list_item_video(folder_name+'-'+i,file[i],pl_list_no) + rendered_item; } if(component_type == 'image') { rendered_item = render_list_item_image(folder_name+'-'+i,file[i],pl_list_no) + rendered_item; } } } $("#files").html(filebrowser_list); //Reload Playlist console.log(rendered_item); return rendered_item; }, error: function() { alert("An error occured while updating. Try again in a while"); } }) } $('document').ready(function() { addToPlaylist($('#component_type').val(),ui_item,0); //This one returns undefined });

    Read the article

  • Failed to Kill Process in SQL 2008

    - by Andrea.Ko
    I have a process with the following information, and i execute the kill process to kill this id, and it return me "Only user processes can be killed." SPID:11 Status:BACKGROUND Login:sa HostName: . BlkBy: . DBName: SAFEMIG Command:CHECKPOINT Normally, all the session to login to this server, it should have a HostName which display our PC name, but this connection is with a dot, so not sure who is executing what process that have this connection. I execute "dbcc inputbuffer(11)" It return me"EventType= No Event, Parameters = 0 and EventInfo=Null" Appreciate for any help\advice on this problem!

    Read the article

  • Preventing focus on next form element after showing alert using JQuery

    - by digitalsanctum
    I have some text inputs which I'm validating when a user tabs to the next one. I would like the focus to stay on a problematic input after showing an alert. I can't seem to nail down the correct syntax to have JQuery do this. Instead the following code shows the alert then focuses on the next text input. How can I prevent tabbing to the next element after showing an alert? $('input.IosOverrideTextBox').bind({ blur: function(e) { var val = $(this).val(); if (val.length == 0) return; var pval = parseTicks(val); if (isNaN(pval) || pval == 0.0) { alert("Invalid override: " + val); return false; } }, focus: function() { $(this).select(); } });

    Read the article

  • Can you notice what's wrong with my PHP or MYSQL code?

    - by Jenna
    I am trying to create a category menu with sub categories. I have the following MySQL table: -- -- Table structure for table `categories` -- CREATE TABLE IF NOT EXISTS `categories` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(1000) NOT NULL, `slug` varchar(1000) NOT NULL, `parent` int(11) NOT NULL, `type` varchar(255) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=66 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` (`ID`, `name`, `slug`, `parent`, `type`) VALUES (63, 'Party', '/category/party/', 0, ''), (62, 'Kitchen', '/category/kitchen/', 61, 'sub'), (59, 'Animals', '/category/animals/', 0, ''), (64, 'Pets', '/category/pets/', 59, 'sub'), (61, 'Rooms', '/category/rooms/', 0, ''), (65, 'Zoo Creatures', '/category/zoo-creatures/', 59, 'sub'); And the following PHP: <?php include("connect.php"); echo "<ul>"; $query = mysql_query("SELECT * FROM categories"); while ($row = mysql_fetch_assoc($query)) { $catId = $row['id']; $catName = $row['name']; $catSlug = $row['slug']; $parent = $row['parent']; $type = $row['type']; if ($type == "sub") { $select = mysql_query("SELECT name FROM categories WHERE ID = $parent"); while ($row = mysql_fetch_assoc($select)) { $parentName = $row['name']; } echo "<li>$parentName >> $catName</li>"; } else if ($type == "") { echo "<li>$catName</li>"; } } echo "</ul>"; ?> Now Here's the Problem, It displays this: * Party * Rooms >> Kitchen * Animals * Animals >> Pets * Rooms * Animals >> Zoo Creatures I want it to display this: * Party * Rooms >> Kitchen * Animals >> Pets >> Zoo Creatures Is there something wrong with my loop? I just can't figure it out.

    Read the article

  • What are the pros and cons of using an in memeory DB rather than a ThreadLocal

    - by Pangea
    we have been using ThreadLocal so far to carry some data so as to not clutter the API. However below are some of issues of using thread local that which I dont like 1) over the years the data items being carried in thread local has increased 2) Since we started using threads (for some light weight processing), we have also migrating these data to the threads in the pool and copying them back again I am thinking of using an in memory DB for these (we doesnt want to add this to the API). I wondering if this approach is good. What r the pros and cons. thx in advance.

    Read the article

  • Texture2D problem

    - by Anders Karlsson
    I have a problem that is driving me crazy, I want to write a number of texts on the screen using Texture2D however I only seem to be able to write the first one. If I individually write one of the labels it works but not if I write all of them, only the first label is displayed. Let me show some code: -(void)drawText:(NSString*)theString AtX:(float)X Y:(float)Y withFont:(UIFont*)aFont { // set color glColor4f(1, 0, 0, 1.0); // Enable modes needed for drawing glEnableClientState(GL_TEXTURE_COORD_ARRAY); Texture2D* textTexture = [[Texture2D alloc] initWithString:theString dimensions:viewSize // 320x480 alignment:UITextAlignmentLeft font:aFont]; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); [textTexture drawInRect:CGRectMake(X,Y,1,1)]; glDisableClientState(GL_TEXTURE_COORD_ARRAY); [textTexture release]; } When I call this drawText once it seems to display the text properly, but if I call it a second time nothing seems to be displayed. Somebody has an idea what it could be? The states like GL_BLEND and GL_TEXTURE_2D have been enabled in the view setup function. In the Texture2D the dimensions are 512x512 as I pass the whole screen to function. If I don't pass that the text gets enlarged and fuzzy. I am a bit uncertain about that parameter. TIA for any help.

    Read the article

  • implement INotifyCollectionChanged etc on xml file changed

    - by netmajor
    It's possible to implement INotifyCollectionChanged or other interface like IObservable to enable to bind filtered data from xml file on this file changed ? I see examples with properties or collection, but what with files changes ? I have that code to filter and bind xml data to list box: XmlDocument channelsDoc = new XmlDocument(); channelsDoc.Load("RssChannels.xml"); XmlNodeList channelsList = channelsDoc.GetElementsByTagName("channel"); this.RssChannelsListBox.DataContext = channelsList;

    Read the article

  • PHP is_file returns false (incorrectly) for Windows share on Ubuntu

    - by M3Mania
    Ubuntu server, PHP 5.3, connected via Samba to Windows server share. I am using file_exists() to check for availability of file on Windows machine. It returns false, although the filepath does exist. Meanwhile, file_get_contents() on the exact same filepath works fine. I'm wondering if it's a permission issue, since I'm having trouble configuring permissions of the files on the Windows share (it says I don't have permission to change permissions on them). When I look at the permissions through Nautilus, it says the user and group are both root, with 755 rights. I'd like to change the group to www-data, but can't seem to do it.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >