Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSquires committed Jan 24, 2025
1 parent e49a86b commit 70be294
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions synapse/lib/snap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
import types
import asyncio
import logging
Expand Down Expand Up @@ -318,7 +319,7 @@ async def setTagProp(self, tag, name, valu):

if prop.locked:
mesg = f'Tagprop {name} is locked.'
return await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg)
return await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg, prop=prop.name)

try:
norm, info = prop.type.norm(valu)
Expand Down Expand Up @@ -348,14 +349,14 @@ async def _set(self, prop, valu, norminfo=None, ignore_ro=False):

if prop.locked:
mesg = f'Prop {prop.full} is locked due to deprecation.'
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg)
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg, prop=prop.full)
return False

if isinstance(prop.type, s_types.Array):
arrayform = self.ctx.snap.core.model.form(prop.type.arraytype.name)
if arrayform is not None and arrayform.locked:
mesg = f'Prop {prop.full} is locked due to deprecation.'
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg)
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg, prop=arrayform.full)
return False

if norminfo is None:
Expand All @@ -375,7 +376,7 @@ async def _set(self, prop, valu, norminfo=None, ignore_ro=False):
ndefform = self.ctx.snap.core.model.form(valu[0])
if ndefform.locked:
mesg = f'Prop {prop.full} is locked due to deprecation.'
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg)
await self.ctx.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg, prop=ndefform.full)
return False

curv = self.get(prop.name)
Expand Down Expand Up @@ -487,7 +488,7 @@ async def _addNode(self, form, valu, props=None, norminfo=None):

if form.locked:
mesg = f'Form {form.full} is locked due to deprecation for valu={valu}.'
return await self.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg)
return await self.snap._raiseOnStrict(s_exc.IsDeprLocked, mesg, prop=form.full)

if norminfo is None:
try:
Expand Down Expand Up @@ -1615,6 +1616,10 @@ async def _getTagNode(self, tagnorm):
return tagnode

async def _raiseOnStrict(self, ctor, mesg, **info):
if __debug__:
if issubclass(ctor, s_exc.IsDeprLocked):
sys.audit('synapse.exc.IsDeprLocked', (mesg, info))

if self.strict:
raise ctor(mesg=mesg, **info)
await self.warn(mesg)
Expand Down

0 comments on commit 70be294

Please sign in to comment.