IronPython and COM Interface
Hello,
I'm new to IronPython and COM so please bear with me.
I have a COM interface provided to me. I need to implement this
interface and pass it to a method as a way of implementing
'callbacks'.
However it appears that the methods of my interface object are never
called.
As a alternative, I implemented the interface in C# and then extended
the C# class in IronPython. However, on running the code, methods of
my C# class rather than the IronPython class are being called.
Can anyone advise? Is this possible in IronPython?
The code is listed below.
Regards,
Divya
---
import time
import clr
clr.AddReference('Interop.MBTCOMLib.dll')
clr.AddReference('Interop.MBTORDERSLib.dll')
clr.AddReference('Interop.MBTQUOTELib.dll')
import MBTCOMLib
import MBTORDERSLib
import MBTQUOTELib
demo_user='user'
demo_pass='pass'
demo_host=9
class MBEvents(MBTQUOTELib.IMbtQuotesNotify):
def __init__(self):
MBTQUOTELib.IMbtQuotesNotify.__init__(self)
def OnLevel2Data(data):
print 'OnLevel2Data'
def OnOptionsData(self, data):
print 'OnOptionsData'
def OnQuoteData(self, data):
print 'OnQuoteData'
def OnTSData(self, data):
print 'OnTSData'
class MB:
def __init__(self):
self.conn = MBTCOMLib.MbtComMgrClass()
#self.conn.EnableSplash(False)
self.orders = self.conn.OrderClient
self.quotes = self.conn.Quotes
self.events = MBEvents()
def login(self, host=demo_host, user=demo_user, passwd=demo_pass):
self.conn.DoLogin(host, user, passwd, '')
print self.quotes.RemoteAddress, self.quotes.RemotePort
self.quotes.AdviseSymbol(self.events, 'EUR/USD', 1|2|3|4)
--
http://mail.python.org/mailman/listinfo/python-list
please solve my problem
hello i need help for my ecommerce project ,and here i am facing some problem
here is my
query
"i want to show image by the help of MEDIA_URL and this is my template file
code for this
http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
#MEDIA_ROOT = "C:/Users/rakesh/Desktop/ecomstore/static/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/";, "http://example.com/media/";
MEDIA_URL = '/static/'
#MEDIA_URL = "http://localhost:8000/static/";
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/";
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
#"C:Users/rakesh/Desktop/ecomstore/static/"
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '2h(8t+9z4z-m(fuhl17eqp78q!yxo4&i54jofml3uoyv@a3y3x'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#'djangodblog.DBLogMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'ecomstore.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'ecomstore.wsgi.application'
TEMPLATE_DIRS = (
os.path.join(CURRENT_PATH,'templates'),
"C:/Users/rakesh/Desktop/ecomstore/templates/",
#"C:/Python27/Lib/site-packages/django/contrib/admin/templates/admin",
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'catalog',
#'djangodblog',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'preview',
'utils',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail
[no subject]
Hello , I would like to parse java files and detect class name's, attributes name's type's and visibility (and or list of methods). Is there any module who can parse easily a java file using jython? Regards Divya -- http://mail.python.org/mailman/listinfo/python-list
creating generic class
Hi, I want to create a generic class to convert ". java " file into xml file (validated against xsd / dtd). What is the best approach to do this with jython or python ? Regards Divya -- http://mail.python.org/mailman/listinfo/python-list
RE:
Hi I don't know how to implement these API's .When I use the method "Parse (file object) " it gives error. So, I m blank how to implement it in order to get all the info of java file and thn represent them in xml format.. Regards Divya -Original Message- From: Gabriel Genellina [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 19, 2006 6:21 AM To: Divya Prakash Cc: [email protected] Subject: Re: At Monday 18/12/2006 03:34, Divya Prakash wrote: > I would like to parse java files and detect class name's, > attributes name's type's and visibility (and or list of > methods). > Is there any module who can parse easily a java file using jython? You could try javadoc (the java package), it is easier to use than a pure reflection approach. -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam !gratis! !Abrm tu cuenta ya! - http://correo.yahoo.com.ar -- http://mail.python.org/mailman/listinfo/python-list
getting subchild of a tree through xerces
Hi I m able to parse xml file using xerces as well as JAXP but I am unable to parse the sub- child of my tree Eg : ...(not able to parse this) But I m unable to parse the child of class"hello" .but I m able to parse the .sibling of class What should I do... Regards Divya -- http://mail.python.org/mailman/listinfo/python-list
FW: [Jython-users] ERROR : parsing xml in jython
Hi
But I am unable to parse all the nodes of the tree .especially the
subtree of the main tree
It displays only the sibling not the subtree
Regards
Divya
-Original Message-
From: Matthias Berth [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 19, 2006 3:18 PM
To: Divya Prakash
Subject: Re: [Jython-users] ERROR : parsing xml in jython
Hi,
looks like you have to make an InputSource from the file, like so:
from java.io import File, FileReader, StringReader
textReader = FileReader(File(filename))
inputSource = InputSource(textReader)
dp.parse(inputSource)
Hope this helps
Matthias
Divya Prakash schrieb:
> Hi All,
>
>
>
> I m facing the problem while parsing xml file ..
>
>
>
> My code is :-
>
>
>
>
>
> import sys
>
> from org.apache.xerces.parsers import DOMParser as dp
>
> import javax.xml.parsers
>
> infilename = open("mos.xml","r")
>
> print infilename
> def test(infilename):
>
> """Parse XML document and show attributes and names.
>
> """
>
> print infilename
>
> parser = dp()
>
> print parser
>
> gh = parser.parse(infilename)
>
> print gh
>
> doc = parser.getDocument()
>
> node = doc.getFirstChild()
>
> print "Attributes:"
>
> show_attrs(node)
>
> print "Names:"
>
> show_names(node)
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: Does Python really follow its philosophy of "Readability counts"?
Hello thats excellant !! On 1/23/09, Russ P. wrote: > > On Jan 23, 4:57 am, Bruno Desthuilliers [email protected]> wrote: > > Russ P. a écrit : > > > > As I said before, if you have the source code you can always change > > > private attributes to public in a pinch if the language enforces > > > encapsulation. > > > > And then have to maintain a fork. No, thanks. > > For crying out loud, how many private attributes do you need to > access? If it's a dozen, then you and your library developer are > obviously not on the same page. If it's one or two, then it's hardly a > "fork." Just take note of the one or two places where you needed to > remove the access restriction and you're done. Heck, you don't even > need to do that, because you will be warned automatically anyway when > you get the new version of the library (unless those private > attributes are changed to public). > > > > But if you are working on a team project, you can't > > > change the code that another member of a team checks in. > > > > Why on earth couldn't I change the code of another member of my team if > > that code needs changes ? The code is the whole team's ownership. > > OK, fine, you can change the code of another member of the team. Are > you going to check with him first, or just do it? The point is that > changing an interface requires agreement of the team members who use > that interface, whether on the calling or the implementation side of > it. If you change interfaces without getting agreement with the other > team members, you probably won't be on the team for long. And without > access restrictions, accessing _private is equivalent to changing the > interface. > > > Now and FWIW, in this case (our own code), I just don't need to "mess > > with internals" - I just just change what needs to be changed. > > > > > That is how > > > enforced data hiding helps teams of developers manage interfaces. > > > > I totally fails to find any evidence of this assertion in the above > > "demonstration". > > > > > The > > > bigger the team and the bigger the project, the more it helps. > > > > Your opinion. > > > > > Mr. D'Aprano gave an excellent example of a large banking program. > > > Without enforced encapsulation, anyone on the development team has > > > access to the entire program and could potentially sneak in fraudulent > > > code much more easily than if encapsulation were enforced by the > > > language. > > > > My my my. If you don't trust your programmers, then indeed, don't use > > Python. What can I say (and what do I care ?). But once again, relying > > on the language's access restriction to manage *security* is, well, kind > > of funny, you know ? > > Are you seriously saying that if you were managing the production of a > major financial software package with hundreds of developers, you > would just "trust" them all to have free access to the most sensitive > and critical parts of the program? Now *that's*, well, kind of funny, > you know? > > Would you give all those developers your password to get into the > system? No? Wait a minute ... you mean you wouldn't "trust" them with > your password? But what about "openness"? Are you some sort of fascist > or what? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
