473,624 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about overriding method

Here is what I need to do: The bsddb3 module
(http://pybsddb.sourceforge.net/) defines a class called _DBWithCursor
which has a method called set_location. The code for set_location
looks like:

def set_location(se lf, key):
self._checkOpen ()
self._checkCurs or()
return self.dbc.set(ke y)

I want to in effect override that method so that in the last line it
calls set_range(key) instead of set(key).

But, I never deal with that class directly; an instance of it is
returned by the function "btopen" which is defined in the __init__.py
file of the bsddb3 module. btopen is not a class method; it is just a
function defined in the bsddb3 namespace.

So when I write:

import bsddb3
mydb = bsddb3.btopen(" mydbfile", "r")

how do I get mydb.set_locati on() to behave as I want? I'm assuming
that there's a way to override this in my program; I don't really want
to change the bsddb3 __init__.py code.

My solution is:

import bsddb3

def my_set_location (self, key):
self._checkOpen ()
self._checkCurs or()
return self.dbc.set_ra nge(key)

bsddb3._DBWithC ursor.__dict__['set_location']=my_set_locatio n
Which seems to do what I want. Is there a better approach?

Allan
Jul 18 '05 #1
0 1412

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4181
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read the documentation but it is rather hard to understand so please don't refer to it :) 3) Many examples in the newsgroups use Return MyBase.ProcessKeyPreview(m) as the last code line while I have used Return MyBase.ProcessKeyEventArgs(m)
18
1650
by: Kamen Yotov | last post by:
hi all, i first posted this on http://msdn.microsoft.com/vcsharp/team/language/ask/default.aspx (ask a c# language designer) a couple of days ago, but no response so far... therefore, i am pasting it here as well... enjoy! (you can skip to the source at the end of the message if you like...) Consider:
4
1925
by: ORi | last post by:
Hi all ! There's a question I've been bothering for a while: I'm actually developing architectural frameworks for application developing and I think virtual methods, although needed because of the flexibility they introduce (flexibility really needed in framework developing), are often a nuisance for final developers. They don't like them because they never know if base class must be called and where should they place the call if...
3
1402
by: James Ramaley | last post by:
I have created a VB.NET User Control which inherits from TextBox. I have a general question regarding how functionality should be overwritten: I can either write a method which handles an event: function MyControl_Enter(...) handles MyControl.Enter or I can overwrite the relevant virtual method:
3
1543
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
15
2520
by: Brian Haynes | last post by:
I am having a problem with overloading. An example: Public Class Base ... End Class Public Class Derived Inherits Base ... End Class
6
1659
by: tshad | last post by:
I am playing with Inheritance and want to make sure I understand it. I have the following Classes: ******************************************* Public Class AuthHeader:Inherits SoapHeader Public AuthHeaderName As String Public SessionKey As String = "Default" End Class Public Class ServiceTicket:Inherits AuthHeader
7
308
by: Steve Long | last post by:
Hello, I have a design question that I'm hoping someone can chime in on. (I still using VS 2003 .NET 1.1 as our company has not upgraded XP to sp2 yet. duh I know, I know) I have a class I wrote (CAppInit) that I use for application configuration. It behaves similarly to Configuration.AppSettings with some extra functionality. This class is in an assembly (AppConfiguration) with another class. I would now like to extend the functionality...
10
1190
by: Frank Millman | last post by:
Hi all I recently posted a question about subclassing. I did not explain my full requirement very clearly, and my proposed solution was not pretty. I will attempt to explain what I am trying to do more fully, and describe a possible solution. It is still not pretty, so I would appreciate any comments. I have a base class (ClassA), which is an abstract class. Most of the methods and attributes are common to all subclasses, so there is...
10
105172
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.