FAQ Database Discussion Community


Overwriting Class Methods to define Kwargs - Which is Pythonic?

python,override
I'm working on an abstraction layer to a database, and I have a super class defined similar to this: class Test(): __init__(self, object): self.obj = object @classmethod def find_object(cls, **kwargs): # Code to search for object to put in parameter using kwargs. return cls(found_object) I then break down that superclass...

In Java Swing Null Layout, set position relative to bottom of container

java,swing,override,layout-manager,null-layout-manager
This is probably a very basic question, but I could't find anything about it online. I'm working in Java swing and have a JPanel with a null Layout Manager (ie using absolute positioning). The JPanel is filling a space in the JFrame so that its size will change when the...

When I override the “put(K key, V value)” in a TreeMap, how can I change “value”?

java,generics,override
I extend a TreeMap, override "put()", and do something equivalent to: public class MyMap<K, Integer> extends TreeMap<K, Integer> { @Override public Integer put(K key, Integer value) throws ClassCastException, NullPointerException { java.lang.Integer newValue = java.lang.Integer.valueOf(123); super.put(key, newValue); // <--- error message here return newValue; } } error message: no suitable method...

Add method in same class or in String class - Best practices

ruby,string,class,override
I want define a new method to validate a string like this: # lib/rips/variables/variable.rb class Variable # Check if value is a valid number (...,-1,0,1...) def number? (value) /\A[-]?\d+\z/ === value end end And it invokes like this in the same class and derived classes: # lib/rips/variables/inmediate.rb class Inmediate <...

Extend Onepage Billing block in Magento

magento,override,extend,billing,onepage
I hope someone already knows how solve this as I've been trying for a couple of days, followed countless tutorials and sadly not got far. I am attempting to override the block file : /app/code/core/Mage/Checkout/Block/Onepage/Billing.php in a custom module (for Magento 1.7) in my module config.xml file, I have added...

Overriding a function outside its class

swift,override
I came across a strange behaviour. The following code produces a compile error where I call bar() with the message: "Missing argument for parameter #1 call" func bar() { println("bar with no argument") } class ClassA { func bar(varOfAnyType: String) { println("bar with argument") } func foo() { bar() }...

Does it make any difference if a virtual method is declared virtual in the subclass? [duplicate]

c++,override,virtual
This question already has an answer here: virtual qualifier in derived class 4 answers Quite often I see code (e.g. here) where the override is also declared virtual even if the class is not meant to be subclassed again. E.g. class A { virtual void foo(); } class B...

Is method hiding a form of Polymorphism?

java,polymorphism,override
Polymorphism is the ability to take many forms. Method overriding is runtime polymorphism. My questions are: Is there anything like static polymorphism in Java? Can method hiding be considered a form of polymorphism? In this question's answer, it is said that static methods are not polymorphic. What is the reason...

C# Explicitly override virtual interface method of base type

c#,inheritance,override
I have an abstract class DataBase which is used as base class for different types of data, such as simple value types (byte, int, string etc.) and more complex data structures like DataList and DataDictionary. DataList implements IList<DataBase> and DataDictionary implements IDictionary<string, DataBase>. For simplicity's sake, I went ahead and...

django rest framework - adding to views.obtain_auth_token

view,override,django-rest-framework,http-token-authentication
I have implemented Token Authentication with django rest framework and I can post username and password to /api-token-auth/ and get the token. url(r'^api-token-auth/', token_views.obtain_auth_token) In addition to the token, I want to get the User object related to the returned token. How can I override/add to this view and also...

How to override private method from a library class

php,override,private
Given are the following classes with class A coming from an external library so that I can not change it: class A { public function test () { $this->privateMethod(); } private function privateMethod () { echo('A'); } } class B extends A { private function privateMethod () { echo('B'); }...

How to override the .get() method in requests?

python,override,python-requests
I would like the .get() method in requests to do extra operations beside the GET itself: print out "hello world" (in reality this will be logging) wait 5 seconds before issuing the actual GET (in reality this will be a more complex wait-and-retry operation) Right now my simplistic solution is...

How to prevent selection of SeparatorList.Separator in a JList?

java,override,selection,jlist,glazedlists
I have created a JList using GrazedLists, specifically an EventList which I then pass into a SeparatorList with a custom Comparator that sorts my EventList elements. I am using a DefaultEventListModel as the JList model, passing in my SeparatorList. And I am using a custom CellRenderer to decorate the SeparatorList.Separator...

Overriding getter in Swift

swift,inheritance,override,getter-setter
I have a situation where I need to override the getter of a property. Let's say we have: public class MyBaseClass { private var _name: String public internal(set) var name: String { get { return self._name } set { self._name = newValue } } } Nothing really fancy, I guess....

Abstract Class with Generic Subtype

c#,.net,generics,override,abstract-class
I implemented an abstract class like the following: public abstract class Pack { protected List<PackEntry> m_Entries; public Int32 EntriesCount { get { return m_Entries.Count; } } public Pack() { m_Entries = new List<PackEntry>(); } #region Methods: Abstract ... #endregion } public sealed class PackTypeA : Pack { ... } public...

Why would you override wndproc

c#,override,wndproc
I have been looking around and haven't really seen much information on why someone would override wndproc to handle messages. So I wondering: Why do it? When to do it? Whats its general purpose in C#? I have tried using it when seeing a serial COM plugged and unplugged from...

why I can't “overwrite” a method in javascript?

javascript,node.js,override
I would like to override a function of a JS object by adding it to its prototype. var originalObject = function(){ this.someFun = function(){ // ... } } var otherObj = function(){ this.otherFun = function(){ originalObject.prototype.fun = function(){ return 'This is the overwritten function.'; } var o = new originalObject();...

How to override CSS in joomla template

css,joomla,override
In my Joomla template I would like to override some styles, so I've created my own css and added styles, also media queries. Most of all works only if I use the !important keyword and something does not work at all. For example: <div id="content_right" class="span3"> In this div I...

Override Symfony\Component\Console\Commande\Command.php

symfony2,console,command,override
I am developping some kind of cronjob monitoring on our symfony2 application. I created a CommandExecution entity with a 'completed' property. I'm using console events to create and persist this entity. My service : kernel.listener.console: class: Evo\CronBundle\EventListener\ConsoleListener arguments: [@doctrine.orm.entity_manager] tags: - { name: kernel.event_listener, event: console.command, method: onConsoleCommand } -...

C# always call a base method from the base class

c#,override,overriding,method-overriding
Lets assume that we have the following classes: class A { public virtual int Number { get { return 1; } } public int Foo(){ return Number; } } class B : A{ public override int Number { get { return 2; } } } As expected, if I'll call...

Virtual method being called using base

c#,polymorphism,override,virtual
In regards to a virtual method: protected internal virtual void PopulateGetParameters( int id, List<SqlParameter> parameters) { } Which is being overridden in a class inheriting the base class. What is confusing me is the overriding method is calling back to the the virtual method? protected override void PopulateGetParameters( int id,...

Function overriding in Java vs C++

java,c++,polymorphism,override
Two similar definitions in Java and C++, but totally different behaviour. Java version: class base{ public void func1(){ func2(); } public void func2(){ System.out.println(" I am in base:func2() \n"); } } class derived extends base{ public void func1(){ super.func1(); } public void func2(){ System.out.println(" I am in derived:func2() \n"); }...

Is changing inherited variable name is still considred as override?

php,oop,inheritance,operator-overloading,override
As ask above I have a function with one input parameter in base class. Does overriding it in derived class but with change of the variable name still considered as override and not as overload? I know it is the case for languages such as Java, but what about php?...

Overriding assign method

php,oop,templates,override,smarty
I'm trying to override the assign method of smarty object and then call the parent one. class View extends Smarty { public function __construct() { parent::__construct(); } public function assign($name, $value) { // some code that manipulate the values of $name and $value // ....... parent::assign($name, $value, false); } }...

how to override min-width

css,override
Wanted to use a custom css option, instead of modifying the source code.Is there any possibility to override these css values please ? @media only screen and (min-width: 40.063em) { .footer-fixed #wrapper [role="main"] { padding: 80px 60px 60px; } } not to sure how to apply !important in order to...

How can I fix the overriding of a CSS property, in the dev tools?

html,css,override
For some reason, all of my background-image elements are not being shown when I run my code. It is being over-ridden, and this is shown by being crossed out in the inspect element > stlyes output. How can I get rid of this over-ride, without using an !important tag? All...

Rails 4 Override belongs_to setter

ruby-on-rails,override,setter,belongs-to
I am having an issue overriding a setter on a belongs_to attribute. I have the following: class Task < ActiveRecord::Base belongs_to :parent_task, :class_name => 'Task', :foreign_key => 'parent_task_id' def parent_task=(value) write_attribute(:parent_task, value) unless value == nil #remove all groups_belonging_to if this has been made into a child task -i.e. if...

Override toString() method of final BluetoothDevice class

java,android,override,android-arrayadapter,tostring
In my Android app I have a ListActivity which displays bluetooth devices. I have an ArrayList<BluetoothDevice> and ArrayAdapter<BluetoothDevice>. Everything works but there is one problem. Each BluetoothDevice is displayed as a MAC address in the list but I need to display its name. As I know adapter calls toString method...

automatic scroll animation disables user scrolling - ability to override it

javascript,jquery,animation,scroll,override
i want to make a website that is scrolled very very slowly to the bottom all the time. var docEnd= $(document).height(); $('html,body').stop(true,false).animate({scrollTop:docEnd}, 1200000,'linear'); the problem is that it is disables user scrolling. and the scroll event lisetener do not distinguish between the animation and the user scrolling. i need to...

Way to override a class __init__ in python

python,override,init
When I call mic.openTheMic(record_seconds = 10), I'd like to either use all of the class defaults, or if I want to change (one or more) parameter(s), then only have to include one, e.g., this case where record_seconds = 10. Is there a way to do this? class myAudio(object): def __init__(self,...

Media is not overriding the original css

css,override,media
For some reason my @media doesn't override my original css. The thing it shows up in my inspector, but it is crossed. I made sure my media override is under my other css. Css code: #content div div:nth-child(even) p{ margin-left: 40px; } @media (max-width:880px){ #content div div p { margin-left:...

javascript window.addEventListener, overwritten the config of first element

javascript,override,config,addeventlistener
My apology, but really I don't know how to fix this code, or even how to search a fixed. the problem is when I re-declared the function with own config value it overwrites the config of first declared. Any help please, it would help me a lot, please and thanks...

Overriding Functions with omnet++

c++,override,omnet++,inet
How to override function from an included class in omnet++? I get a redefinition-error when I try to override the function as I do in c++. redefinition of "handleMessage(cMessage *msg)" This is the current code: #include "MalAODVRouter.h" #include "AODVRouting.cc" #include "AODVRouting.h" Define_Module(MalAODVRouter); void AODVRouting::handleMessage(cMessage *msg) // Error here { //-----------------------------------------------------Added...

HashCode calculation from double

java,double,override,long-integer,hashcode
In Effective Java there is an example of Complex class. That class has overridden hashCode which uses hashDouble method I have a question about. private int hashDouble(double val) { long longBits = Double.doubleToLongBits(re); return (int) (longBits ^ (longBits >>> 32)); } For what purpose it does (int) (longBits ^ (longBits...

Spring MVC 2.5 Command object value is changed on form submit

spring-mvc,override,form-submit,command-objects
I have a string variable in command object which is a hidden tag in my jsp. An on click of a button i'm setting this variable with a value(example "test") and submitting the form. On form submit, I get the control to my Validator.validate() method. In this method the value...

“is not abstract and does not override abstract method java” using Decorator Pattern

java,design-patterns,override,decorator
public abstract class AdicionalesCpd extends Cpd{ public abstract int getCpu(); public abstract int getRam(); public abstract int getDisco(); public abstract String getCadena();} This my abstract class for the decorator pattern, and I have this problem when it compiles: **error: Cpu is not abstract and does not override abstract method getCadena()...

Abstract class and methods, Why?

java,class,methods,override,abstract
Hope anyone can help, i am learning Java and as comparable to anyone else in this forum i guess i am a newbie to programming as well. I have come across a chapter on abstract class and methods but don't really fully understand what they are used for and why,...

Overriding toSting in derived class

c#,override,abstract-class,tostring
I have an abstract class Animal Looking like this abstract class Animal{ protected int numberOfPaws; public abstract String speak(); public String toString(){ return "I have " + numberOfPaws + " paws"; } } Then I have a derived class that has a new implementation of toString() looking like this class...

Is there any way to add an object other than CString to a CComboBox in MFC?

c++,mfc,override,control,ccombobox
I am trying to add an object that has a member variable CString to a CCombobox. I cannot just add the string because I am trying to interface with a tool that requires me to have another member variable other than just a string as a list item in the...

Polymorphism in C#. Base Class's Method is Called But Why? [duplicate]

c#,inheritance,polymorphism,override,virtual
This question already has an answer here: C# virtual keyword 9 answers Most of the articles I read about Polymorphism of methods in an inheritance hierarchy does not provide a reason why this happens. Can someone please provide a reason or analogy of the following behavior? Class A{ public...

Is this an anonymous Object being returned Here?

java,android,interface,callback,override
I am going through the Android code on the camera tutorial. I come from a C#/Obj-C/Swift language set, so Java is still new to me. I am familiar with functional programming but this syntax I am seeing does not seem functional in nature (or maybe I'm wrong). This is the...

Customize gridview repositoryItemComboBox

c#,devexpress,override
I am using a Devexpress 14.2 gridview. I am coding with C# form. I need to customize my repositoryItemComboBox. I have a class that has string name string value string group bool combox list list. so some cells in a column will have different list or items. example list 1...

Java - Force Inheritance of 1 of N Overridden Abstract Methods

java,inheritance,override,abstract
Using Java 6, I have a situation where I want to force a child class to implement 1 of N overridden methods. Let me explain with an example: public abstract class TestClass { public abstract String isValidInput(ObjectOne objectOne); public abstract String isValidInput(ObjectOne objectOne, ObjectTwo objectTwo); public abstract String isValidInput(ObjectOne objectOne,...

the issues of calling overridable methods from constructor

java,constructor,override
if it is possible please make this sentence clear for me here, the author said: Do not call overridable methods from constructors. When creating a subclass object, this could lead to an overridden method being called before the subclass object is fully initialized. Recall that when you construct a subclass...

Overriding function with generics in kotlin

function,generics,override,kotlin
For example I have following sample code fun f<T>( cb: (T, Int) -> Unit ): Unit { println("f called with cb which accepts 2 arguments"); } fun f<T>( cb: (T) -> Unit ): Unit { println("f called with cb which accepts 1 argument"); f<T> {item, position -> cb(item) } }...

How can I check if an ArrayList contains an Object with a specific field value?

java,arraylist,override,equals,contains
I have an ArrayList of Objects. I want to see if that ArrayList contains an Object with a particular field. TeamBuilder.java public class TeamBuilder { public static void main(String[] args) { Team team = new Team(); team.addMember(new TeamMember("myID")); System.out.println(team.containsMember("myID")); //false } } TeamMember.java public class TeamMember { private String id;...

Overriding 'text' in UILabel

variables,swift,properties,uilabel,override
Is there a way to do this? I thought it would be as simple as override var text: String? in a subclass of UILabel. However, this does not work. It shows an error: Cannot override with a stored property 'text' Am I doing something wrong? Is there a way or...

JavaFx handler override

javafx,override
I have a fxml file build from fxml builder and I am using it by a loader in Java. URL resource = getClass().getClassLoader().getResource("fxmlFile.fxml"); FXMLLoader loader = new FXMLLoader(resource, resourceBundle); Pane rootPane = (Pane) loader.load(); this fxml file maps click event to my class; <Group id="Group" layoutX="0.0" layoutY="0.0" onMouseReleased="#handleThis" scaleX="1.0" scaleY="1.0">...

Java Override Abstract Interface Method

java,interface,override,abstract,implements
I have a BankAccount.java that implements NamedAccount.java which is an abstract interface, but it keeps giving me an error that since BankAccount.java is not abstract it can't override it. How do I fix this problem? I tried adding @Override in both situations but it does not work! BankAccount.java: public class...

Error overloading procedure in Delphi

delphi,override,overloading
For some reason I am now getting this error '[DCC Error] MyFile.pas(52): E2137 Method 'Assign' not found in base class'. Here is a snipit of my Assign procedures that worked fine until I added one more, the last Assign. procedure Assign(MyClass: TMyClass); overload; override; procedure Assign(MyClass: ThisService.MyClass); overload; override; procedure...

Override of the same function with inherited class

c++,override,overloading
I have this simple code: #include <iostream> using namespace std; class GenericMove {}; class SwapMove: public GenericMove {}; class SoftConstraint { public: virtual int evaluate(GenericMove& gm) = 0; }; class M1: public SoftConstraint { public: int evaluate(GenericMove& gm){ return 1; } int evaluate(SwapMove& gm){ return 2; } }; int main...

How Can I Override Library Methods in Java?

java,android,methods,override
I'm working on a large Android project which is using Gson. The method fromJson() is called dozens of times in many files. I need to provide some special-case tests every time this method is called. Rather than going through and repeating the tests for each and every time this method...

Third party helper override doesn't work

magento,rewrite,override,magento-1.7,helper
I am writing an extension for Magento 1.7 where I need to override a helper from an third party extension. The name of my extension is Mkpreis_Ebay Name of the third party extension: Ess_M2ePro Helper I want to override: Ess_M2ePro_Helper_Module_Renderer_Description My config.xml <config> <modules> <Mkpreis_Ebay> <version>0.0.1</version> </Mkpreis_Ebay> </modules> <global> <helpers>...

What is the issue with not overriding templates in symfony2.6 and FOSUserBundle 1.3

symfony2,templates,override,fosuserbundle
I'm trying to override the base layout of FOSUserBundle using the 'simple' option of making a cloned path as .app/Resources/FOSUserBundle/views/layout.html.twig , but symfony2.6 continues to render the template from inside the vendor directory. My composer requires: "require": { "php": ">=5.3.3", "symfony/symfony": "2.6.*", "doctrine/orm": "~2.2,>=2.2.3,<2.5", "doctrine/dbal": "<2.5", "doctrine/doctrine-bundle": "~1.2", "twig/extensions": "~1.0",...

Subtype issues with generics in Kotlin

generics,override,kotlin
I have the following inheritance pattern in my code. trait A { fun foo(): Set<A> } trait B : A { override fun foo(): MutableSet<B> } trait C : A { override fun foo(): Set<C> } trait D : C, B { override fun foo(): MutableSet<D> } When B and...

Bash: override built in command

bash,override,alias
I am trying to make a alias that overrides the cd command. This is going to execute a script before and after the "real" cd. Here is what I have so far: alias cd="echo before; cd $1; echo after" This executes the echo before and echo after command however it...

Override a function inside an Object inside of a Trait

scala,override
Say I have something like this: trait A { object B { def doSomething = "test" } } class C extends A { def out = print(B.doSomething) } class D extends A { // override B.doSomething } How do I override the function doSomething that is inside of object B?...

Symfony2 / Doctrine2 : How to override DebugStack class used in doctrine DataCollector?

php,symfony2,doctrine2,doctrine,override
In order to better manage how I was making my database calls using Doctrine, I investigated how I could add the php debug_backtrace to the symfony doctrine db collector. I managed to identify the modifications I had to make but I did not yet found a good way to override...

Overriding OnPaint on Button - Font different

vb.net,winforms,override,onpaint
i am trying to Override OnPaint in WinForms Button controll. I want to align the Image and Text in the center, next to each other. As i am aware there is no way to do this with the default control. The idea was to inherit from Button, and "override" only...

Is there a way to force a derived class to implement an abstract class or an interface nested in base class?

c#,inheritance,interface,override,abstract-class
I have this abstract class: public abstract class Task { public string ID {get; set;} public string Name {get; set;} public abstract class Options{}; public abstract void Execute(); } I have other classes extending this class: public class Copy : Task { public override void Execute() { Console.Write ("running"); }...

Write-Verbose Wrapper in PowerShell?

powershell,override,wrapper,io-redirection
I have a script that uses Write-Verbose calls on it. I want to create a wrapper - override it, add another call, and then invoke the regular Write-Verbose command. Something like: Function global:Write-Verbose ($msg) { MyLogger $msg Real-Write-Verbose $msg } How can I do it?...

Python is there a difference calling a method from super, or from the class

python,inheritance,override
Using Django I am in the habit of overriding methods in generic views using super: class MyClass(SomeGenericView): def method_to_override(self, request, *args, **kwargs): # do something extra here return super(MyClass, self).method_to_override(request, *args, **kwargs) I notice that pydev autocompletes calling the method from the parent class instead: class MyClass(SomeGenericView): def method_to_override(self, request,...

Implementing Iterator for abstractCollection

java,generics,iterator,override,abstract
Hi I want to implement the iterator for a class that extends abstract Collection. class Name<E extends Comparable<E>> extends AbstractCollection<CompRational> implements Iterable<E>{ ... public Iterator<E> iterator(){ return new NameIterator<E>(this); } ... } and the Iterator should look like this class NameIterator<E extends Comparable<E>> implements Iterator<E>{ private Name<E> tree; private int...

Coherence config default override path

java,serialization,override,weblogic12c,oracle-coherence
I've already spent more than 2 days trying to make this work without any result. The server is WebLogic 12c with embedded Coherence server. It is important to mention that I do not run Coherence in standalone mode, instead it starts automatically alongside the application server that has access to...

reading fields which have null value

java,arraylist,override,abstract-class
I have an abstract class "Homework"and 4 other classes that extend it (I only pasted one of them since they are identical). The program compiles, but the output looks like this: null - must read 0 pages null - must read 0 pages null - must read 0 pages null...

Overriding a subscript returning a covariant type in subclasses

class,swift,override,covariance,subscript
I have a class called LLLinkedList, which defines a subscript: class LLLinkedList<L> { //other properties, functions and initializers... subscript(range: Range<Int>) -> LLLinkedList { get { //return something } set { //set something } } } Now the subscript obviously takes a Range<Int> and returns a LLLinkedList. I have also defined...

Override a package method, when that method is internally imported within the package

python,package,override,python-import
If I import a package, let's say networkx. How to override one method inside it so that it's the one called by every other function inside the package ? Example : import networkx as nx def _draw_networkx_nodes(G, pos, nodelist=None, node_size=300, node_color='r', node_shape='o', alpha=1.0, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None, label=None, **kwds):...

Extending the behavior of an inherited function in Python

python,function,inheritance,override,decorator
Let's say we have the following classes: class Base(object): def load(self): # do logic A # do logic B class Child(Base): def load(self): # do logic C I know decorators can be used to extend function behavior in Python but I don't know how I can apply it in my...

Polymorphism and overriden methods: Eclipse has a bug?

eclipse,polymorphism,override
It's rather a meta question, so its not that I don't understand polymorphism. Suppose you have a class and its super class. The super class has a method print, it prints out "Super". The sub class overrides this method it prints out "Sub". If you create two instances, one declared...

C# - Can't pass Out with an Override method

c#,override,out
I have a method very similar to the example below, and it won't let me out the outItem. public override bool myMethod(string item, out string outItem) { outItem = ""; return true; } It keeps giving the the following error: "no suitable method found to override" If I remove the...

Create new function instead of overriding paintComponent

java,user-interface,override
class MultiplicationTablePanel extends JPanel { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawString("Multiplication Table", 0, 0); If I want to draw something on Panel, I need to override paintComponent function. If I want to create a new function instead of override, such as "protected void testPaintComponent(Graphics g)" It doesn't work,...

How do I call a specific overridden method from an inherited method in Java?

java,inheritance,parameters,override,overloading
I have a class named LotteryTicket that have 3 subclasses: Pick4, Pick5, and Pick6. I want to be able to call a method public void pickNumbers()where once called, will be able to recognize which LotteryTicket subclass is being used and ask for the appropriate amount of arguments (i.e. calling pickNumbers()...

Java override method doesn't work

java,override
Thanks for all of you. In fact someone has put a patch for that class which disturbed the correct behaviour. Finally I found this by checking the classloader. Forgive me:) Here, public class Son extends public class Parent extends public class GrandParent In Parent, this method overrides GrandParent: @Override public...

Why am I able to override some methods from java.sql.Connection and not others

java,sql,import,connection,override
I am building a simple JDBC Driver for a text base as an exercise for a class. I've imported the source code provided to eclipse and in one class it seems that I am able to override some methods from java.sql.Connection but for the last few in the class. When...

How can override the view files of the componenet in joomla

view,joomla,override,joomla-component
I using the ARI Quiz lite for online quiz. i need to orverride view of quiz listing, but i dont know how to do this. I tried to override listing file /components/com_ariquizlite/view/quiz_list.html.php to /templates/rhuk_milkyway/html/com_ariquizlite/view/quiz_list.html.php but it's not working. please help me. thx adv.......

Django models: managing transactions when commit_manually is deprecated

python,django,django-models,override
I'm running Django 1.4.11. I overrode the save() method of a Django model in a way similar to the following code: from django.db import models from django.db import transaction class MyModel(models.Model): # model definition @transaction.commit_manually def save(self, *args, **kwargs): try: super(self.__class__, self).save(*args, **kwargs) foo() # do_other_things except: transaction.rollback() raise else:...

Magento: Block rewriting works correctly in local, but in the server does not work

magento,override
I've rewritten a block in magento in my localhost then I transfer files from localhost to my server but overriden does not work. All files in localhost and my server are similar. I use xampp in localhost.

Overriding default behaviour of dictionaries in Swift to ignore zero values?

swift,dictionary,override
I want to create a data type that acts like a Dictionary but ignores any keys whose value is zero, e.g. consider a hypothetical example: typealias SpecialDict = Dictionary<String,Int> let testA: SpecialDict = ["a":1, "b":4, "c":0] let testB: SpecialDict = ["a":1, "b":4] testA == testB // should evaluate as true...

Why does this Swift prepareForSegue function override have instantiation?

ios,oop,swift,override,segue
I'm learning Swift and I am working through passing items from one segue to another. From what it seems to me in the code, you are creating a new ViewController object called "secondVC". In line 3, it seems to me like it's duplicating the segue.destinationViewController by setting this new controller...

How to get rid of duplicate code in derived classes?

c++,oop,inheritance,override
I have a class hierarchy like: class A { list<A*> children; public: void update() { do_something(); update_current(); for(auto child : children) children->update(); } protected: virtual void update_current() {}; }; class B : public A { protected: void update_current() override { do_something_important(); }; }; class C1 : public B { protected:...

How to use the Android GreenMatter lib to change ColorAccent, ColorPrimary in Code?

android,override
Hi i want to use the GreenMatter (https://github.com/negusoft/GreenMatter) lib to change ColorAccent, ColorPrimary and others by code (Programmatically override the colors at runtime). I have setup the lib in my Android Project with https://github.com/negusoft/GreenMatter/wiki/Basic-GreenMatter-setup. But by analyzing the Greenmatter code i can't find out how i could use for example...

Override paint() runs twice

java,netbeans,override,paint
Sorry, Im newer on this site, but I have a problem with my code, Im drawing a set of images on a JPanel, so I Override the paint method, but when I run the project, I looks like it is running twice.. because I tried to put a println, and...

WordPress - Failing to override woocommerce templates

wordpress,templates,woocommerce,override
I am trying to override Woocommerce's templates files by duplicating them in my custom theme directory / woocommerce / templates, but the changes don't appear (I tried simply adding classes to begin with) on the website. Is there something I am doing wrong ? Thank you for your concern....

C++ method overriding when using parent type

c++,vector,override
Heyo, I'm a little confused about how method overriding works when you involve calling objects as their parent type. Here is my example code: #include <iostream> #include <cstdlib> #include <vector> using namespace std; class A { public: A() { std::cout << "Made A.\n"; } void doThing() { std::cout << "A...

VB.Net - Shadows do not hide the original property

.net,vb.net,inheritance,override
I created a specific user control with two ComboBox, inherets from UserControl Public Class CodLibCombo : Inherits System.Windows.Forms.UserControl Then I needed a specific "Enabled" Property, that can Enable the two ComboBox inside. so I tried to use "Shadows" and "Overrides" to redefine it : Public WriteOnly Shadows Property Enabled() As...

Swift: Overriding == in subclass results invocation of == in superclass only

swift,override,equality
I've got a class A, which conforms to Equatable protocol and implements == function. In subclass B I override == with more checks. However, when I do comparison between two arrays of instances of B (which both have type Array<A>), == for A is invoked. Of course if I change...