Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

From Sharp minds come... pointed heads. -- Bryan Sparrowhawk


computers / comp.os.vms / VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

SubjectAuthor
* VMS Python IndexedFile - NotImplementedError:Arne Vajhøj
`* Re: VMS Python IndexedFile - NotImplementedError:Jan-Erik Söderholm
 `* Re: VMS Python IndexedFile - NotImplementedError:Arne Vajhøj
  +* Re: VMS Python IndexedFile - NotImplementedError:Jan-Erik Söderholm
  |+* Re: VMS Python IndexedFile - NotImplementedError:Jan-Erik Söderholm
  ||`- Re: VMS Python IndexedFile - NotImplementedError:Arne Vajhøj
  |`- Re: VMS Python IndexedFile - NotImplementedError:Arne Vajhøj
  `* Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynumSimon Clubley
   `* Re: VMS Python IndexedFile - NotImplementedError:Arne Vajhøj
    `- Re: VMS Python IndexedFile - NotImplementedError:Arne Vajhøj

1
VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<630ac140$0$690$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24594&group=comp.os.vms#24594

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Sat, 27 Aug 2022 21:13:27 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Newsgroups: comp.os.vms
Content-Language: en-US
From: arn...@vajhoej.dk (Arne Vajhøj)
Subject: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 11
Message-ID: <630ac140$0$690$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 92ede1c3.news.sunsite.dk
X-Trace: 1661649216 news.sunsite.dk 690 arne@vajhoej.dk/68.9.63.232:63777
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Sun, 28 Aug 2022 01:13 UTC

JFP VMS Python 2.7.18 on VMS Alpha.

Has anyone gotten vms.rms.IndexedFile working?

I am stuck at:
NotImplementedError: IndexedFile.primary_keynum

And a quick look at the IndexedFile __init__ and
primary_keynum make it look difficult to avoid.

Arne

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<tefb7j$ja7o$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24595&group=comp.os.vms#24595

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jan-erik...@telia.com (Jan-Erik Söderholm)
Newsgroups: comp.os.vms
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Date: Sun, 28 Aug 2022 11:07:01 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <tefb7j$ja7o$1@dont-email.me>
References: <630ac140$0$690$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 28 Aug 2022 09:06:59 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="177b7242f194a9a9e5b05a80077279c3";
logging-data="633080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ue0lrMUXTd27UfHxbIIez"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.1
Cancel-Lock: sha1:FxQ1ptJ+/y2m9a4XX15W1RdAYgQ=
In-Reply-To: <630ac140$0$690$14726298@news.sunsite.dk>
Content-Language: sv
 by: Jan-Erik Söderholm - Sun, 28 Aug 2022 09:07 UTC

Den 2022-08-28 kl. 03:13, skrev Arne Vajhøj:
> JFP VMS Python 2.7.18 on VMS Alpha.
>
> Has anyone gotten vms.rms.IndexedFile working?
>
> I am stuck at:
>   NotImplementedError: IndexedFile.primary_keynum
>
> And a quick look at the IndexedFile __init__ and
> primary_keynum make it look difficult to avoid.
>
> Arne

I have used vms.rms.IndexedFile for many years in routines
that reads RMS indexed files and loads Rdb tables.

But primarily for sequential access, not using key lookup.

I can see that I have this lines, not sure what they does,
probably just added from some RMS example from the
(now closed) JPF PythonVMS web page.

def primary_keynum(self):
return 0

The rest of the code never calls primary_keynum() and I have
no idea what happens if that is removed…

Jan-Erik.

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<630bb577$0$691$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24596&group=comp.os.vms#24596

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Sun, 28 Aug 2022 14:35:35 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Language: en-US
Newsgroups: comp.os.vms
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me>
From: arn...@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <tefb7j$ja7o$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 36
Message-ID: <630bb577$0$691$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 044a4e35.news.sunsite.dk
X-Trace: 1661711736 news.sunsite.dk 691 arne@vajhoej.dk/68.9.63.232:50834
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Sun, 28 Aug 2022 18:35 UTC

On 8/28/2022 5:07 AM, Jan-Erik Söderholm wrote:
> Den 2022-08-28 kl. 03:13, skrev Arne Vajhøj:
>> JFP VMS Python 2.7.18 on VMS Alpha.
>>
>> Has anyone gotten vms.rms.IndexedFile working?
>>
>> I am stuck at:
>>    NotImplementedError: IndexedFile.primary_keynum
>>
>> And a quick look at the IndexedFile __init__ and
>> primary_keynum make it look difficult to avoid.
>>
>> Arne
>
> I have used vms.rms.IndexedFile for many years in routines
> that reads RMS indexed files and loads Rdb tables.
>
> But primarily for sequential access, not using key lookup.
>
> I can see that I have this lines, not sure what they does,
> probably just added from some RMS example from the
> (now closed) JPF PythonVMS web page.
>
>     def primary_keynum(self):
>         return 0
>
> The rest of the code never calls primary_keynum() and I have
> no idea what happens if that is removed…

So you create a class that inherits from IndexedFile and overrides
primary_keynum?

I will have to try that.

Arne

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<tegkie$ja7o$2@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24597&group=comp.os.vms#24597

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jan-erik...@telia.com (Jan-Erik Söderholm)
Newsgroups: comp.os.vms
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Date: Sun, 28 Aug 2022 22:52:30 +0200
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <tegkie$ja7o$2@dont-email.me>
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 28 Aug 2022 20:52:30 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="177b7242f194a9a9e5b05a80077279c3";
logging-data="633080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a0ScD9EQIPB2KMoJzTtzd"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.1
Cancel-Lock: sha1:219ctZq7hyZFr78Mq5JVZxWUlGg=
Content-Language: sv
In-Reply-To: <630bb577$0$691$14726298@news.sunsite.dk>
 by: Jan-Erik Söderholm - Sun, 28 Aug 2022 20:52 UTC

Den 2022-08-28 kl. 20:35, skrev Arne Vajhøj:
> On 8/28/2022 5:07 AM, Jan-Erik Söderholm wrote:
>> Den 2022-08-28 kl. 03:13, skrev Arne Vajhøj:
>>> JFP VMS Python 2.7.18 on VMS Alpha.
>>>
>>> Has anyone gotten vms.rms.IndexedFile working?
>>>
>>> I am stuck at:
>>>    NotImplementedError: IndexedFile.primary_keynum
>>>
>>> And a quick look at the IndexedFile __init__ and
>>> primary_keynum make it look difficult to avoid.
>>>
>>> Arne
>>
>> I have used vms.rms.IndexedFile for many years in routines
>> that reads RMS indexed files and loads Rdb tables.
>>
>> But primarily for sequential access, not using key lookup.
>>
>> I can see that I have this lines, not sure what they does,
>> probably just added from some RMS example from the
>> (now closed) JPF PythonVMS web page.
>>
>>      def primary_keynum(self):
>>          return 0
>>
>> The rest of the code never calls primary_keynum() and I have
>> no idea what happens if that is removed…
>
> So you create a class that inherits from IndexedFile and overrides
> primary_keynum?

If you say so, I guess I do... :-)
As I wrote, I just used one of JFP's examples.

>
> I will have to try that.
>
> Arne
>

I can mail you my complete script if you like.
Reads an RMS file and writes to a Rdb table.

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<tegkji$ja7o$3@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24598&group=comp.os.vms#24598

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jan-erik...@telia.com (Jan-Erik Söderholm)
Newsgroups: comp.os.vms
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Date: Sun, 28 Aug 2022 22:53:06 +0200
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <tegkji$ja7o$3@dont-email.me>
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
<tegkie$ja7o$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 28 Aug 2022 20:53:06 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="177b7242f194a9a9e5b05a80077279c3";
logging-data="633080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wDjy37FRgOuBiSn2c+ves"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.1
Cancel-Lock: sha1:WQoVKTSixRNgC+TaVnIIlevtO/s=
In-Reply-To: <tegkie$ja7o$2@dont-email.me>
Content-Language: sv
 by: Jan-Erik Söderholm - Sun, 28 Aug 2022 20:53 UTC

Den 2022-08-28 kl. 22:52, skrev Jan-Erik Söderholm:
> Den 2022-08-28 kl. 20:35, skrev Arne Vajhøj:
>> On 8/28/2022 5:07 AM, Jan-Erik Söderholm wrote:
>>> Den 2022-08-28 kl. 03:13, skrev Arne Vajhøj:
>>>> JFP VMS Python 2.7.18 on VMS Alpha.
>>>>
>>>> Has anyone gotten vms.rms.IndexedFile working?
>>>>
>>>> I am stuck at:
>>>>    NotImplementedError: IndexedFile.primary_keynum
>>>>
>>>> And a quick look at the IndexedFile __init__ and
>>>> primary_keynum make it look difficult to avoid.
>>>>
>>>> Arne
>>>
>>> I have used vms.rms.IndexedFile for many years in routines
>>> that reads RMS indexed files and loads Rdb tables.
>>>
>>> But primarily for sequential access, not using key lookup.
>>>
>>> I can see that I have this lines, not sure what they does,
>>> probably just added from some RMS example from the
>>> (now closed) JPF PythonVMS web page.
>>>
>>>      def primary_keynum(self):
>>>          return 0
>>>
>>> The rest of the code never calls primary_keynum() and I have
>>> no idea what happens if that is removed…
>>
>> So you create a class that inherits from IndexedFile and overrides
>> primary_keynum?
>
> If you say so, I guess I do... :-)
> As I wrote, I just used one of JFP's examples.
>
>>
>> I will have to try that.
>>
>> Arne
>>
>
>
> I can mail you my complete script if you like.
> Reads an RMS file and writes to a Rdb table.
>
>
>

He he, just saw your email. I'll reply to that...

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<teli22$1hd1d$2@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24620&group=comp.os.vms#24620

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: club...@remove_me.eisner.decus.org-Earth.UFP (Simon Clubley)
Newsgroups: comp.os.vms
Subject: Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum
Date: Tue, 30 Aug 2022 17:40:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <teli22$1hd1d$2@dont-email.me>
References: <630ac140$0$690$14726298@news.sunsite.dk> <tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 30 Aug 2022 17:40:18 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6289ddc3dbcb429ba2a8cfcbbb07766a";
logging-data="1618989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iXNDOmTjLOKdUxQvvD19bPQ2rC+ZI+u0="
User-Agent: slrn/0.9.8.1 (VMS/Multinet)
Cancel-Lock: sha1:sm8qs6tpkMhSFZbSrYfaSMktb4M=
 by: Simon Clubley - Tue, 30 Aug 2022 17:40 UTC

On 2022-08-28, Arne Vajhøj <arne@vajhoej.dk> wrote:
>
> So you create a class that inherits from IndexedFile and overrides
> primary_keynum?
>
> I will have to try that.
>

For the benefit of anyone searching for this in the future, what
was the solution ?

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<630ea151$0$699$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24624&group=comp.os.vms#24624

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Tue, 30 Aug 2022 19:46:23 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Language: en-US
Newsgroups: comp.os.vms
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
<teli22$1hd1d$2@dont-email.me>
From: arn...@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <teli22$1hd1d$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 42
Message-ID: <630ea151$0$699$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: ff983edf.news.sunsite.dk
X-Trace: 1661903185 news.sunsite.dk 699 arne@vajhoej.dk/68.9.63.232:51257
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Tue, 30 Aug 2022 23:46 UTC

On 8/30/2022 1:40 PM, Simon Clubley wrote:
> On 2022-08-28, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> So you create a class that inherits from IndexedFile and overrides
>> primary_keynum?
>>
>> I will have to try that.
>
> For the benefit of anyone searching for this in the future, what
> was the solution ?

That solved the problem in the subject line.

But then I had another problem. Jan-Erik emailed me a
working example (thanks) and based on that I got it working.

Demo code:

from construct import *
from vms.rms.IndexedFile import IndexedFile

class MsgRec:
def __init__(self, id, msg):
self.id = id
self.msg = msg

class MsgFil(IndexedFile):
def __init__(self, fnm):
IndexedFile.__init__(self, fnm, Struct('msgrec', SNInt32('id'),
String('msg', 100, padchar=' ')))
def primary_keynum(self):
return 0

db = MsgFil('msgs.isq')
db.put(MsgRec(5, 'Hi from Python!'))
for msg in db:
print(msg.msg)

Arne

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<630eac3e$0$697$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24627&group=comp.os.vms#24627

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Tue, 30 Aug 2022 20:32:56 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Language: en-US
Newsgroups: comp.os.vms
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
<tegkie$ja7o$2@dont-email.me>
From: arn...@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <tegkie$ja7o$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 130
Message-ID: <630eac3e$0$697$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 8b3db802.news.sunsite.dk
X-Trace: 1661905982 news.sunsite.dk 697 arne@vajhoej.dk/68.9.63.232:52964
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Wed, 31 Aug 2022 00:32 UTC

On 8/28/2022 4:52 PM, Jan-Erik Söderholm wrote:
> Den 2022-08-28 kl. 20:35, skrev Arne Vajhøj:
>> On 8/28/2022 5:07 AM, Jan-Erik Söderholm wrote:
>>> Den 2022-08-28 kl. 03:13, skrev Arne Vajhøj:
>>>> JFP VMS Python 2.7.18 on VMS Alpha.
>>>>
>>>> Has anyone gotten vms.rms.IndexedFile working?
>>>>
>>>> I am stuck at:
>>>>    NotImplementedError: IndexedFile.primary_keynum
>>>>
>>>> And a quick look at the IndexedFile __init__ and
>>>> primary_keynum make it look difficult to avoid.
>>>
>>> I have used vms.rms.IndexedFile for many years in routines
>>> that reads RMS indexed files and loads Rdb tables.
>>>
>>> But primarily for sequential access, not using key lookup.

It is called in the constructor so it is also called
for sequential access.

>>> I can see that I have this lines, not sure what they does,
>>> probably just added from some RMS example from the
>>> (now closed) JPF PythonVMS web page.
>>>
>>>      def primary_keynum(self):
>>>          return 0
>>>
>>> The rest of the code never calls primary_keynum() and I have
>>> no idea what happens if that is removed…

The exception in the subject line.

>> So you create a class that inherits from IndexedFile and overrides
>> primary_keynum?
>
> If you say so, I guess I do... :-)

I understand *what* the method is doing now.

Demo:

$ typ cre.pas
program cre(input, output);

type
data = record
f1 : [key(0)] integer;
f2 : [key(1)] integer;
end;
database = file of data;

var
db : database;
d : data;

begin
open(db, 'demo.isq', new, organization := indexed, access_method :=
keyed);
d.f1 := 1;
d.f2 := 9;
db^ := d;
put(db);
d.f1 := 2;
d.f2 := 8;
db^ := d;
put(db);
d.f1 := 3;
d.f2 := 7;
db^ := d;
put(db);
end.
$ pas cre
$ lin cre
$ run cre
$ typ lst0.py
from construct import *
from vms.rms.IndexedFile import IndexedFile

class DataFil(IndexedFile):
def __init__(self, fnm):
IndexedFile.__init__(self, fnm, Struct('data', SNInt32('f1'),
SNInt32('f2')))
def primary_keynum(self):
return 0 # <---- note this

db = DataFil('demo.isq')
for d in db:
print('%d %d' % (d.f1, d.f2))
$ python lst0.py
1 9
2 8
3 7
$ typ lst1.py
from construct import *
from vms.rms.IndexedFile import IndexedFile

class DataFil(IndexedFile):
def __init__(self, fnm):
IndexedFile.__init__(self, fnm, Struct('data', SNInt32('f1'),
SNInt32('f2')))
def primary_keynum(self):
return 1 # <---- note this

db = DataFil('demo.isq')
for d in db:
print('%d %d' % (d.f1, d.f2))
$ python lst1.py
3 7
2 8
1 9

Sorry for using Pascal and not Cobol to create
the file, but I am much faster writing Pascal than
Cobol. The Cobol version would use:

.... RECORD KEY IS F1 ALTERNATE RECORD KEY IS F2.

I don't understand *why* it works that way. I would have
had it as a ctor argument with default value 0 instead
of having to override a method.

But then I am not a Python person and it would
require 25 volumes of thick books to describe all
that I don't understand.

:-)

Arne

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<630eac78$0$697$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24628&group=comp.os.vms#24628

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Tue, 30 Aug 2022 20:33:59 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Language: en-US
Newsgroups: comp.os.vms
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
<tegkie$ja7o$2@dont-email.me> <tegkji$ja7o$3@dont-email.me>
From: arn...@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <tegkji$ja7o$3@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 17
Message-ID: <630eac78$0$697$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 8b3db802.news.sunsite.dk
X-Trace: 1661906040 news.sunsite.dk 697 arne@vajhoej.dk/68.9.63.232:52964
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Wed, 31 Aug 2022 00:33 UTC

On 8/28/2022 4:53 PM, Jan-Erik Söderholm wrote:
> Den 2022-08-28 kl. 22:52, skrev Jan-Erik Söderholm:
>> Den 2022-08-28 kl. 20:35, skrev Arne Vajhøj:
>>> I will have to try that.
>>
>> I can mail you my complete script if you like.
>> Reads an RMS file and writes to a Rdb table.
>
> He he, just saw your email. I'll reply to that...

I got it working with help from your example.

Thanks.

Arne

Re: VMS Python IndexedFile - NotImplementedError: IndexedFile.primary_keynum

<6313fdf2$0$703$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=24712&group=comp.os.vms#24712

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Sat, 3 Sep 2022 21:22:52 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.13.0
Subject: Re: VMS Python IndexedFile - NotImplementedError:
IndexedFile.primary_keynum
Content-Language: en-US
Newsgroups: comp.os.vms
References: <630ac140$0$690$14726298@news.sunsite.dk>
<tefb7j$ja7o$1@dont-email.me> <630bb577$0$691$14726298@news.sunsite.dk>
<teli22$1hd1d$2@dont-email.me> <630ea151$0$699$14726298@news.sunsite.dk>
From: arn...@vajhoej.dk (Arne Vajhøj)
In-Reply-To: <630ea151$0$699$14726298@news.sunsite.dk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 177
Message-ID: <6313fdf2$0$703$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: daa2f102.news.sunsite.dk
X-Trace: 1662254578 news.sunsite.dk 703 arne@vajhoej.dk/68.9.63.232:52867
X-Complaints-To: staff@sunsite.dk
 by: Arne Vajhøj - Sun, 4 Sep 2022 01:22 UTC

On 8/30/2022 7:46 PM, Arne Vajhøj wrote:
> On 8/30/2022 1:40 PM, Simon Clubley wrote:
>> On 2022-08-28, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>> So you create a class that inherits from IndexedFile and overrides
>>> primary_keynum?
>>>
>>> I will have to try that.
>>
>> For the benefit of anyone searching for this in the future, what
>> was the solution ?
>
> That solved the problem in the subject line.
>
> But then I had another problem. Jan-Erik emailed me a
> working example (thanks) and based on that I got it working.
>
> Demo code:
>
> from construct import *
> from vms.rms.IndexedFile import IndexedFile
>
> class MsgRec:
>     def __init__(self, id, msg):
>         self.id = id
>         self.msg = msg
>
> class MsgFil(IndexedFile):
>     def __init__(self, fnm):
>         IndexedFile.__init__(self, fnm, Struct('msgrec', SNInt32('id'),
> String('msg', 100, padchar=' ')))
>     def primary_keynum(self):
>         return 0
>
> db = MsgFil('msgs.isq')
> db.put(MsgRec(5, 'Hi from Python!'))
> for msg in db:
>     print(msg.msg)

And I got into more problems that I had to solve. Specifically
about VAX floating point and Cobol packed decimals in the
records.

Here is my solution in case anyone need to do something
similar.

Record structure is defined in Cobol as:

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OPTIONAL D-FILE ASSIGN TO "TESTDB.ISQ" ORGANIZATION IS
INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS D-ID.

DATA DIVISION.
FILE SECTION.
FD D-FILE.
01 D-RECORD.
03 D-ID PIC X(8).
03 D-IV PIC 9(8) COMP.
03 D-ZV PIC 9(5)V9(2) PACKED-DECIMAL.
03 D-XV COMP-2.
03 D-SLEN PIC 9(4) COMP.
03 D-SV PIC X(50).

Compiled with /FLOAT=G_FLOAT.

To get that working with Python:

from construct import *
from vms.rms.IndexedFile import IndexedFile
from decimal import *

from extras import *

class Data:
def __init__(self, id, iv, zv, xv, sv):
self.id = id
self.iv = iv
self.zv = zv
self.xv = xv
self.slen = len(sv.rstrip())
self.sv = sv.ljust(50)

class DataFil(IndexedFile):
def __init__(self, fnm):
IndexedFile.__init__(self, fnm, Struct('data', String('id', 8),
SNInt32('iv'), PackedDecimal('zv', 5, 2), VAXGFloat('xv'),
UNInt16('slen'), String('sv', 50)))
def primary_keynum(self):
return 0
def pack_key(self, keynum, keyval):
return keyval
def keyval(self, rec, keynum):
return rec.id

Where extras.py contain some extra stuff that I needed to add
(building on the JFP stuff that VMS Python comes with). Copy
attached below.

Arne

====

from ctypes import CDLL, c_double, c_char_p, cast, byref
from construct import Adapter, Bytes
from vms.rms import BCD2Tuple, Tuple2BCD
from decimal import Decimal

CVT_K_VAX_F = 0
CVT_K_VAX_D = 1
CVT_K_VAX_G = 2
CVT_K_VAX_H = 3
CVT_K_IEEE_S = 4
CVT_K_IEEE_T = 5
CVT_K_IBM_LONG = 6
CVT_K_IBM_SHORT = 7
CVT_K_CRAY = 8

librtl = CDLL('LIBRTL.EXE')
lib_convert_float = getattr(librtl, 'CVT$CONVERT_FLOAT')

def float_to_python(val, typ):
res = c_double()
lib_convert_float(cast(val, c_char_p), typ, byref(res),
CVT_K_IEEE_T, 0)
return res.value

def float_from_python(val, typ):
res = '12345678'
lib_convert_float(byref(c_double(val)), CVT_K_IEEE_T, cast(res,
c_char_p), typ, 0)
return res

class VAXFFloatAdapter(Adapter):
def _decode(self, obj, context):
return float_to_python(obj, CVT_K_VAX_F)
def _encode(self, obj, context):
return float_from_python(obj, CVT_K_VAX_F)

def VAXFFloat(name):
return VAXFFloatAdapter(Bytes(name, 4))

class VAXDFloatAdapter(Adapter):
def _decode(self, obj, context):
return float_to_python(obj, CVT_K_VAX_D)
def _encode(self, obj, context):
return float_from_python(obj, CVT_K_VAX_D)

def VAXDFloat(name):
return VAXDFloatAdapter(Bytes(name, 8))

class VAXGFloatAdapter(Adapter):
def _decode(self, obj, context):
return float_to_python(obj, CVT_K_VAX_G)
def _encode(self, obj, context):
return float_from_python(obj, CVT_K_VAX_G)

def VAXGFloat(name):
return VAXGFloatAdapter(Bytes(name, 8))

class PackedDecimalAdapter(Adapter):
def __init__(self, byts, befdec, aftdec):
Adapter.__init__(self, byts)
self.befdec = befdec
self.aftdec = aftdec
def _decode(self, obj, context):
return Decimal(BCD2Tuple(obj, self.aftdec))
def _encode(self, obj, context):
return Tuple2BCD(obj.as_tuple(), self.befdec, self.aftdec)

def PackedDecimal(name, befdec, aftdec):
return PackedDecimalAdapter(Bytes(name, (befdec + aftdec + 2) / 2),
befdec, aftdec)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor