On Feb 7, 2011, at 11:42 AM, Martijn Moeling wrote:

> I think, I might be helped with the create_instance "event"

Assuming you're talking about when the ORM establishes an instance from a newly 
fetched row, you can use the @reconstructor hook for that.   0.7 publishes this 
event additionally as the "load" event.



> 
> I will never ever stop a class from being saved/persistent, 
> 
> it is the other way around. I thought I was able to use joins and or 
> relations to limit for "allowed" results from a query.
> With all the polymorphic and self references I have got and the fact that I 
> need to do so for multiple Polymorphic colums I came up with the ACL idea.
> 
> Im not sure it if will perform, but in the create_instance I will look up the 
> ACL and set additional properties on the instance or create an empty one.
> 
> This whole system is getting very complex now and limiting returned data 
> involves modifying relationsships a lot. I'm really glad I got that working.
> 
> Many classes are base on top of that and I the only IT guy working on this 
> together with "programmers" with a chemistry degree. Who will need the API I 
> am working on to do their stuff without knowing anything about 
> Databases........
> 
> To have that I Inherit polymorphicly, have many-to-many self references, use 
> mixins. 



> 
> I'll have a look at the PreFilteredQuery example you gave me, Any thoughts 
> are helpful, I'll see If I can make up an example with persons and addresses 
> again since the molecule stuff makes it even more confusing..
> Will take me some time though 
> 
> Martijn
> 
> 
> 
> 
> On Feb 7, 2011, at 5:18 PM, Michael Bayer wrote:
> 
>> 
>> On Feb 7, 2011, at 10:55 AM, Martijn Moeling wrote:
>> 
>>> Hi,
>>> 
>>> It is me again with an interesting thing, I've searched the net, this group 
>>> etc. Not a lot of people seem interested in append_result, I AM!!
>>> 
>>> I am looking for a way to implement the following:
>>> 
>>> 
>>> I have many tables, a lot with polymorphic inheritance and self and cross 
>>> references.
>>> 
>>> In order to control "available" data I have set up a system similar to ACL 
>>> (Access Control Lists)
>>> 
>>> Depending on "Who I am" I can get data from the database.
>>> 
>>> I want to do so within the MapperExtension I already have set up to do some 
>>> "before update" and "before insert"
>> 
>> Limitations on inserts, updates and queries are best done outside of the 
>> Mapper.   By the time the mapper is dealing with instructions to persist or 
>> load a row, its usually too late, unless you're looking to raise an 
>> exception upon certain conditions.       For example there's no way to 
>> "stop" the insert from happening inside of a "before insert" operation, 
>> short of raising an exception (maybe that's what you're doing).    
>> 
>> A SessionExtension.before_flush() OTOH allows you to modify everything 
>> that's going to happen before any flush plans are made.
>> 
>> Regarding append_result(), its a very old hook from 0.1 that's never had any 
>> real use.   In this case I would instead be ensure that the undesired rows 
>> are not in the result set to start with.   The recipe at 
>> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery is a 
>> decent starting point for such a recipe.
>> 
>> 
>>> 
>>> 
>>>  def append_result(self, mapper, selectcontext, row, instance, result, 
>>> **flags):
>>>      if instance.__tablename__ == 'he':
>>>          return EXT_STOP
>>>      else:
>>>          return EXT_CONTINUE
>>> 
>>> would do such a thing, but I want (for the sake of the code behind that) to 
>>> continue with a heavily modified instance.
>>> 
>>> To avoid making this long code (a lot of different object types pass 
>>> through here, remember the polymorhic bit)
>>> 
>>> Does anyone have an interesting approach to this? basically I need to do 
>>> something like instance= instance_class_type(new, configuration, based, on, 
>>> the, ACL)
>>> 
>>> 
>>> 
>>> Any help would be wonderfull,
>>> 
>>> Martijn
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "sqlalchemy" group.
>>> To post to this group, send email to sqlalchemy@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> sqlalchemy+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/sqlalchemy?hl=en.
>>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to